Skip to content

Commit

Permalink
Merge pull request ComputationalRadiationPhysics#375 from f-schmitt-z…
Browse files Browse the repository at this point in the history
…ih/fix-checkpoints

Fix checkpointing in HDF5Writer
  • Loading branch information
ax3l committed Apr 28, 2014
2 parents 671a67e + a8e5098 commit b6e3901
Showing 1 changed file with 32 additions and 35 deletions.
67 changes: 32 additions & 35 deletions src/picongpu/include/plugins/hdf5/HDF5Writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ class HDF5Writer : public ISimulationPlugin
public:

HDF5Writer() :
filename("h5"),
checkpointFilename(""),
restartFilename(""),
notifyFrequency(0),
lastCheckpoint(-1)
filename("h5_data"),
checkpointFilename("h5_checkpoint"),
restartFilename(""), /* set to checkpointFilename by default */
notifyPeriod(0)
{
Environment<>::get().PluginConnector().registerPlugin(this);
}
Expand All @@ -109,7 +108,7 @@ class HDF5Writer : public ISimulationPlugin
void pluginRegisterHelp(po::options_description& desc)
{
desc.add_options()
("hdf5.period", po::value<uint32_t > (&notifyFrequency)->default_value(0),
("hdf5.period", po::value<uint32_t > (&notifyPeriod)->default_value(0),
"enable HDF5 IO [for each n-th step]")
("hdf5.file", po::value<std::string > (&filename)->default_value(filename),
"HDF5 output filename (prefix)")
Expand All @@ -132,14 +131,12 @@ class HDF5Writer : public ISimulationPlugin

__host__ void notify(uint32_t currentStep)
{
if ((int64_t)currentStep > lastCheckpoint)
notificationReceived(currentStep, false);
notificationReceived(currentStep, false);
}

void checkpoint(uint32_t currentStep)
{
notificationReceived(currentStep, true);
lastCheckpoint = currentStep;
}

void restart(uint32_t restartStep)
Expand Down Expand Up @@ -268,44 +265,44 @@ class HDF5Writer : public ISimulationPlugin

void pluginLoad()
{
if (notifyFrequency > 0)
mThreadParams.gridPosition =
Environment<simDim>::get().SubGrid().getSimulationBox().getGlobalOffset();

GridController<simDim> &gc = Environment<simDim>::get().GridController();
/* It is important that we never change the mpi_pos after this point
* because we get problems with the restart.
* Otherwise we do not know which gpu must load the ghost parts around
* the sliding window.
*/
mpi_pos = gc.getPosition();
mpi_size = gc.getGpuNodes();

splashMpiPos.set(0, 0, 0);
splashMpiSize.set(1, 1, 1);

for (uint32_t i = 0; i < simDim; ++i)
{
mThreadParams.gridPosition =
Environment<simDim>::get().SubGrid().getSimulationBox().getGlobalOffset();
splashMpiPos[i] = mpi_pos[i];
splashMpiSize[i] = mpi_size[i];
}

GridController<simDim> &gc = Environment<simDim>::get().GridController();
/* It is important that we never change the mpi_pos after this point
* because we get problems with the restart.
* Otherwise we do not know which gpu must load the ghost parts around
* the sliding window.
*/
mpi_pos = gc.getPosition();
mpi_size = gc.getGpuNodes();

splashMpiPos.set(0, 0, 0);
splashMpiSize.set(1, 1, 1);

for (uint32_t i = 0; i < simDim; ++i)
{
splashMpiPos[i] = mpi_pos[i];
splashMpiSize[i] = mpi_size[i];
}

Environment<>::get().PluginConnector().setNotificationPeriod(this, notifyFrequency);
/* only register for notify callback when .period is set on command line */
if (notifyPeriod > 0)
{
Environment<>::get().PluginConnector().setNotificationPeriod(this, notifyPeriod);
}

if (restartFilename == "")
{
restartFilename = filename;
restartFilename = checkpointFilename;
}

loaded = true;
}

void pluginUnload()
{
if (notifyFrequency > 0)
__delete(mThreadParams.dataCollector);
__delete(mThreadParams.dataCollector);
}

typedef PICToSplash<float_X>::type SplashFloatXType;
Expand Down Expand Up @@ -394,7 +391,7 @@ class HDF5Writer : public ISimulationPlugin

MappingDesc *cellDescription;

uint32_t notifyFrequency;
uint32_t notifyPeriod;
int64_t lastCheckpoint;
std::string filename;
std::string checkpointFilename;
Expand Down

0 comments on commit b6e3901

Please sign in to comment.