mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Discovered bug root cause. setup() is called multiple times. Now ready to copy-paste the LapEvec code
This commit is contained in:
parent
2c7e6bf58b
commit
b45586e81c
@ -106,6 +106,7 @@ BEGIN_MODULE_NAMESPACE(MDistil)
|
|||||||
|
|
||||||
inline GridCartesian * MakeLowerDimGrid( GridCartesian * gridHD )
|
inline GridCartesian * MakeLowerDimGrid( GridCartesian * gridHD )
|
||||||
{
|
{
|
||||||
|
//LOG(Message) << "MakeLowerDimGrid() begin" << std::endl;
|
||||||
int nd{static_cast<int>(gridHD->_ndimension)};
|
int nd{static_cast<int>(gridHD->_ndimension)};
|
||||||
std::vector<int> latt_size = gridHD->_fdimensions;
|
std::vector<int> latt_size = gridHD->_fdimensions;
|
||||||
latt_size[nd-1] = 1;
|
latt_size[nd-1] = 1;
|
||||||
@ -115,7 +116,9 @@ inline GridCartesian * MakeLowerDimGrid( GridCartesian * gridHD )
|
|||||||
|
|
||||||
std::vector<int> mpi_layout = gridHD->_processors;
|
std::vector<int> mpi_layout = gridHD->_processors;
|
||||||
mpi_layout[nd-1] = 1;
|
mpi_layout[nd-1] = 1;
|
||||||
return new GridCartesian(latt_size,simd_layout,mpi_layout,*gridHD);
|
GridCartesian * gridLD = new GridCartesian(latt_size,simd_layout,mpi_layout,*gridHD);
|
||||||
|
//LOG(Message) << "MakeLowerDimGrid() end" << std::endl;
|
||||||
|
return gridLD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <Hadrons/Global.hpp>
|
#include <Hadrons/Global.hpp>
|
||||||
#include <Hadrons/Module.hpp>
|
#include <Hadrons/Module.hpp>
|
||||||
#include <Hadrons/ModuleFactory.hpp>
|
#include <Hadrons/ModuleFactory.hpp>
|
||||||
|
#include <Hadrons/EigenPack.hpp>
|
||||||
|
|
||||||
// These are members of Distillation
|
// These are members of Distillation
|
||||||
#include <Hadrons/Modules/MDistil/Distil.hpp>
|
#include <Hadrons/Modules/MDistil/Distil.hpp>
|
||||||
@ -105,6 +106,7 @@ class LapEvecPar: Serializable
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GRID_SERIALIZABLE_CLASS_MEMBERS(LapEvecPar,
|
GRID_SERIALIZABLE_CLASS_MEMBERS(LapEvecPar,
|
||||||
|
std::string, gauge,
|
||||||
StoutParameters, Stout,
|
StoutParameters, Stout,
|
||||||
ChebyshevParameters, Cheby,
|
ChebyshevParameters, Cheby,
|
||||||
LanczosParameters, Lanczos,
|
LanczosParameters, Lanczos,
|
||||||
@ -122,54 +124,57 @@ template <typename FImpl>
|
|||||||
class TLapEvec: public Module<LapEvecPar>
|
class TLapEvec: public Module<LapEvecPar>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// constructor
|
GAUGE_TYPE_ALIASES(FImpl,);
|
||||||
TLapEvec();
|
typedef std::vector<Grid::Hadrons::EigenPack<LatticeColourVector> > DistilEP;
|
||||||
TLapEvec(const std::string name);
|
|
||||||
// destructor
|
|
||||||
virtual ~TLapEvec(void);
|
|
||||||
// dependency relation
|
|
||||||
virtual std::vector<std::string> getInput(void);
|
|
||||||
virtual std::vector<std::string> getOutput(void);
|
|
||||||
// setup
|
|
||||||
virtual void setup(void);
|
|
||||||
// execution
|
|
||||||
virtual void execute(void);
|
|
||||||
public:
|
public:
|
||||||
GridCartesian * gridLD = nullptr;
|
// constructor
|
||||||
|
TLapEvec(const std::string name);
|
||||||
|
// destructor
|
||||||
|
virtual ~TLapEvec(void);
|
||||||
|
// dependency relation
|
||||||
|
virtual std::vector<std::string> getInput(void);
|
||||||
|
virtual std::vector<std::string> getOutput(void);
|
||||||
|
// setup
|
||||||
|
virtual void setup(void);
|
||||||
|
// execution
|
||||||
|
virtual void execute(void);
|
||||||
|
protected:
|
||||||
|
// These variables are created in setup() and freed in Cleanup()
|
||||||
|
GridCartesian * gridLD; // Owned by me, so I must delete it
|
||||||
|
GridCartesian * gridHD; // Owned by environment (so I won't delete it)
|
||||||
|
int Nx, Ny, Nz, Nt;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Cleanup(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
MODULE_REGISTER_TMP(LapEvec, TLapEvec<FIMPL>, MDistil);
|
MODULE_REGISTER_TMP(LapEvec, TLapEvec<FIMPL>, MDistil);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TLapEvec implementation *
|
TLapEvec implementation
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
// constructor /////////////////////////////////////////////////////////////////
|
// constructor /////////////////////////////////////////////////////////////////
|
||||||
template <typename FImpl>
|
template <typename FImpl>
|
||||||
TLapEvec<FImpl>::TLapEvec(const std::string name) : Module<LapEvecPar>(name)
|
TLapEvec<FImpl>::TLapEvec(const std::string name) : gridLD{nullptr}, Module<LapEvecPar>(name)
|
||||||
{
|
{
|
||||||
// NB: This constructor isn't used!!!
|
|
||||||
LOG(Message) << "TLapEvec constructor : TLapEvec<FImpl>::TLapEvec(const std::string name)" << std::endl;
|
LOG(Message) << "TLapEvec constructor : TLapEvec<FImpl>::TLapEvec(const std::string name)" << std::endl;
|
||||||
LOG(Message) << "TLapEvec constructor : Setting gridLD=nullptr" << std::endl;
|
LOG(Message) << "this=" << this << ", gridLD=" << gridLD << std::endl;
|
||||||
gridLD = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor /////////////////////////////////////////////////////////////////
|
// destructor /////////////////////////////////////////////////////////////////
|
||||||
template <typename FImpl>
|
template <typename FImpl>
|
||||||
TLapEvec<FImpl>::~TLapEvec()
|
TLapEvec<FImpl>::~TLapEvec()
|
||||||
{
|
{
|
||||||
if( gridLD != nullptr ) {
|
Cleanup();
|
||||||
LOG(Message) << "Destroying lower dimensional grid" << std::endl;
|
|
||||||
delete gridLD;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
LOG(Message) << "Lower dimensional grid was never created" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// dependencies/products ///////////////////////////////////////////////////////
|
// dependencies/products ///////////////////////////////////////////////////////
|
||||||
template <typename FImpl>
|
template <typename FImpl>
|
||||||
std::vector<std::string> TLapEvec<FImpl>::getInput(void)
|
std::vector<std::string> TLapEvec<FImpl>::getInput(void)
|
||||||
{
|
{
|
||||||
std::vector<std::string> in;
|
std::vector<std::string> in = {par().gauge};
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
@ -186,15 +191,30 @@ std::vector<std::string> TLapEvec<FImpl>::getOutput(void)
|
|||||||
template <typename FImpl>
|
template <typename FImpl>
|
||||||
void TLapEvec<FImpl>::setup(void)
|
void TLapEvec<FImpl>::setup(void)
|
||||||
{
|
{
|
||||||
LOG(Message) << "setup() : start" << std::endl;
|
Cleanup();
|
||||||
LOG(Message) << "Stout.steps=" << par().Stout.steps << ", Stout.parm=" << par().Stout.parm << std::endl;
|
Environment & e{env()};
|
||||||
if( gridLD ) {
|
gridHD = e.getGrid();
|
||||||
LOG(Message) << "Didn't expect to need to destroy gridLD here!" << std::endl;
|
gridLD = MakeLowerDimGrid( gridHD );
|
||||||
|
Nx = gridHD->_gdimensions[Xdir];
|
||||||
|
Ny = gridHD->_gdimensions[Ydir];
|
||||||
|
Nz = gridHD->_gdimensions[Zdir];
|
||||||
|
Nt = gridHD->_gdimensions[Tdir];
|
||||||
|
// Temporaries
|
||||||
|
envTmpLat(GaugeField, "Umu");
|
||||||
|
envTmpLat(GaugeField, "Umu_stout");
|
||||||
|
envTmpLat(GaugeField, "Umu_smear");
|
||||||
|
// Output objects
|
||||||
|
envCreate(DistilEP, getName(), 1, Nt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean up any temporaries created by setup (that aren't stored in the environment)
|
||||||
|
template <typename FImpl>
|
||||||
|
void TLapEvec<FImpl>::Cleanup(void)
|
||||||
|
{
|
||||||
|
if( gridLD != nullptr ) {
|
||||||
delete gridLD;
|
delete gridLD;
|
||||||
|
gridLD = nullptr;
|
||||||
}
|
}
|
||||||
LOG(Message) << "Creating lower dimensional grid" << std::endl;
|
|
||||||
gridLD = MakeLowerDimGrid( env().getGrid() );
|
|
||||||
LOG(Message) << "setup() : end" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// execution ///////////////////////////////////////////////////////////////////
|
// execution ///////////////////////////////////////////////////////////////////
|
||||||
|
@ -224,8 +224,7 @@ void free_prop(Application &application)
|
|||||||
|
|
||||||
void test_LapEvec(Application &application)
|
void test_LapEvec(Application &application)
|
||||||
{
|
{
|
||||||
const unsigned int nt = GridDefaultLatt()[Tp];
|
const char szGaugeName[] = "gauge";
|
||||||
|
|
||||||
// global parameters
|
// global parameters
|
||||||
Application::GlobalPar globalPar;
|
Application::GlobalPar globalPar;
|
||||||
globalPar.trajCounter.start = 1500;
|
globalPar.trajCounter.start = 1500;
|
||||||
@ -234,11 +233,12 @@ void test_LapEvec(Application &application)
|
|||||||
globalPar.runId = "test";
|
globalPar.runId = "test";
|
||||||
application.setPar(globalPar);
|
application.setPar(globalPar);
|
||||||
// gauge field
|
// gauge field
|
||||||
application.createModule<MGauge::Unit>("gauge");
|
application.createModule<MGauge::Unit>(szGaugeName);
|
||||||
// Now make an instance of the LapEvec object
|
// Now make an instance of the LapEvec object
|
||||||
MDistil::LapEvecPar par;
|
MDistil::LapEvecPar par;
|
||||||
par.Stout.steps = 173;
|
par.Stout.steps = 173;
|
||||||
par.Stout.parm = -9.87654321;
|
par.Stout.parm = -9.87654321;
|
||||||
|
par.gauge = szGaugeName;
|
||||||
application.createModule<MDistil::LapEvec>("LapEvec",par);
|
application.createModule<MDistil::LapEvec>("LapEvec",par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user