nodestack: construct Node with 'number of threads', not 'parent node'
authorBrian Norris <banorris@uci.edu>
Mon, 28 May 2012 17:16:34 +0000 (10:16 -0700)
committerBrian Norris <banorris@uci.edu>
Mon, 28 May 2012 17:16:34 +0000 (10:16 -0700)
I don't really want to base the number of threads off of a 'parent'; I can
just record the global 'number of threads' as a Node parameter.

nodestack.cc
nodestack.h

index 4cbd7cea820fa6ce7e4764a8fd758d87621d3ec2..1d2bc9648fc1365d059cceab96490866c3fd2cf5 100644 (file)
@@ -1,21 +1,17 @@
 #include "nodestack.h"
 #include "action.h"
 #include "common.h"
 #include "nodestack.h"
 #include "action.h"
 #include "common.h"
+#include "model.h"
 
 int Node::total_nodes = 0;
 
 
 int Node::total_nodes = 0;
 
-Node::Node(ModelAction *act, Node *parent)
+Node::Node(ModelAction *act, int nthreads)
        : action(act),
        : action(act),
-       num_threads(parent ? parent->num_threads : 1),
+       num_threads(nthreads),
        explored_children(num_threads),
        backtrack(num_threads)
 {
        total_nodes++;
        explored_children(num_threads),
        backtrack(num_threads)
 {
        total_nodes++;
-       if (act && act->get_type() == THREAD_CREATE) {
-               num_threads++;
-               explored_children.resize(num_threads);
-               backtrack.resize(num_threads);
-       }
 }
 
 Node::~Node()
 }
 
 Node::~Node()
@@ -140,7 +136,7 @@ ModelAction * NodeStack::explore_action(ModelAction *act)
                /* Record action */
                get_head()->explore_child(act);
                act->create_cv(get_head()->get_action());
                /* Record action */
                get_head()->explore_child(act);
                act->create_cv(get_head()->get_action());
-               node_list.push_back(new Node(act, get_head()));
+               node_list.push_back(new Node(act, model->get_num_threads()));
                iter++;
        }
        return (*iter)->get_action();
                iter++;
        }
        return (*iter)->get_action();
index eebfa5ba1c0c8c4771bb625e490fb6dbfeb97c16..cf3c6db146675c0cb7f41d994f988925209fc976 100644 (file)
@@ -11,7 +11,7 @@ class ModelAction;
 
 class Node {
 public:
 
 class Node {
 public:
-       Node(ModelAction *act = NULL, Node *parent = NULL);
+       Node(ModelAction *act = NULL, int nthreads = 1);
        ~Node();
        /* return true = thread choice has already been explored */
        bool has_been_explored(thread_id_t tid);
        ~Node();
        /* return true = thread choice has already been explored */
        bool has_been_explored(thread_id_t tid);