promise: get reference to ModelExecution
authorBrian Norris <banorris@uci.edu>
Tue, 16 Apr 2013 02:25:46 +0000 (19:25 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 16 Apr 2013 02:25:46 +0000 (19:25 -0700)
execution.cc
model.h
promise.cc
promise.h

index dc1b6c53986725a9303a156fcc888c4bb7c8b456..0ec13900b4e56b4bde68db8978bd9d5202b28946 100644 (file)
@@ -616,7 +616,7 @@ bool ModelExecution::process_read(ModelAction *curr)
                case READ_FROM_FUTURE: {
                        /* Read from future value */
                        struct future_value fv = node->get_future_value();
-                       Promise *promise = new Promise(curr, fv);
+                       Promise *promise = new Promise(this, curr, fv);
                        curr->set_read_from_promise(promise);
                        promises->push_back(promise);
                        mo_graph->startChanges();
diff --git a/model.h b/model.h
index dd5df93b0d9466747330160bd9437b569529bd90..4dbe557222c40a0a7d92fb55227a202d54f069f6 100644 (file)
--- a/model.h
+++ b/model.h
@@ -54,7 +54,6 @@ public:
 
        Thread * get_thread(thread_id_t tid) const;
        Thread * get_thread(const ModelAction *act) const;
-       int get_promise_number(const Promise *promise) const;
 
        bool is_enabled(Thread *t) const;
        bool is_enabled(thread_id_t tid) const;
index 29e261f04086dca1891d12934bb75596af03000a..df86090a2335ff3e17c69d33a98c9d370903f199 100644 (file)
@@ -2,17 +2,19 @@
 #include <inttypes.h>
 
 #include "promise.h"
-#include "model.h"
+#include "execution.h"
 #include "schedule.h"
 #include "action.h"
 #include "threads-model.h"
 
 /**
  * @brief Promise constructor
+ * @param execution The execution which is creating this Promise
  * @param read The read which reads from a promised future value
  * @param fv The future value that is promised
  */
-Promise::Promise(ModelAction *read, struct future_value fv) :
+Promise::Promise(const ModelExecution *execution, ModelAction *read, struct future_value fv) :
+       execution(execution),
        num_available_threads(0),
        fv(fv),
        readers(1, read),
@@ -170,5 +172,5 @@ bool Promise::same_location(const ModelAction *act) const
 /** @brief Get this Promise's index within the execution's promise array */
 int Promise::get_index() const
 {
-       return model->get_promise_number(this);
+       return execution->get_promise_number(this);
 }
index e8c233c61d8240d4820fc39ad7d735d0ffeff355..1560b5809dec9672310c5a65fb3c9c28f3841309 100644 (file)
--- a/promise.h
+++ b/promise.h
@@ -14,6 +14,7 @@
 #include "stl-model.h"
 
 class ModelAction;
+class ModelExecution;
 
 struct future_value {
        uint64_t value;
@@ -23,7 +24,7 @@ struct future_value {
 
 class Promise {
  public:
-       Promise(ModelAction *read, struct future_value fv);
+       Promise(const ModelExecution *execution, ModelAction *read, struct future_value fv);
        bool add_reader(ModelAction *reader);
        ModelAction * get_reader(unsigned int i) const;
        unsigned int get_num_readers() const { return readers.size(); }
@@ -52,6 +53,9 @@ class Promise {
 
        SNAPSHOTALLOC
  private:
+       /** @brief The execution which created this Promise */
+       const ModelExecution *execution;
+
        /** @brief Thread ID(s) for thread(s) that potentially can satisfy this
         *  promise */
        SnapVector<bool> available_thread;