1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-27 22:25:56 +01:00

All tests compile.

This commit is contained in:
Guido Cossu 2017-02-10 10:27:51 +00:00
parent 8b6a6c8236
commit c3d7ec65fa
25 changed files with 1482 additions and 1208 deletions

View File

@ -10,6 +10,7 @@ matrix:
osx_image: xcode7.2 osx_image: xcode7.2
compiler: clang compiler: clang
- compiler: gcc - compiler: gcc
sudo: required
addons: addons:
apt: apt:
sources: sources:

37
lib/DisableWarnings.h Normal file
View File

@ -0,0 +1,37 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: ./lib/DisableWarnings.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 DISABLE_WARNINGS_H
#define DISABLE_WARNINGS_H
//disables and intel compiler specific warning (in json.hpp)
#pragma warning disable 488
#endif

View File

@ -60,6 +60,7 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
// Grid headers // Grid headers
/////////////////// ///////////////////
#include "Config.h" #include "Config.h"
#include <Grid/DisableWarnings.h>
#include <Grid/Timer.h> #include <Grid/Timer.h>
#include <Grid/PerfCount.h> #include <Grid/PerfCount.h>
#include <Grid/Log.h> #include <Grid/Log.h>

View File

@ -1348,7 +1348,6 @@ class basic_json
@since version 1.0.0 @since version 1.0.0
*/ */
#pragma warning disable 488 //disables and intel compiler specific warning
template<typename T, typename std::enable_if< template<typename T, typename std::enable_if<
not (std::is_same<T, int>::value) and not (std::is_same<T, int>::value) and
std::is_same<T, number_integer_t>::value, int>::type = 0> std::is_same<T, number_integer_t>::value, int>::type = 0>

View File

@ -179,6 +179,17 @@ using GenericHMCRunnerF = HMCWrapperTemplate<PeriodicGimplF, Integrator>;
template <template <typename, typename, typename> class Integrator> template <template <typename, typename, typename> class Integrator>
using GenericHMCRunnerD = HMCWrapperTemplate<PeriodicGimplD, Integrator>; using GenericHMCRunnerD = HMCWrapperTemplate<PeriodicGimplD, Integrator>;
// These are for gauge fields, default integrator MinimumNorm2
template <template <typename, typename, typename> class Integrator>
using ConjugateHMCRunner = HMCWrapperTemplate<ConjugateGimplR, Integrator>;
template <template <typename, typename, typename> class Integrator>
using ConjugateHMCRunnerF = HMCWrapperTemplate<ConjugateGimplF, Integrator>;
template <template <typename, typename, typename> class Integrator>
using ConjugateHMCRunnerD = HMCWrapperTemplate<ConjugateGimplD, Integrator>;
template <class RepresentationsPolicy, template <class RepresentationsPolicy,
template <typename, typename, typename> class Integrator> template <typename, typename, typename> class Integrator>
using GenericHMCRunnerHirep = using GenericHMCRunnerHirep =
@ -188,7 +199,6 @@ template <class Implementation, class RepresentationsPolicy,
template <typename, typename, typename> class Integrator> template <typename, typename, typename> class Integrator>
using GenericHMCRunnerTemplate = HMCWrapperTemplate<Implementation, Integrator, RepresentationsPolicy>; using GenericHMCRunnerTemplate = HMCWrapperTemplate<Implementation, Integrator, RepresentationsPolicy>;
typedef HMCWrapperTemplate<ScalarImplR, MinimumNorm2, ScalarFields> typedef HMCWrapperTemplate<ScalarImplR, MinimumNorm2, ScalarFields>
ScalarGenericHMCRunner; ScalarGenericHMCRunner;

View File

@ -1,104 +1,160 @@
/************************************************************************************* /*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: ./tests/Test_hmc_EODWFRatio.cc Source file: ./tests/Test_hmc_EODWFRatio.cc
Copyright (C) 2015 Copyright (C) 2015-2016
Author: Peter Boyle <paboyle@ph.ed.ac.uk> Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
Author: paboyle <paboyle@ph.ed.ac.uk> Author: Guido Cossu <guido.cossu@ed.ac.uk>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along 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., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory See the full license in the file "LICENSE" in the top level distribution
*************************************************************************************/ directory
/* END LEGAL */ *************************************************************************************/
/* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid {
namespace QCD {
class HmcRunner : public NerscHmcRunner { int main(int argc, char **argv) {
public: using namespace Grid;
using namespace Grid::QCD;
void BuildTheAction (int argc, char **argv) Grid_init(&argc, &argv);
int threads = GridThread::GetThreads();
// 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 WilsonImplR ImplPolicy; typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
typedef WilsonImplR FermionImplPolicy;
typedef DomainWallFermionR FermionAction; typedef DomainWallFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
HMCWrapper TheHMC;
// Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_EODWF_lat";
CPparams.rng_prefix = "ckpoint_EODWF_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 5.6 ;
WilsonGaugeActionR Waction(beta);
const int Ls = 8; const int Ls = 8;
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
auto FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
auto FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,GridPtr);
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(UGrid); LatticeGaugeField U(GridPtr);
// Gauge action Real mass = 0.04;
WilsonGaugeActionR Waction(5.6);
Real mass= 0.04;
Real pv = 1.0; Real pv = 1.0;
RealD M5 = 1.5; RealD M5 = 1.5;
FermionAction DenOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5);
FermionAction NumOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,pv,M5);
ConjugateGradient<FermionField> CG(1.0e-8,10000); FermionAction DenOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,mass,M5);
TwoFlavourEvenOddRatioPseudoFermionAction<ImplPolicy> Nf2(NumOp, DenOp,CG,CG); FermionAction NumOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,pv, M5);
//Collect actions double StoppingCondition = 1.0e-8;
ActionLevel<LatticeGaugeField> Level1; double MaxCGIterations = 10000;
ConjugateGradient<FermionField> CG(StoppingCondition,MaxCGIterations);
TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> Nf2(NumOp, DenOp,CG,CG);
// Set smearing (true/false), default: false
Nf2.is_smeared = true;
// Collect actions
ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&Nf2); Level1.push_back(&Nf2);
Level1.push_back(&Waction);
TheAction.push_back(Level1);
ActionLevel<HMCWrapper::Field> Level2(4);
Level2.push_back(&Waction);
TheHMC.TheAction.push_back(Level1);
TheHMC.TheAction.push_back(Level2);
/////////////////////////////////////////////////////////////
/*
double rho = 0.1; // smearing parameter
int Nsmear = 2; // number of smearing levels
Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
SmearedConfiguration<HMCWrapper::ImplPolicy> SmearingPolicy(
UGrid, Nsmear, Stout);
*/
// HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0;
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
// Reset performance counters
NumOp.ZeroCounters(); NumOp.ZeroCounters();
DenOp.ZeroCounters(); DenOp.ZeroCounters();
Run(argc,argv); TheHMC.Run(); // no smearing
// TheHMC.Run(SmearingPolicy); // for smearing
std::cout << GridLogMessage << "Numerator report, Pauli-Villars term : " << std::endl; std::cout << GridLogMessage << "Numerator report, Pauli-Villars term : " << std::endl;
NumOp.Report(); NumOp.Report();
std::cout << GridLogMessage << "Denominator report, Dw(m) term (includes CG) : " << std::endl; std::cout << GridLogMessage << "Denominator report, Dw(m) term (includes CG) : " << std::endl;
DenOp.Report(); DenOp.Report();
};
};
}}
int main (int argc, char ** argv) Grid_finalize();
{
Grid_init(&argc,&argv);
int threads = GridThread::GetThreads();
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
HmcRunner TheHMC;
TheHMC.BuildTheAction(argc,argv);
} } // main

View File

@ -2,11 +2,12 @@
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: ./tests/Test_hmc_EODWFRatio.cc Source file: ./tests/Test_hmc_WilsonFermionGauge.cc
Copyright (C) 2015-2016 Copyright (C) 2015
Author: Peter Boyle <pabobyle@ph.ed.ac.uk> Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
Author: neo <cossu@post.kek.jp>
Author: Guido Cossu <guido.cossu@ed.ac.uk> Author: Guido Cossu <guido.cossu@ed.ac.uk>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@ -42,8 +43,9 @@ int main(int argc, char **argv) {
// Typedefs to simplify notation // Typedefs to simplify notation
typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
typedef WilsonImplR FermionImplPolicy;
typedef DomainWallFermionR FermionAction; typedef DomainWallVec5dImplR FermionImplPolicy;
typedef DomainWallFermion<FermionImplPolicy> FermionAction;
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
@ -86,11 +88,14 @@ int main(int argc, char **argv) {
RealD beta = 5.6 ; RealD beta = 5.6 ;
WilsonGaugeActionR Waction(beta); WilsonGaugeActionR Waction(beta);
const int Ls = 8;
auto GridPtr = TheHMC.Resources.GetCartesian(); auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
auto FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr); auto FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
auto FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,GridPtr); auto FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,GridPtr);
auto sUGrid = SpaceTimeGrid::makeFourDimDWFGrid(GridDefaultLatt(),GridDefaultMpi());
auto sUrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(sUGrid);
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(GridPtr); LatticeGaugeField U(GridPtr);
@ -99,16 +104,17 @@ int main(int argc, char **argv) {
Real pv = 1.0; Real pv = 1.0;
RealD M5 = 1.5; RealD M5 = 1.5;
FermionAction DenOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5); FermionAction DenOp(U,*FGrid,*FrbGrid,*sUGrid,*sUrbGrid,mass,M5);
FermionAction NumOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,pv, M5); FermionAction NumOp(U,*FGrid,*FrbGrid,*sUGrid,*sUrbGrid,pv,M5);
double StoppingCondition = 1.0e-8; double StoppingCondition = 1.0e-8;
double MaxCGIterations = 10000; double MaxCGIterations = 10000;
ConjugateGradient<FermionField> CG(StoppingCondition,MaxCGIterations); ConjugateGradient<FermionField> CG(StoppingCondition,MaxCGIterations);
TwoFlavourEvenOddRatioPseudoFermionAction<ImplPolicy> Nf2(NumOp, DenOp,CG,CG); TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> Nf2(NumOp, DenOp,CG,CG);
// Set smearing (true/false), default: false // Set smearing (true/false), default: false
Nf2.is_smeared = true; Nf2.is_smeared = false;
// Collect actions // Collect actions
ActionLevel<HMCWrapper::Field> Level1(1); ActionLevel<HMCWrapper::Field> Level1(1);
@ -120,15 +126,6 @@ int main(int argc, char **argv) {
TheHMC.TheAction.push_back(Level1); TheHMC.TheAction.push_back(Level1);
TheHMC.TheAction.push_back(Level2); TheHMC.TheAction.push_back(Level2);
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
/*
double rho = 0.1; // smearing parameter
int Nsmear = 2; // number of smearing levels
Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
SmearedConfiguration<HMCWrapper::ImplPolicy> SmearingPolicy(
UGrid, Nsmear, Stout);
*/
// HMC parameters are serialisable // HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20; TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0; TheHMC.Parameters.MD.trajL = 1.0;
@ -139,7 +136,6 @@ int main(int argc, char **argv) {
NumOp.ZeroCounters(); NumOp.ZeroCounters();
DenOp.ZeroCounters(); DenOp.ZeroCounters();
TheHMC.Run(); // no smearing TheHMC.Run(); // no smearing
// TheHMC.Run(SmearingPolicy); // for smearing
std::cout << GridLogMessage << "Numerator report, Pauli-Villars term : " << std::endl; std::cout << GridLogMessage << "Numerator report, Pauli-Villars term : " << std::endl;
NumOp.Report(); NumOp.Report();
@ -157,105 +153,3 @@ int main(int argc, char **argv) {
} // main } // main
// Derive from the BinaryHmcRunner (templated for gauge fields)
class HmcRunner : public BinaryHmcRunner {
public:
void BuildTheAction(int argc, char **argv)
{
typedef WilsonImplR ImplPolicy;
//typedef ScaledShamirFermion<ImplPolicy> FermionAction;
typedef DomainWallFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField;
const int Ls = 8;
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
// temporarily need a gauge field
LatticeGaugeField U(UGrid);
// Gauge action
double beta = 5.6;
WilsonGaugeActionR Waction(beta);
Real mass = 0.04;
Real pv = 1.0;
RealD M5 = 1.5;
RealD scale = 2.0;
/*
FermionAction DenOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,scale);
FermionAction NumOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,pv,M5,scale);
*/
FermionAction DenOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5);
FermionAction NumOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,pv,M5);
double StoppingCondition = 1.0e-8;
double MaxCGIterations = 10000;
ConjugateGradient<FermionField> CG(StoppingCondition,MaxCGIterations);
TwoFlavourEvenOddRatioPseudoFermionAction<ImplPolicy> Nf2(NumOp, DenOp,CG,CG);
// Set smearing (true/false), default: false
Nf2.is_smeared = true;
// Collect actions
// here an example of 2 level integration
ActionLevel<Field> Level1(1);
Level1.push_back(&Nf2);
Level1.push_back(&Waction);
// this level will integrate with a
// step that is 4 times finer
// than the previous level
//ActionLevel<Field> Level2(4);
TheAction.push_back(Level1);
//TheAction.push_back(Level2);
// Add observables
int SaveInterval = 1;
std::string format = std::string("IEEE64BIG");
std::string conf_prefix = std::string("DWF_ckpoint_lat");
std::string rng_prefix = std::string("DWF_ckpoint_rng");
BinaryHmcCheckpointer<BinaryHmcRunner::ImplPolicy> Checkpoint(conf_prefix, rng_prefix, SaveInterval, 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"));
ObservablesList.push_back(&PlaqLog);
ObservablesList.push_back(&Checkpoint);
// Smearing section, omit if not needed
double rho = 0.1; // smearing parameter
int Nsmear = 2; // number of smearing levels
Smear_Stout<BinaryHmcRunner::ImplPolicy> Stout(rho);
SmearedConfiguration<BinaryHmcRunner::ImplPolicy> SmearingPolicy(
UGrid, Nsmear, Stout);
///////////////////
NumOp.ZeroCounters();
DenOp.ZeroCounters();
//Run(argc, argv, Checkpoint, SmearingPolicy);
Run(argc, argv, Checkpoint); // no smearing
std::cout << GridLogMessage << "Numerator report, Pauli-Villars term : " << std::endl;
NumOp.Report();
std::cout << GridLogMessage << "Denominator report, Dw(m) term (includes CG) : " << std::endl;
DenOp.Report();
};
};
}
}

View File

@ -1,186 +0,0 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: ./tests/Test_hmc_WilsonFermionGauge.cc
Copyright (C) 2015
Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
Author: neo <cossu@post.kek.jp>
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 */
#include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid {
namespace QCD {
class HMCRunnerParameters : Serializable {
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(HMCRunnerParameters,
double, beta,
double, mass,
int, MaxCGIterations,
double, StoppingCondition,
bool, smearedAction,
int, SaveInterval,
std::string, format,
std::string, conf_prefix,
std::string, rng_prefix,
double, rho,
int, SmearingLevels,
);
HMCRunnerParameters() {}
};
// Derive from the BinaryHmcRunner (templated for gauge fields)
class HmcRunner : public BinaryHmcRunner {
public:
void BuildTheAction(int argc, char **argv)
{
typedef DomainWallVec5dImplR ImplPolicy;
//typedef ScaledShamirFermion<ImplPolicy> FermionAction;
typedef DomainWallFermion<ImplPolicy> FermionAction;
typedef typename FermionAction::FermionField FermionField;
const int Ls = 8;
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
GridCartesian* sUGrid = SpaceTimeGrid::makeFourDimDWFGrid(GridDefaultLatt(),GridDefaultMpi());
GridRedBlackCartesian* sUrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(sUGrid);
FGrid = SpaceTimeGrid::makeFiveDimDWFGrid(Ls,UGrid);
FrbGrid = SpaceTimeGrid::makeFiveDimDWFRedBlackGrid(Ls,UGrid);
// temporarily need a gauge field
LatticeGaugeField U(UGrid);
// Gauge action
double beta = 5.6;
WilsonGaugeActionR Waction(beta);
Real mass = 0.04;
Real pv = 1.0;
RealD M5 = 1.5;
RealD scale = 2.0;
/*
// Scaled Shamir
FermionAction DenOp(U,*FGrid,*FrbGrid,*sUGrid,*sUrbGrid,mass,M5,scale);
FermionAction NumOp(U,*FGrid,*FrbGrid,*sUGrid,*sUrbGrid,pv,M5,scale);
*/
// Std Domain wall fermion
FermionAction DenOp(U,*FGrid,*FrbGrid,*sUGrid,*sUrbGrid,mass,M5);
FermionAction NumOp(U,*FGrid,*FrbGrid,*sUGrid,*sUrbGrid,pv,M5);
double StoppingCondition = 1.0e-8;
double MaxCGIterations = 10000;
ConjugateGradient<FermionField> CG(StoppingCondition,MaxCGIterations);
TwoFlavourEvenOddRatioPseudoFermionAction<ImplPolicy> Nf2(NumOp, DenOp,CG,CG);
// Set smearing (true/false), default: false
Nf2.is_smeared = false;
// Collect actions
// here an example of 2 level integration
ActionLevel<Field> Level1(1);
Level1.push_back(&Nf2);
// this level will integrate with a
// step that is 4 times finer
// than the previous level
ActionLevel<Field> Level2(4);
Level2.push_back(&Waction);
TheAction.push_back(Level1);
TheAction.push_back(Level2);
// Add observables
int SaveInterval = 1;
std::string format = std::string("IEEE64BIG");
std::string conf_prefix = std::string("DWF_ckpoint_lat");
std::string rng_prefix = std::string("DWF_ckpoint_rng");
BinaryHmcCheckpointer<BinaryHmcRunner::ImplPolicy> Checkpoint(conf_prefix, rng_prefix, SaveInterval, 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"));
ObservablesList.push_back(&PlaqLog);
ObservablesList.push_back(&Checkpoint);
// Smearing section, omit if not needed
double rho = 0.1; // smearing parameter
int Nsmear = 2; // number of smearing levels
Smear_Stout<BinaryHmcRunner::ImplPolicy> Stout(rho);
SmearedConfiguration<BinaryHmcRunner::ImplPolicy> SmearingPolicy(
UGrid, Nsmear, Stout);
///////////////////
NumOp.ZeroCounters();
DenOp.ZeroCounters();
//Run(argc, argv, Checkpoint, SmearingPolicy);
Run(argc, argv, Checkpoint); // no smearing
std::cout << GridLogMessage << "Numerator report, Pauli-Villars term : " << std::endl;
NumOp.Report();
std::cout << GridLogMessage << "Denominator report, Dw(m) term (includes CG) : " << std::endl;
DenOp.Report();
};
};
}
}
int main(int argc, char **argv) {
Grid_init(&argc, &argv);
int threads = GridThread::GetThreads();
std::cout << GridLogMessage << "Grid is setup to use " << threads
<< " threads" << std::endl;
HmcRunner TheHMC;
// Seeds for the random number generators
std::vector<int> SerSeed({1, 2, 3, 4, 5});
std::vector<int> ParSeed({6, 7, 8, 9, 10});
TheHMC.RNGSeeds(SerSeed, ParSeed);
TheHMC.MDparameters.set(40, 1.0);// MDsteps, traj length
TheHMC.BuildTheAction(argc, argv);
Grid_finalize();
}

View File

@ -27,40 +27,74 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid {
namespace QCD {
class HmcRunner : public ConjugateNerscHmcRunner { int main(int argc, char **argv) {
public: using namespace Grid;
using namespace Grid::QCD;
void BuildTheAction (int argc, char **argv) Grid_init(&argc, &argv);
int threads = GridThread::GetThreads();
// 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 GparityWilsonImplR ImplPolicy; typedef ConjugateHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
typedef GparityWilsonImplR FermionImplPolicy;
typedef GparityDomainWallFermionR FermionAction; typedef GparityDomainWallFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
HMCWrapper TheHMC;
// Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_EODWF_lat";
CPparams.rng_prefix = "ckpoint_EODWF_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 5.6 ;
ConjugateWilsonGaugeActionR Waction(beta);
const int Ls = 8; const int Ls = 8;
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
auto FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
auto FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,GridPtr);
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(UGrid); LatticeGaugeField U(GridPtr);
// Gauge action
ConjugateWilsonGaugeActionR Waction(5.6);
// Fermion action
const int nu = 3; const int nu = 3;
std::vector<int> twists(Nd,0); std::vector<int> twists(Nd,0);
twists[nu] = 1; twists[nu] = 1;
@ -69,34 +103,50 @@ public:
Real mass=0.04; Real mass=0.04;
Real pv =1.0; Real pv =1.0;
RealD M5=1.5; RealD M5=1.5;
FermionAction DenOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,params);
FermionAction NumOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,pv,M5,params);
ConjugateGradient<FermionField> CG(1.0e-8,10000); FermionAction DenOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,mass,M5, params);
TwoFlavourEvenOddRatioPseudoFermionAction<ImplPolicy> Nf2(NumOp, DenOp,CG,CG); FermionAction NumOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,pv, M5, params);
//Collect actions double StoppingCondition = 1.0e-8;
ActionLevel<LatticeGaugeField> Level1; double MaxCGIterations = 10000;
ConjugateGradient<FermionField> CG(StoppingCondition,MaxCGIterations);
TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> Nf2(NumOp, DenOp,CG,CG);
// Set smearing (true/false), default: false
Nf2.is_smeared = false;
// Collect actions
ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&Nf2); Level1.push_back(&Nf2);
Level1.push_back(&Waction);
TheAction.push_back(Level1);
Run(argc,argv); ActionLevel<HMCWrapper::Field> Level2(4);
}; Level2.push_back(&Waction);
}; TheHMC.TheAction.push_back(Level1);
TheHMC.TheAction.push_back(Level2);
/////////////////////////////////////////////////////////////
}} // HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0;
int main (int argc, char ** argv) TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
{
Grid_init(&argc,&argv);
int threads = GridThread::GetThreads(); // Reset performance counters
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; NumOp.ZeroCounters();
DenOp.ZeroCounters();
TheHMC.Run(); // no smearing
// TheHMC.Run(SmearingPolicy); // for smearing
HmcRunner TheHMC; std::cout << GridLogMessage << "Numerator report, Pauli-Villars term : " << std::endl;
NumOp.Report();
std::cout << GridLogMessage << "Denominator report, Dw(m) term (includes CG) : " << std::endl;
DenOp.Report();
TheHMC.BuildTheAction(argc,argv); Grid_finalize();
} // main
}

View File

@ -28,70 +28,104 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid {
namespace QCD {
class HmcRunner : public NerscHmcRunner { int main(int argc, char **argv) {
public: using namespace Grid;
using namespace Grid::QCD;
void BuildTheAction (int argc, char **argv) Grid_init(&argc, &argv);
int threads = GridThread::GetThreads();
// 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 WilsonImplR ImplPolicy; typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
typedef WilsonImplR FermionImplPolicy;
typedef WilsonFermionR FermionAction; typedef WilsonFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid; //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
FrbGrid = UrbGrid; HMCWrapper TheHMC;
// Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 5.6 ;
WilsonGaugeActionR Waction(beta);
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(UGrid); LatticeGaugeField U(GridPtr);
// Gauge action Real mass = -0.77;
WilsonGaugeActionR Waction(5.6); RealD pv = 0.0;
RealD mass=-0.77; // Can we define an overloaded operator that does not need U and initialises
RealD pv =0.0; // it with zeroes?
FermionAction DenOp(U,*FGrid,*FrbGrid,mass); FermionAction DenOp(U, *GridPtr, *GridRBPtr, mass);
FermionAction NumOp(U,*FGrid,*FrbGrid,pv); FermionAction NumOp(U, *GridPtr, *GridRBPtr, pv);
ConjugateGradient<FermionField> CG(1.0e-8,10000); ConjugateGradient<FermionField> CG(1.0e-8, 2000);
TwoFlavourEvenOddRatioPseudoFermionAction<ImplPolicy> Nf2(NumOp, DenOp,CG,CG);
//Set smearing (true/false), default: false TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> Nf2(NumOp, DenOp,CG,CG);
Nf2.is_smeared=true;
//Collect actions // Set smearing (true/false), default: false
ActionLevel<LatticeGaugeField> Level1; Nf2.is_smeared = false;
// Collect actions
ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&Nf2); Level1.push_back(&Nf2);
Level1.push_back(&Waction);
TheAction.push_back(Level1);
Run(argc,argv); ActionLevel<HMCWrapper::Field> Level2(4);
}; Level2.push_back(&Waction);
}; TheHMC.TheAction.push_back(Level1);
TheHMC.TheAction.push_back(Level2);
/////////////////////////////////////////////////////////////
// HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0;
}} TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
TheHMC.Run(); // no smearing
int main (int argc, char ** argv) Grid_finalize();
{
Grid_init(&argc,&argv);
int threads = GridThread::GetThreads(); } // main
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
HmcRunner TheHMC;
TheHMC.BuildTheAction(argc,argv);
}

View File

@ -27,54 +27,81 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid { int main(int argc, char **argv) {
namespace QCD { using namespace Grid;
using namespace Grid::QCD;
class HmcRunner : public ConjugateNerscHmcRunner {
public:
void BuildTheAction (int argc, char **argv)
{
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid;
FrbGrid = UrbGrid;
// temporarily need a gauge field
LatticeGaugeField U(UGrid);
// Gauge action
ConjugateIwasakiGaugeActionR Gaction(2.6);
//Collect actions
ActionLevel<LatticeGaugeField> Level1(1);
Level1.push_back(&Gaction);
TheAction.push_back(Level1);
Run(argc,argv);
};
};
}}
int main (int argc, char ** argv)
{
Grid_init(&argc,&argv);
Grid_init(&argc, &argv);
int threads = GridThread::GetThreads(); int threads = GridThread::GetThreads();
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; // 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;
HmcRunner TheHMC; // Typedefs to simplify notation
typedef ConjugateHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
TheHMC.BuildTheAction(argc,argv); typedef GparityWilsonImplR FermionImplPolicy;
typedef GparityDomainWallFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField;
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
HMCWrapper TheHMC;
// Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_EODWF_lat";
CPparams.rng_prefix = "ckpoint_EODWF_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 2.6 ;
ConjugateIwasakiGaugeActionR Waction(beta);
// Collect actions
ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&Waction);
TheHMC.TheAction.push_back(Level1);
/////////////////////////////////////////////////////////////
// HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0;
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
TheHMC.Run(); // no smearing
Grid_finalize();
} // main
}

View File

@ -27,54 +27,81 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid {
namespace QCD {
class HmcRunner : public ConjugateNerscHmcRunner { int main(int argc, char **argv) {
public: using namespace Grid;
using namespace Grid::QCD;
void BuildTheAction (int argc, char **argv)
{
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid;
FrbGrid = UrbGrid;
// temporarily need a gauge field
LatticeGaugeField U(UGrid);
// Gauge action
ConjugateWilsonGaugeActionR Waction(5.6);
//Collect actions
ActionLevel<LatticeGaugeField> Level1(1);
Level1.push_back(&Waction);
TheAction.push_back(Level1);
Run(argc,argv);
};
};
}}
int main (int argc, char ** argv)
{
Grid_init(&argc,&argv);
Grid_init(&argc, &argv);
int threads = GridThread::GetThreads(); int threads = GridThread::GetThreads();
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; // 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;
HmcRunner TheHMC; // Typedefs to simplify notation
typedef ConjugateHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
TheHMC.BuildTheAction(argc,argv); typedef GparityWilsonImplR FermionImplPolicy;
typedef GparityDomainWallFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField;
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
HMCWrapper TheHMC;
// Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_EODWF_lat";
CPparams.rng_prefix = "ckpoint_EODWF_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 5.6 ;
ConjugateWilsonGaugeActionR Waction(beta);
// Collect actions
ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&Waction);
TheHMC.TheAction.push_back(Level1);
/////////////////////////////////////////////////////////////
// HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0;
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
TheHMC.Run(); // no smearing
Grid_finalize();
} // main
}

View File

@ -27,58 +27,71 @@ Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid { int main(int argc, char **argv) {
namespace QCD { using namespace Grid;
using namespace Grid::QCD;
class HmcRunner : public NerscHmcRunner {
public:
void BuildTheAction (int argc, char **argv)
{
typedef WilsonImplR ImplPolicy;
typedef WilsonFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid;
FrbGrid = UrbGrid;
// temporarily need a gauge field
LatticeGaugeField U(UGrid);
// Gauge action
IwasakiGaugeActionR Gaction(2.6);
//Collect actions
ActionLevel<LatticeGaugeField> Level1(1);
Level1.push_back(&Gaction);
TheAction.push_back(Level1);
Run(argc,argv);
};
};
}}
int main (int argc, char ** argv)
{
Grid_init(&argc,&argv);
Grid_init(&argc, &argv);
int threads = GridThread::GetThreads(); int threads = GridThread::GetThreads();
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; // 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;
HmcRunner TheHMC; // Typedefs to simplify notation
typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
HMCWrapper TheHMC;
TheHMC.BuildTheAction(argc,argv); // Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 20;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 2.6 ;
IwasakiGaugeActionR Iaction(beta);
ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&Iaction);
//Level1.push_back(WGMod.getPtr());
TheHMC.TheAction.push_back(Level1);
/////////////////////////////////////////////////////////////
// HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0;
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
TheHMC.Run(); // no smearing
Grid_finalize();
} // main
}

View File

@ -1,84 +1,99 @@
/************************************************************************************* /*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: ./tests/Test_hmc_RectGauge.cc Source file: ./tests/Test_hmc_RectGauge.cc
Copyright (C) 2015 Copyright (C) 2015-2016
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk> Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
Author: Guido Cossu <guido.cossu@ed.ac.uk>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along 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., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory See the full license in the file "LICENSE" in the top level distribution
*************************************************************************************/ directory
/* END LEGAL */ *************************************************************************************/
/* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std; int main(int argc, char **argv) {
using namespace Grid; using namespace Grid;
using namespace Grid::QCD; using namespace Grid::QCD;
namespace Grid {
namespace QCD {
class HmcRunner : public NerscHmcRunner {
public:
void BuildTheAction (int argc, char **argv)
{
typedef WilsonImplR ImplPolicy;
typedef WilsonFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid;
FrbGrid = UrbGrid;
// temporarily need a gauge field
LatticeGaugeField U(UGrid);
// Gauge action
PlaqPlusRectangleActionR Gaction(2.0,0.331);
//Collect actions
ActionLevel<LatticeGaugeField> Level1(1);
Level1.push_back(&Gaction);
TheAction.push_back(Level1);
Run(argc,argv);
};
};
}}
int main (int argc, char ** argv)
{
Grid_init(&argc,&argv);
Grid_init(&argc, &argv);
int threads = GridThread::GetThreads(); int threads = GridThread::GetThreads();
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; // 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;
HmcRunner TheHMC; // Typedefs to simplify notation
typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
HMCWrapper TheHMC;
TheHMC.BuildTheAction(argc,argv); // Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 20;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 2.0 ;
RealD c_rect = 0.331;
PlaqPlusRectangleActionR Gaction(beta, c_rect);
ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&Gaction);
//Level1.push_back(WGMod.getPtr());
TheHMC.TheAction.push_back(Level1);
/////////////////////////////////////////////////////////////
// HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0;
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
TheHMC.Run(); // no smearing
Grid_finalize();
} // main
}

View File

@ -31,53 +31,83 @@ directory
/* END LEGAL */ /* END LEGAL */
#include "Grid/Grid.h" #include "Grid/Grid.h"
using namespace std; int main(int argc, char **argv) {
using namespace Grid; using namespace Grid;
using namespace Grid::QCD; using namespace Grid::QCD;
namespace Grid { // Here change the allowed (higher) representations
namespace QCD { typedef Representations< FundamentalRepresentation, AdjointRepresentation > TheRepresentations;
// Here change the allowed (higher) representations Grid_init(&argc, &argv);
typedef Representations< FundamentalRepresentation, AdjointRepresentation > TheRepresentations; int threads = GridThread::GetThreads();
// 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
class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > { typedef GenericHMCRunnerHirep<TheRepresentations, MinimumNorm2> HMCWrapper;
public: typedef WilsonAdjImplR FermionImplPolicy; // gauge field implemetation for the pseudofermions
void BuildTheAction(int argc, char **argv)
{
typedef WilsonAdjImplR ImplPolicy; // gauge field implemetation for the pseudofermions
typedef WilsonAdjFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...) typedef WilsonAdjFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...)
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GridDefaultLatt(), GridDefaultSimd(Nd, vComplex::Nsimd()), HMCWrapper TheHMC;
GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid; // Grid from the command line
FrbGrid = UrbGrid; TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 2.25 ;
WilsonGaugeActionR Waction(beta);
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
// temporarily need a gauge field // temporarily need a gauge field
//LatticeGaugeField U(UGrid); AdjointRepresentation::LatticeField U(GridPtr);
AdjointRepresentation::LatticeField U(UGrid);
// Gauge action
WilsonGaugeActionR Waction(2.25);
Real mass = -0.95; Real mass = -0.95;
FermionAction FermOp(U, *FGrid, *FrbGrid, mass);
ConjugateGradient<FermionField> CG(1.0e-8, 10000, false); // Can we define an overloaded operator that does not need U and initialises
ConjugateResidual<FermionField> CR(1.0e-8, 10000); // it with zeroes?
FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass);
// Pass two solvers: one for the force computation and one for the action ConjugateGradient<FermionField> CG(1.0e-8, 2000, false);
TwoFlavourPseudoFermionAction<ImplPolicy> Nf2(FermOp, CG, CG);
TwoFlavourPseudoFermionAction<FermionImplPolicy> Nf2(FermOp, CG, CG);
// Set smearing (true/false), default: false // Set smearing (true/false), default: false
Nf2.is_smeared = false; Nf2.is_smeared = false;
// Collect actions // Collect actions
ActionLevel<LatticeGaugeField, TheRepresentations > Level1(1); ActionLevel<LatticeGaugeField, TheRepresentations > Level1(1);
Level1.push_back(&Nf2); Level1.push_back(&Nf2);
@ -85,23 +115,18 @@ class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > {
ActionLevel<LatticeGaugeField, TheRepresentations > Level2(4); ActionLevel<LatticeGaugeField, TheRepresentations > Level2(4);
Level2.push_back(&Waction); Level2.push_back(&Waction);
TheAction.push_back(Level1); TheHMC.TheAction.push_back(Level1);
TheAction.push_back(Level2); TheHMC.TheAction.push_back(Level2);
Run(argc, argv); // HMC parameters are serialisable
}; TheHMC.Parameters.MD.MDsteps = 20;
}; TheHMC.Parameters.MD.trajL = 1.0;
}
}
int main(int argc, char **argv) { TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
Grid_init(&argc, &argv); TheHMC.Run(); // no smearing
// TheHMC.Run(SmearingPolicy); // for smearing
int threads = GridThread::GetThreads(); Grid_finalize();
std::cout << GridLogMessage << "Grid is setup to use " << threads
<< " threads" << std::endl;
HmcRunner TheHMC; } // main
TheHMC.BuildTheAction(argc, argv);
}

View File

@ -31,21 +31,24 @@ directory
/* END LEGAL */ /* END LEGAL */
#include "Grid/Grid.h" #include "Grid/Grid.h"
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid {
namespace QCD {
// Here change the allowed (higher) representations
typedef Representations< FundamentalRepresentation, AdjointRepresentation , TwoIndexSymmetricRepresentation> TheRepresentations;
class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > { int main(int argc, char **argv) {
public: using namespace Grid;
void BuildTheAction(int argc, char **argv) using namespace Grid::QCD;
// Here change the allowed (higher) representations
typedef Representations< FundamentalRepresentation, AdjointRepresentation , TwoIndexSymmetricRepresentation> TheRepresentations;
Grid_init(&argc, &argv);
int threads = GridThread::GetThreads();
// 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 GenericHMCRunnerHirep<TheRepresentations, MinimumNorm2> HMCWrapper;
{
typedef WilsonAdjImplR AdjImplPolicy; // gauge field implemetation for the pseudofermions typedef WilsonAdjImplR AdjImplPolicy; // gauge field implemetation for the pseudofermions
typedef WilsonAdjFermionR AdjFermionAction; // type of lattice fermions (Wilson, DW, ...) typedef WilsonAdjFermionR AdjFermionAction; // type of lattice fermions (Wilson, DW, ...)
typedef WilsonTwoIndexSymmetricImplR SymmImplPolicy; typedef WilsonTwoIndexSymmetricImplR SymmImplPolicy;
@ -55,26 +58,56 @@ class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > {
typedef typename AdjFermionAction::FermionField AdjFermionField; typedef typename AdjFermionAction::FermionField AdjFermionField;
typedef typename SymmFermionAction::FermionField SymmFermionField; typedef typename SymmFermionAction::FermionField SymmFermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GridDefaultLatt(), GridDefaultSimd(Nd, vComplex::Nsimd()), HMCWrapper TheHMC;
GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid; // Grid from the command line
FrbGrid = UrbGrid; TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 2.25 ;
WilsonGaugeActionR Waction(beta);
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
// temporarily need a gauge field // temporarily need a gauge field
//LatticeGaugeField U(UGrid); AdjointRepresentation::LatticeField UA(GridPtr);
AdjointRepresentation::LatticeField UA(UGrid); TwoIndexSymmetricRepresentation::LatticeField US(GridPtr);
TwoIndexSymmetricRepresentation::LatticeField US(UGrid);
// Gauge action
WilsonGaugeActionR Waction(5.6);
Real adjoint_mass = -0.1; Real adjoint_mass = -0.1;
Real symm_mass = -0.5; Real symm_mass = -0.5;
AdjFermionAction AdjFermOp(UA, *FGrid, *FrbGrid, adjoint_mass); AdjFermionAction AdjFermOp(UA, *GridPtr, *GridRBPtr, adjoint_mass);
SymmFermionAction SymmFermOp(US, *FGrid, *FrbGrid, symm_mass); SymmFermionAction SymmFermOp(US, *GridPtr, *GridRBPtr, symm_mass);
ConjugateGradient<AdjFermionField> CG_adj(1.0e-8, 10000, false); ConjugateGradient<AdjFermionField> CG_adj(1.0e-8, 10000, false);
ConjugateGradient<SymmFermionField> CG_symm(1.0e-8, 10000, false); ConjugateGradient<SymmFermionField> CG_symm(1.0e-8, 10000, false);
@ -88,26 +121,22 @@ class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > {
Level1.push_back(&Nf2_Adj); Level1.push_back(&Nf2_Adj);
Level1.push_back(&Nf2_Symm); Level1.push_back(&Nf2_Symm);
ActionLevel<LatticeGaugeField, TheRepresentations > Level2(4); ActionLevel<LatticeGaugeField, TheRepresentations > Level2(4);
Level2.push_back(&Waction); Level2.push_back(&Waction);
TheAction.push_back(Level1); TheHMC.TheAction.push_back(Level1);
TheAction.push_back(Level2); TheHMC.TheAction.push_back(Level2);
Run(argc, argv); // HMC parameters are serialisable
}; TheHMC.Parameters.MD.MDsteps = 20;
}; TheHMC.Parameters.MD.trajL = 1.0;
}
}
int main(int argc, char **argv) { TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
Grid_init(&argc, &argv); TheHMC.Run(); // no smearing
int threads = GridThread::GetThreads(); Grid_finalize();
std::cout << GridLogMessage << "Grid is setup to use " << threads
<< " threads" << std::endl; } // main
HmcRunner TheHMC;
TheHMC.BuildTheAction(argc, argv);
}

View File

@ -28,71 +28,109 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid { int main(int argc, char **argv) {
namespace QCD { using namespace Grid;
using namespace Grid::QCD;
Grid_init(&argc, &argv);
int threads = GridThread::GetThreads();
// 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;
class HmcRunner : public NerscHmcRunner { // Typedefs to simplify notation
public: typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
typedef WilsonImplR FermionImplPolicy;
void BuildTheAction (int argc, char **argv)
{
typedef WilsonImplR ImplPolicy;
typedef WilsonFermionR FermionAction; typedef WilsonFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid; //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
FrbGrid = UrbGrid; HMCWrapper TheHMC;
// Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 5.6 ;
WilsonGaugeActionR Waction(beta);
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(UGrid); LatticeGaugeField U(GridPtr);
// Gauge action RealD mass = -0.77;
WilsonGaugeActionR Waction(5.6); RealD pv = 0.0;
RealD mass=-0.77; FermionAction DenOp(U, *GridPtr, *GridRBPtr, mass);
RealD pv =0.0; FermionAction NumOp(U, *GridPtr, *GridRBPtr, pv);
FermionAction DenOp(U,*FGrid,*FrbGrid,mass);
FermionAction NumOp(U,*FGrid,*FrbGrid,pv);
ConjugateGradient<FermionField> CG(1.0e-8,10000); ConjugateGradient<FermionField> CG(1.0e-8, 2000);
TwoFlavourRatioPseudoFermionAction<ImplPolicy> Nf2(NumOp, DenOp,CG,CG);
//Set smearing (true/false), default: false TwoFlavourRatioPseudoFermionAction<FermionImplPolicy> Nf2(NumOp, DenOp,CG,CG);
Nf2.is_smeared=true;
//Collect actions // Set smearing (true/false), default: false
ActionLevel<LatticeGaugeField> Level1; Nf2.is_smeared = false;
// Collect actions
ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&Nf2); Level1.push_back(&Nf2);
Level1.push_back(&Waction);
TheAction.push_back(Level1);
Run(argc,argv); ActionLevel<HMCWrapper::Field> Level2(4);
}; Level2.push_back(&Waction);
}; TheHMC.TheAction.push_back(Level1);
TheHMC.TheAction.push_back(Level2);
/////////////////////////////////////////////////////////////
}} /*
double rho = 0.1; // smearing parameter
int Nsmear = 2; // number of smearing levels
Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
SmearedConfiguration<HMCWrapper::ImplPolicy> SmearingPolicy(
UGrid, Nsmear, Stout);
*/
int main (int argc, char ** argv) // HMC parameters are serialisable
{ TheHMC.Parameters.MD.MDsteps = 20;
Grid_init(&argc,&argv); TheHMC.Parameters.MD.trajL = 1.0;
int threads = GridThread::GetThreads(); TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; TheHMC.Run(); // no smearing
// TheHMC.Run(SmearingPolicy); // for smearing
HmcRunner TheHMC;
TheHMC.BuildTheAction(argc,argv);
}
Grid_finalize();
} // main

View File

@ -29,51 +29,84 @@ directory
/* END LEGAL */ /* END LEGAL */
#include "Grid/Grid.h" #include "Grid/Grid.h"
using namespace std; int main(int argc, char **argv) {
using namespace Grid; using namespace Grid;
using namespace Grid::QCD; using namespace Grid::QCD;
namespace Grid { // Here change the allowed (higher) representations
namespace QCD { typedef Representations< FundamentalRepresentation, TwoIndexSymmetricRepresentation > TheRepresentations;
// Here change the allowed (higher) representations Grid_init(&argc, &argv);
typedef Representations< FundamentalRepresentation, TwoIndexSymmetricRepresentation > TheRepresentations; int threads = GridThread::GetThreads();
// 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 GenericHMCRunnerHirep<TheRepresentations, MinimumNorm2> HMCWrapper;
class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > { typedef WilsonTwoIndexSymmetricImplR FermionImplPolicy; // gauge field implemetation for the pseudofermions
public:
void BuildTheAction(int argc, char **argv)
{
typedef WilsonTwoIndexSymmetricImplR ImplPolicy; // gauge field implemetation for the pseudofermions
typedef WilsonTwoIndexSymmetricFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...) typedef WilsonTwoIndexSymmetricFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...)
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GridDefaultLatt(), GridDefaultSimd(Nd, vComplex::Nsimd()), HMCWrapper TheHMC;
GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid; // Grid from the command line
FrbGrid = UrbGrid; TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 2.25 ;
WilsonGaugeActionR Waction(beta);
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
// temporarily need a gauge field // temporarily need a gauge field
TwoIndexSymmetricRepresentation::LatticeField U(UGrid); TwoIndexSymmetricRepresentation::LatticeField U(GridPtr);
// Gauge action Real mass = -0.95;
WilsonGaugeActionR Waction(2.0);
Real mass = -0.0; // Can we define an overloaded operator that does not need U and initialises
FermionAction FermOp(U, *FGrid, *FrbGrid, mass); // it with zeroes?
FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass);
ConjugateGradient<FermionField> CG(1.0e-8, 10000, false); ConjugateGradient<FermionField> CG(1.0e-8, 2000, false);
// Pass two solvers: one for the force computation and one for the action TwoFlavourPseudoFermionAction<FermionImplPolicy> Nf2(FermOp, CG, CG);
TwoFlavourPseudoFermionAction<ImplPolicy> Nf2(FermOp, CG, CG);
// Set smearing (true/false), default: false // Set smearing (true/false), default: false
Nf2.is_smeared = false; Nf2.is_smeared = false;
// Collect actions // Collect actions
ActionLevel<LatticeGaugeField, TheRepresentations > Level1(1); ActionLevel<LatticeGaugeField, TheRepresentations > Level1(1);
Level1.push_back(&Nf2); Level1.push_back(&Nf2);
@ -81,23 +114,19 @@ class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > {
ActionLevel<LatticeGaugeField, TheRepresentations > Level2(4); ActionLevel<LatticeGaugeField, TheRepresentations > Level2(4);
Level2.push_back(&Waction); Level2.push_back(&Waction);
TheAction.push_back(Level1); TheHMC.TheAction.push_back(Level1);
TheAction.push_back(Level2); TheHMC.TheAction.push_back(Level2);
Run(argc, argv); // HMC parameters are serialisable
}; TheHMC.Parameters.MD.MDsteps = 20;
}; TheHMC.Parameters.MD.trajL = 1.0;
}
}
int main(int argc, char **argv) { TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
Grid_init(&argc, &argv); TheHMC.Run(); // no smearing
// TheHMC.Run(SmearingPolicy); // for smearing
int threads = GridThread::GetThreads(); Grid_finalize();
std::cout << GridLogMessage << "Grid is setup to use " << threads
<< " threads" << std::endl; } // main
HmcRunner TheHMC;
TheHMC.BuildTheAction(argc, argv);
}

View File

@ -28,72 +28,112 @@ See the full license in the file "LICENSE" in the top level distribution directo
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid { int main(int argc, char **argv) {
namespace QCD { using namespace Grid;
using namespace Grid::QCD;
class HmcRunner : public NerscHmcRunner { Grid_init(&argc, &argv);
public: int threads = GridThread::GetThreads();
void BuildTheAction(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 WilsonImplR ImplPolicy; typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
typedef WilsonImplR FermionImplPolicy;
typedef WilsonFermionR FermionAction; typedef WilsonFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid(
GridDefaultLatt(), GridDefaultSimd(Nd, vComplex::Nsimd()),
GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid; //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
FrbGrid = UrbGrid; HMCWrapper TheHMC;
// Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 5.6 ;
WilsonGaugeActionR Waction(beta);
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(UGrid); LatticeGaugeField U(GridPtr);
// Gauge action
WilsonGaugeActionR Waction(5.6);
Real mass = -0.77; Real mass = -0.77;
FermionAction FermOp(U, *FGrid, *FrbGrid, mass);
// Can we define an overloaded operator that does not need U and initialises
// it with zeroes?
FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass);
// 1+1 flavour // 1+1 flavour
OneFlavourRationalParams Params(1.0e-4, 64.0, 2000, 1.0e-6); OneFlavourRationalParams Params(1.0e-4, 64.0, 2000, 1.0e-6);
OneFlavourEvenOddRationalPseudoFermionAction<WilsonImplR> WilsonNf1a( OneFlavourEvenOddRationalPseudoFermionAction<FermionImplPolicy> WilsonNf1a(FermOp, Params);
FermOp, Params); OneFlavourEvenOddRationalPseudoFermionAction<FermionImplPolicy> WilsonNf1b(FermOp, Params);
OneFlavourEvenOddRationalPseudoFermionAction<WilsonImplR> WilsonNf1b(
FermOp, Params);
//Smearing on/off //Smearing on/off
WilsonNf1a.is_smeared = true; WilsonNf1a.is_smeared = false;
WilsonNf1b.is_smeared = true; WilsonNf1b.is_smeared = false;
// Collect actions // Collect actions
ActionLevel<LatticeGaugeField> Level1; ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&WilsonNf1a); Level1.push_back(&WilsonNf1a);
Level1.push_back(&WilsonNf1b); Level1.push_back(&WilsonNf1b);
Level1.push_back(&Waction);
TheAction.push_back(Level1); ActionLevel<HMCWrapper::Field> Level2(4);
Level2.push_back(&Waction);
Run(argc, argv); TheHMC.TheAction.push_back(Level1);
}; TheHMC.TheAction.push_back(Level2);
}; /////////////////////////////////////////////////////////////
}
}
int main(int argc, char **argv) { /*
Grid_init(&argc, &argv); double rho = 0.1; // smearing parameter
int Nsmear = 2; // number of smearing levels
Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
SmearedConfiguration<HMCWrapper::ImplPolicy> SmearingPolicy(
UGrid, Nsmear, Stout);
*/
int threads = GridThread::GetThreads(); // HMC parameters are serialisable
std::cout << GridLogMessage << "Grid is setup to use " << threads TheHMC.Parameters.MD.MDsteps = 20;
<< " threads" << std::endl; TheHMC.Parameters.MD.trajL = 1.0;
HmcRunner TheHMC; TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
TheHMC.Run(); // no smearing
// TheHMC.Run(SmearingPolicy); // for smearing
Grid_finalize();
} // main
TheHMC.BuildTheAction(argc, argv);
}

View File

@ -28,73 +28,122 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid {
namespace QCD {
class HmcRunner : public NerscHmcRunner { int main(int argc, char **argv) {
public: using namespace Grid;
using namespace Grid::QCD;
void BuildTheAction (int argc, char **argv) Grid_init(&argc, &argv);
int threads = GridThread::GetThreads();
// 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 WilsonImplR ImplPolicy; typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
typedef WilsonImplR FermionImplPolicy;
typedef WilsonFermionR FermionAction; typedef WilsonFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid; //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
FrbGrid = UrbGrid; HMCWrapper TheHMC;
// Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 5.6 ;
WilsonGaugeActionR Waction(beta);
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(UGrid); LatticeGaugeField U(GridPtr);
// Gauge action Real mass = -0.77;
WilsonGaugeActionR Waction(5.6); Real pv = 0.0;
RealD mass=-0.77; // Can we define an overloaded operator that does not need U and initialises
RealD pv =0.0; // it with zeroes?
FermionAction DenOp(U,*FGrid,*FrbGrid,mass); FermionAction DenOp(U, *GridPtr, *GridRBPtr, mass);
FermionAction NumOp(U,*FGrid,*FrbGrid,pv); FermionAction NumOp(U, *GridPtr, *GridRBPtr, pv);
// 1+1 flavour
// erange,maxiter,resid,npoly // erange,maxiter,resid,npoly
OneFlavourRationalParams Params(1.0e-2,64.0,1000,1.0e-6,6); OneFlavourRationalParams Params(1.0e-2,64.0,1000,1.0e-6,6);
OneFlavourEvenOddRatioRationalPseudoFermionAction<WilsonImplR> WilsonNf1a(NumOp,DenOp,Params);
OneFlavourEvenOddRatioRationalPseudoFermionAction<WilsonImplR> WilsonNf1b(NumOp,DenOp,Params);
//Collect actions OneFlavourEvenOddRatioRationalPseudoFermionAction<FermionImplPolicy> WilsonNf1a(NumOp,DenOp,Params);
ActionLevel<LatticeGaugeField> Level1; OneFlavourEvenOddRatioRationalPseudoFermionAction<FermionImplPolicy> WilsonNf1b(NumOp,DenOp,Params);
//Smearing on/off
WilsonNf1a.is_smeared = false;
WilsonNf1b.is_smeared = false;
// Collect actions
ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&WilsonNf1a); Level1.push_back(&WilsonNf1a);
Level1.push_back(&WilsonNf1b); Level1.push_back(&WilsonNf1b);
Level1.push_back(&Waction);
TheAction.push_back(Level1); ActionLevel<HMCWrapper::Field> Level2(4);
Level2.push_back(&Waction);
Run(argc,argv); TheHMC.TheAction.push_back(Level1);
}; TheHMC.TheAction.push_back(Level2);
/////////////////////////////////////////////////////////////
}; /*
double rho = 0.1; // smearing parameter
int Nsmear = 2; // number of smearing levels
Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
SmearedConfiguration<HMCWrapper::ImplPolicy> SmearingPolicy(
UGrid, Nsmear, Stout);
*/
}} // HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0;
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
TheHMC.Run(); // no smearing
// TheHMC.Run(SmearingPolicy); // for smearing
Grid_finalize();
} // main
int main (int argc, char ** argv)
{
Grid_init(&argc,&argv);
int threads = GridThread::GetThreads();
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
HmcRunner TheHMC;
TheHMC.BuildTheAction(argc,argv);
}

View File

@ -28,73 +28,115 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid {
namespace QCD {
class HmcRunner : public NerscHmcRunner { int main(int argc, char **argv) {
public: using namespace Grid;
using namespace Grid::QCD;
void BuildTheAction (int argc, char **argv) Grid_init(&argc, &argv);
int threads = GridThread::GetThreads();
// 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 WilsonImplR ImplPolicy; typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
typedef WilsonImplR FermionImplPolicy;
typedef WilsonFermionR FermionAction; typedef WilsonFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid; //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
FrbGrid = UrbGrid; HMCWrapper TheHMC;
// Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 5.6 ;
WilsonGaugeActionR Waction(beta);
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(UGrid); LatticeGaugeField U(GridPtr);
// Gauge action Real mass = -0.77;
WilsonGaugeActionR Waction(5.6);
Real mass=-0.77; // Can we define an overloaded operator that does not need U and initialises
FermionAction FermOp(U,*FGrid,*FrbGrid,mass); // it with zeroes?
FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass);
// 1+1 flavour // 1+1 flavour
OneFlavourRationalParams Params(1.0e-4,64.0,1000,1.0e-6); OneFlavourRationalParams Params(1.0e-4, 64.0, 2000, 1.0e-6);
OneFlavourRationalPseudoFermionAction<WilsonImplR> WilsonNf1a(FermOp,Params); OneFlavourRationalPseudoFermionAction<WilsonImplR> WilsonNf1a(FermOp,Params);
OneFlavourRationalPseudoFermionAction<WilsonImplR> WilsonNf1b(FermOp,Params); OneFlavourRationalPseudoFermionAction<WilsonImplR> WilsonNf1b(FermOp,Params);
//Set smearing (true/false), default: false //Smearing on/off
WilsonNf1a.is_smeared=false; WilsonNf1a.is_smeared = false;
WilsonNf1b.is_smeared=false; WilsonNf1b.is_smeared = false;
//Collect actions // Collect actions
ActionLevel<LatticeGaugeField> Level1; ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&WilsonNf1a); Level1.push_back(&WilsonNf1a);
Level1.push_back(&WilsonNf1b); Level1.push_back(&WilsonNf1b);
Level1.push_back(&Waction);
TheAction.push_back(Level1); ActionLevel<HMCWrapper::Field> Level2(4);
Level2.push_back(&Waction);
Run(argc,argv); TheHMC.TheAction.push_back(Level1);
}; TheHMC.TheAction.push_back(Level2);
/////////////////////////////////////////////////////////////
}; /*
double rho = 0.1; // smearing parameter
int Nsmear = 2; // number of smearing levels
Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
SmearedConfiguration<HMCWrapper::ImplPolicy> SmearingPolicy(
UGrid, Nsmear, Stout);
*/
}} // HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0;
int main (int argc, char ** argv) TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
{ TheHMC.Run(); // no smearing
Grid_init(&argc,&argv); // TheHMC.Run(SmearingPolicy); // for smearing
int threads = GridThread::GetThreads(); Grid_finalize();
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
HmcRunner TheHMC; } // main
TheHMC.BuildTheAction(argc,argv);
}

View File

@ -28,72 +28,119 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
using namespace std;
using namespace Grid;
using namespace Grid::QCD;
namespace Grid { int main(int argc, char **argv) {
namespace QCD { using namespace Grid;
using namespace Grid::QCD;
Grid_init(&argc, &argv);
int threads = GridThread::GetThreads();
// 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;
class HmcRunner : public NerscHmcRunner { // Typedefs to simplify notation
public: typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
typedef WilsonImplR FermionImplPolicy;
void BuildTheAction (int argc, char **argv)
{
typedef WilsonImplR ImplPolicy;
typedef WilsonFermionR FermionAction; typedef WilsonFermionR FermionAction;
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
FGrid = UGrid; //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
FrbGrid = UrbGrid; HMCWrapper TheHMC;
// Grid from the command line
TheHMC.Resources.AddFourDimGrid("gauge");
// Possibile to create the module by hand
// hardcoding parameters or using a Reader
// Checkpointer definition
CheckpointerParameters CPparams;
CPparams.config_prefix = "ckpoint_lat";
CPparams.rng_prefix = "ckpoint_rng";
CPparams.saveInterval = 5;
CPparams.format = "IEEE64BIG";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar;
RNGpar.SerialSeed = {1,2,3,4,5};
RNGpar.ParallelSeed = {6,7,8,9,10};
TheHMC.Resources.SetRNGSeeds(RNGpar);
// Construct observables
// here there is too much indirection
PlaquetteObsParameters PlPar;
PlPar.output_prefix = "Plaquette";
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
TheHMC.Resources.AddObservable(&PlaqModule);
//////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Collect actions, here use more encapsulation
// need wrappers of the fermionic classes
// that have a complex construction
// standard
RealD beta = 5.6 ;
WilsonGaugeActionR Waction(beta);
auto GridPtr = TheHMC.Resources.GetCartesian();
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(UGrid); LatticeGaugeField U(GridPtr);
// Gauge action Real mass = -0.77;
WilsonGaugeActionR Waction(5.6); Real pv = 0.0;
RealD mass=-0.77; // Can we define an overloaded operator that does not need U and initialises
RealD pv =0.0; // it with zeroes?
FermionAction DenOp(U,*FGrid,*FrbGrid,mass); FermionAction DenOp(U, *GridPtr, *GridRBPtr, mass);
FermionAction NumOp(U,*FGrid,*FrbGrid,pv); FermionAction NumOp(U, *GridPtr, *GridRBPtr, pv);
// erange,maxiter,resid,npoly // 1+1 flavour
OneFlavourRationalParams Params(1.0e-2,64.0,1000,1.0e-6,6); OneFlavourRationalParams Params(1.0e-4, 64.0, 2000, 1.0e-6);
OneFlavourRatioRationalPseudoFermionAction<WilsonImplR> WilsonNf1a(NumOp,DenOp,Params); OneFlavourRatioRationalPseudoFermionAction<FermionImplPolicy> WilsonNf1a(NumOp,DenOp,Params);
OneFlavourRatioRationalPseudoFermionAction<WilsonImplR> WilsonNf1b(NumOp,DenOp,Params); OneFlavourRatioRationalPseudoFermionAction<FermionImplPolicy> WilsonNf1b(NumOp,DenOp,Params);
//Collect actions
ActionLevel<LatticeGaugeField> Level1; //Smearing on/off
WilsonNf1a.is_smeared = false;
WilsonNf1b.is_smeared = false;
// Collect actions
ActionLevel<HMCWrapper::Field> Level1(1);
Level1.push_back(&WilsonNf1a); Level1.push_back(&WilsonNf1a);
Level1.push_back(&WilsonNf1b); Level1.push_back(&WilsonNf1b);
Level1.push_back(&Waction);
TheAction.push_back(Level1); ActionLevel<HMCWrapper::Field> Level2(4);
Level2.push_back(&Waction);
Run(argc,argv); TheHMC.TheAction.push_back(Level1);
}; TheHMC.TheAction.push_back(Level2);
/////////////////////////////////////////////////////////////
}; /*
double rho = 0.1; // smearing parameter
int Nsmear = 2; // number of smearing levels
Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
SmearedConfiguration<HMCWrapper::ImplPolicy> SmearingPolicy(
UGrid, Nsmear, Stout);
*/
}} // HMC parameters are serialisable
TheHMC.Parameters.MD.MDsteps = 20;
TheHMC.Parameters.MD.trajL = 1.0;
int main (int argc, char ** argv) TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
{ TheHMC.Run(); // no smearing
Grid_init(&argc,&argv); // TheHMC.Run(SmearingPolicy); // for smearing
int threads = GridThread::GetThreads(); Grid_finalize();
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
} // main
HmcRunner TheHMC;
TheHMC.BuildTheAction(argc,argv);
}

View File

@ -37,9 +37,6 @@ struct scal {
d internal; d internal;
}; };
Gamma::GammaMatrix Gmu[] = {Gamma::GammaX, Gamma::GammaY, Gamma::GammaZ,
Gamma::GammaT};
int main(int argc, char** argv) { int main(int argc, char** argv) {
Grid_init(&argc, &argv); Grid_init(&argc, &argv);