mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Code cleaning, the fermion implementation can be sepcified using the macro FIMPL
This commit is contained in:
parent
7a1a7a685e
commit
a8843c9af6
@ -110,8 +110,8 @@ public:
|
|||||||
friend std::ostream& operator<< (std::ostream& stream, Logger& log){
|
friend std::ostream& operator<< (std::ostream& stream, Logger& log){
|
||||||
|
|
||||||
if ( log.active ) {
|
if ( log.active ) {
|
||||||
stream << log.background()<< log.topName << log.background()<< " : ";
|
stream << log.background()<< std::setw(10) << std::left << log.topName << log.background()<< " : ";
|
||||||
stream << log.colour() <<std::setw(14) << std::left << log.name << log.background() << " : ";
|
stream << log.colour() << std::setw(14) << std::left << log.name << log.background() << " : ";
|
||||||
if ( log.timestamp ) {
|
if ( log.timestamp ) {
|
||||||
StopWatch.Stop();
|
StopWatch.Stop();
|
||||||
GridTime now = StopWatch.Elapsed();
|
GridTime now = StopWatch.Elapsed();
|
||||||
|
@ -171,7 +171,7 @@ void Application::schedule(void)
|
|||||||
for (unsigned int j = 0; j < t.size(); ++j)
|
for (unsigned int j = 0; j < t.size(); ++j)
|
||||||
{
|
{
|
||||||
program_.push_back(t[j]);
|
program_.push_back(t[j]);
|
||||||
LOG(Message) << std::setw(4) << std::right << k + 1 << ": "
|
LOG(Message) << std::setw(4) << k + 1 << ": "
|
||||||
<< env_.getModuleName(program_[k]) << std::endl;
|
<< env_.getModuleName(program_[k]) << std::endl;
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
@ -671,14 +671,14 @@ void Environment::printContent(void)
|
|||||||
LOG(Message) << "Modules: " << std::endl;
|
LOG(Message) << "Modules: " << std::endl;
|
||||||
for (unsigned int i = 0; i < module_.size(); ++i)
|
for (unsigned int i = 0; i < module_.size(); ++i)
|
||||||
{
|
{
|
||||||
LOG(Message) << std::setw(4) << std::right << i << ": "
|
LOG(Message) << std::setw(4) << i << ": "
|
||||||
<< getModuleName(i) << " ("
|
<< getModuleName(i) << " ("
|
||||||
<< getModuleType(i) << ")" << std::endl;
|
<< getModuleType(i) << ")" << std::endl;
|
||||||
}
|
}
|
||||||
LOG(Message) << "Objects: " << std::endl;
|
LOG(Message) << "Objects: " << std::endl;
|
||||||
for (unsigned int i = 0; i < object_.size(); ++i)
|
for (unsigned int i = 0; i < object_.size(); ++i)
|
||||||
{
|
{
|
||||||
LOG(Message) << std::setw(4) << std::right << i << ": "
|
LOG(Message) << std::setw(4) << i << ": "
|
||||||
<< getObjectName(i) << std::endl;
|
<< getObjectName(i) << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,10 +67,6 @@ public:
|
|||||||
typedef std::unique_ptr<ModuleBase> ModPt;
|
typedef std::unique_ptr<ModuleBase> ModPt;
|
||||||
typedef std::unique_ptr<GridCartesian> GridPt;
|
typedef std::unique_ptr<GridCartesian> GridPt;
|
||||||
typedef std::unique_ptr<GridRedBlackCartesian> GridRbPt;
|
typedef std::unique_ptr<GridRedBlackCartesian> GridRbPt;
|
||||||
typedef FermionOperator<WilsonImplR> FMat;
|
|
||||||
typedef std::unique_ptr<FMat> FMatPt;
|
|
||||||
typedef std::function<void(LatticeFermion &,
|
|
||||||
const LatticeFermion &)> Solver;
|
|
||||||
typedef std::unique_ptr<GridParallelRNG> RngPt;
|
typedef std::unique_ptr<GridParallelRNG> RngPt;
|
||||||
typedef std::unique_ptr<LatticeBase> LatticePt;
|
typedef std::unique_ptr<LatticeBase> LatticePt;
|
||||||
private:
|
private:
|
||||||
@ -194,24 +190,21 @@ private:
|
|||||||
std::map<std::string, unsigned int> moduleAddress_;
|
std::map<std::string, unsigned int> moduleAddress_;
|
||||||
// lattice store
|
// lattice store
|
||||||
std::map<unsigned int, LatticePt> lattice_;
|
std::map<unsigned int, LatticePt> lattice_;
|
||||||
// fermion matrix store
|
|
||||||
std::map<unsigned int, FMatPt> fMat_;
|
|
||||||
// solver store & solver/action map
|
|
||||||
std::map<unsigned int, Solver> solver_;
|
|
||||||
std::map<std::string, std::string> solverAction_;
|
|
||||||
// object store
|
// object store
|
||||||
std::vector<ObjInfo> object_;
|
std::vector<ObjInfo> object_;
|
||||||
std::map<std::string, unsigned int> objectAddress_;
|
std::map<std::string, unsigned int> objectAddress_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* template implementation *
|
* Holder template implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
// constructor /////////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Holder<T>::Holder(T *pt)
|
Holder<T>::Holder(T *pt)
|
||||||
: objPt_(pt)
|
: objPt_(pt)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
// access //////////////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T & Holder<T>::get(void) const
|
T & Holder<T>::get(void) const
|
||||||
{
|
{
|
||||||
@ -230,6 +223,10 @@ void Holder<T>::reset(T *pt)
|
|||||||
objPt_.reset(pt);
|
objPt_.reset(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Environment template implementation *
|
||||||
|
******************************************************************************/
|
||||||
|
// module management ///////////////////////////////////////////////////////////
|
||||||
template <typename M>
|
template <typename M>
|
||||||
M * Environment::getModule(const unsigned int address) const
|
M * Environment::getModule(const unsigned int address) const
|
||||||
{
|
{
|
||||||
|
@ -43,6 +43,11 @@ using Grid::operator<<;
|
|||||||
* error with GCC (clang compiles fine without it).
|
* error with GCC (clang compiles fine without it).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// FIXME: find a way to do that in a more general fashion
|
||||||
|
#ifndef FIMPL
|
||||||
|
#define FIMPL WilsonImplR
|
||||||
|
#endif
|
||||||
|
|
||||||
BEGIN_HADRONS_NAMESPACE
|
BEGIN_HADRONS_NAMESPACE
|
||||||
|
|
||||||
class HadronsLogger: public Logger
|
class HadronsLogger: public Logger
|
||||||
|
@ -55,10 +55,6 @@ static mod##ModuleRegistrar mod##ModuleRegistrarInstance;
|
|||||||
// base class
|
// base class
|
||||||
class ModuleBase
|
class ModuleBase
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
// convenient type shortcuts
|
|
||||||
typedef Environment::FMat FMat;
|
|
||||||
typedef Environment::Solver Solver;
|
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
ModuleBase(const std::string name);
|
ModuleBase(const std::string name);
|
||||||
|
@ -49,6 +49,8 @@ public:
|
|||||||
|
|
||||||
class ADWF: public Module<ADWFPar>
|
class ADWF: public Module<ADWFPar>
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
typedef FermionOperator<FIMPL> FMat;
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
ADWF(const std::string name);
|
ADWF(const std::string name);
|
||||||
|
@ -47,6 +47,8 @@ public:
|
|||||||
|
|
||||||
class AWilson: public Module<AWilsonPar>
|
class AWilson: public Module<AWilsonPar>
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
typedef FermionOperator<FIMPL> FMat;
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
AWilson(const std::string name);
|
AWilson(const std::string name);
|
||||||
|
@ -76,7 +76,7 @@ void MQuark::execute(void)
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
LatticePropagator &prop = *env().createLattice<LatticePropagator>(propName);
|
LatticePropagator &prop = *env().createLattice<LatticePropagator>(propName);
|
||||||
LatticePropagator &fullSrc = *env().getObject<LatticePropagator>(par().source);
|
LatticePropagator &fullSrc = *env().getObject<LatticePropagator>(par().source);
|
||||||
Environment::Solver &solver = *env().getObject<Environment::Solver>(par().solver);
|
Solver &solver = *env().getObject<Solver>(par().solver);
|
||||||
if (Ls_ > 1)
|
if (Ls_ > 1)
|
||||||
{
|
{
|
||||||
env().createLattice<LatticePropagator>(getName());
|
env().createLattice<LatticePropagator>(getName());
|
||||||
|
@ -47,6 +47,9 @@ public:
|
|||||||
|
|
||||||
class MQuark: public Module<MQuarkPar>
|
class MQuark: public Module<MQuarkPar>
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
typedef FIMPL::FermionField FermionField;
|
||||||
|
typedef std::function<void(FermionField &, const FermionField &)> Solver;
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
MQuark(const std::string name);
|
MQuark(const std::string name);
|
||||||
@ -60,8 +63,8 @@ public:
|
|||||||
// execution
|
// execution
|
||||||
virtual void execute(void);
|
virtual void execute(void);
|
||||||
private:
|
private:
|
||||||
unsigned int Ls_;
|
unsigned int Ls_;
|
||||||
Environment::Solver *solver_{nullptr};
|
Solver *solver_{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
MODULE_REGISTER(MQuark);
|
MODULE_REGISTER(MQuark);
|
||||||
|
@ -66,7 +66,7 @@ void SolRBPrecCG::setup(void)
|
|||||||
// execution ///////////////////////////////////////////////////////////////////
|
// execution ///////////////////////////////////////////////////////////////////
|
||||||
void SolRBPrecCG::execute(void)
|
void SolRBPrecCG::execute(void)
|
||||||
{
|
{
|
||||||
auto &mat = *(env().getObject<Environment::FMat>(par().action));
|
auto &mat = *(env().getObject<FMat>(par().action));
|
||||||
auto solver = [&mat, this](LatticeFermion &sol,
|
auto solver = [&mat, this](LatticeFermion &sol,
|
||||||
const LatticeFermion &source)
|
const LatticeFermion &source)
|
||||||
{
|
{
|
||||||
@ -79,5 +79,5 @@ void SolRBPrecCG::execute(void)
|
|||||||
LOG(Message) << "setting up Schur red-black preconditioned CG for"
|
LOG(Message) << "setting up Schur red-black preconditioned CG for"
|
||||||
<< " action '" << par().action << "' with residual "
|
<< " action '" << par().action << "' with residual "
|
||||||
<< par().residual << std::endl;
|
<< par().residual << std::endl;
|
||||||
env().setObject(getName(), new Environment::Solver(solver));
|
env().setObject(getName(), new Solver(solver));
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,10 @@ public:
|
|||||||
|
|
||||||
class SolRBPrecCG: public Module<SolRBPrecCGPar>
|
class SolRBPrecCG: public Module<SolRBPrecCGPar>
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
typedef FermionOperator<FIMPL> FMat;
|
||||||
|
typedef FIMPL::FermionField FermionField;
|
||||||
|
typedef std::function<void(FermionField &, const FermionField &)> Solver;
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
SolRBPrecCG(const std::string name);
|
SolRBPrecCG(const std::string name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user