1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-09 21:50:45 +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) 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) << e.what() << std::endl;
LOG(Error) << "Aborting program" << std::endl; LOG(Error) << "Aborting program" << std::endl;
Grid_finalize(); Grid_finalize();

View File

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

View File

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