mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
added Serial RNG - code compiles but not tested!
This commit is contained in:
parent
5c23abe507
commit
a8f3a111a5
@ -84,6 +84,16 @@ GridParallelRNG * Environment::get4dRng(void)
|
||||
return rng4d_.get();
|
||||
}
|
||||
|
||||
GridSerialRNG * Environment::getSerialRng(void)
|
||||
{
|
||||
if (rngSerial_ == nullptr)
|
||||
{
|
||||
rngSerial_.reset(new GridSerialRNG());
|
||||
}
|
||||
|
||||
return rngSerial_.get();
|
||||
}
|
||||
|
||||
// general memory management ///////////////////////////////////////////////////
|
||||
void Environment::addObject(const std::string name, const int moduleAddress)
|
||||
{
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
typedef std::unique_ptr<GridCartesian> GridPt;
|
||||
typedef std::unique_ptr<GridRedBlackCartesian> GridRbPt;
|
||||
typedef std::unique_ptr<GridParallelRNG> RngPt;
|
||||
typedef std::unique_ptr<GridSerialRNG> SerialRngPt;
|
||||
enum class Storage {object, cache, temporary};
|
||||
private:
|
||||
struct ObjInfo
|
||||
@ -114,6 +115,7 @@ public:
|
||||
double getVolume(void) const;
|
||||
// random number generator
|
||||
GridParallelRNG * get4dRng(void);
|
||||
GridSerialRNG * getSerialRng(void);
|
||||
// general memory management
|
||||
void addObject(const std::string name,
|
||||
const int moduleAddress = -1);
|
||||
@ -183,6 +185,7 @@ private:
|
||||
unsigned int nd_;
|
||||
// random number generator
|
||||
RngPt rng4d_{nullptr};
|
||||
SerialRngPt rngSerial_{nullptr};
|
||||
// object store
|
||||
std::vector<ObjInfo> object_;
|
||||
std::map<std::string, unsigned int> objectAddress_;
|
||||
|
@ -93,3 +93,18 @@ GridParallelRNG & ModuleBase::rng4d(void)
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
GridSerialRNG & ModuleBase::rngSerial(void)
|
||||
{
|
||||
auto &r = *env().getSerialRng();
|
||||
|
||||
if (makeSeedString() != seed_)
|
||||
{
|
||||
seed_ = makeSeedString();
|
||||
LOG(Message) << "Seeding Serial RNG " << &r << " with string '"
|
||||
<< seed_ << "'" << std::endl;
|
||||
r.SeedUniqueString(seed_);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: Hadrons/Module.hpp
|
||||
|
||||
Copyright (C) 2015-2019
|
||||
@ -196,6 +195,7 @@ protected:
|
||||
DEFINE_VM_ALIAS;
|
||||
// RNG seeded from module string
|
||||
GridParallelRNG &rng4d(void);
|
||||
GridSerialRNG &rngSerial(void);
|
||||
private:
|
||||
std::string makeSeedString(void);
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user