1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-09 21:50:45 +01:00

Hadrons: basic GraphViz visualisation

This commit is contained in:
Antonin Portelli 2018-03-03 13:42:36 +00:00
parent fcac5c0772
commit e93c883470
2 changed files with 48 additions and 1 deletions

View File

@ -111,6 +111,7 @@ void VirtualMachine::pushModule(VirtualMachine::ModPt &pt)
{ {
// output does not exists, add it // output does not exists, add it
env().addObject(out, address); env().addObject(out, address);
module_[address].output.push_back(env().getObjectAddress(out));
} }
else else
{ {
@ -313,6 +314,48 @@ void VirtualMachine::makeModuleGraph(void)
graph_ = graph; graph_ = graph;
} }
// dump GraphViz graph /////////////////////////////////////////////////////////
void VirtualMachine::dumpModuleGraph(std::ostream &out)
{
makeModuleGraph();
out << "digraph hadrons {" << std::endl;
out << "node [shape=record, fontname=\"Courier\", fontsize=\"11\"];" << std::endl;
out << "graph [fontname = \"Courier\", fontsize=\"11\"];" << std::endl;
out << "edge [fontname = \"Courier\", fontsize=\"11\"];"<< std::endl;
for (unsigned int m = 0; m < module_.size(); ++m)
{
}
for (unsigned int m = 0; m < module_.size(); ++m)
{
for (auto &in: module_[m].input)
{
int min = env().getObjectModule(in);
out << min << " -> " << m << " [ label = \""
<< env().getObjectName(in) << "\" ];" << std::endl;
}
}
for (unsigned int m = 0; m < module_.size(); ++m)
{
out << m << " [ label = \"{<f0> " << getModule(m)->getRegisteredName()
<< " |<f1> " << getModuleName(m) << "}\" ];" << std::endl;
}
out << "}\n" << std::endl;
}
void VirtualMachine::dumpModuleGraph(void)
{
dumpModuleGraph(std::cout);
}
void VirtualMachine::dumpModuleGraph(const std::string filename)
{
std::ofstream f(filename);
dumpModuleGraph(f);
}
// memory profile ////////////////////////////////////////////////////////////// // memory profile //////////////////////////////////////////////////////////////
const VirtualMachine::MemoryProfile & VirtualMachine::getMemoryProfile(void) const VirtualMachine::MemoryProfile & VirtualMachine::getMemoryProfile(void)
{ {

View File

@ -84,7 +84,7 @@ private:
const std::type_info *type{nullptr}; const std::type_info *type{nullptr};
std::string name; std::string name;
ModPt data{nullptr}; ModPt data{nullptr};
std::vector<unsigned int> input; std::vector<unsigned int> input, output;
size_t maxAllocated; size_t maxAllocated;
}; };
public: public:
@ -120,6 +120,10 @@ public:
void printContent(void) const; void printContent(void) const;
// module graph (could be a const reference if topoSort was const) // module graph (could be a const reference if topoSort was const)
Graph<unsigned int> getModuleGraph(void); Graph<unsigned int> getModuleGraph(void);
// dump GraphViz graph
void dumpModuleGraph(std::ostream &out);
void dumpModuleGraph(void);
void dumpModuleGraph(const std::string filename);
// memory profile // memory profile
const MemoryProfile &getMemoryProfile(void); const MemoryProfile &getMemoryProfile(void);
// garbage collector // garbage collector