mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-10-31 03:54:33 +00:00 
			
		
		
		
	Removing redundant arguments for integrator functions, step 1
This commit is contained in:
		| @@ -268,6 +268,15 @@ PARALLEL_FOR_LOOP | ||||
|  | ||||
|     virtual ~Lattice(void) = default; | ||||
|      | ||||
|     void reset(GridBase* grid) { | ||||
|       if (_grid != grid) { | ||||
|         _grid = grid; | ||||
|         _odata.resize(grid->oSites()); | ||||
|         checkerboard = 0; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     template<class sobj> strong_inline Lattice<vobj> & operator = (const sobj & r){ | ||||
| PARALLEL_FOR_LOOP | ||||
|         for(int ss=0;ss<_grid->oSites();ss++){ | ||||
|   | ||||
| @@ -27,17 +27,17 @@ with this program; if not, write to the Free Software Foundation, Inc., | ||||
|   directory | ||||
|   *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef GENERIC_HMC_RUNNER | ||||
| #define GENERIC_HMC_RUNNER | ||||
| #ifndef GRID_GENERIC_HMC_RUNNER | ||||
| #define GRID_GENERIC_HMC_RUNNER | ||||
|  | ||||
| namespace Grid { | ||||
| namespace QCD { | ||||
|  | ||||
|   // Virtual Class for HMC specific for gauge theories | ||||
|   // implement a specific theory by defining the BuildTheAction | ||||
|   template <class Implementation, class RepresentationsPolicy = NoHirep> | ||||
|   class BinaryHmcRunnerTemplate { | ||||
|   public: | ||||
| // Virtual Class for HMC specific for gauge theories | ||||
| // implement a specific theory by defining the BuildTheAction | ||||
| template <class Implementation, class RepresentationsPolicy = NoHirep> | ||||
| class BinaryHmcRunnerTemplate { | ||||
| public: | ||||
|     INHERIT_FIELD_TYPES(Implementation); | ||||
|     typedef Implementation ImplPolicy; | ||||
|  | ||||
| @@ -56,8 +56,10 @@ namespace QCD { | ||||
|     IntegratorParameters MDparameters; | ||||
|  | ||||
|     GridCartesian *        UGrid; | ||||
|     GridCartesian *        FGrid; | ||||
|     GridRedBlackCartesian *UrbGrid; | ||||
|  | ||||
|     // These two are unnecessary, eliminate | ||||
|     GridCartesian *        FGrid; | ||||
|     GridRedBlackCartesian *FrbGrid; | ||||
|  | ||||
|     std::vector<int> SerialSeed; | ||||
| @@ -84,6 +86,8 @@ namespace QCD { | ||||
|     ////////////////////////////// | ||||
|  | ||||
|      | ||||
|  | ||||
|  | ||||
|     template <class SmearingPolicy, class IOCheckpointer> | ||||
|     void Runner(int             argc, | ||||
|                 char **         argv, | ||||
| @@ -141,11 +145,7 @@ namespace QCD { | ||||
|       Field           U(UGrid); | ||||
|  | ||||
|  | ||||
|       typedef MinimumNorm2<Implementation, | ||||
|                            SmearingPolicy, | ||||
|                            RepresentationsPolicy> | ||||
|           IntegratorType; // change here to change the algorithm | ||||
|            | ||||
|       typedef MinimumNorm2<Implementation, SmearingPolicy, RepresentationsPolicy> IntegratorType;  // change here to change the algorithm | ||||
|       IntegratorType MDynamics(UGrid, MDparameters, TheAction, Smearing); | ||||
|  | ||||
|       HMCparameters HMCpar; | ||||
| @@ -187,7 +187,7 @@ namespace QCD { | ||||
|       // Run it | ||||
|       HMC.evolve(); | ||||
|     } | ||||
|   }; | ||||
| }; | ||||
|  | ||||
|   // These are for gauge fields | ||||
|   typedef BinaryHmcRunnerTemplate<PeriodicGimplR> BinaryHmcRunner; | ||||
| @@ -199,6 +199,7 @@ namespace QCD { | ||||
|  | ||||
|   typedef BinaryHmcRunnerTemplate<ScalarImplR, ScalarFields> | ||||
|       ScalarBinaryHmcRunner; | ||||
| } | ||||
| } | ||||
|  | ||||
| }  // namespace QCD | ||||
| }  // namespace Grid | ||||
| #endif  | ||||
|   | ||||
| @@ -189,7 +189,8 @@ class Integrator { | ||||
|  | ||||
|   // Initialization of momenta and actions | ||||
|   void refresh(Field& U, GridParallelRNG& pRNG) { | ||||
|     assert(P._grid == U._grid); | ||||
|     //assert(P._grid == U._grid); | ||||
|     P.reset(U._grid); | ||||
|     std::cout << GridLogIntegrator << "Integrator refresh\n"; | ||||
|     FieldImplementation::generate_momenta(P, pRNG); | ||||
|   | ||||
|   | ||||
| @@ -29,15 +29,6 @@ Author: paboyle <paboyle@ph.ed.ac.uk> | ||||
|     See the full license in the file "LICENSE" in the top level distribution directory | ||||
|     *************************************************************************************/ | ||||
|     /*  END LEGAL */ | ||||
| //---------------------------------------------------------------------- | ||||
| /*! @file Grid_avx.h | ||||
|   @brief Optimization libraries for AVX1/2 instructions set | ||||
|  | ||||
|   Using intrinsics | ||||
| */ | ||||
| // Time-stamp: <2015-06-16 23:30:41 neo> | ||||
| //---------------------------------------------------------------------- | ||||
|  | ||||
| #include <immintrin.h> | ||||
| #ifdef AVXFMA4 | ||||
| #include <x86intrin.h> | ||||
| @@ -67,8 +58,8 @@ namespace Optimization { | ||||
|   }; | ||||
|  | ||||
|  struct Vsplat{ | ||||
|     //Complex float | ||||
|     inline __m256 operator()(float a, float b){ | ||||
|     // Complex float | ||||
|     inline __m256 operator()(float a, float b) { | ||||
|       return _mm256_set_ps(b,a,b,a,b,a,b,a); | ||||
|     } | ||||
|     // Real float | ||||
| @@ -144,8 +135,8 @@ namespace Optimization { | ||||
|  | ||||
|   template <typename Out_type, typename In_type> | ||||
|   struct Reduce{ | ||||
|     //Need templated class to overload output type | ||||
|     //General form must generate error if compiled | ||||
|     // Need templated class to overload output type | ||||
|     // General form must generate error if compiled | ||||
|     inline Out_type operator()(In_type in){ | ||||
|       printf("Error, using wrong Reduce function\n"); | ||||
|       exit(1); | ||||
| @@ -241,10 +232,10 @@ namespace Optimization { | ||||
| #endif | ||||
|     } | ||||
|     // Complex double | ||||
|     inline __m256d operator()(__m256d a, __m256d b){ | ||||
|       //Multiplication of (ak+ibk)*(ck+idk) | ||||
|     inline __m256d operator()(__m256d a, __m256d b) { | ||||
|       // Multiplication of (ak+ibk)*(ck+idk) | ||||
|       // a + i b can be stored as a data structure | ||||
|       //From intel optimisation reference guide | ||||
|       // From intel optimisation reference guide | ||||
|       /* | ||||
| 	movsldup xmm0, Src1; load real parts into the destination, | ||||
| 	; a1, a1, a0, a0 | ||||
| @@ -365,10 +356,10 @@ namespace Optimization { | ||||
|     } | ||||
|   }; | ||||
|  | ||||
|   struct Div{ | ||||
|   struct Div { | ||||
|     // Real float | ||||
|     inline __m256 operator()(__m256 a, __m256 b){ | ||||
|       return _mm256_div_ps(a,b); | ||||
|     inline __m256 operator()(__m256 a, __m256 b) { | ||||
|       return _mm256_div_ps(a, b); | ||||
|     } | ||||
|     // Real double | ||||
|     inline __m256d operator()(__m256d a, __m256d b){ | ||||
| @@ -514,19 +505,19 @@ namespace Optimization { | ||||
|     template<int n> | ||||
|     static inline __m256 tRotate(__m256 in){ | ||||
|       __m256 tmp = Permute::Permute0(in); | ||||
|       __m256 ret = in; | ||||
|       __m256 ret; | ||||
|       if ( n > 3 ) { | ||||
|           _mm256_alignr_epi32_grid(ret,in,tmp,n); | ||||
|       } else { | ||||
|           _mm256_alignr_epi32_grid(ret,tmp,in,n); | ||||
|       } | ||||
|       return ret; | ||||
|     }; | ||||
|     } | ||||
|  | ||||
|     template<int n> | ||||
|     static inline __m256d tRotate(__m256d in){ | ||||
|       __m256d tmp = Permute::Permute0(in); | ||||
|       __m256d ret = in; | ||||
|       __m256d ret; | ||||
|       if ( n > 1 ) { | ||||
| 	_mm256_alignr_epi64_grid(ret,in,tmp,n); | ||||
|       } else { | ||||
| @@ -611,7 +602,7 @@ namespace Optimization { | ||||
|     } | ||||
|   } | ||||
|   inline void prefetch_HINT_T0(const char *ptr){ | ||||
|     _mm_prefetch(ptr,_MM_HINT_T0); | ||||
|     _mm_prefetch(ptr, _MM_HINT_T0); | ||||
|   } | ||||
|  | ||||
|   // Function name aliases | ||||
| @@ -620,7 +611,7 @@ namespace Optimization { | ||||
|   typedef Optimization::Vset     VsetSIMD; | ||||
|   typedef Optimization::Vstream  VstreamSIMD; | ||||
|  | ||||
|   template <typename S, typename T> using ReduceSIMD = Optimization::Reduce<S,T>; | ||||
|   template <typename S, typename T> using ReduceSIMD = Optimization::Reduce<S, T>; | ||||
|  | ||||
|   // Arithmetic operations | ||||
|   typedef Optimization::Sum         SumSIMD; | ||||
| @@ -632,4 +623,4 @@ namespace Optimization { | ||||
|   typedef Optimization::TimesMinusI TimesMinusISIMD; | ||||
|   typedef Optimization::TimesI      TimesISIMD; | ||||
|  | ||||
| } | ||||
| }  // namespace Grid | ||||
|   | ||||
| @@ -46,4 +46,4 @@ | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #endif | ||||
| #endif  // COMPILER_CHECK_H | ||||
|   | ||||
| @@ -63,6 +63,11 @@ class HMCRunnerParameters : Serializable { | ||||
| class HmcRunner : public BinaryHmcRunner { | ||||
|  public: | ||||
|     HMCRunnerParameters HMCPar; | ||||
|     void BuildTheAction(int argc, char **argv){} | ||||
| }; | ||||
| /* | ||||
|  | ||||
|     // eliminate arcg and argv from here | ||||
|     void BuildTheAction(int argc, char **argv) | ||||
|  | ||||
|   { | ||||
| @@ -90,6 +95,7 @@ class HmcRunner : public BinaryHmcRunner { | ||||
|  | ||||
|     // Add observables | ||||
|     // options for checkpointers | ||||
|     // this can be moved outside the BuildTheAction | ||||
|     //BinaryHmcCheckpointer | ||||
|     //ILDGHmcCheckpointer | ||||
|     //NerscHmcCheckpointer | ||||
| @@ -107,9 +113,11 @@ class HmcRunner : public BinaryHmcRunner { | ||||
|     ObservablesList.push_back(&PlaqLog); | ||||
|     ObservablesList.push_back(&Checkpoint); | ||||
|  | ||||
|     // This must run from here so that the grids are defined | ||||
|     Run(argc, argv, Checkpoint);  // no smearing | ||||
|   }; | ||||
| }; | ||||
| */ | ||||
| } | ||||
| } | ||||
|  | ||||
| @@ -136,7 +144,57 @@ int main(int argc, char **argv) { | ||||
|  | ||||
|   TheHMC.MDparameters.set(TheHMC.HMCPar.MDsteps, TheHMC.HMCPar.TrajectorLength); | ||||
|  | ||||
|   TheHMC.BuildTheAction(argc, argv); | ||||
|   //TheHMC.BuildTheAction(argc, argv); | ||||
|  | ||||
|  | ||||
|  | ||||
|      // Typedefs to simplify notation | ||||
|     typedef WilsonGaugeActionR GaugeAction; | ||||
|     typedef WilsonImplR ImplPolicy; | ||||
|     typedef WilsonFermionR FermionAction; | ||||
|     typedef typename FermionAction::FermionField FermionField; | ||||
|  | ||||
|     // this can be simplified too. MakeDefaultGrid(Nd) | ||||
|     TheHMC.UGrid = SpaceTimeGrid::makeFourDimGrid( | ||||
|         GridDefaultLatt(),  | ||||
|         GridDefaultSimd(Nd, vComplex::Nsimd()),  | ||||
|         GridDefaultMpi()); | ||||
|      | ||||
|  | ||||
|     // Gauge action | ||||
|     std::cout << GridLogMessage << "Beta: " << TheHMC.HMCPar.beta << std::endl; | ||||
|     GaugeAction Waction(TheHMC.HMCPar.beta); | ||||
|  | ||||
|     // Collect actions | ||||
|     ActionLevel<BinaryHmcRunner::Field> Level1(1); | ||||
|     Level1.push_back(&Waction); | ||||
|     TheHMC.TheAction.push_back(Level1); | ||||
|  | ||||
|     // Add observables | ||||
|     // options for checkpointers | ||||
|     // this can be moved outside the BuildTheAction | ||||
|     //BinaryHmcCheckpointer | ||||
|     //ILDGHmcCheckpointer | ||||
|     //NerscHmcCheckpointer | ||||
|     NerscHmcCheckpointer<BinaryHmcRunner::ImplPolicy> Checkpoint( | ||||
|         TheHMC.HMCPar.conf_prefix, TheHMC.HMCPar.rng_prefix, TheHMC.HMCPar.SaveInterval, TheHMC.HMCPar.format); | ||||
|     // Can implement also a specific function in the hmcrunner | ||||
|     // AddCheckpoint (...) that takes the same parameters + a string/tag | ||||
|     // defining the type of the checkpointer | ||||
|     // with tags can be implemented by overloading and no ifs | ||||
|     // Then force all checkpoint to have few common functions | ||||
|     // return an object that is then passed to the Run function | ||||
|  | ||||
|     PlaquetteLogger<BinaryHmcRunner::ImplPolicy> PlaqLog( | ||||
|         std::string("Plaquette")); | ||||
|     TheHMC.ObservablesList.push_back(&PlaqLog); | ||||
|     TheHMC.ObservablesList.push_back(&Checkpoint); | ||||
|  | ||||
|     // This must run from here so that the grids are defined | ||||
|     TheHMC.Run(argc, argv, Checkpoint);  // no smearing | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|   Grid_finalize(); | ||||
| } | ||||
|   | ||||
| @@ -67,7 +67,7 @@ int main(int argc, char** argv) { | ||||
|   GridParallelRNG RNG4(UGrid); | ||||
|   RNG4.SeedFixedIntegers(seeds4); | ||||
|  | ||||
|   std::cout << GridLogMessage << "Generating random ferrmion field" << std::endl; | ||||
|   std::cout << GridLogMessage << "Generating random fermion field" << std::endl; | ||||
|   LatticeFermion src(FGrid); | ||||
|   random(RNG5, src); | ||||
|   LatticeFermion result(FGrid); | ||||
| @@ -96,7 +96,7 @@ int main(int argc, char** argv) { | ||||
|   GridStopWatch CGTimer; | ||||
|  | ||||
|   SchurDiagMooeeOperator<DomainWallFermionVec5dR, LatticeFermion> HermOpEO(Ddwf); | ||||
|   ConjugateGradient<LatticeFermion> CG(1.0e-8, 10000, 0);// switch off the assert | ||||
|   ConjugateGradient<LatticeFermion> CG(1.0e-8, 10000, 0);  // switch off the assert | ||||
|  | ||||
|   Ddwf.ZeroCounters(); | ||||
|   CGTimer.Start(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user