1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Moving registrations in an independent file

This commit is contained in:
Guido Cossu 2017-01-27 11:23:51 +00:00
parent e863a948e3
commit 5c779a789b
12 changed files with 159 additions and 238 deletions

View File

@ -46,13 +46,12 @@ namespace QCD {
struct HMCparameters: Serializable {
GRID_SERIALIZABLE_CLASS_MEMBERS(HMCparameters,
Integer, StartTrajectory,
Integer, Trajectories, /* @brief Number of sweeps in this run */
bool, MetropolisTest,
Integer, NoMetropolisUntil,
std::string, StartingType,
IntegratorParameters, MD,
)
Integer, StartTrajectory,
Integer, Trajectories, /* @brief Number of sweeps in this run */
bool, MetropolisTest,
Integer, NoMetropolisUntil,
std::string, StartingType,
IntegratorParameters, MD)
HMCparameters() {
////////////////////////////// Default values
@ -103,10 +102,15 @@ class PlaquetteLogger : public HmcObservable<typename Impl::Field> {
std::string Stem;
public:
INHERIT_GIMPL_TYPES(Impl);
// here forces the Impl to be of gauge fields
// if not the compiler will complain
INHERIT_GIMPL_TYPES(Impl);
typedef typename Impl::Field Field; // necessary for HmcObservable compatibility
PlaquetteLogger(std::string cf) { Stem = cf; };
void TrajectoryComplete(int traj, GaugeField &U, GridSerialRNG &sRNG,
void TrajectoryComplete(int traj,
Field &U,
GridSerialRNG &sRNG,
GridParallelRNG &pRNG) {
std::string file;
{

View File

@ -104,7 +104,7 @@ class HMCResourceManager {
SetRNGSeeds(RNGpar);
// Observables
auto &ObsFactory = HMC_ObservablesModuleFactory<observable_string, ReaderClass>::getInstance();
auto &ObsFactory = HMC_ObservablesModuleFactory<observable_string, typename ImplementationPolicy::Field, ReaderClass>::getInstance();
Read.push(observable_string);// here must check if existing...
do {
std::string obs_type;

View File

@ -105,7 +105,6 @@ class HMCMinimumNorm2: public HMCModule< QCD::GenericHMCRunnerTemplate<Implement
// aquire resource
virtual void initialize(){
std::cout << "Initializing the pointer" << std::endl;
this->HMCPtr.reset(new QCD::GenericHMCRunnerTemplate<ImplementationPolicy, RepresentationPolicy, QCD::MinimumNorm2>(this->Par_));
}
};

View File

@ -467,16 +467,6 @@ class OneFlavourRatioEOFModule:
};
typedef WilsonGModule<PeriodicGimplR> WilsonGMod;
typedef SymanzikGModule<PeriodicGimplR> SymanzikGMod;
typedef IwasakiGModule<PeriodicGimplR> IwasakiGMod;
typedef DBW2GModule<PeriodicGimplR> DBW2GMod;
typedef RBCGModule<PeriodicGimplR> RBCGMod;
typedef PlaqPlusRectangleGModule<PeriodicGimplR> PlaqPlusRectangleGMod;
}// QCD temporarily here
@ -521,31 +511,6 @@ class HMC_LGTActionModuleFactory
extern char gauge_string[];
/*
static Registrar<QCD::WilsonGMod, HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __WGmodXMLInit("Wilson");
static Registrar<QCD::SymanzikGMod, HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __SymGmodXMLInit("Symanzik");
static Registrar<QCD::IwasakiGMod, HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __IwGmodXMLInit("Iwasaki");
static Registrar<QCD::DBW2GMod, HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __DBW2GmodXMLInit("DBW2");
static Registrar<QCD::RBCGMod, HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __RBCGmodXMLInit("RBC");
static Registrar<QCD::PlaqPlusRectangleGMod, HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __PPRectGmodXMLInit("PlaqPlusRect");
// FIXME more general implementation
static Registrar<QCD::TwoFlavourFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourFmodXMLInit("TwoFlavours");
static Registrar<QCD::TwoFlavourRatioFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourRatioFmodXMLInit("TwoFlavoursRatio");
static Registrar<QCD::TwoFlavourEOFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourEOFmodXMLInit("TwoFlavoursEvenOdd");
static Registrar<QCD::TwoFlavourRatioEOFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourRatioEOFmodXMLInit("TwoFlavoursEvenOddRatio");
static Registrar<QCD::OneFlavourFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __OneFlavourFmodXMLInit("OneFlavour");
static Registrar<QCD::OneFlavourEOFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __OneFlavourEOFmodXMLInit("OneFlavourEvenOdd");
static Registrar<QCD::OneFlavourRatioFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __OneFlavourRatioFmodXMLInit("OneFlavourRatio");
static Registrar<QCD::OneFlavourRatioEOFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __OneFlavourRatioEOFmodXMLInit("OneFlavourEvenOddRatio");
*/
// add here the registration for other implementations and readers
} // Grid

View File

@ -203,27 +203,8 @@ class DomainWallFermionModule: public FermionOperatorModule<DomainWallFermion, F
// Now a specific registration with a fermion field
/*
static Registrar< WilsonFermionModule<WilsonImplR>,
HMC_FermionOperatorModuleFactory<fermionop_string, WilsonImplR, XmlReader> > __WilsonFOPmodXMLInit("Wilson");
static Registrar< MobiusFermionModule<WilsonImplR>,
HMC_FermionOperatorModuleFactory<fermionop_string, WilsonImplR, XmlReader> > __MobiusFOPmodXMLInit("Mobius");
static Registrar< DomainWallFermionModule<WilsonImplR>,
HMC_FermionOperatorModuleFactory<fermionop_string, WilsonImplR, XmlReader> > __DWFOPmodXMLInit("DomainWall");
*/
} // QCD
} // Grid
#endif //SOLVER_MODULES_H
#endif //FERMIONOPERATOR_MODULES_H

View File

@ -88,9 +88,9 @@ class Parametrized<NoParameters>{
/*
Lowest level abstract module class
*/
////////////////////////////////////////
// Lowest level abstract module class
////////////////////////////////////////
template <class Prod>
class HMCModuleBase {
public:
@ -103,103 +103,10 @@ class HMCModuleBase {
virtual void print_parameters(){}; // default to nothing
};
/////////////////////////////
// Observables
/////////////////////////////
// explicit gauge field here....
template <class ObservableType, class OPar>
class ObservableModule
: public Parametrized<OPar>,
public HMCModuleBase< QCD::HmcObservable<typename ObservableType::GaugeField> > {
public:
typedef HMCModuleBase< QCD::HmcObservable< typename ObservableType::GaugeField> > Base;
typedef typename Base::Product Product;
std::unique_ptr<ObservableType> ObservablePtr;
ObservableModule(OPar Par) : Parametrized<OPar>(Par) {}
virtual void print_parameters(){
std::cout << this->Par_ << std::endl;
}
template <class ReaderClass>
ObservableModule(Reader<ReaderClass>& Reader) : Parametrized<OPar>(Reader){};
Product* getPtr() {
if (!ObservablePtr) initialize();
return ObservablePtr.get();
}
private:
virtual void initialize() = 0;
};
////////////////
// Modules
////////////////
namespace QCD{
//// Observables module
class PlaquetteObsParameters : Serializable {
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(PlaquetteObsParameters,
std::string, output_prefix);
};
template < class Impl >
class PlaquetteMod: public ObservableModule<PlaquetteLogger<Impl>, PlaquetteObsParameters>{
typedef ObservableModule<PlaquetteLogger<Impl>, PlaquetteObsParameters> ObsBase;
using ObsBase::ObsBase; // for constructors
// acquire resource
virtual void initialize(){
this->ObservablePtr.reset(new PlaquetteLogger<Impl>(this->Par_.output_prefix));
}
};
}// QCD temporarily here
////////////////////////////////////////
// Factories specialisations
////////////////////////////////////////
// explicit ref to LatticeGaugeField must be changed of put in the factory
typedef HMCModuleBase< QCD::HmcObservable<QCD::LatticeGaugeField> > HMC_ObsModBase;
template <char const *str, class ReaderClass >
class HMC_ObservablesModuleFactory
: public Factory < HMC_ObsModBase , Reader<ReaderClass> > {
public:
typedef Reader<ReaderClass> TheReader;
// use SINGLETON FUNCTOR MACRO HERE
HMC_ObservablesModuleFactory(const HMC_ObservablesModuleFactory& e) = delete;
void operator=(const HMC_ObservablesModuleFactory& e) = delete;
static HMC_ObservablesModuleFactory& getInstance(void) {
static HMC_ObservablesModuleFactory e;
return e;
}
private:
HMC_ObservablesModuleFactory(void) = default;
std::string obj_type() const {
return std::string(str);
}
};
/////////////////////////////////////////////
// Registration class
/////////////////////////////////////////////
template <class T, class TheFactory>
class Registrar {
@ -217,10 +124,6 @@ class Registrar {
extern char observable_string[];
//static Registrar<QCD::PlaquetteMod<QCD::PeriodicGimplR>, HMC_ObservablesModuleFactory<observable_string, XmlReader> > __OBSPLmodXMLInit("Plaquette");
}

View File

@ -0,0 +1,127 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: ./lib/qcd/modules/ObservableModules.h
Copyright (C) 2016
Author: Guido Cossu <guido.cossu@ed.ac.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution
directory
*************************************************************************************/
/* END LEGAL */
#ifndef HMC_OBSERVABLE_MODULES_H
#define HMC_OBSERVABLE_MODULES_H
namespace Grid {
/////////////////////////////
// Observables
/////////////////////////////
template <class ObservableType, class OPar>
class ObservableModule
: public Parametrized<OPar>,
public HMCModuleBase< QCD::HmcObservable<typename ObservableType::Field> > {
public:
typedef HMCModuleBase< QCD::HmcObservable< typename ObservableType::Field> > Base;
typedef typename Base::Product Product;
std::unique_ptr<ObservableType> ObservablePtr;
ObservableModule(OPar Par) : Parametrized<OPar>(Par) {}
virtual void print_parameters(){
std::cout << this->Par_ << std::endl;
}
template <class ReaderClass>
ObservableModule(Reader<ReaderClass>& Reader) : Parametrized<OPar>(Reader){};
Product* getPtr() {
if (!ObservablePtr) initialize();
return ObservablePtr.get();
}
private:
virtual void initialize() = 0;
};
////////////////
// Modules
////////////////
namespace QCD{
//// Observables module
class PlaquetteObsParameters : Serializable {
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(PlaquetteObsParameters,
std::string, output_prefix);
};
template < class Impl >
class PlaquetteMod: public ObservableModule<PlaquetteLogger<Impl>, PlaquetteObsParameters>{
typedef ObservableModule<PlaquetteLogger<Impl>, PlaquetteObsParameters> ObsBase;
using ObsBase::ObsBase; // for constructors
// acquire resource
virtual void initialize(){
this->ObservablePtr.reset(new PlaquetteLogger<Impl>(this->Par_.output_prefix));
}
};
}// QCD temporarily here
////////////////////////////////////////
// Factories specialisations
////////////////////////////////////////
// explicit ref to LatticeGaugeField must be changed or put in the factory
//typedef HMCModuleBase< QCD::HmcObservable<QCD::LatticeGaugeField> > HMC_ObsModBase;
template <char const *str, class Field, class ReaderClass >
class HMC_ObservablesModuleFactory
: public Factory < HMCModuleBase< QCD::HmcObservable<Field> >, Reader<ReaderClass> > {
public:
typedef Reader<ReaderClass> TheReader;
// use SINGLETON FUNCTOR MACRO HERE
HMC_ObservablesModuleFactory(const HMC_ObservablesModuleFactory& e) = delete;
void operator=(const HMC_ObservablesModuleFactory& e) = delete;
static HMC_ObservablesModuleFactory& getInstance(void) {
static HMC_ObservablesModuleFactory e;
return e;
}
private:
HMC_ObservablesModuleFactory(void) = default;
std::string obj_type() const {
return std::string(str);
}
};
extern char observable_string[];
}
#endif //HMC_OBSERVABLE_MODULES_H

View File

@ -33,9 +33,14 @@ directory
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Actions
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef QCD::WilsonGModule<ImplementationPolicy> WilsonGMod;
typedef QCD::SymanzikGModule<ImplementationPolicy> SymanzikGMod;
typedef QCD::IwasakiGModule<ImplementationPolicy> IwasakiGMod;
typedef QCD::DBW2GModule<ImplementationPolicy> DBW2GMod;
typedef QCD::RBCGModule<ImplementationPolicy> RBCGMod;
typedef QCD::PlaqPlusRectangleGModule<ImplementationPolicy> PlaqPlusRectangleGMod;
static Registrar<QCD::WilsonGMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser > > __WGmodXMLInit("Wilson");
static Registrar<QCD::WilsonGMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __WGmodXMLInit("Wilson");
static Registrar<QCD::SymanzikGMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __SymGmodXMLInit("Symanzik");
static Registrar<QCD::IwasakiGMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __IwGmodXMLInit("Iwasaki");
static Registrar<QCD::DBW2GMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __DBW2GmodXMLInit("DBW2");
@ -72,9 +77,9 @@ static Registrar<QCD::OneFlavourRatioEOFModule<FermionImplementationPolicy>,
// here must instantiate CG and CR for every new fermion field type (macro!!)
static Registrar< ConjugateGradientModule<QCD::WilsonFermionR::FermionField>,
HMC_SolverModuleFactory<solver_string, QCD::WilsonFermionR::FermionField, Serialiser> > __CGWFmodXMLInit("ConjugateGradientWF");
HMC_SolverModuleFactory<solver_string, QCD::WilsonFermionR::FermionField, Serialiser> > __CGWFmodXMLInit("ConjugateGradient");
static Registrar< ConjugateResidualModule<QCD::WilsonFermionR::FermionField>,
HMC_SolverModuleFactory<solver_string, QCD::WilsonFermionR::FermionField, Serialiser> > __CRWFmodXMLInit("ConjugateResidualWF");
HMC_SolverModuleFactory<solver_string, QCD::WilsonFermionR::FermionField, Serialiser> > __CRWFmodXMLInit("ConjugateResidual");
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -93,7 +98,7 @@ static Registrar< QCD::DomainWallFermionModule<FermionImplementationPolicy>,
// Observables
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static Registrar<QCD::PlaquetteMod<ImplementationPolicy>, HMC_ObservablesModuleFactory<observable_string, Serialiser> > __OBSPLmodXMLInit("Plaquette");
static Registrar<QCD::PlaquetteMod<ImplementationPolicy>, HMC_ObservablesModuleFactory<observable_string, typename ImplementationPolicy::Field, Serialiser> > __OBSPLmodXMLInit("Plaquette");
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Checkpointers

View File

@ -136,18 +136,6 @@ class ConjugateResidualModule: public SolverModule<ConjugateResidual, Field, Sol
};
extern char solver_string[];
/*
// Now a specific registration with a fermion field
static Registrar< ConjugateGradientModule<QCD::WilsonFermionR::FermionField>,
HMC_SolverModuleFactory<solver_string, QCD::WilsonFermionR::FermionField, XmlReader> > __CGWFmodXMLInit("ConjugateGradientWF");
static Registrar< ConjugateResidualModule<QCD::WilsonFermionR::FermionField>,
HMC_SolverModuleFactory<solver_string, QCD::WilsonFermionR::FermionField, XmlReader> > __CRWFmodXMLInit("ConjugateResidualWF");
*/
} // Grid

View File

@ -39,6 +39,7 @@ directory
#include <Grid/qcd/modules/SolverModules.h>
#include <Grid/qcd/modules/FermionOperatorModules.h>
#include <Grid/qcd/modules/ActionModules.h>
#include <Grid/qcd/modules/ObservableModules.h>

View File

@ -1,49 +0,0 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: ./lib/supported_compilers.h
Copyright (C) 2016
Author: Guido Cossu <guido.cossu@ed.ac.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/
/* END LEGAL */
#ifndef COMPILER_CHECK_H
#define COMPILER_CHECK_H
// exclude unsupported compilers
#if defined(__clang__)
#define CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#if CLANG_VERSION < 30800
#error "unsupported Clang version"
#endif
#elif defined(__GNUC__)
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if GCC_VERSION < 40800
#error "unsupported GCC version"
#endif
#endif
#endif // COMPILER_CHECK_H

View File

@ -52,9 +52,6 @@ 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
//typedef XmlReader InputFileReader;
// Reader, file should come from command line
Serialiser Reader("input.wilson_gauge.params.xml");