From 3f128443ab73d087bd61484f7a780e60e922808b Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Sat, 30 Apr 2016 00:13:33 -0700 Subject: [PATCH 1/6] OS X icpc fix --- lib/PerfCount.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 From ca5eebe10c69da23e0dd6258822b6cdd4c46002c Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Sat, 30 Apr 2016 00:13:53 -0700 Subject: [PATCH 2/6] gitignore update --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 # ##################### From 23b6172c31de8ca735e6cc8f601576c9a113e0d7 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Sat, 30 Apr 2016 00:14:13 -0700 Subject: [PATCH 3/6] Bernoulli RNG --- lib/lattice/Lattice_rng.h | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) 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 From 6aa000176f6bf58924c1ac8d4ebc03597a6c9911 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Sat, 30 Apr 2016 00:14:33 -0700 Subject: [PATCH 4/6] Fermion <-> Propagator functions --- lib/qcd/QCD.h | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) 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 ////////////////////////////////////////////// From ba09cbae3e81be0df779215aa0ffa8acfb9dd81a Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Sat, 30 Apr 2016 00:15:24 -0700 Subject: [PATCH 5/6] function to read std::vector from a string (blank separated values) --- lib/serialisation/BaseIO.h | 16 ++++++++++++++++ tests/Test_serialisation.cc | 14 ++++++++++++++ 2 files changed, 30 insertions(+) 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/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; } From 344d251fc4db2bbf744afa82906774b1b5a8397d Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Sat, 30 Apr 2016 00:24:50 -0700 Subject: [PATCH 6/6] re-fix of test Make.inc --- tests/Make.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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