61 nodes_.insert(std::make_pair(
id, name));
73 if (src == 0 || dst == 0)
85 idn = curdstme->second;
112 dstn = curdst->second;
124 idn->
links.push_back(ret);
130 std::ofstream &out, std::unordered_set<Node *> &nnl,
131 std::unordered_set<std::pair<const void *, const void *>> &dependencies,
132 std::unordered_set<Node *> &declared)
140 if (declared.find(tmp) == declared.end())
142 out <<
"\t" << ((
size_t)tmp) <<
" [label=\"" << find->second <<
"\"];\n";
144 declared.insert(tmp);
150 out <<
"\t" << ((
size_t)start_) <<
" -> " << ((
size_t)tmp);
155 attr = attr + ((attr.size() == 0) ?
"" :
" ") +
"label=\"" + alabels +
"\"";
158 out <<
" [" << attr <<
"];\n";
166 dependencies.insert(std::make_pair(start_->
id, tmp->
id));
171 std::list<Link *> tmplinks = tmp->
links;
174 for (
auto iter = tmplinks.begin(); iter != tmplinks.end(); ++iter)
177 std::string l = alabels +
"," + (*iter)->label;
179 filterTmp(start_, (*iter)->dst, hideedge, l, out, nnl, dependencies,
189 std::unordered_set<std::pair<const void *, const void *>> dependencies;
191 out <<
"digraph " << graph <<
"{\n";
194 std::unordered_set<Node *> nl;
197 out <<
"\t" << ((
size_t)&
start) <<
" [label=\"START\"];\n";
199 std::unordered_set<Node *> defined;
201 while (nl.size() > 0)
204 std::unordered_set<Node *> nnl;
205 for (
auto iter = nl.begin(); iter != nl.end(); ++iter)
210 for (
auto iter2 = cur->
links.begin(); iter2 != cur->
links.end(); ++iter2)
217 curl->
label, out, nnl, dependencies, defined);
255 out <<
"digraph " << graph <<
"_dep {\n";
258 std::unordered_set<const void *> present;
259 for (
auto iter = dependencies.begin(); iter != dependencies.end(); ++iter)
261 if (present.find(iter->first) == present.end())
263 present.insert(iter->first);
264 std::string name =
nodes_[iter->first];
266 out <<
"\t" << ((
size_t)iter->first) <<
" [label=\"" << name <<
"\"];\n";
268 if (present.find(iter->second) == present.end())
270 present.insert(iter->second);
271 std::string name =
nodes_[iter->second];
273 out <<
"\t" << ((
size_t)iter->second) <<
" [label=\"" << name <<
"\"];\n";
275 out <<
"\t" << ((
size_t)iter->first) <<
" -> " << ((
size_t)iter->second) <<
";\n";
286 std::vector<std::string> al;
288 ss <<
" color=" <<
color;
290 ss <<
" time=" << std::setprecision(std::numeric_limits<double>::digits10 + 2) << std::fixed <<
time;
292 ss <<
" cluster=\"" <<
cluster <<
"\"";
294 ss <<
" weight=" <<
weight;
299 ss <<
" " << attr.first <<
"=\"" << attr.second <<
"\"";
311 attrMap =
new std::map<std::string, std::string>();
312 (*attrMap)[name] = value;
324 std::vector<std::string> al;
325 if (color && color[0])
326 ss <<
" color=" << color;
328 ss <<
" label=\"" << label <<
"\"";
351 std::cout <<
"Error: Can't open either " << file <<
" or " << depfile << std::endl;
355 out <<
"digraph VOT {\n";
356 depout <<
"digraph VOTD {\n";
368 depout <<
"\t" << ((
size_t)
id) <<
"[label=\"" << name <<
"\"];\n";
382 if (((*find)->links_out.size() == 0))
418 if ((*find)->links_out.empty())
436 while ((src_[pos] != 0) && (pos < (label_size - 1)))
438 label[pos] = src_[pos];
456 Node **srcns =
new Node *[sources.size()];
460 for (
auto iter = sources.begin();
likely(iter != sources.end()); ++iter)
462 const void *ptr = *iter;
483 for (
size_t i = 0; i < pos; ++i)
511 auto src =
path.back()->src;
512 auto dst =
path.front()->dst;
517 if ((dfind != 0) && (sfind != 0))
519 std::cout <<
"writePath" << std::endl;
520 std::pair<const void *, const void *> p = std::make_pair(src->id, dst->id);
532 if ((dfind != 0) && (sfind != 0))
536 out <<
"\tnode [shape=ellipse];\n";
541 out <<
"\t" << +(*sifind) <<
" [label=\"" << *sfind <<
"\"";
542 src->attrToString(
out);
549 out <<
"\t" << +(*difind) <<
" [label=\"" << *dfind <<
"\"";
550 dst->attrToString(
out);
559 out <<
"\t" << +(*sifind) <<
" -> " << +(*difind) <<
" [";
595 auto find = current.find(n->
id);
608 bool dellink =
false;
613 cur =
path.back()->src;
620 path.back()->dst->links_in.erase(
path.back());
666 std::unordered_set<Link *> &links = cur->
links_in;
667 for (
auto iter = links.begin(); iter != links.end();)
726 tmp_.rehash(1 << 13);
728 deps_.rehash(1 << 13);
734 if (names_.find(dst) != names_.end())
736 for (
auto iter = sources.begin(); iter != sources.end(); ++iter)
738 std::pair<const void *, const void *> tmpp(0, dst);
739 if (names_.find(*iter) != names_.end())
746 const std::unordered_set<const void *> &srcset = tmp_[*iter];
747 for (
auto iter2 = srcset.begin(); iter2 != srcset.end(); ++iter2)
757 std::unordered_set<const void *> &tmpset = tmp_[dst];
758 for (
auto iter = sources.begin(); iter != sources.end(); ++iter)
760 if (names_.find(*iter) != names_.end())
762 tmpset.insert(*iter);
766 const std::unordered_set<const void *> &srcset = tmp_[*iter];
767 for (
auto iter2 = srcset.begin(); iter2 != srcset.end(); ++iter2)
769 tmpset.insert(*iter2);
777 std::function<
bool(
const void *,
const void *, std::string &)> filterOutCon,
778 std::function<
void(
const void *, std::string & )> nodeattr)
781 bool hideDisconnected =
true;
783 out <<
"digraph " << graphname <<
"{\n";
785 if (!hideDisconnected)
787 for (
auto iter = names_.begin(); iter != names_.end(); ++iter)
789 out <<
"\t" << ((
size_t)iter->first) <<
" [label=\"" << iter->second <<
"\"];\n";
794 std::unordered_set<const void *> cids;
795 for (
auto iter = deps_.begin(); iter != deps_.end(); ++iter)
798 if ((!filterOutCon) || ((!filterOutCon(iter->first, iter->second, color))))
800 cids.insert(iter->first);
801 cids.insert(iter->second);
804 for (
auto iter = cids.begin(); iter != cids.end(); ++iter)
807 nodeattr(*iter, color);
808 out <<
"\t" << ((
size_t)*iter) <<
" [label=\"" << names_[*iter] <<
"\"";
809 if (color.size() > 0)
810 out <<
" color=" << color;
815 for (
auto iter = deps_.begin(); iter != deps_.end(); ++iter)
818 if ((!filterOutCon) || ((!filterOutCon(iter->first, iter->second, color))))
820 out <<
"\t" << ((
size_t)iter->first) <<
" -> " << ((
size_t)iter->second);
821 bool hasattr = color.size() > 0;
826 if (color.size() > 0)
827 out <<
"color=" << color <<
" ";
838 #ifdef TRACEABLEFIED_H_
840 void VariableDependencyGraph::tf_write(
const std::string & filename,
841 const std::string & graphname,
842 std::function<
size_t(
const std::string & ,
size_t >
split);
860 bool none = label_.empty() && color_.empty() && appendedattr.empty();
865 if (label_.size() > 0)
867 out << (first ?
"" :
" ") <<
"label=\"" << label_ <<
"\"";
870 if (color_.size() > 0)
872 out << (first ?
"" :
" ") <<
" color=" << color_;
875 if (!appendedattr.empty())
877 out << (first ?
"" :
" ") << appendedattr;
909 out <<
depth(
this) <<
" \"" << id_ <<
"\" ";
910 AttrList::print(out, aa);
912 icl.insert(links_.begin(), links_.end());
917 out <<
depth(src_ ? src_ : dst_) <<
"\"" << (src_ ? src_->id_ :
"0") <<
"\" "
918 <<
"->" <<
" \"" << (dst_ ? dst_->id_ :
"0") <<
"\" ";
919 AttrList::print(out,
"");
936 out <<
depth(
this) << (parent_ ?
"subgraph \"cluster_" :
"digraph \"cluster_");
942 out <<
depth(
this) <<
"label=\"";
947 out <<
"\";\n\nnode;\n";
949 std::unordered_set<Link *> links;
951 for (
auto iter = nodes_.begin(); iter != nodes_.end(); ++iter)
953 if (!(*iter)->asGraph())
954 (*iter)->print(out, links);
957 for (
auto iter = nodes_.begin(); iter != nodes_.end(); ++iter)
959 if ((*iter)->asGraph())
960 (*iter)->print(out, links);
963 for (
auto iter = links.begin(); iter != links.end(); ++iter)
975 out <<
depth(
this) <<
"}\n";
980 for (
auto iter = graphs_.begin(); iter != graphs_.end(); ++iter)
982 std::unordered_set<Link *> icl;
983 (*iter)->print(out, icl);
993 for (
auto iter = graphs_.begin(); iter != graphs_.end();)
1003 graphs_.push_back(ret);
1008 if (parent ==
nullptr)
1016 if (parent ==
nullptr)
1018 if ((!
id.empty()) && (idmap_.find(
id) != idmap_.end()))
1020 Node *ret =
new Node(
this, parent,
id);
1026 if ((dst ==
nullptr) || (src ==
nullptr))
1035 auto find = idmap_.find(
id);
1036 if (find != idmap_.end())
1037 return find->second;
1043 if (labelpath.size() < 2)
1045 auto iter = labelpath.begin();
1047 for (
auto i = graphs_.begin(); i != graphs_.end(); ++i)
1049 if ((*i)->label_ == *iter)
1055 if (parent ==
nullptr)
1056 parent = createG(*iter);
1061 while (niter != labelpath.end())
1063 Graph *nparent =
nullptr;
1064 for (
auto i = parent->
nodes().begin(); i != parent->
nodes().end(); ++i)
1066 if ((*i)->asGraph())
1068 if ((*i)->label_ == *iter)
1075 if (nparent ==
nullptr)
1076 nparent = createG(parent, *iter);
1082 Node *ret =
nullptr;
1083 for (
auto i = parent->
nodes().begin(); i != parent->
nodes().end(); ++i)
1085 if ((*i)->label_ == *iter)
1092 ret = createN(parent,
"", *iter);
#define etiss_log(LEVEL, MSG)
void print(std::ostream &out, const std::string &appendedattr)
Graph * asGraph() override
const std::unordered_set< Node * > & nodes()
void print(std::ostream &out, std::unordered_set< Link * > &icl) override
void print(std::ostream &out)
virtual void print(std::ostream &out, std::unordered_set< Link * > &icl)
Node * createN(Graph *, const std::string &id, std::string name="")
virtual void print(std::ostream &out)
Graph * createG(std::string name="")
Node * lopenN(const std::list< std::string > &labelpath)
travel/creates sub graphs with the given labels until i find/creates a node for the lase label.
Link * createE(Node *src, Node *dst, std::string name="")
Node * find(const std::string &id)
void attrToString(std::ostream &out)
void setLabel(const char *)
const std::unordered_set< Link * > & links_out_
void attrToString(std::ostream &out)
void setAttr(const std::string &name, const std::string &value)
std::map< std::string, std::string > * attrMap
std::unordered_set< Link * > links_in
std::unordered_set< Link * > links_out
const std::unordered_set< std::pair< const void *, const void * > > & staticDependencies() const
Node * openSourceNode(const void *const src)
bool enable_default_graph_streaming_
set to false to disable the streaming of variable dependencies over time.
void undefineNode(const void *id)
std::function< void(Link *, const etiss::ExpandingNativeStack< Link *, 1000 > &)> setMetaLinkAttr
etiss::ObjectPool< Link > link_alloc_
etiss::FixedSizeHashMap< const void *, Node *, etiss::pointerHash< const void > > currentnodes_
etiss::ObjectPool< Node > node_alloc_
char depout_buf[256 *256]
std::function< void(Node *)> setCurrentNodeAttr
std::function< void(const etiss::ExpandingNativeStack< Link *, 1000 > &)> custWritePath
std::unordered_set< std::pair< const void *, const void * > > dependencies_
ValueOperationTraceGraphStreamer(const std::string &file, const std::string &depfile)
void link(const void *dst, std::initializer_list< const void * > sources, const char *label=0)
etiss::ExpandingNativeStack< Link *, 1000 > path
std::function< bool(const etiss::ExpandingNativeStack< Link *, 1000 > &)> hidePath
std::function< void(Link *, Node *, Node *const *, size_t, std::initializer_list< const void * > &, const char *)> setCurrentLinkAttr
Node * openDestNode(const void *const dst, Node *&cleanup)
etiss::FixedSizeHashMap< Node *, uint64_t, etiss::pointerHash< const void > > nodeToTmpId_
void defineNode(const void *id, const std::string &name)
etiss::FixedSizeHashMap< const void *, std::string, etiss::pointerHash< const void > > nodes_
~ValueOperationTraceGraphStreamer()
std::list< Link * > links
Link * link(const void *src, const void *dst)
void filterTmp(Node *start, Node *tmp, bool hideedge, const std::string &alabels, std::ofstream &out, std::unordered_set< Node * > &nnl, std::unordered_set< std::pair< const void *, const void * >> &dependencies, std::unordered_set< Node * > &declared)
std::unordered_map< const void *, Node * > currentdstnodes_
void defineNode(const void *id, const std::string &name)
void undefineNode(const void *id)
std::unordered_map< const void *, Node * > currentnodes_
std::unordered_map< const void *, std::string > nodes_
void flush(std::ofstream &out, const std::string &graph)
VariableDependencyGraph()
void link(const void *dst, const std::initializer_list< const void * > &sources)
void write(std::ostream &out, const std::string &graphname, std::function< bool(const void *, const void *, std::string &)> filterOutCon=[](const void *, const void *, std::string &) { return false;}, std::function< void(const void *, std::string &)> nodeattr=[](const void *, std::string &) {})
std::set< Instruction * > Node
Holding unique instruction sets code chunks after permutation.
static bool keepNode(ValueOperationTraceGraphStreamer::Node *n, const etiss::FixedSizeHashMap< const void *, ValueOperationTraceGraphStreamer::Node *, etiss::pointerHash< const void >> ¤t)
static std::string node_getCluster(Dot::Node *n)
static std::string graph_getCluster(Dot::Graph *g)
static std::string depth(Dot::Node *node)
static bool graph_contains(Dot::Graph *g, Dot::Node *n)
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
std::list< std::string > split(const std::string &str, std::function< size_t(const std::string &, size_t, size_t &)> findsplit)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
float __ovld __cnfn dot(float p0, float p1)
Compute dot product.