mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00: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){
|
||||
|
||||
if ( log.active ) {
|
||||
stream << log.background()<< log.topName << log.background()<< " : ";
|
||||
stream << log.colour() <<std::setw(14) << std::left << log.name << 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() << " : ";
|
||||
if ( log.timestamp ) {
|
||||
StopWatch.Stop();
|
||||
GridTime now = StopWatch.Elapsed();
|
||||
|
@ -171,7 +171,7 @@ void Application::schedule(void)
|
||||
for (unsigned int j = 0; j < t.size(); ++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;
|
||||
k++;
|
||||
}
|
||||
|
@ -671,14 +671,14 @@ void Environment::printContent(void)
|
||||
LOG(Message) << "Modules: " << std::endl;
|
||||
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) << " ("
|
||||
<< getModuleType(i) << ")" << std::endl;
|
||||
}
|
||||
LOG(Message) << "Objects: " << std::endl;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -67,10 +67,6 @@ public:
|
||||
typedef std::unique_ptr<ModuleBase> ModPt;
|
||||
typedef std::unique_ptr<GridCartesian> GridPt;
|
||||
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<LatticeBase> LatticePt;
|
||||
private:
|
||||
@ -194,24 +190,21 @@ private:
|
||||
std::map<std::string, unsigned int> moduleAddress_;
|
||||
// lattice store
|
||||
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
|
||||
std::vector<ObjInfo> object_;
|
||||
std::map<std::string, unsigned int> objectAddress_;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* template implementation *
|
||||
* Holder template implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
Holder<T>::Holder(T *pt)
|
||||
: objPt_(pt)
|
||||
{}
|
||||
|
||||
// access //////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
T & Holder<T>::get(void) const
|
||||
{
|
||||
@ -230,6 +223,10 @@ void Holder<T>::reset(T *pt)
|
||||
objPt_.reset(pt);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Environment template implementation *
|
||||
******************************************************************************/
|
||||
// module management ///////////////////////////////////////////////////////////
|
||||
template <typename M>
|
||||
M * Environment::getModule(const unsigned int address) const
|
||||
{
|
||||
|
@ -43,6 +43,11 @@ using Grid::operator<<;
|
||||
* 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
|
||||
|
||||
class HadronsLogger: public Logger
|
||||
|
@ -55,10 +55,6 @@ static mod##ModuleRegistrar mod##ModuleRegistrarInstance;
|
||||
// base class
|
||||
class ModuleBase
|
||||
{
|
||||
public:
|
||||
// convenient type shortcuts
|
||||
typedef Environment::FMat FMat;
|
||||
typedef Environment::Solver Solver;
|
||||
public:
|
||||
// constructor
|
||||
ModuleBase(const std::string name);
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
|
||||
class ADWF: public Module<ADWFPar>
|
||||
{
|
||||
public:
|
||||
typedef FermionOperator<FIMPL> FMat;
|
||||
public:
|
||||
// constructor
|
||||
ADWF(const std::string name);
|
||||
|
@ -47,6 +47,8 @@ public:
|
||||
|
||||
class AWilson: public Module<AWilsonPar>
|
||||
{
|
||||
public:
|
||||
typedef FermionOperator<FIMPL> FMat;
|
||||
public:
|
||||
// constructor
|
||||
AWilson(const std::string name);
|
||||
|
@ -76,7 +76,7 @@ void MQuark::execute(void)
|
||||
<< std::endl;
|
||||
LatticePropagator &prop = *env().createLattice<LatticePropagator>(propName);
|
||||
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)
|
||||
{
|
||||
env().createLattice<LatticePropagator>(getName());
|
||||
|
@ -47,6 +47,9 @@ public:
|
||||
|
||||
class MQuark: public Module<MQuarkPar>
|
||||
{
|
||||
public:
|
||||
typedef FIMPL::FermionField FermionField;
|
||||
typedef std::function<void(FermionField &, const FermionField &)> Solver;
|
||||
public:
|
||||
// constructor
|
||||
MQuark(const std::string name);
|
||||
@ -60,8 +63,8 @@ public:
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
private:
|
||||
unsigned int Ls_;
|
||||
Environment::Solver *solver_{nullptr};
|
||||
unsigned int Ls_;
|
||||
Solver *solver_{nullptr};
|
||||
};
|
||||
|
||||
MODULE_REGISTER(MQuark);
|
||||
|
@ -66,7 +66,7 @@ void SolRBPrecCG::setup(void)
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
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,
|
||||
const LatticeFermion &source)
|
||||
{
|
||||
@ -79,5 +79,5 @@ void SolRBPrecCG::execute(void)
|
||||
LOG(Message) << "setting up Schur red-black preconditioned CG for"
|
||||
<< " action '" << par().action << "' with residual "
|
||||
<< 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>
|
||||
{
|
||||
public:
|
||||
typedef FermionOperator<FIMPL> FMat;
|
||||
typedef FIMPL::FermionField FermionField;
|
||||
typedef std::function<void(FermionField &, const FermionField &)> Solver;
|
||||
public:
|
||||
// constructor
|
||||
SolRBPrecCG(const std::string name);
|
||||
|
Loading…
Reference in New Issue
Block a user