From cae6e82ba84ee7f3067f1279930452ae1fb66914 Mon Sep 17 00:00:00 2001 From: weiyu Date: Mon, 29 Jul 2019 12:44:05 -0700 Subject: [PATCH] performance fix --- funcnode.cc | 14 +++----------- funcnode.h | 3 ++- history.cc | 9 ++++++--- history.h | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/funcnode.cc b/funcnode.cc index 208bc3be..4c49f2c3 100644 --- a/funcnode.cc +++ b/funcnode.cc @@ -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::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); } +*/ } diff --git a/funcnode.h b/funcnode.h index 08e07fb1..d2d3c427 100644 --- a/funcnode.h +++ b/funcnode.h @@ -4,6 +4,7 @@ #include "action.h" #include "funcinst.h" #include "hashtable.h" +#include "hashset.h" typedef ModelList func_inst_list_mt; typedef HashTable read_map_t; @@ -53,7 +54,7 @@ private: /* Store the values read by atomic read actions per memory location for each thread */ ModelVector thrd_read_map; - ModelList read_locations; + HashSet read_locations; }; #endif /* __FUNCNODE_H__ */ diff --git a/history.cc b/history.cc index 7b6e3c87..a60dfa6b 100644 --- a/history.cc +++ b/history.cc @@ -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); } diff --git a/history.h b/history.h index 5709ab6c..4457750e 100644 --- a/history.h +++ b/history.h @@ -7,7 +7,7 @@ #include "hashset.h" #include "threads-model.h" -typedef HashSet write_set_t; +typedef HashSet write_set_t; class ModelHistory { public: -- 2.34.1