little fixes
authorweiyu <weiyuluo1232@gmail.com>
Thu, 25 Jul 2019 01:04:18 +0000 (18:04 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Thu, 25 Jul 2019 01:04:18 +0000 (18:04 -0700)
execution.cc
funcnode.cc
funcnode.h
history.cc

index 33a608d6fa18f55b869045b67d6485b6332bb1d6..01125bb2b0910b7e64fa3933afed1f1693e01c2a 100644 (file)
@@ -277,7 +277,6 @@ ModelAction * ModelExecution::convertNonAtomicStore(void * location) {
        return act;
 }
 
-
 /**
  * Processes a read model action.
  * @param curr is the read model action to process.
@@ -1632,7 +1631,7 @@ Thread * ModelExecution::take_step(ModelAction *curr)
        ASSERT(curr);
 
        /* Process this action in ModelHistory for records*/
-       model->get_history()->process_action( curr, curr_thrd->get_id() );
+       model->get_history()->process_action( curr, curr->get_tid() );
 
        if (curr_thrd->is_blocked() || curr_thrd->is_complete())
                scheduler->remove_thread(curr_thrd);
index 8e76ebc674bf8e6d7339b45768b6a8b87c0a961d..281e0f0559486a1ae64dad4480232a4f1b773b06 100644 (file)
@@ -112,15 +112,15 @@ void FuncNode::store_read(ModelAction * act, uint32_t tid)
        void * location = act->get_location();
        uint64_t read_from_val = act->get_reads_from_value();
 
-       if (thrd_read_map.size() <= tid)
+       /* resize and initialize */
+       uint32_t old_size = thrd_read_map.size();
+       if (old_size <= tid) {
                thrd_read_map.resize(tid + 1);
-
-       read_map_t * read_map = thrd_read_map[tid];
-       if (read_map == NULL) {
-               read_map = new read_map_t();
-               thrd_read_map[tid] = read_map;
+               for (uint32_t i = old_size; i < tid + 1; i++)
+                       thrd_read_map[i] = new read_map_t();
        }
 
+       read_map_t * read_map = thrd_read_map[tid];
        read_map->put(location, read_from_val);
 
        /* Store the memory locations where atomic reads happen */
@@ -137,13 +137,12 @@ void FuncNode::store_read(ModelAction * act, uint32_t tid)
                read_locations.push_back(location);
 }
 
-uint64_t FuncNode::query_last_read(ModelAction * act, uint32_t tid)
+uint64_t FuncNode::query_last_read(void * location, uint32_t tid)
 {
        if (thrd_read_map.size() <= tid)
                return 0xdeadbeef;
 
        read_map_t * read_map = thrd_read_map[tid];
-       void * location = act->get_location();
 
        /* last read value not found */
        if ( !read_map->contains(location) )
index be6f406a4e3453b029247e8e23550deb9186cd99..f80e9266087e4bc448554ea6bb00a98d7c5f7c02 100644 (file)
@@ -26,7 +26,7 @@ public:
        void link_insts(func_inst_list_t * inst_list);
 
        void store_read(ModelAction * act, uint32_t tid);
-       uint64_t query_last_read(ModelAction * act, uint32_t tid);
+       uint64_t query_last_read(void * location, uint32_t tid);
        void clear_read_map(uint32_t tid);
 
        void print_last_read(uint32_t tid);
index abf1182315b18410e2f3275e77f98218452515d8..267205db559ebba3a06b109ca897b09d5a08d31a 100644 (file)
@@ -98,13 +98,11 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
        uint32_t id = id_to_int(tid);
        if ( thrd_func_list->size() <= id )
                return;
-//     else if ( (*thrd_func_list)[id] == NULL)
-//             return;
 
        /* get the function id that thread i is currently in */
+       uint32_t func_id = (*thrd_func_list)[id].back();
        SnapList<func_inst_list_t *> * func_inst_lists = thrd_func_inst_lists->at(id);
 
-       uint32_t func_id = (*thrd_func_list)[id].back();
        if ( func_nodes.size() <= func_id )
                resize_func_nodes( func_id + 1 );