1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-20 09:15:38 +01:00

Hadrons: can trace which module is throwing an error

This commit is contained in:
Antonin Portelli 2018-04-13 18:45:31 +02:00
parent 4669ecd4ba
commit 334da7f452
3 changed files with 27 additions and 7 deletions

View File

@ -69,7 +69,17 @@ int main(int argc, char *argv[])
}
catch (const std::exception& e)
{
LOG(Error) << "FATAL ERROR -- Exception " << typeName(&typeid(e)) << std::endl;
auto &vm = VirtualMachine::getInstance();
int mod = vm.getCurrentModule();
LOG(Error) << "FATAL ERROR -- Exception " << typeName(&typeid(e))
<< std::endl;
if (mod >= 0)
{
LOG(Error) << "During execution of module '"
<< vm.getModuleName(mod) << "' (address " << mod << ")"
<< std::endl;
}
LOG(Error) << e.what() << std::endl;
LOG(Error) << "Aborting program" << std::endl;
Grid_finalize();

View File

@ -250,6 +250,11 @@ std::string VirtualMachine::getModuleNamespace(const std::string name) const
return getModuleNamespace(getModuleAddress(name));
}
int VirtualMachine::getCurrentModule(void) const
{
return currentModule_;
}
bool VirtualMachine::hasModule(const unsigned int address) const
{
return (address < module_.size());
@ -468,7 +473,9 @@ void VirtualMachine::memoryProfile(const unsigned int address)
<< "' (" << address << ")..." << std::endl;
try
{
currentModule_ = address;
m->setup();
currentModule_ = -1;
updateProfile(address);
}
catch (Exceptions::Definition &)
@ -622,7 +629,7 @@ VirtualMachine::Program VirtualMachine::schedule(const GeneticPar &par)
#define SEP "---------------"
#define MEM_MSG(size) sizeString(size)
void VirtualMachine::executeProgram(const Program &p) const
void VirtualMachine::executeProgram(const Program &p)
{
Size memPeak = 0, sizeBefore, sizeAfter;
GarbageSchedule freeProg;
@ -650,7 +657,9 @@ void VirtualMachine::executeProgram(const Program &p) const
LOG(Message) << SEP << " Measurement step " << i + 1 << "/"
<< p.size() << " (module '" << module_[p[i]].name
<< "') " << SEP << std::endl;
currentModule_ = p[i];
(*module_[p[i]].data)();
currentModule_ = -1;
sizeBefore = env().getTotalSize();
// print used memory after execution
LOG(Message) << "Allocated objects: " << MEM_MSG(sizeBefore)
@ -679,7 +688,7 @@ void VirtualMachine::executeProgram(const Program &p) const
}
}
void VirtualMachine::executeProgram(const std::vector<std::string> &p) const
void VirtualMachine::executeProgram(const std::vector<std::string> &p)
{
Program pAddress;

View File

@ -114,6 +114,7 @@ public:
std::string getModuleType(const std::string name) const;
std::string getModuleNamespace(const unsigned int address) const;
std::string getModuleNamespace(const std::string name) const;
int getCurrentModule(void) const;
bool hasModule(const unsigned int address) const;
bool hasModule(const std::string name) const;
// print VM content
@ -133,8 +134,8 @@ public:
// genetic scheduler
Program schedule(const GeneticPar &par);
// general execution
void executeProgram(const Program &p) const;
void executeProgram(const std::vector<std::string> &p) const;
void executeProgram(const Program &p);
void executeProgram(const std::vector<std::string> &p);
private:
// environment shortcut
DEFINE_ENV_ALIAS;
@ -154,13 +155,13 @@ private:
// module and related maps
std::vector<ModuleInfo> module_;
std::map<std::string, unsigned int> moduleAddress_;
std::string currentModule_{""};
int currentModule_{-1};
// module graph
bool graphOutdated_{true};
Graph<unsigned int> graph_;
// memory profile
bool memoryProfileOutdated_{true};
MemoryProfile profile_;
MemoryProfile profile_;
};
/******************************************************************************