more changes towards keeping track of promises resolved by a given write statement
authorBrian Demsky <bdemsky@uci.edu>
Thu, 26 Jul 2012 23:20:02 +0000 (16:20 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 2 Aug 2012 17:12:52 +0000 (10:12 -0700)
model.cc
model.h
nodestack.cc
nodestack.h
promise.h

index 29e16aa35ac75e63fc051e7fbf1062b5e95c143a..de5687317c7e794f1a2dfa9bf99d01bb303e4036 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -22,7 +22,6 @@ ModelChecker::ModelChecker()
        /* First thread created will have id INITIAL_THREAD_ID */
        next_thread_id(INITIAL_THREAD_ID),
        used_sequence_numbers(0),
        /* First thread created will have id INITIAL_THREAD_ID */
        next_thread_id(INITIAL_THREAD_ID),
        used_sequence_numbers(0),
-
        num_executions(0),
        current_action(NULL),
        diverge(NULL),
        num_executions(0),
        current_action(NULL),
        diverge(NULL),
@@ -320,6 +319,7 @@ void ModelChecker::check_current_action(void)
                }
        } else if (curr->is_write()) {
                w_modification_order(curr);
                }
        } else if (curr->is_write()) {
                w_modification_order(curr);
+               resolve_promises(curr);
        }
 
        th->set_return_value(value);
        }
 
        th->set_return_value(value);
@@ -515,6 +515,24 @@ ClockVector * ModelChecker::get_cv(thread_id_t tid) {
        return get_parent_action(tid)->get_cv();
 }
 
        return get_parent_action(tid)->get_cv();
 }
 
+
+/** Resolve promises. */
+
+void ModelChecker::resolve_promises(ModelAction *curr) {
+       for(unsigned int i=0;i<promises->size();i++) {
+               Promise * promise=(*promises)[i];
+               const ModelAction * act=promise->get_action();
+               if (!act->happens_before(curr)&&
+                               act->is_read()&&
+                               !act->is_synchronizing(curr)&&
+                               !act->same_thread(curr)&&
+                               promise->get_value()==curr->get_value()) {
+                       
+                       
+               }
+       }
+}
+
 /** Checks promises in response to change in ClockVector Threads. */
 
 void ModelChecker::check_promises(ClockVector *old_cv, ClockVector * merge_cv) {
 /** Checks promises in response to change in ClockVector Threads. */
 
 void ModelChecker::check_promises(ClockVector *old_cv, ClockVector * merge_cv) {
@@ -567,7 +585,7 @@ void ModelChecker::build_reads_from_past(ModelAction *curr)
                action_list_t::reverse_iterator rit;
                for (rit = list->rbegin(); rit != list->rend(); rit++) {
                        ModelAction *act = *rit;
                action_list_t::reverse_iterator rit;
                for (rit = list->rbegin(); rit != list->rend(); rit++) {
                        ModelAction *act = *rit;
-
+                       
                        /* Only consider 'write' actions */
                        if (!act->is_write())
                                continue;
                        /* Only consider 'write' actions */
                        if (!act->is_write())
                                continue;
diff --git a/model.h b/model.h
index e6dc06ddd97c2aef7d7c7dd17ae71854162ffb5e..3c225559606224878ce5c84497242f29604dda23 100644 (file)
--- a/model.h
+++ b/model.h
@@ -78,6 +78,7 @@ private:
        thread_id_t get_next_replay_thread();
        ModelAction * get_next_backtrack();
        void reset_to_initial_state();
        thread_id_t get_next_replay_thread();
        ModelAction * get_next_backtrack();
        void reset_to_initial_state();
+       void resolve_promises(ModelAction *curr);
 
        void add_action_to_lists(ModelAction *act);
        ModelAction * get_last_action(thread_id_t tid);
 
        void add_action_to_lists(ModelAction *act);
        ModelAction * get_last_action(thread_id_t tid);
index 082835802629ac989c13e57ed4adbdd8de81eb48..6eb71dc89c8f15097514781ed95209304414d1f6 100644 (file)
@@ -57,19 +57,60 @@ void Node::print_may_read_from()
                (*it)->print();
 }
 
                (*it)->print();
 }
 
+void Node::set_promise(uint32_t i) {
+       if (i>=promises.size())
+               promises.resize(i+1,0);
+       promises[i]=1;
+}
+
+bool Node::get_promise(uint32_t i) {
+       return (promises[i]==2);
+}
+
+bool Node::increment_promises() {
+       for (unsigned int i=0;i<promises.size();i++) {
+               if (promises[i]==1) {
+                       promises[i]=2;
+                       do {
+                               i--;
+                               if (promises[i]==2)
+                                       promises[i]=1;
+                       } while(i>0);
+                       return true;
+               }
+       }
+       return false;
+}
+
+bool Node::promises_empty() {
+       for (unsigned int i=0;i<promises.size();i++)
+               if (promises[i]==1)
+                       return false;
+       return true;
+}
+
 /**
  * Adds a value from a weakly ordered future write to backtrack to.
  * @param value is the value to backtrack to.
  */
 
 bool Node::add_future_value(uint64_t value) {
 /**
  * Adds a value from a weakly ordered future write to backtrack to.
  * @param value is the value to backtrack to.
  */
 
 bool Node::add_future_value(uint64_t value) {
-       for(int i=0;i<future_values.size();i++)
+       for(unsigned int i=0;i<future_values.size();i++)
                if (future_values[i]==value)
                        return false;
        future_values.push_back(value);
        return true;
 }
 
                if (future_values[i]==value)
                        return false;
        future_values.push_back(value);
        return true;
 }
 
+/** 
+ * Checks whether the future_values set for this node is empty.
+ * @return true if the future_values set is empty.
+ */
+
+bool Node::futurevalues_empty() {
+       return ((future_index+1)>=future_values.size());
+}
+
 
 /**
  * Checks if the Thread associated with this thread ID has been explored from
 
 /**
  * Checks if the Thread associated with this thread ID has been explored from
@@ -102,14 +143,7 @@ bool Node::readsfrom_empty() {
        return ((read_from_index+1)>=may_read_from.size());
 }
 
        return ((read_from_index+1)>=may_read_from.size());
 }
 
-/** 
- * Checks whether the future_values set for this node is empty.
- * @return true if the future_values set is empty.
- */
 
 
-bool Node::futurevalues_empty() {
-       return ((future_index+1)>=future_values.size());
-}
 
 /**
  * Mark the appropriate backtracking information for exploring a thread choice.
 
 /**
  * Mark the appropriate backtracking information for exploring a thread choice.
index 9ccde8da34e953052660292d6b865cb53dbe76e0..4162ff748e778bf8affcd0ad4fb23aef910f46cd 100644 (file)
@@ -15,6 +15,7 @@ class ModelAction;
 
 typedef std::vector< const ModelAction *, MyAlloc< const ModelAction * > > readfrom_set_t;
 typedef std::vector< uint64_t, MyAlloc< uint64_t > > futurevalues_t;
 
 typedef std::vector< const ModelAction *, MyAlloc< const ModelAction * > > readfrom_set_t;
 typedef std::vector< uint64_t, MyAlloc< uint64_t > > futurevalues_t;
+typedef std::vector< uint32_t, MyAlloc< uint32_t > > promises_t;
 
 /**
  * @brief A single node in a NodeStack
 
 /**
  * @brief A single node in a NodeStack
@@ -33,8 +34,7 @@ public:
        bool has_been_explored(thread_id_t tid);
        /* return true = backtrack set is empty */
        bool backtrack_empty();
        bool has_been_explored(thread_id_t tid);
        /* return true = backtrack set is empty */
        bool backtrack_empty();
-       bool readsfrom_empty();
-       bool futurevalues_empty();
+
        void explore_child(ModelAction *act);
        /* return false = thread was already in backtrack */
        bool set_backtrack(thread_id_t id);
        void explore_child(ModelAction *act);
        /* return false = thread was already in backtrack */
        bool set_backtrack(thread_id_t id);
@@ -47,11 +47,19 @@ public:
        Node * get_parent() const { return parent; }
 
        bool add_future_value(uint64_t value);
        Node * get_parent() const { return parent; }
 
        bool add_future_value(uint64_t value);
+       uint64_t get_future_value();
+       bool increment_future_values();
+       bool futurevalues_empty();
+
        void add_read_from(const ModelAction *act);
        const ModelAction * get_read_from();
        void add_read_from(const ModelAction *act);
        const ModelAction * get_read_from();
-       uint64_t get_future_value();
        bool increment_read_from();
        bool increment_read_from();
-       bool increment_future_values();
+       bool readsfrom_empty();
+
+       void set_promise(uint32_t i);
+       bool get_promise(uint32_t i);
+       bool increment_promises();
+       bool promises_empty();
 
        void print();
        void print_may_read_from();
 
        void print();
        void print_may_read_from();
@@ -73,6 +81,7 @@ private:
        unsigned int read_from_index;
 
        futurevalues_t future_values;
        unsigned int read_from_index;
 
        futurevalues_t future_values;
+       promises_t promises;
        unsigned int future_index;
 };
 
        unsigned int future_index;
 };
 
index 180d9b01cc3bfc723d8dc3deb62c83c1a4e90e5a..0bf62d6b6a6bb1358383cd772ac0c5c9cd6d04a0 100644 (file)
--- a/promise.h
+++ b/promise.h
@@ -16,6 +16,7 @@ class Promise {
        Promise(ModelAction * act, uint64_t value);
        const ModelAction * get_action() { return read; }
        int increment_threads() { return ++numthreads; }
        Promise(ModelAction * act, uint64_t value);
        const ModelAction * get_action() { return read; }
        int increment_threads() { return ++numthreads; }
+       uint64_t get_value() { return value; }
        
  private:
        uint64_t value;
        
  private:
        uint64_t value;