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 addEdges(SnapList<ModelAction *> * edgeset, ModelAction *to);
27 void addEdge(ModelAction *from, ModelAction *to);
28 void addEdge(ModelAction *from, ModelAction *to, bool forceedge);
29 void addRMWEdge(ModelAction *from, ModelAction *rmw);
30 bool checkReachable(const ModelAction *from, const ModelAction *to) const;
31 void freeAction(const ModelAction * act);
32 #if SUPPORT_MOD_ORDER_DUMP
33 void dumpNodes(FILE *file) const;
34 void dumpGraphToFile(const char *filename) const;
35 void dot_print_node(FILE *file, const ModelAction *act);
36 void dot_print_edge(FILE *file, const ModelAction *from, const ModelAction *to, const char *prop);
39 CycleNode * getNode_noCreate(const ModelAction *act) const;
42 void addNodeEdge(CycleNode *fromnode, CycleNode *tonode, bool forceedge);
43 void putNode(const ModelAction *act, CycleNode *node);
44 CycleNode * getNode(ModelAction *act);
46 /** @brief A table for mapping ModelActions to CycleNodes */
47 HashTable<const ModelAction *, CycleNode *, uintptr_t, 4> actionToNode;
48 SnapVector<const CycleNode *> * queue;
50 #if SUPPORT_MOD_ORDER_DUMP
51 SnapVector<CycleNode *> nodeList;
54 bool checkReachable(const CycleNode *from, const CycleNode *to) const;
58 * @brief A node within a CycleGraph; corresponds either to one ModelAction
62 CycleNode(ModelAction *act);
63 void addEdge(CycleNode *node);
64 CycleNode * getEdge(unsigned int i) const;
65 unsigned int getNumEdges() const;
66 CycleNode * getInEdge(unsigned int i) const;
67 unsigned int getNumInEdges() const;
68 bool setRMW(CycleNode *);
69 CycleNode * getRMW() const;
70 void clearRMW() { hasRMW = NULL; }
71 ModelAction * getAction() const { return action; }
72 void removeInEdge(CycleNode *src);
73 void removeEdge(CycleNode *dst);
78 /** @brief The ModelAction that this node represents */
81 /** @brief The edges leading out from this node */
82 SnapVector<CycleNode *> edges;
84 /** @brief The edges leading in from this node */
85 SnapVector<CycleNode *> inedges;
87 /** Pointer to a RMW node that reads from this node, or NULL, if none
91 /** ClockVector for this Node. */
93 friend class CycleGraph;
96 #endif /* __CYCLEGRAPH_H__ */