Skip to content

Commit b8f9e33

Browse files
Merge pull request #253 from ComputationalRadiationPhysics/dev
Release 1.5.0: Write Emtpy Group Attributes & File Name API
2 parents e3f2a88 + 563da86 commit b8f9e33

16 files changed

+292
-152
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ env:
2020
script:
2121
- cd $BUILD
2222
# compile libSplash and install
23-
- cmake -DTOOLS_MPI=$SPLASHMPI $SRC
23+
- CXXFLAGS="-Werror" cmake -DCMAKE_BUILD_TYPE=Debug -DTOOLS_MPI=$SPLASHMPI $SRC
2424
- make package
2525
- sudo dpkg -i libsplash*.deb
2626
- ls -hal /usr/share/pyshared/
2727
- rm -rf $BUILD/*
2828
# compile examples/
29-
- cmake -DWITH_MPI=$SPLASHMPI $SRC/examples
29+
- CXXFLAGS="-Werror" cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_MPI=$SPLASHMPI $SRC/examples
3030
- make
3131
- rm -rf $BUILD/*
3232
# compile and run tests/
33-
- cmake -DWITH_MPI=$SPLASHMPI $SRC/tests
33+
- CXXFLAGS="-Werror" cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_MPI=$SPLASHMPI $SRC/tests
3434
- make
3535
# run tests
3636
- $SRC/tests/run_tests $BUILD

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
Change Log for libSplash
22
================================================================
33

4+
Release 1.5.0
5+
-------------
6+
**Date:** 2016-10-26
7+
8+
Written attributes do now generate their according group path
9+
recursively if it does not exist and the `SerialDataCollector`
10+
interface for file names has been changed to be more consistent.
11+
12+
**Interface Changes**
13+
14+
- `SerialDataCollector` file name interface changed #242
15+
- `writeAttribute()` now creates missing groups recursively #231 #250
16+
17+
**Bug Fixes**
18+
19+
- throw more exceptions on wrong usage of `ParallelDataCollector` #247
20+
21+
**Misc**
22+
23+
- compiling via `-Werror` is not shipped any more #251
24+
- python tools: indentiation cleanup #249
25+
- `generateCollectionType` refactored, docs fixed #243 #246
26+
27+
428
Release 1.4.0
529
-------------
630
**Date:** 2016-04-12

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ UNSET(HDF5_HAS_SHARED_POS)
8787

8888
#-------------------------------------------------------------------------------
8989

90-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Woverloaded-virtual")
90+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Woverloaded-virtual")
9191

9292
# options
9393
OPTION(DEBUG_VERBOSE "Enable verbose HDF5 debug output" OFF)
@@ -111,7 +111,8 @@ ENDIF(NOT SPLASH_RELEASE)
111111
SET(SPLASH_LIBS z ${HDF5_LIBRARIES})
112112

113113
# serial or parallel version of libSplash
114-
SET(SPLASH_CLASSES logging DCAttribute DCDataSet DCGroup HandleMgr SerialDataCollector DomainCollector SDCHelper)
114+
SET(SPLASH_CLASSES logging DCAttribute DCDataSet DCGroup HandleMgr SerialDataCollector
115+
DomainCollector SDCHelper generateCollectionType)
115116
IF(HDF5_IS_PARALLEL)
116117
#parallel version
117118
MESSAGE(STATUS "Parallel HDF5 found. Building parallel version")

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Introduction
1515
I/O library for HPC simulations. It is created as an easy-to-use frontend for the
1616
standard HDF5 library with support for MPI processes in a cluster environment.
1717
While the standard HDF5 library provides detailed low-level control, libSplash
18-
simplifies tasks commonly found in large-scale HPC simulations, such as iter-
19-
ative computations and MPI distributed processes.
18+
simplifies tasks commonly found in large-scale HPC simulations, such as
19+
iterative computations and MPI distributed processes.
2020

2121

2222
libSplash is developed and maintained by the

src/ParallelDataCollector.cpp

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ namespace splash
470470
if (ndims < 1u || ndims > DSP_DIM_MAX)
471471
throw DCException(getExceptionString("writeAttribute", "maximum dimension `ndims` is invalid"));
472472

473+
/* group_path: absolute path to the last inode
474+
* obj_name: last inode, can be a group or a dataset
475+
*/
473476
std::string group_path, obj_name;
474477
std::string dataNameInternal = "";
475478
if (dataName)
@@ -479,6 +482,16 @@ namespace splash
479482
DCParallelGroup group;
480483
if (dataName)
481484
{
485+
/* if the specified inode (obj_name) does not exist
486+
* (as dataset or group), create all missing groups along group_path
487+
* and even create an empty group for obj_name itself
488+
*
489+
* group_path + "/" + obj_name is the absolute path of dataName
490+
*/
491+
std::string pathAndName(group_path + "/" + obj_name);
492+
if(!DCParallelGroup::exists(handles.get(id), pathAndName))
493+
group.create(handles.get(id), pathAndName);
494+
482495
// attach attribute to the dataset or group
483496
group.open(handles.get(id), group_path);
484497
hid_t obj_id = H5Oopen(group.getHandle(), obj_name.c_str(), H5P_DEFAULT);
@@ -774,33 +787,6 @@ namespace splash
774787
src_dataset.close();
775788
}
776789

777-
void ParallelDataCollector::createReference(int32_t srcID,
778-
const char *srcName,
779-
int32_t dstID,
780-
const char *dstName,
781-
Dimensions /*count*/,
782-
Dimensions /*offset*/,
783-
Dimensions /*stride*/)
784-
throw (DCException)
785-
{
786-
if (srcName == NULL || dstName == NULL)
787-
throw DCException(getExceptionString("createReference", "a parameter was NULL"));
788-
789-
if (fileStatus == FST_CLOSED || fileStatus == FST_READING)
790-
throw DCException(getExceptionString("createReference", "this access is not permitted"));
791-
792-
if (srcID != dstID)
793-
throw DCException(getExceptionString("createReference",
794-
"source and destination ID must be identical", NULL));
795-
796-
if (srcName == dstName)
797-
throw DCException(getExceptionString("createReference",
798-
"a reference must not be identical to the referenced data", srcName));
799-
800-
throw DCException(getExceptionString("createReference",
801-
"feature currently not supported by Parallel HDF5", NULL));
802-
}
803-
804790
/*******************************************************************************
805791
* PROTECTED FUNCTIONS
806792
*******************************************************************************/
@@ -1143,4 +1129,56 @@ namespace splash
11431129
dataset.close();
11441130
}
11451131

1132+
/* UNIMPLEMENTED METHODS FROM DATACOLLECTOR. TODO: Unify interface to remove those */
1133+
void ParallelDataCollector::readGlobalAttribute(const char*, void*, Dimensions*)
1134+
throw (DCException)
1135+
{
1136+
throw DCException(getExceptionString("readGlobalAttribute",
1137+
"feature currently not supported by Parallel HDF5"));
1138+
}
1139+
1140+
void ParallelDataCollector::writeGlobalAttribute(const CollectionType& /*type*/,
1141+
const char* /*name*/, const void* /*data*/) throw (DCException)
1142+
{
1143+
throw DCException(getExceptionString("readGlobalAttribute",
1144+
"feature currently not supported by Parallel HDF5"));
1145+
}
1146+
1147+
void ParallelDataCollector::writeGlobalAttribute(const CollectionType& /*type*/,
1148+
const char* /*name*/, uint32_t /*ndims*/, const Dimensions /*dims*/,
1149+
const void* /*data*/) throw (DCException)
1150+
{
1151+
throw DCException(getExceptionString("readGlobalAttribute",
1152+
"feature currently not supported by Parallel HDF5"));
1153+
}
1154+
1155+
void ParallelDataCollector::append(int32_t /*id*/, const CollectionType& /*type*/,
1156+
size_t /*count*/, const char* /*name*/, const void* /*data*/)
1157+
throw (DCException)
1158+
{
1159+
throw DCException(getExceptionString("readGlobalAttribute",
1160+
"feature currently not supported by Parallel HDF5"));
1161+
}
1162+
1163+
void ParallelDataCollector::append(int32_t /*id*/, const CollectionType& /*type*/,
1164+
size_t /*count*/, size_t /*offset*/, size_t /*stride*/, const char* /*name*/,
1165+
const void* /*data*/) throw (DCException)
1166+
{
1167+
throw DCException(getExceptionString("readGlobalAttribute",
1168+
"feature currently not supported by Parallel HDF5"));
1169+
}
1170+
1171+
void ParallelDataCollector::createReference(int32_t /*srcID*/,
1172+
const char */*srcName*/,
1173+
int32_t /*dstID*/,
1174+
const char */*dstName*/,
1175+
Dimensions /*count*/,
1176+
Dimensions /*offset*/,
1177+
Dimensions /*stride*/)
1178+
throw (DCException)
1179+
{
1180+
throw DCException(getExceptionString("readGlobalAttribute",
1181+
"feature currently not supported by Parallel HDF5"));
1182+
}
1183+
11461184
}

src/SerialDataCollector.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ namespace splash
369369
if (ndims < 1u || ndims > DSP_DIM_MAX)
370370
throw DCException(getExceptionString("writeAttribute", "maximum dimension `ndims` is invalid"));
371371

372+
/* group_path: absolute path to the last inode
373+
* obj_name: last inode, can be a group or a dataset
374+
*/
372375
std::string group_path, obj_name;
373376
std::string dataNameInternal = "";
374377
if (dataName)
@@ -378,6 +381,16 @@ namespace splash
378381
DCGroup group;
379382
if (dataName)
380383
{
384+
/* if the specified inode (obj_name) does not exist
385+
* (as dataset or group), create all missing groups along group_path
386+
* and even create an empty group for obj_name itself
387+
*
388+
* group_path + "/" + obj_name is the absolute path of dataName
389+
*/
390+
std::string pathAndName(group_path + "/" + obj_name);
391+
if(!DCGroup::exists(handles.get(id), pathAndName))
392+
group.create(handles.get(id), pathAndName);
393+
381394
// attach attribute to the dataset or group
382395
group.open(handles.get(0), group_path);
383396

src/generateCollectionType.cpp

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/**
2+
* Copyright 2015-2016 Carlchristian Eckert, Alexander Grund
3+
*
4+
* This file is part of libSplash.
5+
*
6+
* libSplash is free software: you can redistribute it and/or modify
7+
* it under the terms of of either the GNU General Public License or
8+
* the GNU Lesser General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* libSplash is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License and the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* and the GNU Lesser General Public License along with libSplash.
20+
* If not, see <http://www.gnu.org/licenses/>.
21+
*/
22+
23+
#ifndef GENERATE_COLLECTION_TYPE_H
24+
#define GENERATE_COLLECTION_TYPE_H
25+
26+
27+
#include "splash/basetypes/generateCollectionType.hpp"
28+
#include "splash/basetypes/basetypes.hpp"
29+
#include <typeinfo>
30+
#include <cassert>
31+
32+
namespace splash
33+
{
34+
35+
/**
36+
* Checks if a datatype_id (from an outer scope) can be used to generate a
37+
* specific CollectionType instance.
38+
*
39+
* If the call to the genType member function of a specific collection type
40+
* is successful, it will return the pointer to an instance of this type.
41+
*
42+
* @param _name the suffix of the ColType. i.e. to check for ColTypeBool,
43+
* _name should be set to Bool.
44+
*/
45+
#define TRY_COLTYPE(_name) \
46+
{ \
47+
CollectionType* t = ColType##_name::genType(datatype_id); \
48+
assert(t == NULL || typeid(*t) == typeid(ColType##_name)); \
49+
if(t != NULL) return t; \
50+
} \
51+
52+
53+
/**
54+
* Creates a new instance of a CollectionType based on the given datatype_id
55+
*
56+
* @param datatype_id the H5 datatype_id that should be converted into a
57+
* CollectionType
58+
*
59+
* @return A pointer to a heap-allocated CollectionType.
60+
* The allocated object must be freed by the caller at the end of its
61+
* lifetime.
62+
* If no matching CollectionType was found, returns a ColTypeUnknown
63+
* instance.
64+
*/
65+
CollectionType* generateCollectionType(hid_t datatype_id)
66+
{
67+
// basetypes atomic
68+
TRY_COLTYPE(Int8)
69+
TRY_COLTYPE(Int16)
70+
TRY_COLTYPE(Int32)
71+
TRY_COLTYPE(Int64)
72+
73+
TRY_COLTYPE(UInt8)
74+
TRY_COLTYPE(UInt16)
75+
TRY_COLTYPE(UInt32)
76+
TRY_COLTYPE(UInt64)
77+
78+
TRY_COLTYPE(Float)
79+
TRY_COLTYPE(Double)
80+
TRY_COLTYPE(Char)
81+
TRY_COLTYPE(Int)
82+
83+
84+
// ColType Bool -> must be before the other enum types!
85+
TRY_COLTYPE(Bool)
86+
87+
88+
// ColType String
89+
TRY_COLTYPE(String)
90+
91+
92+
// ColTypeArray()
93+
TRY_COLTYPE(Float2Array)
94+
TRY_COLTYPE(Float3Array)
95+
TRY_COLTYPE(Float4Array)
96+
97+
TRY_COLTYPE(Double2Array)
98+
TRY_COLTYPE(Double3Array)
99+
TRY_COLTYPE(Double4Array)
100+
101+
TRY_COLTYPE(Int4Array)
102+
TRY_COLTYPE(Int3Array)
103+
TRY_COLTYPE(Int2Array)
104+
105+
106+
// ColTypeDimArray
107+
TRY_COLTYPE(DimArray)
108+
109+
110+
// ColType Dim
111+
TRY_COLTYPE(Dim)
112+
113+
114+
// Coltype Compound
115+
TRY_COLTYPE(Float2)
116+
TRY_COLTYPE(Float3)
117+
TRY_COLTYPE(Float4)
118+
119+
TRY_COLTYPE(Double2)
120+
TRY_COLTYPE(Double3)
121+
TRY_COLTYPE(Double4)
122+
123+
TRY_COLTYPE(Int2)
124+
TRY_COLTYPE(Int3)
125+
TRY_COLTYPE(Int4)
126+
127+
return new ColTypeUnknown;
128+
}
129+
130+
#undef TRY_COLTYPE
131+
132+
} /* namespace splash */
133+
134+
135+
#endif /* GENERATE_COLLECTION_TYPE_H */

src/include/splash/DataCollector.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ namespace splash
366366
* @param type Type information for data.
367367
* @param dataName Name of the dataset in group \p id to write attribute to.
368368
* If dataName is NULL, the attribute is written for the iteration group.
369+
* If the path dataName does not yet exist, missing groups will be created.
369370
* @param attrName Name of the attribute.
370371
* @param buf Buffer to be written as attribute.
371372
*/

0 commit comments

Comments
 (0)