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