mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-25 21:25:56 +01:00
HDF5 types static initialisation is mysteriously buggy on BG/Q, changing strategy
This commit is contained in:
parent
2c673666da
commit
6eea9e4da7
@ -27,7 +27,6 @@ endif
|
|||||||
|
|
||||||
if BUILD_HDF5
|
if BUILD_HDF5
|
||||||
extra_sources+=serialisation/Hdf5IO.cc
|
extra_sources+=serialisation/Hdf5IO.cc
|
||||||
extra_sources+=serialisation/Hdf5Type.cc
|
|
||||||
extra_headers+=serialisation/Hdf5IO.h
|
extra_headers+=serialisation/Hdf5IO.h
|
||||||
extra_headers+=serialisation/Hdf5Type.h
|
extra_headers+=serialisation/Hdf5Type.h
|
||||||
endif
|
endif
|
||||||
|
@ -12,7 +12,7 @@ Hdf5Writer::Hdf5Writer(const std::string &fileName)
|
|||||||
{
|
{
|
||||||
group_ = file_.openGroup("/");
|
group_ = file_.openGroup("/");
|
||||||
writeSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold",
|
writeSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold",
|
||||||
*Hdf5Type<unsigned int>::type);
|
*Hdf5Type<unsigned int>::type());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hdf5Writer::push(const std::string &s)
|
void Hdf5Writer::push(const std::string &s)
|
||||||
@ -62,7 +62,7 @@ Hdf5Reader::Hdf5Reader(const std::string &fileName)
|
|||||||
{
|
{
|
||||||
group_ = file_.openGroup("/");
|
group_ = file_.openGroup("/");
|
||||||
readSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold",
|
readSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold",
|
||||||
*Hdf5Type<unsigned int>::type);
|
*Hdf5Type<unsigned int>::type());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hdf5Reader::push(const std::string &s)
|
void Hdf5Reader::push(const std::string &s)
|
||||||
|
@ -92,7 +92,7 @@ namespace Grid
|
|||||||
template <typename U>
|
template <typename U>
|
||||||
void Hdf5Writer::writeDefault(const std::string &s, const U &x)
|
void Hdf5Writer::writeDefault(const std::string &s, const U &x)
|
||||||
{
|
{
|
||||||
writeSingleAttribute(x, s, *Hdf5Type<U>::type);
|
writeSingleAttribute(x, s, *Hdf5Type<U>::type());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -122,15 +122,15 @@ namespace Grid
|
|||||||
{
|
{
|
||||||
H5NS::DataSet dataSet;
|
H5NS::DataSet dataSet;
|
||||||
|
|
||||||
dataSet = group_.createDataSet(s, *Hdf5Type<Element>::type, dataSpace);
|
dataSet = group_.createDataSet(s, *Hdf5Type<Element>::type(), dataSpace);
|
||||||
dataSet.write(flatx.data(), *Hdf5Type<Element>::type);
|
dataSet.write(flatx.data(), *Hdf5Type<Element>::type());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
H5NS::Attribute attribute;
|
H5NS::Attribute attribute;
|
||||||
|
|
||||||
attribute = group_.createAttribute(s, *Hdf5Type<Element>::type, dataSpace);
|
attribute = group_.createAttribute(s, *Hdf5Type<Element>::type(), dataSpace);
|
||||||
attribute.write(*Hdf5Type<Element>::type, flatx.data());
|
attribute.write(*Hdf5Type<Element>::type(), flatx.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ namespace Grid
|
|||||||
{
|
{
|
||||||
push(s);
|
push(s);
|
||||||
writeSingleAttribute(x.size(), HDF5_GRID_GUARD "vector_size",
|
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)
|
for (hsize_t i = 0; i < x.size(); ++i)
|
||||||
{
|
{
|
||||||
write(s + "_" + std::to_string(i), x[i]);
|
write(s + "_" + std::to_string(i), x[i]);
|
||||||
@ -162,7 +162,7 @@ namespace Grid
|
|||||||
template <typename U>
|
template <typename U>
|
||||||
void Hdf5Reader::readDefault(const std::string &s, U &output)
|
void Hdf5Reader::readDefault(const std::string &s, U &output)
|
||||||
{
|
{
|
||||||
readSingleAttribute(output, s, *Hdf5Type<U>::type);
|
readSingleAttribute(output, s, *Hdf5Type<U>::type());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -210,14 +210,14 @@ namespace Grid
|
|||||||
H5NS::DataSet dataSet;
|
H5NS::DataSet dataSet;
|
||||||
|
|
||||||
dataSet = group_.openDataSet(s);
|
dataSet = group_.openDataSet(s);
|
||||||
dataSet.read(buf.data(), *Hdf5Type<Element>::type);
|
dataSet.read(buf.data(), *Hdf5Type<Element>::type());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
H5NS::Attribute attribute;
|
H5NS::Attribute attribute;
|
||||||
|
|
||||||
attribute = group_.openAttribute(s);
|
attribute = group_.openAttribute(s);
|
||||||
attribute.read(*Hdf5Type<Element>::type, buf.data());
|
attribute.read(*Hdf5Type<Element>::type(), buf.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
// reconstruct the multidimensional vector
|
// reconstruct the multidimensional vector
|
||||||
@ -234,7 +234,7 @@ namespace Grid
|
|||||||
|
|
||||||
push(s);
|
push(s);
|
||||||
readSingleAttribute(size, HDF5_GRID_GUARD "vector_size",
|
readSingleAttribute(size, HDF5_GRID_GUARD "vector_size",
|
||||||
*Hdf5Type<uint64_t>::type);
|
*Hdf5Type<uint64_t>::type());
|
||||||
x.resize(size);
|
x.resize(size);
|
||||||
for (hsize_t i = 0; i < x.size(); ++i)
|
for (hsize_t i = 0; i < x.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -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;
|
|
@ -12,7 +12,10 @@
|
|||||||
template <>\
|
template <>\
|
||||||
struct Hdf5Type<cType>\
|
struct Hdf5Type<cType>\
|
||||||
{\
|
{\
|
||||||
static const H5NS::PredType *type;\
|
static inline const H5NS::PredType *type(void)\
|
||||||
|
{\
|
||||||
|
return &H5NS::PredType::predType;\
|
||||||
|
}\
|
||||||
static constexpr bool isNative = true;\
|
static constexpr bool isNative = true;\
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user