From: weiyu Date: Thu, 13 Feb 2020 01:34:01 +0000 (-0800) Subject: Assign each predicate's initial weight ad 100. Remove some unused function and data... X-Git-Url: http://demsky.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=84be13530714785804bfdb52d2ae4114e6c3bbbf Assign each predicate's initial weight ad 100. Remove some unused function and data structures --- diff --git a/funcnode.cc b/funcnode.cc index c01173ae..5a0969d2 100644 --- a/funcnode.cc +++ b/funcnode.cc @@ -22,8 +22,6 @@ FuncNode::FuncNode(ModelHistory * history) : thrd_loc_inst_map(), thrd_predicate_tree_position(), thrd_predicate_trace(), - predicate_leaves(), - leaves_tmp_storage(), failed_predicates(), edge_table(32), out_edges() @@ -353,8 +351,6 @@ void FuncNode::update_predicate_tree(ModelAction * next_act) add_predicate_to_trace(tid, curr_pred); break; } - -// leaves_tmp_storage.push_back(curr_pred); } /* Given curr_pred and next_inst, find the branch following curr_pred that @@ -496,10 +492,6 @@ void FuncNode::generate_predicates(Predicate * curr_pred, FuncInst * next_inst, curr_pred->add_child(new_pred); new_pred->set_parent(curr_pred); - /* Maintain predicate leaves */ - predicate_leaves.add(new_pred); - predicate_leaves.remove(curr_pred); - /* entry predicates and predicates containing pure write actions * have no predicate expressions */ if ( curr_pred->is_entry_predicate() ) @@ -541,14 +533,8 @@ void FuncNode::generate_predicates(Predicate * curr_pred, FuncInst * next_inst, Predicate * pred= predicates[i]; curr_pred->add_child(pred); pred->set_parent(curr_pred); - - /* Add new predicate leaves */ - predicate_leaves.add(pred); } - /* Remove predicate node that has children */ - predicate_leaves.remove(curr_pred); - /* Free memories allocated by infer_predicate */ for (uint i = 0;i < half_pred_expressions->size();i++) { struct half_pred_expr * tmp = (*half_pred_expressions)[i]; @@ -846,41 +832,6 @@ void FuncNode::add_failed_predicate(Predicate * pred) failed_predicates.add(pred); } -/* Implement quick sort to sort leaves before assigning base scores */ -template -static int partition(ModelVector<_Tp *> * arr, int low, int high) -{ - unsigned int pivot = (*arr)[high] -> get_depth(); - int i = low - 1; - - for (int j = low;j <= high - 1;j ++) { - if ( (*arr)[j] -> get_depth() < pivot ) { - i ++; - _Tp * tmp = (*arr)[i]; - (*arr)[i] = (*arr)[j]; - (*arr)[j] = tmp; - } - } - - _Tp * tmp = (*arr)[i + 1]; - (*arr)[i + 1] = (*arr)[high]; - (*arr)[high] = tmp; - - return i + 1; -} - -/* Implement quick sort to sort leaves before assigning base scores */ -template -static void quickSort(ModelVector<_Tp *> * arr, int low, int high) -{ - if (low < high) { - int pi = partition(arr, low, high); - - quickSort(arr, low, pi - 1); - quickSort(arr, pi + 1, high); - } -} - void FuncNode::update_predicate_tree_weight(thread_id_t tid) { failed_predicates.reset(); @@ -890,13 +841,13 @@ void FuncNode::update_predicate_tree_weight(thread_id_t tid) // Update predicate weights based on prediate trace for (mllnode * rit = trace->end(); rit != NULL; rit = rit->getPrev()) { Predicate * node = rit->getVal(); + ModelVector * children = node->get_children(); - if (predicate_leaves.contains(node)) { + if (children->size() == 0) { double weight = 100.0 / sqrt(node->get_expl_count() + node->get_fail_count() + 1); node->set_weight(weight); } else { double weight_sum = 0.0; - ModelVector * children = node->get_children(); for (uint i = 0;i < children->size();i++) { Predicate * child = (*children)[i]; double weight = child->get_weight(); diff --git a/funcnode.h b/funcnode.h index d8b0bc1a..354534d5 100644 --- a/funcnode.h +++ b/funcnode.h @@ -9,12 +9,12 @@ #define MAX_DIST 10 typedef ModelList func_inst_list_mt; +typedef ModelList predicate_trace_t; + typedef HashTable loc_inst_map_t; typedef HashTable inst_id_map_t; typedef HashTable inst_pred_map_t; -typedef ModelList predicate_trace_t; - typedef enum edge_type { IN_EDGE, OUT_EDGE, BI_EDGE } edge_type_t; @@ -136,8 +136,6 @@ private: void init_predicate_tree_data_structure(thread_id_t tid); void reset_predicate_tree_data_structure(thread_id_t tid); - PredSet predicate_leaves; - ModelVector leaves_tmp_storage; PredSet failed_predicates; /* Store the relation between this FuncNode and other FuncNodes */ diff --git a/predicate.cc b/predicate.cc index 22fb0c7e..44f5e8d1 100644 --- a/predicate.cc +++ b/predicate.cc @@ -8,7 +8,7 @@ Predicate::Predicate(FuncInst * func_inst, bool is_entry, bool is_exit) : exit_predicate(is_exit), does_write(false), depth(0), - weight(0), + weight(100), exploration_count(0), store_visible_count(0), total_checking_count(0),