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__
12 #include "hashtable.h"
22 /** @brief A graph of Model Actions for tracking cycles. */
27 void addEdge(const ModelAction *from, const ModelAction *to);
28 bool checkForCycles() const;
29 void addRMWEdge(const ModelAction *from, const ModelAction *rmw);
30 bool checkPromise(const ModelAction *from, Promise *p) const;
31 bool checkReachable(const ModelAction *from, const ModelAction *to) const;
34 void rollbackChanges();
35 #if SUPPORT_MOD_ORDER_DUMP
36 void dumpNodes(FILE *file) const;
37 void dumpGraphToFile(const char *filename) const;
42 void addEdge(CycleNode *fromnode, CycleNode *tonode);
43 void putNode(const ModelAction *act, CycleNode *node);
44 CycleNode * getNode(const ModelAction *);
45 HashTable<const CycleNode *, const CycleNode *, uintptr_t, 4, model_malloc, model_calloc, model_free> *discovered;
47 /** @brief A table for mapping ModelActions to CycleNodes */
48 HashTable<const ModelAction *, CycleNode *, uintptr_t, 4> actionToNode;
49 #if SUPPORT_MOD_ORDER_DUMP
50 std::vector<CycleNode *> nodeList;
53 bool checkReachable(const CycleNode *from, const CycleNode *to) const;
55 /** @brief A flag: true if this graph contains cycles */
59 std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > rollbackvector;
60 std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > rmwrollbackvector;
63 /** @brief A node within a CycleGraph; corresponds to one ModelAction */
66 CycleNode(const ModelAction *act);
67 bool addEdge(CycleNode *node);
68 CycleNode * getEdge(unsigned int i) const;
69 unsigned int getNumEdges() const;
70 CycleNode * getBackEdge(unsigned int i) const;
71 unsigned int getNumBackEdges() const;
72 bool setRMW(CycleNode *);
73 CycleNode * getRMW() const;
74 const ModelAction * getAction() const { return action; }
85 /** @brief The ModelAction that this node represents */
86 const ModelAction *action;
88 /** @brief The edges leading out from this node */
89 std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > edges;
91 /** @brief The edges leading into this node */
92 std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > back_edges;
94 /** Pointer to a RMW node that reads from this node, or NULL, if none
99 #endif /* __CYCLEGRAPH_H__ */