return act;
}
-
/**
* Processes a read model action.
* @param curr is the read model action to process.
continue;
/* Establish hypothetical release sequences */
- ClockVector *cv = get_hb_from_write(act);
- if (curr->get_cv()->merge(cv))
+ ClockVector *cv = get_hb_from_write(act->get_reads_from());
+ if (cv != NULL && curr->get_cv()->merge(cv))
updated = true;
}
}
if (act->happens_before(curr)) {
if (i==0) {
if (last_sc_fence_local == NULL ||
- (*last_sc_fence_local < *prev_same_thread)) {
+ (*last_sc_fence_local < *act)) {
prev_same_thread = act;
}
}
unsigned int i;
ASSERT(curr->is_write());
+ SnapList<ModelAction *> edgeset;
+
if (curr->is_seqcst()) {
/* We have to at least see the last sequentially consistent write,
so we are initialized. */
ModelAction *last_seq_cst = get_last_seq_cst_write(curr);
if (last_seq_cst != NULL) {
- mo_graph->addEdge(last_seq_cst, curr);
+ edgeset.push_back(last_seq_cst);
}
+ //update map for next query
+ obj_last_sc_map.put(curr->get_location(), curr);
}
/* Last SC fence in the current thread */
/* Iterate over actions in thread, starting from most recent */
action_list_t *list = &(*thrd_lists)[i];
action_list_t::reverse_iterator rit;
- bool force_edge = false;
for (rit = list->rbegin();rit != list->rend();rit++) {
ModelAction *act = *rit;
if (act == curr) {
* 3) If normal write, we need to look at earlier actions, so
* continue processing list.
*/
- force_edge = true;
if (curr->is_rmw()) {
if (curr->get_reads_from() != NULL)
break;
/* C++, Section 29.3 statement 7 */
if (last_sc_fence_thread_before && act->is_write() &&
*act < *last_sc_fence_thread_before) {
- mo_graph->addEdge(act, curr, force_edge);
+ edgeset.push_back(act);
break;
}
* readfrom(act) --mo--> act
*/
if (act->is_write())
- mo_graph->addEdge(act, curr, force_edge);
+ edgeset.push_back(act);
else if (act->is_read()) {
//if previous read accessed a null, just keep going
- mo_graph->addEdge(act->get_reads_from(), curr, force_edge);
+ edgeset.push_back(act->get_reads_from());
}
break;
}
}
}
+ mo_graph->addEdges(&edgeset, curr);
+
}
/**
void ModelExecution::add_write_to_lists(ModelAction *write) {
- // Update seq_cst map
- if (write->is_seqcst())
- obj_last_sc_map.put(write->get_location(), write);
-
SnapVector<action_list_t> *vec = get_safe_ptr_vect_action(&obj_wr_thrd_map, write->get_location());
int tid = id_to_int(write->get_tid());
if (tid >= (int)vec->size())
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);
func_counter(1), /* function id starts with 1 */
func_map(),
func_map_rev(),
- func_nodes()
+ func_nodes(),
+ write_history()
{}
void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
{
//model_print("thread %d entering func %d\n", tid, func_id);
uint32_t id = id_to_int(tid);
- SnapVector<func_id_list_t *> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+ SnapVector<func_id_list_t> * thrd_func_list = model->get_execution()->get_thrd_func_list();
SnapVector< SnapList<func_inst_list_t *> *> *
thrd_func_inst_lists = model->get_execution()->get_thrd_func_inst_lists();
thrd_func_inst_lists->resize( id + 1 );
}
- func_id_list_t * func_list = thrd_func_list->at(id);
SnapList<func_inst_list_t *> * func_inst_lists = thrd_func_inst_lists->at(id);
- if (func_list == NULL) {
- func_list = new func_id_list_t();
- thrd_func_list->at(id) = func_list;
- }
-
if (func_inst_lists == NULL) {
func_inst_lists = new SnapList< func_inst_list_t *>();
thrd_func_inst_lists->at(id) = func_inst_lists;
}
- func_list->push_back(func_id);
+ (*thrd_func_list)[id].push_back(func_id);
func_inst_lists->push_back( new func_inst_list_t() );
if ( func_nodes.size() <= func_id )
void ModelHistory::exit_function(const uint32_t func_id, thread_id_t tid)
{
uint32_t id = id_to_int(tid);
- SnapVector<func_id_list_t *> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+ SnapVector<func_id_list_t> * thrd_func_list = model->get_execution()->get_thrd_func_list();
SnapVector< SnapList<func_inst_list_t *> *> *
thrd_func_inst_lists = model->get_execution()->get_thrd_func_inst_lists();
- func_id_list_t * func_list = thrd_func_list->at(id);
SnapList<func_inst_list_t *> * func_inst_lists = thrd_func_inst_lists->at(id);
-
- uint32_t last_func_id = func_list->back();
+ uint32_t last_func_id = (*thrd_func_list)[id].back();
if (last_func_id == func_id) {
- /* clear read map upon exiting functions */
FuncNode * func_node = func_nodes[func_id];
func_node->clear_read_map(tid);
func_inst_list_t * curr_inst_list = func_inst_lists->back();
func_node->link_insts(curr_inst_list);
- func_list->pop_back();
+ (*thrd_func_list)[id].pop_back();
func_inst_lists->pop_back();
} else {
model_print("trying to exit with a wrong function id\n");
if ( old_size < new_size )
func_nodes.resize(new_size);
- for (uint32_t id = old_size; id < new_size; id++) {
+ for (uint32_t id = old_size;id < new_size;id++) {
const char * func_name = func_map_rev[id];
FuncNode * func_node = new FuncNode();
func_node->set_func_id(id);
{
/* return if thread i has not entered any function or has exited
from all functions */
- SnapVector<func_id_list_t *> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+ SnapVector<func_id_list_t> * thrd_func_list = model->get_execution()->get_thrd_func_list();
SnapVector< SnapList<func_inst_list_t *> *> *
thrd_func_inst_lists = model->get_execution()->get_thrd_func_inst_lists();
uint32_t id = id_to_int(tid);
if ( thrd_func_list->size() <= id )
return;
- else if (thrd_func_list->at(id) == NULL)
- return;
/* get the function id that thread i is currently in */
- func_id_list_t * func_list = thrd_func_list->at(id);
+ 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 = func_list->back();
-
if ( func_nodes.size() <= func_id )
resize_func_nodes( func_id + 1 );
if (inst == NULL)
return;
- if (inst->is_read())
- func_node->store_read(act, tid);
+ // if (inst->is_read())
+ // func_node->store_read(act, tid);
+ if (inst->is_write())
+ add_to_write_history(act->get_location(), act->get_write_value());
+
/* add to curr_inst_list */
func_inst_list_t * curr_inst_list = func_inst_lists->back();
ASSERT(curr_inst_list != NULL);
return func_nodes[func_id];
}
+ uint64_t ModelHistory::query_last_read(void * location, thread_id_t tid)
+ {
+ SnapVector<func_id_list_t> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+ uint32_t id = id_to_int(tid);
+
+ ASSERT( thrd_func_list->size() > id );
+ uint32_t func_id = (*thrd_func_list)[id].back();
+ FuncNode * func_node = func_nodes[func_id];
+
+ uint64_t last_read_val = 0xdeadbeef;
+ if (func_node != NULL) {
+ last_read_val = func_node->query_last_read(location, tid);
+ }
+
+ return last_read_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->add(write_val);
+ }
+
void ModelHistory::print()
{
/* function id starts with 1 */