Commit 0fd21eba authored by fabianw's avatar fabianw
Browse files

added MPI wavelet reader

parent 6ced3abf
......@@ -217,8 +217,7 @@ void Interpolator<TKernel>::_load_wavelet(ArgumentParser& p)
abort();
}
const string fname(filename);
Reader_WaveletCompression myreader(fname, byte_swap, wavelet_type);
Reader_WaveletCompression myreader(filename, byte_swap, wavelet_type);
myreader.load_file();
const int NBX = myreader.xblocks();
const int NBY = myreader.yblocks();
......@@ -228,22 +227,24 @@ void Interpolator<TKernel>::_load_wavelet(ArgumentParser& p)
Real* const data = new Real[num_elem];
Real blockdata[_BLOCKSIZE_][_BLOCKSIZE_][_BLOCKSIZE_];
for (int iz=0; iz < NBZ; ++iz)
for (int iy=0; iy < NBY; ++iy)
for (int ix=0; ix < NBX; ++ix)
const int nBlocks = NBX * NBY * NBZ;
for (int i = 0; i < nBlocks; ++i)
{
const int ix = i%NBX;
const int iy = (i/NBX)%NBY;
const int iz = (i/(NBX*NBY))%NBZ;
const double zratio = myreader.load_block2(ix, iy, iz, blockdata);
for (int z=0; z < _BLOCKSIZE_; ++z)
for (int y=0; y < _BLOCKSIZE_; ++y)
{
const double zratio = myreader.load_block2(ix, iy, iz, blockdata);
for (int z=0; z < _BLOCKSIZE_; ++z)
for (int y=0; y < _BLOCKSIZE_; ++y)
{
assert(iy*_BLOCKSIZE_+y < maxDim[1]);
assert(iz*_BLOCKSIZE_+z < maxDim[2]);
const size_t offset = _BLOCKSIZE_*(static_cast<size_t>(ix) + NBX*(y+iy*_BLOCKSIZE_ + (z+static_cast<size_t>(iz)*_BLOCKSIZE_)*NBY*_BLOCKSIZE_));
Real* const dst = data + offset;
memcpy(dst, &blockdata[z][y][0], _BLOCKSIZE_*sizeof(Real));
}
assert(iy*_BLOCKSIZE_+y < maxDim[1]);
assert(iz*_BLOCKSIZE_+z < maxDim[2]);
const size_t offset = _BLOCKSIZE_*(static_cast<size_t>(ix) + NBX*(y+iy*_BLOCKSIZE_ + (z+static_cast<size_t>(iz)*_BLOCKSIZE_)*NBY*_BLOCKSIZE_));
Real* const dst = data + offset;
memcpy(dst, &blockdata[z][y][0], _BLOCKSIZE_*sizeof(Real));
}
}
this->m_data = std::move(Matrix_t(maxDim[0], maxDim[1], maxDim[2], data));
delete [] data;
......
......@@ -324,6 +324,63 @@ void InterpolatorMPI<Tinterp>::_load_h5_MPI(ArgumentParser& parser)
template <typename Tinterp>
void InterpolatorMPI<Tinterp>::_load_wavelet_MPI(ArgumentParser& p)
{
#ifdef _USE_CUBISMZ_
const bool byte_swap = p("-swap").asBool(false);
const int wavelet_type = p("-wtype").asInt(1);
const std::string filename = p("file").asString("");
if (filename == "")
{
if (m_isroot)
std::cerr << "ERROR: InterpolatorMPI: -file is not specified. No input file given" << std::endl;
abort();
}
// Reader_WaveletCompressionMPI myreader(m_comm, filename, byte_swap, wavelet_type);
Reader_WaveletCompressionMPI myreader(MPI::COMM_WORLD, filename, byte_swap, wavelet_type);
myreader.load_file();
const int NBX = myreader.xblocks();
const int NBY = myreader.yblocks();
const int NBZ = myreader.zblocks();
assert(NBX % m_PESize[0] == 0);
assert(NBY % m_PESize[1] == 0);
assert(NBZ % m_PESize[2] == 0);
const int myNBX = NBX/m_PESize[0];
const int myNBY = NBY/m_PESize[1];
const int myNBZ = NBZ/m_PESize[2];
const int maxDim[3] = {myNBX*_BLOCKSIZE_, myNBY*_BLOCKSIZE_, myNBZ*_BLOCKSIZE_};
const size_t num_elem = static_cast<size_t>(maxDim[0]) * maxDim[1] * maxDim[2];
Real* const data = new Real[num_elem];
Real blockdata[_BLOCKSIZE_][_BLOCKSIZE_][_BLOCKSIZE_];
const int nBlocks = myNBX * myNBY * myNBZ;
for (int i = 0; i < nBlocks; ++i)
{
const int ix = i%myNBX;
const int iy = (i/myNBX)%myNBY;
const int iz = (i/(myNBX*myNBY))%myNBZ;
const double zratio = myreader.load_block2(
ix+myNBX*m_myPEIndex[0],
iy+myNBY*m_myPEIndex[1],
iz+myNBZ*m_myPEIndex[2],
blockdata);
for (int z=0; z < _BLOCKSIZE_; ++z)
for (int y=0; y < _BLOCKSIZE_; ++y)
{
assert(iy*_BLOCKSIZE_+y < maxDim[1]);
assert(iz*_BLOCKSIZE_+z < maxDim[2]);
const size_t offset = _BLOCKSIZE_*(static_cast<size_t>(ix) + myNBX*(y+iy*_BLOCKSIZE_ + (z+static_cast<size_t>(iz)*_BLOCKSIZE_)*myNBY*_BLOCKSIZE_));
Real* const dst = data + offset;
memcpy(dst, &blockdata[z][y][0], _BLOCKSIZE_*sizeof(Real));
}
}
this->m_data = std::move(Matrix_t(maxDim[0], maxDim[1], maxDim[2], data));
delete [] data;
#else
fprintf(stderr, "WARNING: Executable was compiled without wavelet compressor support...\n");
#endif /* _USE_CUBISMZ_ */
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment