2015-12-20 02:29:51 +00:00
|
|
|
#ifndef NERSC_CHECKPOINTER
|
|
|
|
#define NERSC_CHECKPOINTER
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
|
|
namespace Grid{
|
|
|
|
namespace QCD{
|
|
|
|
|
|
|
|
|
2016-01-02 13:37:25 +00:00
|
|
|
template<class Gimpl>
|
|
|
|
class NerscHmcCheckpointer : public HmcObservable<typename Gimpl::GaugeField> {
|
2015-12-20 02:29:51 +00:00
|
|
|
private:
|
|
|
|
std::string configStem;
|
|
|
|
std::string rngStem;
|
|
|
|
int SaveInterval;
|
|
|
|
public:
|
2016-01-02 13:37:25 +00:00
|
|
|
INHERIT_GIMPL_TYPES(Gimpl);
|
|
|
|
|
2015-12-20 02:29:51 +00:00
|
|
|
NerscHmcCheckpointer(std::string cf, std::string rn,int savemodulo) {
|
|
|
|
configStem = cf;
|
|
|
|
rngStem = rn;
|
|
|
|
SaveInterval= savemodulo;
|
|
|
|
};
|
|
|
|
|
|
|
|
void TrajectoryComplete(int traj, GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG & pRNG )
|
|
|
|
{
|
|
|
|
if ( (traj % SaveInterval)== 0 ) {
|
2015-12-21 15:37:26 +00:00
|
|
|
std::string rng; { std::ostringstream os; os << rngStem <<"."<< traj; rng = os.str(); }
|
|
|
|
std::string config;{ std::ostringstream os; os << configStem <<"."<< traj; config = os.str();}
|
2015-12-20 02:29:51 +00:00
|
|
|
|
|
|
|
int precision32=1;
|
|
|
|
int tworow =0;
|
|
|
|
NerscIO::writeRNGState(sRNG,pRNG,rng);
|
|
|
|
NerscIO::writeConfiguration(U,config,tworow,precision32);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void CheckpointRestore(int traj, GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG & pRNG ){
|
2015-12-21 15:37:26 +00:00
|
|
|
|
|
|
|
std::string rng; { std::ostringstream os; os << rngStem <<"."<< traj; rng = os.str(); }
|
|
|
|
std::string config;{ std::ostringstream os; os << configStem <<"."<< traj; config = os.str();}
|
2015-12-20 02:29:51 +00:00
|
|
|
|
|
|
|
NerscField header;
|
|
|
|
NerscIO::readRNGState(sRNG,pRNG,header,rng);
|
|
|
|
NerscIO::readConfiguration(U,header,config);
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}}
|
|
|
|
#endif
|