diff --git a/tests/IO/Test_nersc_io.cc b/tests/IO/Test_nersc_io.cc index 0273d02a..e5ea7cec 100644 --- a/tests/IO/Test_nersc_io.cc +++ b/tests/IO/Test_nersc_io.cc @@ -54,8 +54,8 @@ int main (int argc, char ** argv) GridSerialRNG sRNGa; GridSerialRNG sRNGb; - pRNGa.SeedRandomDevice(); - sRNGa.SeedRandomDevice(); + pRNGa.SeedFixedIntegers(std::vector({45,12,81,9}); + sRNGa.SeedFixedIntegers(std::vector({45,12,81,9}); std::string rfile("./ckpoint_rng.4000"); NerscIO::writeRNGState(sRNGa,pRNGa,rfile); diff --git a/tests/Test_cshift.cc b/tests/Test_cshift.cc index e1dd0db8..f9559a83 100644 --- a/tests/Test_cshift.cc +++ b/tests/Test_cshift.cc @@ -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({45,12,81,9})); LatticeComplex U(&Fine); LatticeComplex ShiftU(&Fine); diff --git a/tests/Test_simd.cc b/tests/Test_simd.cc index f19ebd76..b3933ec6 100644 --- a/tests/Test_simd.cc +++ b/tests/Test_simd.cc @@ -125,7 +125,7 @@ template void Tester(const functor &func) { GridSerialRNG sRNG; - sRNG.SeedRandomDevice(); + sRNG.SeedFixedIntegers(std::vector({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({45,12,81,9})); int Nsimd = vec::Nsimd(); @@ -242,7 +242,7 @@ template void ReductionTester(const functor &func) { GridSerialRNG sRNG; - sRNG.SeedRandomDevice(); + sRNG.SeedFixedIntegers(std::vector({45,12,81,9})); int Nsimd = vec::Nsimd(); @@ -343,7 +343,7 @@ template void PermTester(const functor &func) { GridSerialRNG sRNG; - sRNG.SeedRandomDevice(); + sRNG.SeedFixedIntegers(std::vector({45,12,81,9})); int Nsimd = vec::Nsimd(); @@ -409,7 +409,7 @@ template void ExchangeTester(const functor &func) { GridSerialRNG sRNG; - sRNG.SeedRandomDevice(); + sRNG.SeedFixedIntegers(std::vector({45,12,81,9})); int Nsimd = vec::Nsimd(); diff --git a/tests/Test_stencil.cc b/tests/Test_stencil.cc index 38873310..d7bc5a6c 100644 --- a/tests/Test_stencil.cc +++ b/tests/Test_stencil.cc @@ -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({45,12,81,9}); std::vector seeds({1,2,3,4}); fRNG.SeedFixedIntegers(seeds); diff --git a/tests/core/Test_cshift_red_black.cc b/tests/core/Test_cshift_red_black.cc index ae55cece..f9269709 100644 --- a/tests/core/Test_cshift_red_black.cc +++ b/tests/core/Test_cshift_red_black.cc @@ -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({45,12,81,9})); LatticeComplex U(&Fine); LatticeComplex ShiftU(&Fine); diff --git a/tests/core/Test_cshift_red_black_rotate.cc b/tests/core/Test_cshift_red_black_rotate.cc index 4ff7067b..3ef1cd21 100644 --- a/tests/core/Test_cshift_red_black_rotate.cc +++ b/tests/core/Test_cshift_red_black_rotate.cc @@ -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({45,12,81,9})); LatticeComplex err(&Fine); LatticeComplex U(&Fine); diff --git a/tests/core/Test_cshift_rotate.cc b/tests/core/Test_cshift_rotate.cc index a42fd22e..64c08892 100644 --- a/tests/core/Test_cshift_rotate.cc +++ b/tests/core/Test_cshift_rotate.cc @@ -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({45,12,81,9})); LatticeComplex U(&Fine); LatticeComplex ShiftU(&Fine); diff --git a/tests/core/Test_gamma.cc b/tests/core/Test_gamma.cc index ee31a69a..f3805bdb 100644 --- a/tests/core/Test_gamma.cc +++ b/tests/core/Test_gamma.cc @@ -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({45,12,81,9})); std::cout << GridLogMessage << "======== Test algebra" << std::endl; createTestAlgebra(); diff --git a/tests/core/Test_gpwilson_even_odd.cc b/tests/core/Test_gpwilson_even_odd.cc index b8b320d8..fc12fe75 100644 --- a/tests/core/Test_gpwilson_even_odd.cc +++ b/tests/core/Test_gpwilson_even_odd.cc @@ -50,7 +50,7 @@ int main (int argc, char ** argv) GridParallelRNG pRNG(&Grid); // std::vector seeds({1,2,3,4}); // pRNG.SeedFixedIntegers(seeds); - pRNG.SeedRandomDevice(); + pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); typedef typename GparityWilsonFermionR::FermionField FermionField; diff --git a/tests/core/Test_lie_generators.cc b/tests/core/Test_lie_generators.cc index 5623b74b..114b49f7 100644 --- a/tests/core/Test_lie_generators.cc +++ b/tests/core/Test_lie_generators.cc @@ -86,7 +86,7 @@ int main(int argc, char** argv) { // Projectors GridParallelRNG gridRNG(grid); - gridRNG.SeedRandomDevice(); + gridRNG.SeedFixedIntegers(std::vector({45,12,81,9})); SU3Adjoint::LatticeAdjMatrix Gauss(grid); SU3::LatticeAlgebraVector ha(grid); SU3::LatticeAlgebraVector hb(grid); diff --git a/tests/core/Test_main.cc b/tests/core/Test_main.cc index 78c28539..1868b0fe 100644 --- a/tests/core/Test_main.cc +++ b/tests/core/Test_main.cc @@ -89,8 +89,8 @@ int main(int argc, char **argv) { GridSerialRNG SerialRNG; GridSerialRNG SerialRNG1; - FineRNG.SeedRandomDevice(); - SerialRNG.SeedRandomDevice(); + FineRNG.SeedFixedIntegers(std::vector({45,12,81,9})); + SerialRNG.SeedFixedIntegers(std::vector({45,12,81,9})); std::cout << "SerialRNG" << SerialRNG._generators[0] << std::endl; diff --git a/tests/core/Test_rng.cc b/tests/core/Test_rng.cc index 1fcb3a13..b5d27c29 100644 --- a/tests/core/Test_rng.cc +++ b/tests/core/Test_rng.cc @@ -43,10 +43,10 @@ int main (int argc, char ** argv) std::vector seeds({1,2,3,4}); - GridSerialRNG sRNG; sRNG.SeedRandomDevice(); + GridSerialRNG sRNG; sRNG.SeedFixedIntegers(std::vector({45,12,81,9})); GridSerialRNG fsRNG; fsRNG.SeedFixedIntegers(seeds); - GridParallelRNG pRNG(&Grid); pRNG.SeedRandomDevice(); + GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); GridParallelRNG fpRNG(&Grid); fpRNG.SeedFixedIntegers(seeds); SpinMatrix rnd ; diff --git a/tests/core/Test_staggered.cc b/tests/core/Test_staggered.cc index 89055fc7..75531c83 100644 --- a/tests/core/Test_staggered.cc +++ b/tests/core/Test_staggered.cc @@ -51,7 +51,7 @@ int main (int argc, char ** argv) std::vector seeds({1,2,3,4}); GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds); - // pRNG.SeedRandomDevice(); + // pRNG.SeedFixedIntegers(std::vector({45,12,81,9}); typedef typename ImprovedStaggeredFermionR::FermionField FermionField; typedef typename ImprovedStaggeredFermionR::ComplexField ComplexField; diff --git a/tests/core/Test_wilson_even_odd.cc b/tests/core/Test_wilson_even_odd.cc index b33bd74d..4933c36e 100644 --- a/tests/core/Test_wilson_even_odd.cc +++ b/tests/core/Test_wilson_even_odd.cc @@ -62,7 +62,7 @@ int main (int argc, char ** argv) GridParallelRNG pRNG(&Grid); // std::vector seeds({1,2,3,4}); // pRNG.SeedFixedIntegers(seeds); - pRNG.SeedRandomDevice(); + pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); LatticeFermion src (&Grid); random(pRNG,src); LatticeFermion phi (&Grid); random(pRNG,phi); diff --git a/tests/core/Test_wilson_tm_even_odd.cc b/tests/core/Test_wilson_tm_even_odd.cc index 36de83ea..a2773244 100644 --- a/tests/core/Test_wilson_tm_even_odd.cc +++ b/tests/core/Test_wilson_tm_even_odd.cc @@ -61,7 +61,7 @@ int main (int argc, char ** argv) GridParallelRNG pRNG(&Grid); // std::vector seeds({1,2,3,4}); // pRNG.SeedFixedIntegers(seeds); - pRNG.SeedRandomDevice(); + pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); LatticeFermion src (&Grid); random(pRNG,src); LatticeFermion phi (&Grid); random(pRNG,phi); diff --git a/tests/forces/Test_dwf_gpforce.cc b/tests/forces/Test_dwf_gpforce.cc index 5094b8a7..96a90ff6 100644 --- a/tests/forces/Test_dwf_gpforce.cc +++ b/tests/forces/Test_dwf_gpforce.cc @@ -54,8 +54,8 @@ int main (int argc, char ** argv) std::vector seeds({1,2,3,4}); - GridParallelRNG RNG5(FGrid); RNG5.SeedRandomDevice(); - GridParallelRNG RNG4(UGrid); RNG4.SeedRandomDevice(); + GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(std::vector({45,12,81,9})); + GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(std::vector({45,12,81,9})); FermionField phi (FGrid); gaussian(RNG5,phi); FermionField Mphi (FGrid); diff --git a/tests/forces/Test_gp_rect_force.cc b/tests/forces/Test_gp_rect_force.cc index 551c3a20..17a7cd2b 100644 --- a/tests/forces/Test_gp_rect_force.cc +++ b/tests/forces/Test_gp_rect_force.cc @@ -50,7 +50,7 @@ int main (int argc, char ** argv) std::vector seeds({1,2,3,4}); GridParallelRNG pRNG(&Grid); - pRNG.SeedRandomDevice(); + pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); LatticeGaugeField U(&Grid); diff --git a/tests/forces/Test_rect_force.cc b/tests/forces/Test_rect_force.cc index 97281854..2e2f87b2 100644 --- a/tests/forces/Test_rect_force.cc +++ b/tests/forces/Test_rect_force.cc @@ -50,7 +50,7 @@ int main (int argc, char ** argv) std::vector seeds({1,2,3,4}); GridParallelRNG pRNG(&Grid); - pRNG.SeedRandomDevice(); + pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); LatticeGaugeField U(&Grid); diff --git a/tests/forces/Test_wilson_force.cc b/tests/forces/Test_wilson_force.cc index 60d31b51..52ed00b4 100644 --- a/tests/forces/Test_wilson_force.cc +++ b/tests/forces/Test_wilson_force.cc @@ -50,7 +50,7 @@ int main (int argc, char ** argv) std::vector seeds({1,2,3,4}); GridParallelRNG pRNG(&Grid); - pRNG.SeedRandomDevice(); + pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); LatticeFermion phi (&Grid); gaussian(pRNG,phi); LatticeFermion Mphi (&Grid); diff --git a/tests/forces/Test_wilson_force_phiMdagMphi.cc b/tests/forces/Test_wilson_force_phiMdagMphi.cc index 7717e9bc..2a5814fe 100644 --- a/tests/forces/Test_wilson_force_phiMdagMphi.cc +++ b/tests/forces/Test_wilson_force_phiMdagMphi.cc @@ -50,7 +50,7 @@ int main (int argc, char ** argv) std::vector seeds({1,2,3,4}); GridParallelRNG pRNG(&Grid); - pRNG.SeedRandomDevice(); + pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); LatticeFermion phi (&Grid); gaussian(pRNG,phi); LatticeFermion Mphi (&Grid); diff --git a/tests/forces/Test_wilson_force_phiMphi.cc b/tests/forces/Test_wilson_force_phiMphi.cc index c9e56c32..8cfb1de6 100644 --- a/tests/forces/Test_wilson_force_phiMphi.cc +++ b/tests/forces/Test_wilson_force_phiMphi.cc @@ -50,7 +50,7 @@ int main (int argc, char ** argv) std::vector seeds({1,2,3,4}); GridParallelRNG pRNG(&Grid); - pRNG.SeedRandomDevice(); + pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); LatticeFermion phi (&Grid); gaussian(pRNG,phi); LatticeFermion Mphi (&Grid); diff --git a/tests/testu01/Makefile.am b/tests/testu01/Makefile.am new file mode 100644 index 00000000..eb4d1eae --- /dev/null +++ b/tests/testu01/Makefile.am @@ -0,0 +1,3 @@ +AM_LDFLAGS += -L$(LIBRARY_PATH) -ltestu01 -lprobdist -lmylib -lm +AM_CXXFLAGS += -I$(C_INCLUDE_PATH) +include Make.inc diff --git a/tests/testu01/Test_smallcrush.cc b/tests/testu01/Test_smallcrush.cc new file mode 100644 index 00000000..28974855 --- /dev/null +++ b/tests/testu01/Test_smallcrush.cc @@ -0,0 +1,176 @@ + /************************************************************************************* + + Grid physics library, www.github.com/paboyle/Grid + + Source file: ./tests/Test_smallcrush.cc + + Copyright (C) 2015 + +Author: Peter Boyle + + 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 + +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 EngineRanlux; +std::vector EngineMT; +std::vector EngineSitmo; + +std::uniform_int_distribution 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 " < 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 "< latt_size = GridDefaultLatt(); + std::vector simd_layout = GridDefaultSimd(4,vComplex::Nsimd()); + std::vector mpi_layout = GridDefaultMpi(); + + GridCartesian Grid(latt_size,simd_layout,mpi_layout); + + std::vector 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 "<({43,12,7019,9})); + GridSerialRNG sRNG; + sRNG.SeedFixedIntegers(std::vector({102,12,99,15})); + std::cout << GridLogMessage<< "Initialised Grid RNGs "<