1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-04 11:15:55 +01:00

HMC factories

This commit is contained in:
Guido Cossu 2017-01-17 10:46:49 +00:00
parent 87e8aad5a0
commit 0157274762
5 changed files with 26 additions and 19 deletions

View File

@ -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);

View File

@ -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

View File

@ -103,7 +103,7 @@ class BinaryCPModule: public CheckPointerModule< ImplementationPolicy> {
// acquire resource
virtual void initialize(){
this->CheckPointPtr.reset(new BinaryHmcCheckpointer<ImplementationPolicy>(this->Par_));
this->CheckPointPtr.reset(new BinaryHmcCheckpointer<ImplementationPolicy>(this->Par_));
}
};
@ -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");

View File

@ -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
}

View File

@ -39,7 +39,7 @@ int main(int argc, char **argv) {
// here make a routine to print all the relevant information on the run
std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl;
// Typedefs to simplify notation
// Typedefs to simplify notation
typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
typedef Grid::XmlReader InputFileReader;