diff --git a/.gitignore b/.gitignore index ce2bf144..03554467 100644 --- a/.gitignore +++ b/.gitignore @@ -94,8 +94,7 @@ Thumbs.db # build directory # ################### -build/* -build_debug/* +build*/* # IDE related files # ##################### diff --git a/lib/PerfCount.h b/lib/PerfCount.h index c4ee8eea..1e9a98be 100644 --- a/lib/PerfCount.h +++ b/lib/PerfCount.h @@ -65,8 +65,11 @@ inline uint64_t cyclecount(void){ return tmp; } #elif defined __x86_64__ +#include +#ifndef __INTEL_COMPILER #include -inline uint64_t cyclecount(void){ +#endif +inline uint64_t cyclecount(void){ return __rdtsc(); } #else diff --git a/lib/lattice/Lattice_rng.h b/lib/lattice/Lattice_rng.h index 42162b34..da0f2207 100644 --- a/lib/lattice/Lattice_rng.h +++ b/lib/lattice/Lattice_rng.h @@ -75,7 +75,7 @@ namespace Grid { std::seed_seq src; - fixedSeed(std::vector &seeds) : src(seeds.begin(),seeds.end()) {}; + fixedSeed(const std::vector &seeds) : src(seeds.begin(),seeds.end()) {}; result_type operator () (void){ @@ -119,9 +119,10 @@ namespace Grid { typedef uint32_t RngStateType; static const int RngStateCount = std::mt19937::state_size; #endif - std::vector _generators; - std::vector > _uniform; - std::vector > _gaussian; + std::vector _generators; + std::vector> _uniform; + std::vector> _gaussian; + std::vector> _bernoulli; void GetState(std::vector & saved,int gen) { saved.resize(RngStateCount); @@ -161,6 +162,7 @@ namespace Grid { _generators.resize(1); _uniform.resize(1,std::uniform_real_distribution{0,1}); _gaussian.resize(1,std::normal_distribution(0.0,1.0) ); + _bernoulli.resize(1,std::discrete_distribution{1,1}); _seeded=0; } @@ -242,7 +244,7 @@ namespace Grid { std::random_device rd; Seed(rd); } - void SeedFixedIntegers(std::vector &seeds){ + void SeedFixedIntegers(const std::vector &seeds){ fixedSeed src(seeds); Seed(src); } @@ -266,6 +268,7 @@ namespace Grid { _generators.resize(_vol); _uniform.resize(_vol,std::uniform_real_distribution{0,1}); _gaussian.resize(_vol,std::normal_distribution(0.0,1.0) ); + _bernoulli.resize(_vol,std::discrete_distribution{1,1}); _seeded=0; } @@ -354,7 +357,7 @@ PARALLEL_FOR_LOOP std::random_device rd; Seed(rd); } - void SeedFixedIntegers(std::vector &seeds){ + void SeedFixedIntegers(const std::vector &seeds){ fixedSeed src(seeds); Seed(src); } @@ -368,14 +371,22 @@ PARALLEL_FOR_LOOP template inline void gaussian(GridParallelRNG &rng,Lattice &l){ rng.fill(l,rng._gaussian); } - + + template inline void bernoulli(GridParallelRNG &rng,Lattice &l){ + rng.fill(l,rng._bernoulli); + } template inline void random(GridSerialRNG &rng,sobj &l){ rng.fill(l,rng._uniform); } + template inline void gaussian(GridSerialRNG &rng,sobj &l){ rng.fill(l,rng._gaussian); } + + template inline void bernoulli(GridSerialRNG &rng,sobj &l){ + rng.fill(l,rng._bernoulli); + } } #endif diff --git a/lib/qcd/QCD.h b/lib/qcd/QCD.h index 60345ccd..92fa5857 100644 --- a/lib/qcd/QCD.h +++ b/lib/qcd/QCD.h @@ -383,7 +383,6 @@ namespace QCD { ////////////////////////////////////////////// // Poke scalars ////////////////////////////////////////////// - template void pokeSpin(vobj &lhs,const decltype(peekIndex(lhs,0)) & rhs,int i) { pokeIndex(lhs,rhs,i); @@ -407,7 +406,41 @@ namespace QCD { pokeIndex(lhs,rhs,i); } - + ////////////////////////////////////////////// + // Fermion <-> propagator assignements + ////////////////////////////////////////////// + template + void FermToProp(Prop &p, const Ferm &f, const int s, const int c) + { + for(int j = 0; j < Ns; ++j) + { + auto pjs = peekSpin(p, j, s); + auto fj = peekSpin(f, j); + + for(int i = 0; i < Nc; ++i) + { + pokeColour(pjs, peekColour(fj, i), i, c); + } + pokeSpin(p, pjs, j, s); + } + } + + template + void PropToFerm(Ferm &f, const Prop &p, const int s, const int c) + { + for(int j = 0; j < Ns; ++j) + { + auto pjs = peekSpin(p, j, s); + auto fj = peekSpin(f, j); + + for(int i = 0; i < Nc; ++i) + { + pokeColour(fj, peekColour(pjs, i, c), i); + } + pokeSpin(f, fj, j); + } + } + ////////////////////////////////////////////// // transpose array and scalar ////////////////////////////////////////////// diff --git a/lib/serialisation/BaseIO.h b/lib/serialisation/BaseIO.h index b89d27ad..3c49692f 100644 --- a/lib/serialisation/BaseIO.h +++ b/lib/serialisation/BaseIO.h @@ -32,6 +32,22 @@ Author: Peter Boyle #include namespace Grid { + // helper function to read space-separated values + template + std::vector strToVec(const std::string s) + { + std::istringstream sstr(s); + T buf; + std::vector v; + + while(!sstr.eof()) + { + sstr >> buf; + v.push_back(buf); + } + + return v; + } class Serializable {}; diff --git a/tests/Make.inc b/tests/Make.inc index cd4ab811..b5991fa0 100644 --- a/tests/Make.inc +++ b/tests/Make.inc @@ -1,5 +1,5 @@ -bin_PROGRAMS = Test_GaugeAction Test_RectPlaq Test_cayley_cg Test_cayley_coarsen_support Test_cayley_even_odd Test_cayley_ldop_cr Test_cf_coarsen_support Test_cf_cr_unprec Test_cheby Test_contfrac_cg Test_contfrac_even_odd Test_contfrac_force Test_cshift Test_cshift_red_black Test_cshift_red_black_rotate Test_cshift_rotate Test_dwf_cg_prec Test_dwf_cg_schur Test_dwf_cg_unprec Test_dwf_cr_unprec Test_dwf_even_odd Test_dwf_force Test_dwf_fpgcr Test_dwf_gpforce Test_dwf_hdcr Test_dwf_lanczos Test_dwf_rb5d Test_gamma Test_gp_rect_force Test_gparity Test_gpdwf_force Test_gpwilson_even_odd Test_hmc_EODWFRatio Test_hmc_EODWFRatio_Gparity Test_hmc_EOWilsonFermionGauge Test_hmc_EOWilsonRatio Test_hmc_GparityIwasakiGauge Test_hmc_GparityWilsonGauge Test_hmc_IwasakiGauge Test_hmc_RectGauge Test_hmc_WilsonFermionGauge Test_hmc_WilsonGauge Test_hmc_WilsonRatio Test_lie_generators Test_main Test_multishift_sqrt Test_nersc_io Test_partfrac_force Test_quenched_update Test_rect_force Test_remez Test_rhmc_EOWilson1p1 Test_rhmc_EOWilsonRatio Test_rhmc_Wilson1p1 Test_rhmc_WilsonRatio Test_rng Test_rng_fixed Test_serialisation Test_simd Test_stencil Test_synthetic_lanczos Test_wilson_cg_prec Test_wilson_cg_schur Test_wilson_cg_unprec Test_wilson_cr_unprec Test_wilson_even_odd Test_wilson_force Test_wilson_force_phiMdagMphi Test_wilson_force_phiMphi Test_wilson_tm_even_odd +bin_PROGRAMS += Test_GaugeAction Test_RectPlaq Test_cayley_cg Test_cayley_coarsen_support Test_cayley_even_odd Test_cayley_ldop_cr Test_cf_coarsen_support Test_cf_cr_unprec Test_cheby Test_contfrac_cg Test_contfrac_even_odd Test_contfrac_force Test_cshift Test_cshift_red_black Test_cshift_red_black_rotate Test_cshift_rotate Test_dwf_cg_prec Test_dwf_cg_schur Test_dwf_cg_unprec Test_dwf_cr_unprec Test_dwf_even_odd Test_dwf_force Test_dwf_fpgcr Test_dwf_gpforce Test_dwf_hdcr Test_dwf_lanczos Test_dwf_rb5d Test_gamma Test_gp_rect_force Test_gparity Test_gpdwf_force Test_gpwilson_even_odd Test_hmc_EODWFRatio Test_hmc_EODWFRatio_Gparity Test_hmc_EOWilsonFermionGauge Test_hmc_EOWilsonRatio Test_hmc_GparityIwasakiGauge Test_hmc_GparityWilsonGauge Test_hmc_IwasakiGauge Test_hmc_RectGauge Test_hmc_WilsonFermionGauge Test_hmc_WilsonGauge Test_hmc_WilsonRatio Test_lie_generators Test_main Test_multishift_sqrt Test_nersc_io Test_partfrac_force Test_quenched_update Test_rect_force Test_remez Test_rhmc_EOWilson1p1 Test_rhmc_EOWilsonRatio Test_rhmc_Wilson1p1 Test_rhmc_WilsonRatio Test_rng Test_rng_fixed Test_serialisation Test_simd Test_stencil Test_synthetic_lanczos Test_wilson_cg_prec Test_wilson_cg_schur Test_wilson_cg_unprec Test_wilson_cr_unprec Test_wilson_even_odd Test_wilson_force Test_wilson_force_phiMdagMphi Test_wilson_force_phiMphi Test_wilson_tm_even_odd Test_GaugeAction_SOURCES=Test_GaugeAction.cc diff --git a/tests/Test_serialisation.cc b/tests/Test_serialisation.cc index 22bb7025..42fdcccb 100644 --- a/tests/Test_serialisation.cc +++ b/tests/Test_serialisation.cc @@ -140,4 +140,18 @@ int main(int argc,char **argv) std::cout << "Loaded (txt) -----------------" << std::endl; std::cout << copy3 << std::endl << veccopy3 << std::endl; } + + std::vector iv = strToVec("1 2 2 4"); + std::vector sv = strToVec("bli bla blu"); + + for (auto &e: iv) + { + std::cout << e << " "; + } + std::cout << std::endl; + for (auto &e: sv) + { + std::cout << e << " "; + } + std::cout << std::endl; }