1 /** @file cyclegraph.h @brief Data structure to track ordering
2 * constraints on modification order. The idea is to see whether a
3 * total order exists that satisfies the ordering constriants.*/
18 /** @brief A graph of Model Actions for tracking cycles. */
23 void addEdge(const ModelAction *from, const ModelAction *to);
24 bool checkForCycles();
25 bool checkForRMWViolation();
26 void addRMWEdge(const ModelAction *from, const ModelAction *rmw);
27 bool checkPromise(const ModelAction *from, Promise *p);
28 bool checkReachable(const ModelAction *from, const ModelAction *to);
31 void rollbackChanges();
32 #if SUPPORT_MOD_ORDER_DUMP
33 void dumpNodes(FILE *file);
34 void dumpGraphToFile(const char *filename);
39 CycleNode * getNode(const ModelAction *);
40 HashTable<CycleNode *, CycleNode *, uintptr_t, 4, model_malloc, model_calloc, model_free> *discovered;
42 /** @brief A table for mapping ModelActions to CycleNodes */
43 HashTable<const ModelAction *, CycleNode *, uintptr_t, 4> actionToNode;
44 #if SUPPORT_MOD_ORDER_DUMP
45 std::vector<CycleNode *> nodeList;
48 bool checkReachable(CycleNode *from, CycleNode *to);
50 /** @brief A flag: true if this graph contains cycles */
57 std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > rollbackvector;
58 std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > rmwrollbackvector;
61 /** @brief A node within a CycleGraph; corresponds to one ModelAction */
64 CycleNode(const ModelAction *action);
65 bool addEdge(CycleNode *node);
66 CycleNode * getEdge(unsigned int i) const;
67 unsigned int getNumEdges() const;
68 bool setRMW(CycleNode *);
69 CycleNode * getRMW() const;
70 const ModelAction * getAction() const { return action; }
81 /** @brief The ModelAction that this node represents */
82 const ModelAction *action;
84 /** @brief The edges leading out from this node */
85 std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > edges;
87 /** Pointer to a RMW node that reads from this node, or NULL, if none