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 *> rollbackvector;
58 std::vector<CycleNode *> rmwrollbackvector;
61 /** @brief A node within a CycleGraph; corresponds to one ModelAction */
64 CycleNode(const ModelAction *action);
65 bool addEdge(CycleNode * node);
66 std::vector<CycleNode *> * getEdges();
67 bool setRMW(CycleNode *);
69 const ModelAction * getAction() {return action;};
80 /** @brief The ModelAction that this node represents */
81 const ModelAction *action;
83 /** @brief The edges leading out from this node */
84 std::vector<CycleNode *> edges;
86 /** Pointer to a RMW node that reads from this node, or NULL, if none