1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

HDF5 types static initialisation is mysteriously buggy on BG/Q, changing strategy

This commit is contained in:
Antonin Portelli 2017-01-19 18:02:53 -08:00
parent 2c673666da
commit 6eea9e4da7
5 changed files with 16 additions and 22 deletions

View File

@ -27,7 +27,6 @@ endif
if BUILD_HDF5
extra_sources+=serialisation/Hdf5IO.cc
extra_sources+=serialisation/Hdf5Type.cc
extra_headers+=serialisation/Hdf5IO.h
extra_headers+=serialisation/Hdf5Type.h
endif

View File

@ -12,7 +12,7 @@ Hdf5Writer::Hdf5Writer(const std::string &fileName)
{
group_ = file_.openGroup("/");
writeSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold",
*Hdf5Type<unsigned int>::type);
*Hdf5Type<unsigned int>::type());
}
void Hdf5Writer::push(const std::string &s)
@ -62,7 +62,7 @@ Hdf5Reader::Hdf5Reader(const std::string &fileName)
{
group_ = file_.openGroup("/");
readSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold",
*Hdf5Type<unsigned int>::type);
*Hdf5Type<unsigned int>::type());
}
void Hdf5Reader::push(const std::string &s)

View File

@ -92,7 +92,7 @@ namespace Grid
template <typename U>
void Hdf5Writer::writeDefault(const std::string &s, const U &x)
{
writeSingleAttribute(x, s, *Hdf5Type<U>::type);
writeSingleAttribute(x, s, *Hdf5Type<U>::type());
}
template <>
@ -122,15 +122,15 @@ namespace Grid
{
H5NS::DataSet dataSet;
dataSet = group_.createDataSet(s, *Hdf5Type<Element>::type, dataSpace);
dataSet.write(flatx.data(), *Hdf5Type<Element>::type);
dataSet = group_.createDataSet(s, *Hdf5Type<Element>::type(), dataSpace);
dataSet.write(flatx.data(), *Hdf5Type<Element>::type());
}
else
{
H5NS::Attribute attribute;
attribute = group_.createAttribute(s, *Hdf5Type<Element>::type, dataSpace);
attribute.write(*Hdf5Type<Element>::type, flatx.data());
attribute = group_.createAttribute(s, *Hdf5Type<Element>::type(), dataSpace);
attribute.write(*Hdf5Type<Element>::type(), flatx.data());
}
}
@ -140,7 +140,7 @@ namespace Grid
{
push(s);
writeSingleAttribute(x.size(), HDF5_GRID_GUARD "vector_size",
*Hdf5Type<uint64_t>::type);
*Hdf5Type<uint64_t>::type());
for (hsize_t i = 0; i < x.size(); ++i)
{
write(s + "_" + std::to_string(i), x[i]);
@ -162,7 +162,7 @@ namespace Grid
template <typename U>
void Hdf5Reader::readDefault(const std::string &s, U &output)
{
readSingleAttribute(output, s, *Hdf5Type<U>::type);
readSingleAttribute(output, s, *Hdf5Type<U>::type());
}
template <>
@ -210,14 +210,14 @@ namespace Grid
H5NS::DataSet dataSet;
dataSet = group_.openDataSet(s);
dataSet.read(buf.data(), *Hdf5Type<Element>::type);
dataSet.read(buf.data(), *Hdf5Type<Element>::type());
}
else
{
H5NS::Attribute attribute;
attribute = group_.openAttribute(s);
attribute.read(*Hdf5Type<Element>::type, buf.data());
attribute.read(*Hdf5Type<Element>::type(), buf.data());
}
// reconstruct the multidimensional vector
@ -234,7 +234,7 @@ namespace Grid
push(s);
readSingleAttribute(size, HDF5_GRID_GUARD "vector_size",
*Hdf5Type<uint64_t>::type);
*Hdf5Type<uint64_t>::type());
x.resize(size);
for (hsize_t i = 0; i < x.size(); ++i)
{

View File

@ -1,8 +0,0 @@
#include "Hdf5Type.h"
using namespace Grid;
#define HDF5_NATIVE_TYPE(predType, cType)\
const H5NS::PredType * Hdf5Type<cType>::type = &H5NS::PredType::predType;
DEFINE_HDF5_NATIVE_TYPES;

View File

@ -12,7 +12,10 @@
template <>\
struct Hdf5Type<cType>\
{\
static const H5NS::PredType *type;\
static inline const H5NS::PredType *type(void)\
{\
return &H5NS::PredType::predType;\
}\
static constexpr bool isNative = true;\
};