mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Merge branch 'feature/hadrons' into feature/qed-fvol
This commit is contained in:
commit
f3ca29af6c
@ -42,7 +42,6 @@ using namespace Hadrons;
|
||||
******************************************************************************/
|
||||
// constructors ////////////////////////////////////////////////////////////////
|
||||
Application::Application(void)
|
||||
: env_(Environment::getInstance())
|
||||
{
|
||||
LOG(Message) << "Modules available:" << std::endl;
|
||||
auto list = ModuleFactory::getInstance().getBuilderList();
|
||||
@ -74,11 +73,17 @@ Application::Application(const std::string parameterFileName)
|
||||
parameterFileName_ = parameterFileName;
|
||||
}
|
||||
|
||||
// environment shortcut ////////////////////////////////////////////////////////
|
||||
Environment & Application::env(void) const
|
||||
{
|
||||
return Environment::getInstance();
|
||||
}
|
||||
|
||||
// access //////////////////////////////////////////////////////////////////////
|
||||
void Application::setPar(const Application::GlobalPar &par)
|
||||
{
|
||||
par_ = par;
|
||||
env_.setSeed(strToVec<int>(par_.seed));
|
||||
env().setSeed(strToVec<int>(par_.seed));
|
||||
}
|
||||
|
||||
const Application::GlobalPar & Application::getPar(void)
|
||||
@ -89,7 +94,7 @@ const Application::GlobalPar & Application::getPar(void)
|
||||
// execute /////////////////////////////////////////////////////////////////////
|
||||
void Application::run(void)
|
||||
{
|
||||
if (!parameterFileName_.empty() and (env_.getNModule() == 0))
|
||||
if (!parameterFileName_.empty() and (env().getNModule() == 0))
|
||||
{
|
||||
parseParameterFile(parameterFileName_);
|
||||
}
|
||||
@ -124,7 +129,7 @@ void Application::parseParameterFile(const std::string parameterFileName)
|
||||
do
|
||||
{
|
||||
read(reader, "id", id);
|
||||
env_.createModule(id.name, id.type, reader);
|
||||
env().createModule(id.name, id.type, reader);
|
||||
} while (reader.nextElement("module"));
|
||||
pop(reader);
|
||||
pop(reader);
|
||||
@ -134,7 +139,7 @@ void Application::saveParameterFile(const std::string parameterFileName)
|
||||
{
|
||||
XmlWriter writer(parameterFileName);
|
||||
ObjectId id;
|
||||
const unsigned int nMod = env_.getNModule();
|
||||
const unsigned int nMod = env().getNModule();
|
||||
|
||||
LOG(Message) << "Saving application to '" << parameterFileName << "'..." << std::endl;
|
||||
write(writer, "parameters", getPar());
|
||||
@ -142,10 +147,10 @@ void Application::saveParameterFile(const std::string parameterFileName)
|
||||
for (unsigned int i = 0; i < nMod; ++i)
|
||||
{
|
||||
push(writer, "module");
|
||||
id.name = env_.getModuleName(i);
|
||||
id.type = env_.getModule(i)->getRegisteredName();
|
||||
id.name = env().getModuleName(i);
|
||||
id.type = env().getModule(i)->getRegisteredName();
|
||||
write(writer, "id", id);
|
||||
env_.getModule(i)->saveParameters(writer, "options");
|
||||
env().getModule(i)->saveParameters(writer, "options");
|
||||
pop(writer);
|
||||
}
|
||||
pop(writer);
|
||||
@ -164,10 +169,10 @@ auto memPeak = [this](const std::vector<unsigned int> &program)\
|
||||
\
|
||||
msg = HadronsLogMessage.isActive();\
|
||||
HadronsLogMessage.Active(false);\
|
||||
env_.dryRun(true);\
|
||||
memPeak = env_.executeProgram(program);\
|
||||
env_.dryRun(false);\
|
||||
env_.freeAll();\
|
||||
env().dryRun(true);\
|
||||
memPeak = env().executeProgram(program);\
|
||||
env().dryRun(false);\
|
||||
env().freeAll();\
|
||||
HadronsLogMessage.Active(true);\
|
||||
\
|
||||
return memPeak;\
|
||||
@ -179,7 +184,7 @@ void Application::schedule(void)
|
||||
|
||||
// build module dependency graph
|
||||
LOG(Message) << "Building module graph..." << std::endl;
|
||||
auto graph = env_.makeModuleGraph();
|
||||
auto graph = env().makeModuleGraph();
|
||||
auto con = graph.getConnectedComponents();
|
||||
|
||||
// constrained topological sort using a genetic algorithm
|
||||
@ -256,7 +261,7 @@ void Application::saveSchedule(const std::string filename)
|
||||
<< std::endl;
|
||||
for (auto address: program_)
|
||||
{
|
||||
program.push_back(env_.getModuleName(address));
|
||||
program.push_back(env().getModuleName(address));
|
||||
}
|
||||
write(writer, "schedule", program);
|
||||
}
|
||||
@ -274,7 +279,7 @@ void Application::loadSchedule(const std::string filename)
|
||||
program_.clear();
|
||||
for (auto &name: program)
|
||||
{
|
||||
program_.push_back(env_.getModuleAddress(name));
|
||||
program_.push_back(env().getModuleAddress(name));
|
||||
}
|
||||
scheduled_ = true;
|
||||
memPeak_ = memPeak(program_);
|
||||
@ -291,7 +296,7 @@ void Application::printSchedule(void)
|
||||
for (unsigned int i = 0; i < program_.size(); ++i)
|
||||
{
|
||||
LOG(Message) << std::setw(4) << i + 1 << ": "
|
||||
<< env_.getModuleName(program_[i]) << std::endl;
|
||||
<< env().getModuleName(program_[i]) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,9 +309,9 @@ void Application::configLoop(void)
|
||||
{
|
||||
LOG(Message) << BIG_SEP << " Starting measurement for trajectory " << t
|
||||
<< " " << BIG_SEP << std::endl;
|
||||
env_.setTrajectory(t);
|
||||
env_.executeProgram(program_);
|
||||
env().setTrajectory(t);
|
||||
env().executeProgram(program_);
|
||||
}
|
||||
LOG(Message) << BIG_SEP << " End of measurement " << BIG_SEP << std::endl;
|
||||
env_.freeAll();
|
||||
env().freeAll();
|
||||
}
|
||||
|
@ -98,11 +98,13 @@ public:
|
||||
void printSchedule(void);
|
||||
// loop on configurations
|
||||
void configLoop(void);
|
||||
private:
|
||||
// environment shortcut
|
||||
Environment & env(void) const;
|
||||
private:
|
||||
long unsigned int locVol_;
|
||||
std::string parameterFileName_{""};
|
||||
GlobalPar par_;
|
||||
Environment &env_;
|
||||
std::vector<unsigned int> program_;
|
||||
Environment::Size memPeak_;
|
||||
bool scheduled_{false};
|
||||
@ -115,14 +117,14 @@ private:
|
||||
template <typename M>
|
||||
void Application::createModule(const std::string name)
|
||||
{
|
||||
env_.createModule<M>(name);
|
||||
env().createModule<M>(name);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void Application::createModule(const std::string name,
|
||||
const typename M::Par &par)
|
||||
{
|
||||
env_.createModule<M>(name, par);
|
||||
env().createModule<M>(name, par);
|
||||
}
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user