mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Hadrons: meson field IO fix
This commit is contained in:
parent
c012899ed5
commit
c632455129
@ -39,13 +39,14 @@ public:
|
|||||||
A2AMatrixIo(void) = default;
|
A2AMatrixIo(void) = default;
|
||||||
A2AMatrixIo(std::string filename, std::string dataname,
|
A2AMatrixIo(std::string filename, std::string dataname,
|
||||||
const unsigned int nt, const unsigned int ni,
|
const unsigned int nt, const unsigned int ni,
|
||||||
const unsigned int nj, const unsigned int blockSize);
|
const unsigned int nj);
|
||||||
~A2AMatrixIo(void) = default;
|
~A2AMatrixIo(void) = default;
|
||||||
void initFile(const MetadataType &d);
|
void initFile(const MetadataType &d, const unsigned int chunkSize);
|
||||||
void saveBlock(const T *data, const unsigned int i, const unsigned int j);
|
void saveBlock(const T *data, const unsigned int i, const unsigned int j,
|
||||||
|
const unsigned int blockSizei, const unsigned int blockSizej);
|
||||||
private:
|
private:
|
||||||
std::string filename_, dataname_;
|
std::string filename_, dataname_;
|
||||||
unsigned int nt_, ni_, nj_, blockSize_;
|
unsigned int nt_, ni_, nj_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename MetadataType>
|
template <typename T, typename MetadataType>
|
||||||
@ -53,22 +54,21 @@ A2AMatrixIo<T, MetadataType>::A2AMatrixIo(std::string filename,
|
|||||||
std::string dataname,
|
std::string dataname,
|
||||||
const unsigned int nt,
|
const unsigned int nt,
|
||||||
const unsigned int ni,
|
const unsigned int ni,
|
||||||
const unsigned int nj,
|
const unsigned int nj)
|
||||||
const unsigned int blockSize)
|
|
||||||
: filename_(filename), dataname_(dataname)
|
: filename_(filename), dataname_(dataname)
|
||||||
, nt_(nt), ni_(ni), nj_(nj), blockSize_(blockSize)
|
, nt_(nt), ni_(ni), nj_(nj)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename T, typename MetadataType>
|
template <typename T, typename MetadataType>
|
||||||
void A2AMatrixIo<T, MetadataType>::initFile(const MetadataType &d)
|
void A2AMatrixIo<T, MetadataType>::initFile(const MetadataType &d, const unsigned int chunkSize)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_HDF5
|
#ifdef HAVE_HDF5
|
||||||
std::vector<hsize_t> dim = {static_cast<hsize_t>(nt_),
|
std::vector<hsize_t> dim = {static_cast<hsize_t>(nt_),
|
||||||
static_cast<hsize_t>(ni_),
|
static_cast<hsize_t>(ni_),
|
||||||
static_cast<hsize_t>(nj_)},
|
static_cast<hsize_t>(nj_)},
|
||||||
chunk = {static_cast<hsize_t>(nt_),
|
chunk = {static_cast<hsize_t>(nt_),
|
||||||
static_cast<hsize_t>(blockSize_),
|
static_cast<hsize_t>(chunkSize),
|
||||||
static_cast<hsize_t>(blockSize_)};
|
static_cast<hsize_t>(chunkSize)};
|
||||||
H5NS::DataSpace dataspace(dim.size(), dim.data());
|
H5NS::DataSpace dataspace(dim.size(), dim.data());
|
||||||
H5NS::DataSet dataset;
|
H5NS::DataSet dataset;
|
||||||
H5NS::DSetCreatPropList plist;
|
H5NS::DSetCreatPropList plist;
|
||||||
@ -94,11 +94,13 @@ void A2AMatrixIo<T, MetadataType>::initFile(const MetadataType &d)
|
|||||||
template <typename T, typename MetadataType>
|
template <typename T, typename MetadataType>
|
||||||
void A2AMatrixIo<T, MetadataType>::saveBlock(const T *data,
|
void A2AMatrixIo<T, MetadataType>::saveBlock(const T *data,
|
||||||
const unsigned int i,
|
const unsigned int i,
|
||||||
const unsigned int j)
|
const unsigned int j,
|
||||||
|
const unsigned int blockSizei,
|
||||||
|
const unsigned int blockSizej)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_HDF5
|
#ifdef HAVE_HDF5
|
||||||
Hdf5Reader reader(filename_);
|
Hdf5Reader reader(filename_);
|
||||||
std::vector<hsize_t> count = {nt_, blockSize_, blockSize_},
|
std::vector<hsize_t> count = {nt_, blockSizei, blockSizej},
|
||||||
offset = {0, static_cast<hsize_t>(i),
|
offset = {0, static_cast<hsize_t>(i),
|
||||||
static_cast<hsize_t>(j)},
|
static_cast<hsize_t>(j)},
|
||||||
stride = {1, 1, 1},
|
stride = {1, 1, 1},
|
||||||
|
@ -85,6 +85,7 @@ public:
|
|||||||
MatrixIo io;
|
MatrixIo io;
|
||||||
A2AMesonFieldMetadata metadata;
|
A2AMesonFieldMetadata metadata;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
unsigned int i, j, blockSizei, blockSizej;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
@ -100,9 +101,9 @@ public:
|
|||||||
virtual void execute(void);
|
virtual void execute(void);
|
||||||
private:
|
private:
|
||||||
// IO
|
// IO
|
||||||
std::string ioname(unsigned int m, unsigned int g) const;
|
std::string ioname(const unsigned int m, const unsigned int g) const;
|
||||||
std::string filename(unsigned int m, unsigned int g) const;
|
std::string filename(const unsigned int m, const unsigned int g) const;
|
||||||
void saveBlock(const MF_IO_TYPE *data, IoHelper &h, unsigned int i, unsigned int j);
|
void saveBlock(const MF_IO_TYPE *data, IoHelper &h);
|
||||||
private:
|
private:
|
||||||
bool hasPhase_{false};
|
bool hasPhase_{false};
|
||||||
std::string momphName_;
|
std::string momphName_;
|
||||||
@ -350,19 +351,23 @@ void TA2AMesonField<FImpl>::execute(void)
|
|||||||
const unsigned int m = f/ngamma, g = f % ngamma;
|
const unsigned int m = f/ngamma, g = f % ngamma;
|
||||||
IoHelper h;
|
IoHelper h;
|
||||||
|
|
||||||
h.io = MatrixIo(filename(m, g), ioname(m, g), nt, N_i, N_j, block);
|
h.io = MatrixIo(filename(m, g), ioname(m, g), nt, N_i, N_j);
|
||||||
for (auto pmu: mom_[m])
|
for (auto pmu: mom_[m])
|
||||||
{
|
{
|
||||||
h.metadata.momentum.push_back(pmu);
|
h.metadata.momentum.push_back(pmu);
|
||||||
}
|
}
|
||||||
h.metadata.gamma = gamma_[g];
|
h.metadata.gamma = gamma_[g];
|
||||||
h.offset = (m*ngamma + g)*nt*block*block;
|
h.i = i;
|
||||||
|
h.j = j;
|
||||||
|
h.blockSizei = mfBlock.dimension(3);
|
||||||
|
h.blockSizej = mfBlock.dimension(4);
|
||||||
|
h.offset = (m*ngamma + g)*nt*h.blockSizei*h.blockSizej;
|
||||||
nodeIo_.push_back(h);
|
nodeIo_.push_back(h);
|
||||||
}
|
}
|
||||||
// parallel IO
|
// parallel IO
|
||||||
for (auto &h: nodeIo_)
|
for (auto &h: nodeIo_)
|
||||||
{
|
{
|
||||||
saveBlock(mfBlock.data(), h, i, j);
|
saveBlock(mfBlock.data(), h);
|
||||||
}
|
}
|
||||||
env().getGrid()->Barrier();
|
env().getGrid()->Barrier();
|
||||||
#else
|
#else
|
||||||
@ -372,14 +377,18 @@ void TA2AMesonField<FImpl>::execute(void)
|
|||||||
{
|
{
|
||||||
IoHelper h;
|
IoHelper h;
|
||||||
|
|
||||||
h.io = MatrixIo(filename(m, g), ioname(m, g), nt, N_i, N_j, block);
|
h.io = MatrixIo(filename(m, g), ioname(m, g), nt, N_i, N_j);
|
||||||
for (auto pmu: mom_[m])
|
for (auto pmu: mom_[m])
|
||||||
{
|
{
|
||||||
h.metadata.momentum.push_back(pmu);
|
h.metadata.momentum.push_back(pmu);
|
||||||
}
|
}
|
||||||
h.metadata.gamma = gamma_[g];
|
h.metadata.gamma = gamma_[g];
|
||||||
h.offset = (m*ngamma + g)*nt*block*block;
|
h.i = i;
|
||||||
saveBlock(mfBlock.data(), h, i, j);
|
h.j = j;
|
||||||
|
h.blockSizei = mfBlock.dimension(3);
|
||||||
|
h.blockSizej = mfBlock.dimension(4);
|
||||||
|
h.offset = (m*ngamma + g)*nt*h.blockSizei*h.blockSizej;
|
||||||
|
saveBlock(mfBlock.data(), h);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
stopTimer("IO: total");
|
stopTimer("IO: total");
|
||||||
@ -416,17 +425,16 @@ std::string TA2AMesonField<FImpl>::filename(unsigned int m, unsigned int g) cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename FImpl>
|
template <typename FImpl>
|
||||||
void TA2AMesonField<FImpl>::saveBlock(const MF_IO_TYPE *data, IoHelper &h,
|
void TA2AMesonField<FImpl>::saveBlock(const MF_IO_TYPE *data, IoHelper &h)
|
||||||
unsigned int i, unsigned int j)
|
|
||||||
{
|
{
|
||||||
if ((i == 0) and (j == 0))
|
if ((h.i == 0) and (h.j == 0))
|
||||||
{
|
{
|
||||||
startTimer("IO: file creation");
|
startTimer("IO: file creation");
|
||||||
h.io.initFile(h.metadata);
|
h.io.initFile(h.metadata, par().block);
|
||||||
stopTimer("IO: file creation");
|
stopTimer("IO: file creation");
|
||||||
}
|
}
|
||||||
startTimer("IO: write block");
|
startTimer("IO: write block");
|
||||||
h.io.saveBlock(data + h.offset, i, j);
|
h.io.saveBlock(data + h.offset, h.i, h.j, h.blockSizei, h.blockSizej);
|
||||||
stopTimer("IO: write block");
|
stopTimer("IO: write block");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user