mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-10 06:00:45 +01: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{
|
class RNGModule{
|
||||||
// Random number generators
|
// Random number generators
|
||||||
GridSerialRNG sRNG_;
|
GridSerialRNG sRNG_;
|
||||||
std::unique_ptr<GridParallelRNG> pRNG_;
|
std::unique_ptr<GridParallelRNG> pRNG_;
|
||||||
std::vector<int> SerialSeed_;
|
RNGModuleParameters Params_;
|
||||||
std::vector<int> ParallelSeed_;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_pRNG(GridParallelRNG* pRNG){
|
template < class ReaderClass >
|
||||||
pRNG_.reset(pRNG);
|
RNGModule(ReaderClass &Reader):Params_(Reader){};
|
||||||
}
|
|
||||||
|
|
||||||
void set_RNGSeeds(const std::vector<int> S, const std::vector<int> P) {
|
RNGModule(){};
|
||||||
SerialSeed_ = S;
|
|
||||||
ParallelSeed_ = P;
|
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(){
|
void seed(){
|
||||||
sRNG_.SeedFixedIntegers(SerialSeed_);
|
sRNG_.SeedFixedIntegers(Params_.SerialSeed_);
|
||||||
pRNG_->SeedFixedIntegers(ParallelSeed_);
|
pRNG_->SeedFixedIntegers(Params_.ParallelSeed_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////
|
||||||
/// Smearing module
|
/// Smearing module
|
||||||
template <class ImplementationPolicy>
|
template <class ImplementationPolicy>
|
||||||
class SmearingModule{
|
class SmearingModule{
|
||||||
@ -96,6 +151,8 @@ class StoutSmearingModule: public SmearingModule<ImplementationPolicy>{
|
|||||||
SmearedConfiguration<ImplementationPolicy> SmearingPolicy;
|
SmearedConfiguration<ImplementationPolicy> SmearingPolicy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Checkpoint module, owns the Checkpointer
|
// Checkpoint module, owns the Checkpointer
|
||||||
template <class ImplementationPolicy>
|
template <class ImplementationPolicy>
|
||||||
class CheckPointModule {
|
class CheckPointModule {
|
||||||
|
@ -43,10 +43,6 @@ namespace Grid {
|
|||||||
double, beta,
|
double, beta,
|
||||||
int, MDsteps,
|
int, MDsteps,
|
||||||
double, TrajectoryLength,
|
double, TrajectoryLength,
|
||||||
//int, SaveInterval,
|
|
||||||
//std::string, format,
|
|
||||||
//std::string, conf_prefix,
|
|
||||||
//std::string, rng_prefix,
|
|
||||||
std::string, serial_seeds,
|
std::string, serial_seeds,
|
||||||
std::string, parallel_seeds,
|
std::string, parallel_seeds,
|
||||||
);
|
);
|
||||||
@ -86,6 +82,9 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
HMCWrapper TheHMC;
|
HMCWrapper TheHMC;
|
||||||
TheHMC.Resources.AddFourDimGrid("gauge");
|
TheHMC.Resources.AddFourDimGrid("gauge");
|
||||||
|
|
||||||
|
// here using the Reader but an overloaded function to pass the
|
||||||
|
// parameters class is provided
|
||||||
TheHMC.Resources.LoadBinaryCheckpointer(Reader);
|
TheHMC.Resources.LoadBinaryCheckpointer(Reader);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user