void seissol::checkpoint::mpio::Wavefield::write(const void* header, size_t headerSize) { SCOREP_USER_REGION("CheckPoint_write", SCOREP_USER_REGION_TYPE_FUNCTION); logInfo(rank()) << "Checkpoint backend: Writing."; // Write the header writeHeader(header, headerSize); // Save data SCOREP_USER_REGION_DEFINE(r_write_wavefield); SCOREP_USER_REGION_BEGIN(r_write_wavefield, "checkpoint_write_wavefield", SCOREP_USER_REGION_TYPE_COMMON); checkMPIErr(setDataView(file())); unsigned int totalIter = totalIterations(); unsigned int iter = iterations(); unsigned int count = dofsPerIteration(); if (m_useLargeBuffer) { totalIter = (totalIter + sizeof(real) - 1) / sizeof(real); iter = (iter + sizeof(real) - 1) / sizeof(real); count *= sizeof(real); } unsigned long offset = 0; for (unsigned int i = 0; i < totalIter; i++) { if (i == iter-1) // Last iteration count = numDofs() - (iter-1) * count; checkMPIErr(MPI_File_write_all(file(), const_cast<real*>(&dofs()[offset]), count, MPI_DOUBLE, MPI_STATUS_IGNORE)); if (i < iter-1) offset += count; // otherwise we just continue writing the last chunk over and over else if (i != totalIter-1) checkMPIErr(MPI_File_seek(file(), -count * sizeof(real), MPI_SEEK_CUR)); } SCOREP_USER_REGION_END(r_write_wavefield); // Finalize the checkpoint finalizeCheckpoint(); logInfo(rank()) << "Checkpoint backend: Writing. Done."; }
void seissol::checkpoint::h5::Wavefield::load(double &time, int ×tepWavefield, real* dofs) { logInfo(rank()) << "Loading wave field checkpoint"; seissol::checkpoint::CheckPoint::setLoaded(); hid_t h5file = open(linkFile()); checkH5Err(h5file); // Attributes hid_t h5attr = H5Aopen(h5file, "time", H5P_DEFAULT); checkH5Err(h5attr); checkH5Err(H5Aread(h5attr, H5T_NATIVE_DOUBLE, &time)); checkH5Err(H5Aclose(h5attr)); h5attr = H5Aopen(h5file, "timestep_wavefield", H5P_DEFAULT); checkH5Err(h5attr); checkH5Err(H5Aread(h5attr, H5T_NATIVE_INT, ×tepWavefield)); checkH5Err(H5Aclose(h5attr)); // Get dataset hid_t h5data = H5Dopen(h5file, "values", H5P_DEFAULT); checkH5Err(h5data); hid_t h5fSpace = H5Dget_space(h5data); checkH5Err(h5fSpace); // Read the data unsigned int offset = 0; hsize_t fStart = fileOffset(); hsize_t count = dofsPerIteration(); hid_t h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); for (unsigned int i = 0; i < totalIterations()-1; i++) { checkH5Err(H5Sselect_hyperslab(h5fSpace, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dread(h5data, H5T_NATIVE_DOUBLE, h5memSpace, h5fSpace, h5XferList(), &dofs[offset])); // We are finished in less iterations, read data twice // so everybody needs the same number of iterations if (i < iterations()-1) { fStart += count; offset += count; } } checkH5Err(H5Sclose(h5memSpace)); // Read reminding data in the last iteration count = numDofs() - (iterations() - 1) * count; h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); checkH5Err(H5Sselect_hyperslab(h5fSpace, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dread(h5data, H5T_NATIVE_DOUBLE, h5memSpace, h5fSpace, h5XferList(), &dofs[offset])); checkH5Err(H5Sclose(h5memSpace)); checkH5Err(H5Sclose(h5fSpace)); checkH5Err(H5Dclose(h5data)); checkH5Err(H5Fclose(h5file)); }
void seissol::checkpoint::h5::Wavefield::write(double time, int waveFieldTimeStep) { EPIK_TRACER("CheckPoint_write"); SCOREP_USER_REGION("CheckPoint_write", SCOREP_USER_REGION_TYPE_FUNCTION); logInfo(rank()) << "Writing check point."; EPIK_USER_REG(r_header, "checkpoint_write_header"); SCOREP_USER_REGION_DEFINE(r_header); EPIK_USER_START(r_header); SCOREP_USER_REGION_BEGIN(r_header, "checkpoint_write_header", SCOREP_USER_REGION_TYPE_COMMON); // Time checkH5Err(H5Awrite(m_h5time[odd()], H5T_NATIVE_DOUBLE, &time)); // Wavefield writer checkH5Err(H5Awrite(m_h5timestepWavefield[odd()], H5T_NATIVE_INT, &waveFieldTimeStep)); EPIK_USER_END(r_header); SCOREP_USER_REGION_END(r_header); // Save data EPIK_USER_REG(r_write_wavefield, "checkpoint_write_wavefield"); SCOREP_USER_REGION_DEFINE(r_write_wavefield); EPIK_USER_START(r_write_wavefield); SCOREP_USER_REGION_BEGIN(r_write_wavefield, "checkpoint_write_wavefield", SCOREP_USER_REGION_TYPE_COMMON); // Write the wave field unsigned int offset = 0; hsize_t fStart = fileOffset(); hsize_t count = dofsPerIteration(); hid_t h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); for (unsigned int i = 0; i < totalIterations()-1; i++) { checkH5Err(H5Sselect_hyperslab(m_h5fSpaceData, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dwrite(m_h5data[odd()], H5T_NATIVE_DOUBLE, h5memSpace, m_h5fSpaceData, h5XferList(), &const_cast<real*>(dofs())[offset])); // We are finished in less iterations, read data twice // so everybody needs the same number of iterations if (i < iterations()-1) { fStart += count; offset += count; } } checkH5Err(H5Sclose(h5memSpace)); // Save reminding data in the last iteration count = numDofs() - (iterations() - 1) * count; h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); checkH5Err(H5Sselect_hyperslab(m_h5fSpaceData, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dwrite(m_h5data[odd()], H5T_NATIVE_DOUBLE, h5memSpace, m_h5fSpaceData, h5XferList(), &dofs()[offset])); checkH5Err(H5Sclose(h5memSpace)); EPIK_USER_END(r_write_wavefield); SCOREP_USER_REGION_END(r_write_wavefield); // Finalize the checkpoint finalizeCheckpoint(); logInfo(rank()) << "Writing check point. Done."; }