X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=cyclegraph.h;h=c0bd7d66167aea6bd71fa323efb29e18a57dfac4;hp=a909c10b50a49f97453bf1f6114223400b11c4ac;hb=d3dffe991352938e5c2ab738ce70e3ec0f069d5f;hpb=eb07120dfdbb206124f7857016a71b6ef0b9eb99 diff --git a/cyclegraph.h b/cyclegraph.h index a909c10b..c0bd7d66 100644 --- a/cyclegraph.h +++ b/cyclegraph.h @@ -19,12 +19,17 @@ class Promise; class CycleNode; class ModelAction; +typedef std::vector< const Promise *, ModelAlloc > promise_list_t; + /** @brief A graph of Model Actions for tracking cycles. */ class CycleGraph { public: CycleGraph(); ~CycleGraph(); - void addEdge(const ModelAction *from, const ModelAction *to); + + template + void addEdge(const T from, const U to); + bool checkForCycles() const; void addRMWEdge(const ModelAction *from, const ModelAction *rmw); bool checkPromise(const ModelAction *from, Promise *p) const; @@ -37,15 +42,26 @@ class CycleGraph { void dumpGraphToFile(const char *filename) const; #endif + bool resolvePromise(ModelAction *reader, ModelAction *writer, + promise_list_t *mustResolve); + SNAPSHOTALLOC private: - void addEdge(CycleNode *fromnode, CycleNode *tonode); + void addNodeEdge(CycleNode *fromnode, CycleNode *tonode); void putNode(const ModelAction *act, CycleNode *node); CycleNode * getNode(const ModelAction *); + CycleNode * getNode(const Promise *promise); + bool mergeNodes(CycleNode *node1, CycleNode *node2, + promise_list_t *mustMerge); + HashTable *discovered; /** @brief A table for mapping ModelActions to CycleNodes */ HashTable actionToNode; + /** @brief A table for mapping reader ModelActions to Promise + * CycleNodes */ + HashTable readerToPromiseNode; + #if SUPPORT_MOD_ORDER_DUMP std::vector nodeList; #endif @@ -80,12 +96,14 @@ class CycleNode { CycleNode * getRMW() const; void clearRMW() { hasRMW = NULL; } const ModelAction * getAction() const { return action; } + const Promise * getPromise() const { return promise; } void popEdge() { edges.pop_back(); } bool is_promise() const { return !action; } + void resolvePromise(const ModelAction *writer); SNAPSHOTALLOC private: