From 56967818626452a318c058684b9594adca4f7fa4 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Wed, 26 Jul 2017 12:07:34 +0100 Subject: [PATCH 1/6] Debug error in Tensor mult --- lib/tensors/Tensor_arith_mul.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tensors/Tensor_arith_mul.h b/lib/tensors/Tensor_arith_mul.h index c24853b7..a474db9c 100644 --- a/lib/tensors/Tensor_arith_mul.h +++ b/lib/tensors/Tensor_arith_mul.h @@ -98,7 +98,9 @@ template strong_inline void mult(iVector * __restrict__ ret, const iVector * __restrict__ rhs, const iScalar * __restrict__ lhs){ - mult(ret,lhs,rhs); + for(int c1=0;c1_internal[c1],&rhs->_internal[c1],&lhs->_internal); + } } From 237cfd11ab493e1ea8ffaf24fc1da5171b8b929a Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Wed, 26 Jul 2017 12:08:51 +0100 Subject: [PATCH 2/6] Solving the spurious O2 flags --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index dc6754da..a028fb0a 100644 --- a/configure.ac +++ b/configure.ac @@ -13,6 +13,10 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) ################ Get git info #AC_REVISION([m4_esyscmd_s([./scripts/configure.commit])]) +################ Set flags +# do not move! +CXXFLAGS="-O3 $CXXFLAGS" + ############### Checks for programs AC_PROG_CXX AC_PROG_RANLIB @@ -27,7 +31,6 @@ AX_GXX_VERSION AC_DEFINE_UNQUOTED([GXX_VERSION],["$GXX_VERSION"], [version of g++ that will compile the code]) -CXXFLAGS="-O3 $CXXFLAGS" ############### Checks for typedefs, structures, and compiler characteristics From 7abc5613bde6fb4e704145b0f2a4c8fa19090944 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Wed, 26 Jul 2017 16:21:17 +0100 Subject: [PATCH 3/6] Added smearing to the topological charge observable --- lib/qcd/modules/ObservableModules.h | 15 ++--- lib/qcd/observables/topological_charge.h | 70 +++++++++++++++++++++--- tests/hmc/Test_hmc_WilsonGauge.cc | 5 +- 3 files changed, 73 insertions(+), 17 deletions(-) diff --git a/lib/qcd/modules/ObservableModules.h b/lib/qcd/modules/ObservableModules.h index 579fc1ec..24511617 100644 --- a/lib/qcd/modules/ObservableModules.h +++ b/lib/qcd/modules/ObservableModules.h @@ -84,8 +84,6 @@ class PlaquetteMod: public ObservableModule, NoParameters> typedef ObservableModule, NoParameters> ObsBase; using ObsBase::ObsBase; // for constructors - - // acquire resource virtual void initialize(){ this->ObservablePtr.reset(new PlaquetteLogger()); @@ -94,23 +92,22 @@ class PlaquetteMod: public ObservableModule, NoParameters> PlaquetteMod(): ObsBase(NoParameters()){} }; + template < class Impl > -class TopologicalChargeMod: public ObservableModule, NoParameters>{ - typedef ObservableModule, NoParameters> ObsBase; +class TopologicalChargeMod: public ObservableModule, TopologyObsParameters>{ + typedef ObservableModule, TopologyObsParameters> ObsBase; using ObsBase::ObsBase; // for constructors - - // acquire resource virtual void initialize(){ - this->ObservablePtr.reset(new TopologicalCharge()); + this->ObservablePtr.reset(new TopologicalCharge(this->Par_)); } public: - TopologicalChargeMod(): ObsBase(NoParameters()){} + TopologicalChargeMod(TopologyObsParameters Par): ObsBase(Par){} + TopologicalChargeMod(): ObsBase(){} }; - }// QCD temporarily here diff --git a/lib/qcd/observables/topological_charge.h b/lib/qcd/observables/topological_charge.h index 5d09c420..c2c419fb 100644 --- a/lib/qcd/observables/topological_charge.h +++ b/lib/qcd/observables/topological_charge.h @@ -33,9 +33,45 @@ directory namespace Grid { namespace QCD { +struct TopologySmearingParameters : Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(TopologySmearingParameters, + int, steps, + float, step_size, + int, meas_interval, + float, maxTau); + + TopologySmearingParameters(int s = 0, float ss = 0.0f, int mi = 0, float mT = 0.0f): + steps(s), step_size(ss), meas_interval(mi), maxTau(mT){} + + template < class ReaderClass > + TopologySmearingParameters(Reader& Reader){ + read(Reader, "Smearing", *this); + } +}; + + + +struct TopologyObsParameters : Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(TopologyObsParameters, + int, interval, + bool, do_smearing, + TopologySmearingParameters, Smearing); + + TopologyObsParameters(int interval = 1, bool smearing = false): + interval(interval), Smearing(smearing){} + + template + TopologyObsParameters(Reader& Reader){ + read(Reader, "TopologyMeasurement", *this); + } +}; + + // this is only defined for a gauge theory template class TopologicalCharge : public HmcObservable { + TopologyObsParameters Pars; + public: // here forces the Impl to be of gauge fields // if not the compiler will complain @@ -44,20 +80,40 @@ class TopologicalCharge : public HmcObservable { // necessary for HmcObservable compatibility typedef typename Impl::Field Field; + TopologicalCharge(int interval = 1, bool do_smearing = false): + Pars(interval, do_smearing){} + + TopologicalCharge(TopologyObsParameters P):Pars(P){ + std::cout << GridLogDebug << "Creating TopologicalCharge " << std::endl; + } + void TrajectoryComplete(int traj, Field &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG) { - Real q = WilsonLoops::TopologicalCharge(U); + if (traj%Pars.interval == 0){ + // Smearing + Field Usmear = U; + int def_prec = std::cout.precision(); + + if (Pars.do_smearing){ + // using wilson flow by default here + std::cout << "1. " << Pars.Smearing.step_size << std::endl; + WilsonFlow WF(Pars.Smearing.steps, Pars.Smearing.step_size, Pars.Smearing.meas_interval); + WF.smear_adaptive(Usmear, U, Pars.Smearing.maxTau); + Real T0 = WF.energyDensityPlaquette(Usmear); + std::cout << GridLogMessage << std::setprecision(std::numeric_limits::digits10 + 1) + << "T0 : [ " << traj << " ] "<< T0 << std::endl; + } - int def_prec = std::cout.precision(); + Real q = WilsonLoops::TopologicalCharge(Usmear); + std::cout << GridLogMessage + << std::setprecision(std::numeric_limits::digits10 + 1) + << "Topological Charge: [ " << traj << " ] "<< q << std::endl; - std::cout << GridLogMessage - << std::setprecision(std::numeric_limits::digits10 + 1) - << "Topological Charge: [ " << traj << " ] "<< q << std::endl; - - std::cout.precision(def_prec); + std::cout.precision(def_prec); + } } }; diff --git a/tests/hmc/Test_hmc_WilsonGauge.cc b/tests/hmc/Test_hmc_WilsonGauge.cc index b2d5fb02..4cf6d923 100644 --- a/tests/hmc/Test_hmc_WilsonGauge.cc +++ b/tests/hmc/Test_hmc_WilsonGauge.cc @@ -66,7 +66,10 @@ int main(int argc, char **argv) { typedef PlaquetteMod PlaqObs; typedef TopologicalChargeMod QObs; TheHMC.Resources.AddObservable(); - TheHMC.Resources.AddObservable(); + TopologyObsParameters TopParams; + TopParams.interval = 1; + TopParams.do_smearing = false; + TheHMC.Resources.AddObservable(TopParams); ////////////////////////////////////////////// ///////////////////////////////////////////////////////////// From c0485d799d915637fdc455dfa900ee9786f7cd69 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Wed, 26 Jul 2017 16:26:04 +0100 Subject: [PATCH 4/6] Explicit parameter declaration in the WilsonGauge test --- lib/qcd/observables/topological_charge.h | 1 - tests/hmc/Test_hmc_WilsonGauge.cc | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/qcd/observables/topological_charge.h b/lib/qcd/observables/topological_charge.h index c2c419fb..5af8d77b 100644 --- a/lib/qcd/observables/topological_charge.h +++ b/lib/qcd/observables/topological_charge.h @@ -99,7 +99,6 @@ class TopologicalCharge : public HmcObservable { if (Pars.do_smearing){ // using wilson flow by default here - std::cout << "1. " << Pars.Smearing.step_size << std::endl; WilsonFlow WF(Pars.Smearing.steps, Pars.Smearing.step_size, Pars.Smearing.meas_interval); WF.smear_adaptive(Usmear, U, Pars.Smearing.maxTau); Real T0 = WF.energyDensityPlaquette(Usmear); diff --git a/tests/hmc/Test_hmc_WilsonGauge.cc b/tests/hmc/Test_hmc_WilsonGauge.cc index 4cf6d923..05bf81a2 100644 --- a/tests/hmc/Test_hmc_WilsonGauge.cc +++ b/tests/hmc/Test_hmc_WilsonGauge.cc @@ -67,8 +67,12 @@ int main(int argc, char **argv) { typedef TopologicalChargeMod QObs; TheHMC.Resources.AddObservable(); TopologyObsParameters TopParams; - TopParams.interval = 1; - TopParams.do_smearing = false; + TopParams.interval = 5; + TopParams.do_smearing = true; + TopParams.Smearing.steps = 200; + TopParams.Smearing.step_size = 0.01; + TopParams.Smearing.meas_interval = 50; + TopParams.Smearing.maxTau = 2.0; TheHMC.Resources.AddObservable(TopParams); ////////////////////////////////////////////// From c7036f671754710c41de00cb0fa90a6e35104467 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Thu, 27 Jul 2017 11:15:09 +0100 Subject: [PATCH 5/6] Adding checks for libm and libstdc++ --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index a028fb0a..bf078b13 100644 --- a/configure.ac +++ b/configure.ac @@ -58,6 +58,10 @@ AC_CHECK_HEADERS(numaif.h) AC_CHECK_DECLS([ntohll],[], [], [[#include ]]) AC_CHECK_DECLS([be64toh],[], [], [[#include ]]) +############## Standard libraries +AC_CHECK_LIB([m],[cos]) +AC_CHECK_LIB([stdc++],[abort]) + ############### GMP and MPFR AC_ARG_WITH([gmp], [AS_HELP_STRING([--with-gmp=prefix], From 8bd869da37fc3911665213f96e431e3b60cb0332 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Thu, 27 Jul 2017 15:12:50 +0100 Subject: [PATCH 6/6] Correcting a bug in the IO routines --- lib/parallelIO/BinaryIO.h | 133 ++++++++++++++++++++++++-------------- 1 file changed, 86 insertions(+), 47 deletions(-) diff --git a/lib/parallelIO/BinaryIO.h b/lib/parallelIO/BinaryIO.h index 117bec01..108e7ef8 100644 --- a/lib/parallelIO/BinaryIO.h +++ b/lib/parallelIO/BinaryIO.h @@ -98,35 +98,39 @@ class BinaryIO { NerscChecksum(grid,scalardata,nersc_csum); } - - template static inline void NerscChecksum(GridBase *grid,std::vector &fbuf,uint32_t &nersc_csum) + + template + static inline void NerscChecksum(GridBase *grid, std::vector &fbuf, uint32_t &nersc_csum) { - const uint64_t size32 = sizeof(fobj)/sizeof(uint32_t); + const uint64_t size32 = sizeof(fobj) / sizeof(uint32_t); - - uint64_t lsites =grid->lSites(); - if (fbuf.size()==1) { - lsites=1; + uint64_t lsites = grid->lSites(); + if (fbuf.size() == 1) + { + lsites = 1; } -#pragma omp parallel - { - uint32_t nersc_csum_thr=0; + #pragma omp parallel + { + uint32_t nersc_csum_thr = 0; -#pragma omp for - for(uint64_t local_site=0;local_site static inline void ScidacChecksum(GridBase *grid,std::vector &fbuf,uint32_t &scidac_csuma,uint32_t &scidac_csumb) { const uint64_t size32 = sizeof(fobj)/sizeof(uint32_t); @@ -266,7 +270,7 @@ class BinaryIO { grid->Barrier(); GridStopWatch timer; GridStopWatch bstimer; - + nersc_csum=0; scidac_csuma=0; scidac_csumb=0; @@ -362,18 +366,22 @@ class BinaryIO { #else assert(0); #endif - } else { - std::cout<< GridLogMessage<< "C++ read I/O "<< file<<" : " - << iodata.size()*sizeof(fobj)<<" bytes"<Barrier(); - grid->GlobalSum(nersc_csum); - grid->GlobalXOR(scidac_csuma); - grid->GlobalXOR(scidac_csumb); - grid->Barrier(); + // if the data size is 1 we do not want to sum over the MPI ranks + if (iodata.size() != 1){ + grid->Barrier(); + grid->GlobalSum(nersc_csum); + grid->GlobalXOR(scidac_csuma); + grid->GlobalXOR(scidac_csumb); + grid->Barrier(); + } } ///////////////////////////////////////////////////////////////////////////// @@ -546,9 +585,9 @@ class BinaryIO { int gsites = grid->gSites(); int lsites = grid->lSites(); - uint32_t nersc_csum_tmp; - uint32_t scidac_csuma_tmp; - uint32_t scidac_csumb_tmp; + uint32_t nersc_csum_tmp = 0; + uint32_t scidac_csuma_tmp = 0; + uint32_t scidac_csumb_tmp = 0; GridStopWatch timer;