mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 14:04:32 +00:00 
			
		
		
		
	HMC factories
This commit is contained in:
		@@ -35,10 +35,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 | 
			
		||||
namespace Grid {
 | 
			
		||||
namespace QCD {
 | 
			
		||||
 | 
			
		||||
class HMCBase{
 | 
			
		||||
public:
 | 
			
		||||
  virtual void Run() = 0;
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template <class Implementation,
 | 
			
		||||
          template <typename, typename, typename> class Integrator,
 | 
			
		||||
          class RepresentationsPolicy = NoHirep>
 | 
			
		||||
class HMCWrapperTemplate {
 | 
			
		||||
class HMCWrapperTemplate: public HMCBase {
 | 
			
		||||
 public:
 | 
			
		||||
  INHERIT_FIELD_TYPES(Implementation);
 | 
			
		||||
  typedef Implementation ImplPolicy;  // visible from outside
 | 
			
		||||
@@ -134,6 +141,7 @@ class HMCWrapperTemplate {
 | 
			
		||||
    Resources.AddRNGs();
 | 
			
		||||
    Field U(UGrid);
 | 
			
		||||
 | 
			
		||||
    // Can move this outside?
 | 
			
		||||
    typedef IntegratorType<SmearingPolicy> TheIntegrator;
 | 
			
		||||
    TheIntegrator MDynamics(UGrid, MDparameters, TheAction, Smearing);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -44,11 +44,13 @@ directory
 | 
			
		||||
namespace Grid {
 | 
			
		||||
namespace QCD {
 | 
			
		||||
 | 
			
		||||
struct HMCparameters {
 | 
			
		||||
  Integer StartTrajectory;
 | 
			
		||||
  Integer Trajectories; /* @brief Number of sweeps in this run */
 | 
			
		||||
  bool MetropolisTest;
 | 
			
		||||
  Integer NoMetropolisUntil;
 | 
			
		||||
struct HMCparameters: Serializable {
 | 
			
		||||
	GRID_SERIALIZABLE_CLASS_MEMBERS(HMCparameters,
 | 
			
		||||
  Integer, StartTrajectory,
 | 
			
		||||
  Integer, Trajectories, /* @brief Number of sweeps in this run */
 | 
			
		||||
  bool, MetropolisTest,
 | 
			
		||||
  Integer, NoMetropolisUntil,
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  // nest here the MDparameters and make all serializable
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -112,7 +112,7 @@ class BinaryCPModule: public CheckPointerModule< ImplementationPolicy> {
 | 
			
		||||
template<class ImplementationPolicy>
 | 
			
		||||
class NerscCPModule: public CheckPointerModule< ImplementationPolicy> {
 | 
			
		||||
  typedef CheckPointerModule< ImplementationPolicy> CPBase;
 | 
			
		||||
  using CPBase::CPBase; // for constructors
 | 
			
		||||
  using CPBase::CPBase; // for constructors inheritance
 | 
			
		||||
 | 
			
		||||
  // acquire resource
 | 
			
		||||
  virtual void initialize(){
 | 
			
		||||
@@ -140,6 +140,8 @@ class ILDGCPModule: public CheckPointerModule< ImplementationPolicy> {
 | 
			
		||||
 | 
			
		||||
extern char cp_string[];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// use macros?
 | 
			
		||||
static Registrar<QCD::BinaryCPModule<QCD::PeriodicGimplR>, HMC_CPModuleFactory<cp_string, QCD::PeriodicGimplR, XmlReader> > __CPBinarymodXMLInit("Binary");
 | 
			
		||||
static Registrar<QCD::NerscCPModule<QCD::PeriodicGimplR> , HMC_CPModuleFactory<cp_string, QCD::PeriodicGimplR, XmlReader> > __CPNerscmodXMLInit("Nersc");
 | 
			
		||||
static Registrar<QCD::ILDGCPModule<QCD::PeriodicGimplR>  , HMC_CPModuleFactory<cp_string, QCD::PeriodicGimplR, XmlReader> > __CPILDGmodXMLInit("ILDG");
 | 
			
		||||
 
 | 
			
		||||
@@ -173,7 +173,7 @@ typedef WilsonGModule<PeriodicGimplR> WilsonGMod;
 | 
			
		||||
// Factory is perfectly fine
 | 
			
		||||
// Registar must be changed because I do not want to use the ModuleFactory
 | 
			
		||||
 | 
			
		||||
// ref to LatticeGaugeField must be changed
 | 
			
		||||
// explicit ref to LatticeGaugeField must be changed
 | 
			
		||||
typedef HMCModuleBase< QCD::Action< QCD::LatticeGaugeField > > HMC_LGTActionModBase;
 | 
			
		||||
 | 
			
		||||
template <char const *str, class ReaderClass >
 | 
			
		||||
@@ -196,17 +196,10 @@ class HMC_LGTActionModuleFactory
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
then rewrite the registar
 | 
			
		||||
 | 
			
		||||
when this is done we have all the modules that contain the pointer to the objects
 | 
			
		||||
(actions, integrators, checkpointers, solvers)
 | 
			
		||||
 | 
			
		||||
factory will create only the modules and prepare the parameters
 | 
			
		||||
when needed a pointer is released
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -226,6 +219,8 @@ class Registrar {
 | 
			
		||||
 | 
			
		||||
extern char gauge_string[];
 | 
			
		||||
static Registrar<QCD::WilsonGMod, HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __WGmodXMLInit("Wilson"); 
 | 
			
		||||
// add here the registration for other implementations and readers
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user