3 * @brief Data structure to track ordering constraints on modification order
5 * Used to determine whether a total order exists that satisfies the ordering
9 #ifndef __CYCLEGRAPH_H__
10 #define __CYCLEGRAPH_H__
15 #include "hashtable.h"
18 #include "stl-model.h"
19 #include "classlist.h"
21 /** @brief A graph of Model Actions for tracking cycles. */
26 void addEdge(const ModelAction *from, const ModelAction *to);
27 void addRMWEdge(const ModelAction *from, const ModelAction *rmw);
28 bool checkReachable(const ModelAction *from, const ModelAction *to) const;
30 #if SUPPORT_MOD_ORDER_DUMP
31 void dumpNodes(FILE *file) const;
32 void dumpGraphToFile(const char *filename) const;
33 void dot_print_node(FILE *file, const ModelAction *act);
34 void dot_print_edge(FILE *file, const ModelAction *from, const ModelAction *to, const char *prop);
37 CycleNode * getNode_noCreate(const ModelAction *act) const;
40 void addNodeEdge(CycleNode *fromnode, CycleNode *tonode);
41 void putNode(const ModelAction *act, CycleNode *node);
42 CycleNode * getNode(const ModelAction *act);
44 /** @brief A table for mapping ModelActions to CycleNodes */
45 HashTable<const ModelAction *, CycleNode *, uintptr_t, 4> actionToNode;
46 SnapVector<const CycleNode *> * queue;
48 #if SUPPORT_MOD_ORDER_DUMP
49 SnapVector<CycleNode *> nodeList;
52 bool checkReachable(const CycleNode *from, const CycleNode *to) const;
56 * @brief A node within a CycleGraph; corresponds either to one ModelAction
60 CycleNode(const ModelAction *act);
61 void addEdge(CycleNode *node);
62 CycleNode * getEdge(unsigned int i) const;
63 unsigned int getNumEdges() const;
64 CycleNode * removeEdge();
65 bool setRMW(CycleNode *);
66 CycleNode * getRMW() const;
67 void clearRMW() { hasRMW = NULL; }
68 const ModelAction * getAction() const { return action; }
72 /** @brief The ModelAction that this node represents */
73 const ModelAction *action;
75 /** @brief The edges leading out from this node */
76 SnapVector<CycleNode *> edges;
78 /** Pointer to a RMW node that reads from this node, or NULL, if none
82 /** ClockVector for this Node. */
84 friend class CycleGraph;
87 #endif /* __CYCLEGRAPH_H__ */