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 addEdge(const ModelAction *from, const ModelAction *to, bool forceedge);
28 void addRMWEdge(const ModelAction *from, const ModelAction *rmw);
29 bool checkReachable(const ModelAction *from, const ModelAction *to) const;
31 #if SUPPORT_MOD_ORDER_DUMP
32 void dumpNodes(FILE *file) const;
33 void dumpGraphToFile(const char *filename) const;
34 void dot_print_node(FILE *file, const ModelAction *act);
35 void dot_print_edge(FILE *file, const ModelAction *from, const ModelAction *to, const char *prop);
38 CycleNode * getNode_noCreate(const ModelAction *act) const;
41 void addNodeEdge(CycleNode *fromnode, CycleNode *tonode, bool forceedge);
42 void putNode(const ModelAction *act, CycleNode *node);
43 CycleNode * getNode(const ModelAction *act);
45 /** @brief A table for mapping ModelActions to CycleNodes */
46 HashTable<const ModelAction *, CycleNode *, uintptr_t, 4> actionToNode;
47 SnapVector<const CycleNode *> * queue;
49 #if SUPPORT_MOD_ORDER_DUMP
50 SnapVector<CycleNode *> nodeList;
53 bool checkReachable(const CycleNode *from, const CycleNode *to) const;
57 * @brief A node within a CycleGraph; corresponds either to one ModelAction
61 CycleNode(const ModelAction *act);
62 void addEdge(CycleNode *node);
63 CycleNode * getEdge(unsigned int i) const;
64 unsigned int getNumEdges() const;
65 CycleNode * removeEdge();
66 bool setRMW(CycleNode *);
67 CycleNode * getRMW() const;
68 void clearRMW() { hasRMW = NULL; }
69 const ModelAction * getAction() const { return action; }
73 /** @brief The ModelAction that this node represents */
74 const ModelAction *action;
76 /** @brief The edges leading out from this node */
77 SnapVector<CycleNode *> edges;
79 /** Pointer to a RMW node that reads from this node, or NULL, if none
83 /** ClockVector for this Node. */
85 friend class CycleGraph;
88 #endif /* __CYCLEGRAPH_H__ */