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 208bc3b..4c49f2c 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 */
        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)
 }
 
 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)
 {
  */
 void FuncNode::print_last_read(uint32_t tid)
 {
+/*
        ASSERT(thrd_read_map.size() > tid);
        read_map_t * read_map = thrd_read_map[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);
        }
                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 08e07fb..d2d3c42 100644 (file)
@@ -4,6 +4,7 @@
 #include "action.h"
 #include "funcinst.h"
 #include "hashtable.h"
 #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;
 
 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;
 
        /* 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__ */
 };
 
 #endif /* __FUNCNODE_H__ */
index 7b6e3c8..a60dfa6 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)
 {
 
 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);
        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);
 }
 
        write_set->add(write_val);
 }
 
index 5709ab6..4457750 100644 (file)
--- a/history.h
+++ b/history.h
@@ -7,7 +7,7 @@
 #include "hashset.h"
 #include "threads-model.h"
 
 #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:
 
 class ModelHistory {
 public: