1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-19 16:27:05 +01:00

Options to use mersenne twister OR ranlux48 via --enable-rng flag at configure time.

Can save and restore RNG state via new (serial) I/O routines in a NERSC header style file.
Store a Parallel (one per site) and a single serial RNG file.
This commit is contained in:
paboyle
2015-12-19 18:32:25 +00:00
parent e108e708a3
commit 5710966324
8 changed files with 331 additions and 22 deletions

View File

@ -56,19 +56,25 @@ int main (int argc, char ** argv)
GridRedBlackCartesian rbFine(latt_size,simd_layout,mpi_layout);
GridParallelRNG FineRNG(&Fine);
GridSerialRNG SerialRNG;
GridSerialRNG SerialRNG1;
FineRNG.SeedRandomDevice();
SerialRNG.SeedRandomDevice();
std::cout <<"SerialRNG" << SerialRNG._generators[0] <<std::endl;
std::stringstream output(std::stringstream::out|std::stringstream::binary);
output <<SerialRNG._generators[0]<<std::endl;
std::cout << output.str();
{
std::ofstream of("rngstate",std::ios::out|std::ios::binary);
of << SerialRNG._generators[0];
std::vector<typename GridSerialRNG::RngStateType> saved;
SerialRNG.GetState(saved,0);
SerialRNG1.SetState(saved,0);
RealD dd1,dd2;
std::cout << "Testing RNG state save restore"<<std::endl;
for(int i=0;i<10;i++){
random(SerialRNG,dd1);
random(SerialRNG1,dd2);
std::cout << "i "<<i<<" "<<dd1<< " " <<dd2<<std::endl;
}
LatticeColourMatrix Foo(&Fine);
LatticeColourMatrix Bar(&Fine);