Optimizations
authorBrian Demsky <bdemsky@uci.edu>
Thu, 20 Jun 2019 20:29:33 +0000 (13:29 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Thu, 20 Jun 2019 20:29:33 +0000 (13:29 -0700)
Makefile
execution.cc
execution.h
fuzzer.cc
fuzzer.h
main.cc

index 7c73b9ba92ab8744b55598a3d57a6436e26238d2..b62e72a9de19225ab7bcc57a9da8cd8d6465a4b5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -36,9 +36,6 @@ README.html: README.md
 malloc.o: malloc.c
        $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES -DHAVE_MMAP=0 $(CPPFLAGS) -Wno-unused-variable
 
-futex.o: futex.cc
-       $(CXX) -fPIC -c futex.cc -std=c++11 $(CPPFLAGS)
-
 
 %.o : %.cc
        $(CXX) -MMD -MF .$@.d -fPIC -c $< $(CPPFLAGS)
index 99f86195713523cb02791fb8ae75fcc309a1b0ec..8b718ba5fde29ddc6085850934925ff368adb968 100644 (file)
@@ -109,18 +109,6 @@ static SnapVector<action_list_t> * get_safe_ptr_vect_action(HashTable<void *, Sn
        return tmp;
 }
 
-action_list_t * ModelExecution::get_actions_on_obj(void * obj, thread_id_t tid) const
-{
-       SnapVector<action_list_t> *wrv = obj_thrd_map.get(obj);
-       if (wrv==NULL)
-               return NULL;
-       unsigned int thread=id_to_int(tid);
-       if (thread < wrv->size())
-               return &(*wrv)[thread];
-       else
-               return NULL;
-}
-
 /** @return a thread ID for a new Thread */
 thread_id_t ModelExecution::get_next_id()
 {
@@ -272,7 +260,7 @@ bool ModelExecution::is_complete_execution() const
  * @param rf_set is the set of model actions we can possibly read from
  * @return True if processing this read updates the mo_graph.
  */
-void ModelExecution::process_read(ModelAction *curr, SnapVector<ModelAction *> * rf_set)
+void ModelExecution::process_read(ModelAction *curr, SnapVector<const ModelAction *> * rf_set)
 {
        SnapVector<const ModelAction *> * priorset = new SnapVector<const ModelAction *>();
        while(true) {
@@ -374,8 +362,10 @@ bool ModelExecution::process_mutex(ModelAction *curr)
        }
        case ATOMIC_NOTIFY_ONE: {
                action_list_t *waiters = get_safe_ptr_action(&condvar_waiters_map, curr->get_location());
-               Thread * thread = fuzzer->selectNotify(waiters);
-               scheduler->wake(thread);
+               if (waiters->size() != 0) {
+                       Thread * thread = fuzzer->selectNotify(waiters);
+                       scheduler->wake(thread);
+               }
                break;
        }
 
@@ -685,7 +675,7 @@ ModelAction * ModelExecution::check_current_action(ModelAction *curr)
        if (!second_part_of_rmw && curr->get_type() != NOOP)
                add_action_to_lists(curr);
 
-       SnapVector<ModelAction *> * rf_set = NULL;
+       SnapVector<const ModelAction *> * rf_set = NULL;
        /* Build may_read_from set for newly-created actions */
        if (newly_explored && curr->is_read())
                rf_set = build_may_read_from(curr);
@@ -1313,7 +1303,7 @@ bool valequals(uint64_t val1, uint64_t val2, int size) {
  * @param curr is the current ModelAction that we are exploring; it must be a
  * 'read' operation.
  */
-SnapVector<ModelAction *> *  ModelExecution::build_may_read_from(ModelAction *curr)
+SnapVector<const ModelAction *> *  ModelExecution::build_may_read_from(ModelAction *curr)
 {
        SnapVector<action_list_t> *thrd_lists = obj_thrd_map.get(curr->get_location());
        unsigned int i;
@@ -1324,7 +1314,7 @@ SnapVector<ModelAction *> *  ModelExecution::build_may_read_from(ModelAction *cu
        if (curr->is_seqcst())
                last_sc_write = get_last_seq_cst_write(curr);
 
-       SnapVector<ModelAction *> * rf_set = new SnapVector<ModelAction *>();
+       SnapVector<const ModelAction *> * rf_set = new SnapVector<const ModelAction *>();
 
        /* Iterate over all threads */
        for (i = 0;i < thrd_lists->size();i++) {
@@ -1332,10 +1322,21 @@ SnapVector<ModelAction *> *  ModelExecution::build_may_read_from(ModelAction *cu
                action_list_t *list = &(*thrd_lists)[i];
                action_list_t::reverse_iterator rit;
                for (rit = list->rbegin();rit != list->rend();rit++) {
-                       ModelAction *act = *rit;
+                       const ModelAction *act = *rit;
 
                        /* Only consider 'write' actions */
-                       if (!act->is_write() || act == curr)
+                       if (!act->is_write()) {
+                               if (act != curr && act->is_read() && act->happens_before(curr)) {
+                                       const ModelAction *tmp = act->get_reads_from();
+                                       if (((unsigned int) id_to_int(tmp->get_tid()))==i)
+                                               act = tmp;
+                                       else
+                                               break;
+                               } else
+                                       continue;
+                       }
+
+                       if (act == curr)
                                continue;
 
                        /* Don't consider more than one seq_cst write if we are a seq_cst read. */
index b78837fc7219bd77dcea34744ff6214fb5fecaa6..990a7a8ab694b9e81559ee582e52ab7e1d592e25 100644 (file)
@@ -84,7 +84,6 @@ public:
        ModelAction * get_parent_action(thread_id_t tid) const;
        bool isfeasibleprefix() const;
 
-       action_list_t * get_actions_on_obj(void * obj, thread_id_t tid) const;
        ModelAction * get_last_action(thread_id_t tid) const;
 
        bool check_action_enabled(ModelAction *curr);
@@ -127,7 +126,7 @@ private:
        bool next_execution();
        ModelAction * check_current_action(ModelAction *curr);
        bool initialize_curr_action(ModelAction **curr);
-       void process_read(ModelAction *curr, SnapVector<ModelAction *> * rf_set);
+       void process_read(ModelAction *curr, SnapVector<const ModelAction *> * rf_set);
        void process_write(ModelAction *curr);
        bool process_fence(ModelAction *curr);
        bool process_mutex(ModelAction *curr);
@@ -141,7 +140,7 @@ private:
        ModelAction * get_last_seq_cst_write(ModelAction *curr) const;
        ModelAction * get_last_seq_cst_fence(thread_id_t tid, const ModelAction *before_fence) const;
        ModelAction * get_last_unlock(ModelAction *curr) const;
-       SnapVector<ModelAction *> * build_may_read_from(ModelAction *curr);
+       SnapVector<const ModelAction *> * build_may_read_from(ModelAction *curr);
        ModelAction * process_rmw(ModelAction *curr);
 
        bool r_modification_order(ModelAction *curr, const ModelAction *rf, SnapVector<const ModelAction *> *priorset);
index 9ad61c3c5cddbc96073e85c15e8dd05f46bffadb..3a3f98831b1c64245a5ab85569667e604878b361 100644 (file)
--- a/fuzzer.cc
+++ b/fuzzer.cc
@@ -3,7 +3,7 @@
 #include "threads-model.h"
 #include "model.h"
 
-int Fuzzer::selectWrite(ModelAction *read, SnapVector<ModelAction *> * rf_set) {
+int Fuzzer::selectWrite(ModelAction *read, SnapVector<const ModelAction *> * rf_set) {
        int random_index = random() % rf_set->size();
        return random_index;
 }
index 6cf1efbad26352782e4a45b985654e8f52069a1b..691477bd6e2e3db8833add08de8c3d5f619bd94d 100644 (file)
--- a/fuzzer.h
+++ b/fuzzer.h
@@ -7,7 +7,7 @@
 class Fuzzer {
 public:
        Fuzzer() {}
-       int selectWrite(ModelAction *read, SnapVector<ModelAction *>* rf_set);
+       int selectWrite(ModelAction *read, SnapVector<const ModelAction *>* rf_set);
        Thread * selectThread(Node *n, int * threadlist, int numthreads);
        Thread * selectNotify(action_list_t * waiters);
        MEMALLOC
diff --git a/main.cc b/main.cc
index dd0722b9b4416ee0d5fbd6712cd764c6f2eedc88..7ce43cbf0f1ce9a4a8b7a0de4f7b5b27f0c5b6ff 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -208,5 +208,5 @@ int main(int argc, char **argv)
        redirect_output();
 
        /* Let's jump in quickly and start running stuff */
-       snapshot_system_init(10000, 1024, 1024, 4000, &model_main);
+       snapshot_system_init(10000, 1024, 1024, 40000, &model_main);
 }