mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Working on the RNGModule
This commit is contained in:
parent
1189ebc8b5
commit
0dfda4bb90
@ -60,31 +60,86 @@ class GridFourDimModule : public GridModule {
|
||||
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class RNGModuleParameters: Serializable {
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(RNGModuleParameters,
|
||||
std::vector<int>, SerialSeed_,
|
||||
std::vector<int>, ParallelSeed_,);
|
||||
|
||||
|
||||
// default constructor, needed for the non-Reader
|
||||
// construction of the module
|
||||
RNGModuleParameters(){
|
||||
SerialSeed_.resize(0);
|
||||
ParallelSeed_.resize(0);
|
||||
}
|
||||
|
||||
RNGModuleParameters(const std::vector<int> S, const std::vector<int> P){
|
||||
set_RNGSeeds(S,P);
|
||||
}
|
||||
|
||||
template < class ReaderClass >
|
||||
RNGModuleParameters(ReaderClass &Reader){
|
||||
read(Reader, "RandomNumberGenerator", *this);
|
||||
}
|
||||
|
||||
void set_RNGSeeds(const std::vector<int>& S, const std::vector<int>& P){
|
||||
SerialSeed_ = S;
|
||||
ParallelSeed_ = P;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class RNGModule{
|
||||
// Random number generators
|
||||
GridSerialRNG sRNG_;
|
||||
std::unique_ptr<GridParallelRNG> pRNG_;
|
||||
std::vector<int> SerialSeed_;
|
||||
std::vector<int> ParallelSeed_;
|
||||
RNGModuleParameters Params_;
|
||||
|
||||
public:
|
||||
void set_pRNG(GridParallelRNG* pRNG){
|
||||
pRNG_.reset(pRNG);
|
||||
}
|
||||
template < class ReaderClass >
|
||||
RNGModule(ReaderClass &Reader):Params_(Reader){};
|
||||
|
||||
void set_RNGSeeds(const std::vector<int> S, const std::vector<int> P) {
|
||||
SerialSeed_ = S;
|
||||
ParallelSeed_ = P;
|
||||
RNGModule(){};
|
||||
|
||||
void set_pRNG(GridParallelRNG* pRNG){
|
||||
pRNG_.reset(pRNG);
|
||||
}
|
||||
|
||||
void set_RNGSeeds(const std::vector<int> S, const std::vector<int> P) {
|
||||
Params_.set_RNGSeeds(S,P);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GridSerialRNG& get_sRNG(){
|
||||
if (Params_.SerialSeed_.size()==0){
|
||||
std::cout << "Serial seeds not initialized" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
return sRNG_;
|
||||
}
|
||||
GridParallelRNG& get_pRNG(){
|
||||
if (Params_.ParallelSeed_.size()==0){
|
||||
std::cout << "Parallel seeds not initialized" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
return *pRNG_.get();
|
||||
}
|
||||
|
||||
GridSerialRNG& get_sRNG(){return sRNG_;}
|
||||
GridParallelRNG& get_pRNG(){return *pRNG_.get();}
|
||||
void seed(){
|
||||
sRNG_.SeedFixedIntegers(SerialSeed_);
|
||||
pRNG_->SeedFixedIntegers(ParallelSeed_);
|
||||
sRNG_.SeedFixedIntegers(Params_.SerialSeed_);
|
||||
pRNG_->SeedFixedIntegers(Params_.ParallelSeed_);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
/// Smearing module
|
||||
template <class ImplementationPolicy>
|
||||
class SmearingModule{
|
||||
@ -96,6 +151,8 @@ class StoutSmearingModule: public SmearingModule<ImplementationPolicy>{
|
||||
SmearedConfiguration<ImplementationPolicy> SmearingPolicy;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Checkpoint module, owns the Checkpointer
|
||||
template <class ImplementationPolicy>
|
||||
class CheckPointModule {
|
||||
|
@ -43,10 +43,6 @@ namespace Grid {
|
||||
double, beta,
|
||||
int, MDsteps,
|
||||
double, TrajectoryLength,
|
||||
//int, SaveInterval,
|
||||
//std::string, format,
|
||||
//std::string, conf_prefix,
|
||||
//std::string, rng_prefix,
|
||||
std::string, serial_seeds,
|
||||
std::string, parallel_seeds,
|
||||
);
|
||||
@ -86,6 +82,9 @@ int main(int argc, char **argv) {
|
||||
|
||||
HMCWrapper TheHMC;
|
||||
TheHMC.Resources.AddFourDimGrid("gauge");
|
||||
|
||||
// here using the Reader but an overloaded function to pass the
|
||||
// parameters class is provided
|
||||
TheHMC.Resources.LoadBinaryCheckpointer(Reader);
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user