mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-09 23:45:36 +00:00
No random device
This commit is contained in:
parent
9dc7ca4c3b
commit
0fade84ab2
@ -54,8 +54,8 @@ int main (int argc, char ** argv)
|
||||
GridSerialRNG sRNGa;
|
||||
GridSerialRNG sRNGb;
|
||||
|
||||
pRNGa.SeedRandomDevice();
|
||||
sRNGa.SeedRandomDevice();
|
||||
pRNGa.SeedFixedIntegers(std::vector<int>({45,12,81,9});
|
||||
sRNGa.SeedFixedIntegers(std::vector<int>({45,12,81,9});
|
||||
|
||||
std::string rfile("./ckpoint_rng.4000");
|
||||
NerscIO::writeRNGState(sRNGa,pRNGa,rfile);
|
||||
|
@ -41,7 +41,7 @@ int main (int argc, char ** argv)
|
||||
|
||||
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedRandomDevice();
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeComplex U(&Fine);
|
||||
LatticeComplex ShiftU(&Fine);
|
||||
|
@ -125,7 +125,7 @@ template<class scal, class vec,class functor >
|
||||
void Tester(const functor &func)
|
||||
{
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedRandomDevice();
|
||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
int Nsimd = vec::Nsimd();
|
||||
|
||||
@ -184,7 +184,7 @@ void IntTester(const functor &func)
|
||||
typedef Integer scal;
|
||||
typedef vInteger vec;
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedRandomDevice();
|
||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
int Nsimd = vec::Nsimd();
|
||||
|
||||
@ -242,7 +242,7 @@ template<class reduced,class scal, class vec,class functor >
|
||||
void ReductionTester(const functor &func)
|
||||
{
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedRandomDevice();
|
||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
int Nsimd = vec::Nsimd();
|
||||
|
||||
@ -343,7 +343,7 @@ template<class scal, class vec,class functor >
|
||||
void PermTester(const functor &func)
|
||||
{
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedRandomDevice();
|
||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
int Nsimd = vec::Nsimd();
|
||||
|
||||
@ -409,7 +409,7 @@ template<class scal, class vec,class functor >
|
||||
void ExchangeTester(const functor &func)
|
||||
{
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedRandomDevice();
|
||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
int Nsimd = vec::Nsimd();
|
||||
|
||||
|
@ -52,7 +52,7 @@ int main (int argc, char ** argv)
|
||||
GridRedBlackCartesian rbFine(latt_size,simd_layout,mpi_layout);
|
||||
GridParallelRNG fRNG(&Fine);
|
||||
|
||||
// fRNG.SeedRandomDevice();
|
||||
// fRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9});
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
fRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
|
@ -49,7 +49,7 @@ int main (int argc, char ** argv)
|
||||
GridCartesian Fine (latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBFine(latt_size,simd_layout,mpi_layout,mask,1);
|
||||
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedRandomDevice();
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeComplex U(&Fine);
|
||||
LatticeComplex ShiftU(&Fine);
|
||||
|
@ -49,7 +49,7 @@ int main (int argc, char ** argv)
|
||||
GridCartesian Fine (latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBFine(latt_size,simd_layout,mpi_layout,mask,1);
|
||||
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedRandomDevice();
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeComplex err(&Fine);
|
||||
LatticeComplex U(&Fine);
|
||||
|
@ -41,7 +41,7 @@ int main (int argc, char ** argv)
|
||||
|
||||
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedRandomDevice();
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeComplex U(&Fine);
|
||||
LatticeComplex ShiftU(&Fine);
|
||||
|
@ -245,7 +245,7 @@ int main(int argc, char *argv[])
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridSerialRNG sRNG;
|
||||
|
||||
sRNG.SeedRandomDevice();
|
||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
std::cout << GridLogMessage << "======== Test algebra" << std::endl;
|
||||
createTestAlgebra();
|
||||
|
@ -50,7 +50,7 @@ int main (int argc, char ** argv)
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
// std::vector<int> seeds({1,2,3,4});
|
||||
// pRNG.SeedFixedIntegers(seeds);
|
||||
pRNG.SeedRandomDevice();
|
||||
pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
typedef typename GparityWilsonFermionR::FermionField FermionField;
|
||||
|
||||
|
@ -86,7 +86,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
// Projectors
|
||||
GridParallelRNG gridRNG(grid);
|
||||
gridRNG.SeedRandomDevice();
|
||||
gridRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
SU3Adjoint::LatticeAdjMatrix Gauss(grid);
|
||||
SU3::LatticeAlgebraVector ha(grid);
|
||||
SU3::LatticeAlgebraVector hb(grid);
|
||||
|
@ -89,8 +89,8 @@ int main(int argc, char **argv) {
|
||||
GridSerialRNG SerialRNG;
|
||||
GridSerialRNG SerialRNG1;
|
||||
|
||||
FineRNG.SeedRandomDevice();
|
||||
SerialRNG.SeedRandomDevice();
|
||||
FineRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
SerialRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
std::cout << "SerialRNG" << SerialRNG._generators[0] << std::endl;
|
||||
|
||||
|
@ -43,10 +43,10 @@ int main (int argc, char ** argv)
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridSerialRNG sRNG; sRNG.SeedRandomDevice();
|
||||
GridSerialRNG sRNG; sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
GridSerialRNG fsRNG; fsRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
GridParallelRNG pRNG(&Grid); pRNG.SeedRandomDevice();
|
||||
GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
GridParallelRNG fpRNG(&Grid); fpRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
SpinMatrix rnd ;
|
||||
|
@ -51,7 +51,7 @@ int main (int argc, char ** argv)
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
pRNG.SeedFixedIntegers(seeds);
|
||||
// pRNG.SeedRandomDevice();
|
||||
// pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9});
|
||||
|
||||
typedef typename ImprovedStaggeredFermionR::FermionField FermionField;
|
||||
typedef typename ImprovedStaggeredFermionR::ComplexField ComplexField;
|
||||
|
@ -62,7 +62,7 @@ int main (int argc, char ** argv)
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
// std::vector<int> seeds({1,2,3,4});
|
||||
// pRNG.SeedFixedIntegers(seeds);
|
||||
pRNG.SeedRandomDevice();
|
||||
pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeFermion src (&Grid); random(pRNG,src);
|
||||
LatticeFermion phi (&Grid); random(pRNG,phi);
|
||||
|
@ -61,7 +61,7 @@ int main (int argc, char ** argv)
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
// std::vector<int> seeds({1,2,3,4});
|
||||
// pRNG.SeedFixedIntegers(seeds);
|
||||
pRNG.SeedRandomDevice();
|
||||
pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeFermion src (&Grid); random(pRNG,src);
|
||||
LatticeFermion phi (&Grid); random(pRNG,phi);
|
||||
|
@ -54,8 +54,8 @@ int main (int argc, char ** argv)
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedRandomDevice();
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedRandomDevice();
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
FermionField phi (FGrid); gaussian(RNG5,phi);
|
||||
FermionField Mphi (FGrid);
|
||||
|
@ -50,7 +50,7 @@ int main (int argc, char ** argv)
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
pRNG.SeedRandomDevice();
|
||||
pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeGaugeField U(&Grid);
|
||||
|
||||
|
@ -50,7 +50,7 @@ int main (int argc, char ** argv)
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
pRNG.SeedRandomDevice();
|
||||
pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeGaugeField U(&Grid);
|
||||
|
||||
|
@ -50,7 +50,7 @@ int main (int argc, char ** argv)
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
pRNG.SeedRandomDevice();
|
||||
pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeFermion phi (&Grid); gaussian(pRNG,phi);
|
||||
LatticeFermion Mphi (&Grid);
|
||||
|
@ -50,7 +50,7 @@ int main (int argc, char ** argv)
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
pRNG.SeedRandomDevice();
|
||||
pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeFermion phi (&Grid); gaussian(pRNG,phi);
|
||||
LatticeFermion Mphi (&Grid);
|
||||
|
@ -50,7 +50,7 @@ int main (int argc, char ** argv)
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
pRNG.SeedRandomDevice();
|
||||
pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
LatticeFermion phi (&Grid); gaussian(pRNG,phi);
|
||||
LatticeFermion Mphi (&Grid);
|
||||
|
3
tests/testu01/Makefile.am
Normal file
3
tests/testu01/Makefile.am
Normal file
@ -0,0 +1,3 @@
|
||||
AM_LDFLAGS += -L$(LIBRARY_PATH) -ltestu01 -lprobdist -lmylib -lm
|
||||
AM_CXXFLAGS += -I$(C_INCLUDE_PATH)
|
||||
include Make.inc
|
176
tests/testu01/Test_smallcrush.cc
Normal file
176
tests/testu01/Test_smallcrush.cc
Normal file
@ -0,0 +1,176 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_smallcrush.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
See the full license in the file "LICENSE" in the top level distribution directory
|
||||
*************************************************************************************/
|
||||
/* END LEGAL */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
// Wrap Grid's parallel RNG for testU01
|
||||
|
||||
extern "C" {
|
||||
#include "TestU01.h"
|
||||
#include "gdef.h"
|
||||
#include "unif01.h"
|
||||
#include "ucarry.h"
|
||||
#include "bbattery.h"
|
||||
}
|
||||
|
||||
std::vector<std::ranlux48> EngineRanlux;
|
||||
std::vector<std::mt19937> EngineMT;
|
||||
std::vector<sitmo::prng_engine> EngineSitmo;
|
||||
|
||||
std::uniform_int_distribution<uint32_t> uid;
|
||||
|
||||
uint32_t GetU01Ranlux(void) {
|
||||
return uid(EngineRanlux[0]);
|
||||
};
|
||||
uint32_t GetU01MT(void) {
|
||||
return uid(EngineMT[0]);
|
||||
};
|
||||
uint32_t GetU01Sitmo(void) {
|
||||
return uid(EngineSitmo[0]);
|
||||
};
|
||||
|
||||
typedef Grid::GridRNGbase::RngEngine RngEngine;
|
||||
|
||||
struct TestRNG {
|
||||
public:
|
||||
static GridParallelRNG *pRNG;
|
||||
static GridSerialRNG *sRNG;
|
||||
static GridBase *_grid;
|
||||
static RngEngine Eng;
|
||||
static uint64_t site;
|
||||
static uint64_t gsites;
|
||||
static char *name;
|
||||
|
||||
static void Init(GridParallelRNG *_pRNG,GridSerialRNG *_sRNG,GridBase *grid) {
|
||||
pRNG = _pRNG;
|
||||
sRNG = _sRNG;
|
||||
_grid= grid;
|
||||
gsites= grid->_gsites;
|
||||
std::cout << "Init: Global sites is " <<gsites<<std::endl;
|
||||
site = 0;
|
||||
}
|
||||
static uint32_t GetU01(void) {
|
||||
// std::uniform_int_distribution<uint32_t> uid;
|
||||
uint32_t ret_val;
|
||||
#if 0
|
||||
ret_val = sRNG->_uid[0](sRNG->_generators[0]);
|
||||
#else
|
||||
ret_val = pRNG->GlobalU01(site);
|
||||
site=(site+1)%gsites;
|
||||
#endif
|
||||
// std::cout << "site "<<site <<" "<<std::hex << ret_val <<std::dec<<std::endl;
|
||||
return ret_val;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
GridParallelRNG *TestRNG::pRNG;
|
||||
GridSerialRNG *TestRNG::sRNG;
|
||||
GridBase *TestRNG::_grid;
|
||||
RngEngine TestRNG::Eng;
|
||||
uint64_t TestRNG::site;
|
||||
uint64_t TestRNG::gsites;
|
||||
|
||||
#ifdef RNG_SITMO
|
||||
char * TestRNG::name = (char *)"Grid_Sitmo";
|
||||
#endif
|
||||
#ifdef RNG_RANLUX
|
||||
char * TestRNG::name = (char *)"Grid_ranlux48";
|
||||
#endif
|
||||
#ifdef RNG_MT19937
|
||||
char * TestRNG::name = (char *)"Grid_mt19937";
|
||||
#endif
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
std::seed_seq seq(seeds.begin(),seeds.end());
|
||||
|
||||
EngineRanlux.push_back(std::ranlux48(seq));
|
||||
EngineMT.push_back(std::mt19937(seq));
|
||||
EngineSitmo.push_back(sitmo::prng_engine(seq));
|
||||
|
||||
std::cout << GridLogMessage<< "Initialising Grid RNGs "<<std::endl;
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
pRNG.SeedFixedIntegers(std::vector<int>({43,12,7019,9}));
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedFixedIntegers(std::vector<int>({102,12,99,15}));
|
||||
std::cout << GridLogMessage<< "Initialised Grid RNGs "<<std::endl;
|
||||
|
||||
TestRNG::Init(&pRNG,&sRNG,&Grid);
|
||||
std::cout << GridLogMessage<< "Grid RNG's are "<< std::string(TestRNG::name) <<std::endl;
|
||||
|
||||
unif01_Gen * gen;
|
||||
|
||||
// gen = ulcg_CreateLCG (2147483647, 397204094, 0, 12345);
|
||||
// bbattery_SmallCrush (gen);
|
||||
|
||||
// gen = ucarry_CreateRanlux (48, 0x12345);
|
||||
// bbattery_SmallCrush (gen);
|
||||
|
||||
/*
|
||||
std::cout << GridLogMessage<< "Testing Standalone Ranlux" <<std::endl;
|
||||
gen = unif01_CreateExternGenBits ((char *)"GridRanlux",GetU01Ranlux);
|
||||
bbattery_SmallCrush (gen);
|
||||
unif01_DeleteExternGenBits(gen);
|
||||
std::cout << GridLogMessage<< "Testing Standalone Ranlux is complete" <<std::endl;
|
||||
*/
|
||||
/*
|
||||
std::cout << GridLogMessage<< "Testing Standalone Mersenne Twister" <<std::endl;
|
||||
gen = unif01_CreateExternGenBits ((char *)"GridMT",GetU01MT);
|
||||
bbattery_SmallCrush (gen);
|
||||
unif01_DeleteExternGenBits(gen);
|
||||
std::cout << GridLogMessage<< "Testing Standalone Mersenne Twister is complete" <<std::endl;
|
||||
|
||||
std::cout << GridLogMessage<< "Testing Standalone Sitmo" <<std::endl;
|
||||
gen = unif01_CreateExternGenBits ((char *)"GridSitmo",GetU01Sitmo);
|
||||
bbattery_SmallCrush (gen);
|
||||
unif01_DeleteExternGenBits(gen);
|
||||
std::cout << GridLogMessage<< "Testing Standalone Sitmo is complete" <<std::endl;
|
||||
*/
|
||||
|
||||
// gen = unif01_CreateExternGenBits ((char *)"xorshift", xorshift);
|
||||
std::cout << GridLogMessage<< "Testing Grid "<< std::string(TestRNG::name) <<std::endl;
|
||||
gen = unif01_CreateExternGenBits(TestRNG::name,TestRNG::GetU01);
|
||||
bbattery_SmallCrush (gen);
|
||||
std::cout << GridLogMessage<< "Testing Grid "<< std::string(TestRNG::name)<<" is complete" <<std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user