mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Hadrons: can trace which module is throwing an error
This commit is contained in:
parent
4669ecd4ba
commit
334da7f452
@ -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();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,7 +155,7 @@ 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_;
|
||||
|
Loading…
Reference in New Issue
Block a user