1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-05 19:55:56 +01:00

Hadrons: smarter memory profiler

This commit is contained in:
Antonin Portelli 2018-07-26 16:47:45 +01:00
parent 80de748737
commit ef5452cddf
4 changed files with 31 additions and 33 deletions

View File

@ -35,7 +35,7 @@ using namespace QCD;
using namespace Hadrons;
#define ERROR_NO_ADDRESS(address)\
HADRONS_ERROR(Definition, "no object with address " + std::to_string(address));
HADRONS_ERROR_REF(ObjectDefinition, "no object with address " + std::to_string(address), address);
/******************************************************************************
* Environment implementation *
@ -220,7 +220,8 @@ void Environment::addObject(const std::string name, const int moduleAddress)
}
else
{
HADRONS_ERROR(Definition, "object '" + name + "' already exists");
HADRONS_ERROR_REF(ObjectDefinition, "object '" + name + "' already exists",
getObjectAddress(name));
}
}

View File

@ -245,7 +245,7 @@ void Environment::createDerivedObject(const std::string name,
(object_[address].type != &typeid(B)) or
(object_[address].derivedType != &typeid(T)))
{
HADRONS_ERROR(Definition, "object '" + name + "' already allocated");
HADRONS_ERROR_REF(ObjectDefinition, "object '" + name + "' already allocated", address);
}
}
@ -279,28 +279,31 @@ T * Environment::getDerivedObject(const unsigned int address) const
}
else
{
HADRONS_ERROR(Definition, "object with address " + std::to_string(address) +
HADRONS_ERROR_REF(ObjectDefinition, "object with address " +
std::to_string(address) +
" cannot be casted to '" + typeName(&typeid(T)) +
"' (has type '" + typeName(&typeid(h->get())) + "')");
"' (has type '" + typeName(&typeid(h->get())) + "')", address);
}
}
}
else
{
HADRONS_ERROR(Definition, "object with address " + std::to_string(address) +
HADRONS_ERROR_REF(ObjectDefinition, "object with address " +
std::to_string(address) +
" does not have type '" + typeName(&typeid(B)) +
"' (has type '" + getObjectType(address) + "')");
"' (has type '" + getObjectType(address) + "')", address);
}
}
else
{
HADRONS_ERROR(Definition, "object with address " + std::to_string(address) +
" is empty");
HADRONS_ERROR_REF(ObjectDefinition, "object with address " +
std::to_string(address) + " is empty", address);
}
}
else
{
HADRONS_ERROR(Definition, "no object with address " + std::to_string(address));
HADRONS_ERROR_REF(ObjectDefinition, "no object with address " +
std::to_string(address), address);
}
}
@ -338,7 +341,8 @@ bool Environment::isObjectOfType(const unsigned int address) const
}
else
{
HADRONS_ERROR(Definition, "no object with address " + std::to_string(address));
HADRONS_ERROR_REF(ObjectDefinition, "no object with address "
+ std::to_string(address), address);
}
}

View File

@ -158,7 +158,7 @@ void TRBPrecCG<FImpl, nBasis>::setup(void)
guesser.reset(new CoarseGuesser(epack.evec, epack.evecCoarse,
epack.evalCoarse));
}
catch (Exceptions::Definition &e)
catch (Exceptions::ObjectDefinition &)
{
auto &epack = envGet(EPack, par().eigenPack);

View File

@ -123,10 +123,11 @@ void VirtualMachine::pushModule(VirtualMachine::ModPt &pt)
else
{
// output already fully registered, error
HADRONS_ERROR(Definition, "object '" + out
HADRONS_ERROR_REF(ObjectDefinition, "object '" + out
+ "' is already produced by module '"
+ module_[env().getObjectModule(out)].name
+ "' (while pushing module '" + name + "')");
+ "' (while pushing module '" + name + "')",
env().getObjectAddress(out));
}
if (getModule(address)->getReference().size() > 0)
{
@ -306,10 +307,10 @@ void VirtualMachine::makeModuleGraph(void)
if (min < 0)
{
HADRONS_ERROR(Definition, "dependency '"
HADRONS_ERROR_REF(ObjectDefinition, "dependency '"
+ env().getObjectName(in) + "' (address "
+ std::to_string(in)
+ ") is not produced by any module");
+ ") is not produced by any module", in);
}
else
{
@ -394,7 +395,7 @@ void VirtualMachine::makeMemoryProfile(void)
if (profile_.module[a].empty())
{
LOG(Debug) << "Profiling memory for module '" << module_[a].name
<< "' (" << a << ")..." << std::endl;
<< "' (" << a << ")" << std::endl;
memoryProfile(a);
env().freeAll();
}
@ -471,7 +472,7 @@ void VirtualMachine::memoryProfile(const unsigned int address)
auto m = getModule(address);
LOG(Debug) << "Setting up module '" << m->getName()
<< "' (" << address << ")..." << std::endl;
<< "' (" << address << ")" << std::endl;
try
{
currentModule_ = address;
@ -479,25 +480,17 @@ void VirtualMachine::memoryProfile(const unsigned int address)
currentModule_ = -1;
updateProfile(address);
}
catch (Exceptions::Definition &)
catch (Exceptions::ObjectDefinition &exc)
{
cleanEnvironment();
for (auto &in: m->getInput())
if (!env().hasCreatedObject(exc.getAddress()))
{
if (!env().hasCreatedObject(in))
{
memoryProfile(env().getObjectModule(in));
}
LOG(Debug) << "Object '" << env().getObjectName(exc.getAddress())
<< "' missing for setup of '" << m->getName()
<< "' (" << address << ")" << std::endl;
memoryProfile(env().getObjectModule(exc.getAddress()));
}
for (auto &ref: m->getReference())
{
if (!env().hasCreatedObject(ref))
{
memoryProfile(env().getObjectModule(ref));
}
}
m->setup();
updateProfile(address);
memoryProfile(address);
}
}