performance fix
authorweiyu <weiyuluo1232@gmail.com>
Mon, 29 Jul 2019 19:44:05 +0000 (12:44 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Mon, 29 Jul 2019 19:44:05 +0000 (12:44 -0700)
funcnode.cc
funcnode.h
history.cc
history.h

index 208bc3beb2666520d20ac30f873234b1e9775e00..4c49f2c315275d371fb48c3c19b9c3ece0476a3e 100644 (file)
@@ -125,17 +125,7 @@ void FuncNode::store_read(ModelAction * act, uint32_t tid)
        read_map->put(location, read_from_val);
 
        /* Store the memory locations where atomic reads happen */
-       bool push_loc = true;
-       ModelList<void *>::iterator it;
-       for (it = read_locations.begin();it != read_locations.end();it++) {
-               if (location == *it) {
-                       push_loc = false;
-                       break;
-               }
-       }
-
-       if (push_loc)
-               read_locations.push_back(location);
+       read_locations.add(location);
 }
 
 uint64_t FuncNode::query_last_read(void * location, uint32_t tid)
@@ -175,6 +165,7 @@ void FuncNode::generate_predicate(FuncInst *func_inst)
  */
 void FuncNode::print_last_read(uint32_t tid)
 {
+/*
        ASSERT(thrd_read_map.size() > tid);
        read_map_t * read_map = thrd_read_map[tid];
 
@@ -186,4 +177,5 @@ void FuncNode::print_last_read(uint32_t tid)
                uint64_t read_val = read_map->get(*it);
                model_print("last read of thread %d at %p: 0x%x\n", tid, *it, read_val);
        }
+*/
 }
index 08e07fb188ffcbd009f2ee6b160f0b674fd97935..d2d3c427331632574dd70a648cce47c356aeab4c 100644 (file)
@@ -4,6 +4,7 @@
 #include "action.h"
 #include "funcinst.h"
 #include "hashtable.h"
+#include "hashset.h"
 
 typedef ModelList<FuncInst *> func_inst_list_mt;
 typedef HashTable<void *, uint64_t, uintptr_t, 4, model_malloc, model_calloc, model_free> read_map_t;
@@ -53,7 +54,7 @@ private:
 
        /* Store the values read by atomic read actions per memory location for each thread */
        ModelVector<read_map_t *> thrd_read_map;
-       ModelList<void *> read_locations;
+       HashSet<void *, uintptr_t, 4, model_malloc, model_calloc, model_free> read_locations;
 };
 
 #endif /* __FUNCNODE_H__ */
index 7b6e3c87fe6adfca4e5bbcd54e99203b8ec35234..a60dfa6b4ed19e649ff4caee2874159744eef054 100644 (file)
@@ -156,10 +156,13 @@ uint64_t ModelHistory::query_last_read(void * location, thread_id_t tid)
 
 void ModelHistory::add_to_write_history(void * location, uint64_t write_val)
 {
-       if ( !write_history.contains(location) )
-               write_history.put(location, new write_set_t() );
-
        write_set_t * write_set = write_history.get(location);
+
+       if (write_set == NULL) {
+               write_set = new write_set_t();
+               write_history.put(location, write_set);
+       }
+
        write_set->add(write_val);
 }
 
index 5709ab6cc9baa405dc2f5febc00b3910b639c4bf..4457750e961ee69c076ee7b00d91bf98c2f842c3 100644 (file)
--- a/history.h
+++ b/history.h
@@ -7,7 +7,7 @@
 #include "hashset.h"
 #include "threads-model.h"
 
-typedef HashSet<uint64_t, uint64_t, 4, model_malloc, model_calloc, model_free> write_set_t;
+typedef HashSet<uint64_t, uint64_t, 0, model_malloc, model_calloc, model_free> write_set_t;
 
 class ModelHistory {
 public: