X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1c99636ddba1ba34a07f2ac4b0b58a5e7f1afb72..2376a01092173679830310f4d57b267445959f97:/src/mc/CommunicationDeterminismChecker.cpp diff --git a/src/mc/CommunicationDeterminismChecker.cpp b/src/mc/CommunicationDeterminismChecker.cpp index 1f5f320704..ae4e36c11e 100644 --- a/src/mc/CommunicationDeterminismChecker.cpp +++ b/src/mc/CommunicationDeterminismChecker.cpp @@ -28,8 +28,6 @@ using simgrid::mc::remote; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_comm_determinism, mc, "Logging specific to MC communication determinism detection"); -XBT_PRIVATE static xbt_fifo_t mc_stack; - /********** Global variables **********/ xbt_dynar_t initial_communications_pattern; @@ -317,40 +315,31 @@ CommunicationDeterminismChecker::~CommunicationDeterminismChecker() RecordTrace CommunicationDeterminismChecker::getRecordTrace() // override { RecordTrace res; - - xbt_fifo_item_t start = xbt_fifo_get_last_item(mc_stack); - for (xbt_fifo_item_t item = start; item; item = xbt_fifo_get_prev_item(item)) { - - // Find (pid, value): - simgrid::mc::State* state = (simgrid::mc::State*) xbt_fifo_get_item_content(item); + for (simgrid::mc::State* state : stack_) { int value = 0; smx_simcall_t saved_req = MC_state_get_executed_request(state, &value); const smx_process_t issuer = MC_smx_simcall_get_issuer(saved_req); const int pid = issuer->pid; - res.push_back(RecordTraceElement(pid, value)); } - return res; } // TODO, deduplicate with SafetyChecker std::vector CommunicationDeterminismChecker::getTextualTrace() // override { - std::vector res; - for (xbt_fifo_item_t item = xbt_fifo_get_last_item(mc_stack); - item; item = xbt_fifo_get_prev_item(item)) { - simgrid::mc::State* state = (simgrid::mc::State*)xbt_fifo_get_item_content(item); + std::vector trace; + for (simgrid::mc::State* state : stack_) { int value; smx_simcall_t req = MC_state_get_executed_request(state, &value); if (req) { char* req_str = simgrid::mc::request_to_string( req, value, simgrid::mc::RequestType::executed); - res.push_back(req_str); + trace.push_back(req_str); xbt_free(req_str); } } - return res; + return trace; } void CommunicationDeterminismChecker::prepare() @@ -389,7 +378,7 @@ void CommunicationDeterminismChecker::prepare() if (simgrid::mc::process_is_enabled(&p.copy)) MC_state_interleave_process(initial_state, &p.copy); - xbt_fifo_unshift(mc_stack, initial_state); + stack_.push_back(initial_state); } static inline @@ -413,23 +402,22 @@ int CommunicationDeterminismChecker::main(void) int value; std::unique_ptr visited_state = nullptr; smx_simcall_t req = nullptr; - simgrid::mc::State* state = nullptr; simgrid::mc::State* next_state = nullptr; - while (xbt_fifo_size(mc_stack) > 0) { + while (!stack_.empty()) { /* Get current state */ - state = (simgrid::mc::State*) xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack)); + simgrid::mc::State* state = stack_.back(); XBT_DEBUG("**************************************************"); - XBT_DEBUG("Exploration depth = %d (state = %d, interleaved processes = %d)", - xbt_fifo_size(mc_stack), state->num, + XBT_DEBUG("Exploration depth = %zi (state = %d, interleaved processes = %d)", + stack_.size(), state->num, MC_state_interleave_size(state)); /* Update statistics */ mc_stats->visited_states++; - if ((xbt_fifo_size(mc_stack) <= _sg_mc_max_depth) + if (stack_.size() <= _sg_mc_max_depth && (req = MC_state_get_request(state, &value)) && (visited_state == nullptr)) { @@ -483,27 +471,29 @@ int CommunicationDeterminismChecker::main(void) fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num, visited_state->other_num == -1 ? visited_state->num : visited_state->other_num, req_str); - xbt_fifo_unshift(mc_stack, next_state); + stack_.push_back(next_state); if (dot_output != nullptr) xbt_free(req_str); } else { - if (xbt_fifo_size(mc_stack) > _sg_mc_max_depth) + if (stack_.size() > _sg_mc_max_depth) XBT_WARN("/!\\ Max depth reached ! /!\\ "); else if (visited_state != nullptr) XBT_DEBUG("State already visited (equal to state %d), exploration stopped on this path.", visited_state->other_num == -1 ? visited_state->num : visited_state->other_num); else - XBT_DEBUG("There are no more processes to interleave. (depth %d)", xbt_fifo_size(mc_stack)); + XBT_DEBUG("There are no more processes to interleave. (depth %zi)", + stack_.size()); if (!initial_global_state->initial_communications_pattern_done) initial_global_state->initial_communications_pattern_done = 1; /* Trash the current state, no longer needed */ - xbt_fifo_shift(mc_stack); + stack_.pop_back(); MC_state_delete(state, !state->in_visited_states ? 1 : 0); - XBT_DEBUG("Delete state %d at depth %d", state->num, xbt_fifo_size(mc_stack) + 1); + XBT_DEBUG("Delete state %d at depth %zi", + state->num, stack_.size() + 1); visited_state = nullptr; @@ -513,22 +503,28 @@ int CommunicationDeterminismChecker::main(void) return SIMGRID_MC_EXIT_DEADLOCK; } - while ((state = (simgrid::mc::State*) xbt_fifo_shift(mc_stack)) != nullptr) - if (MC_state_interleave_size(state) && xbt_fifo_size(mc_stack) < _sg_mc_max_depth) { + while (!stack_.empty()) { + simgrid::mc::State* state = stack_.back(); + stack_.pop_back(); + if (MC_state_interleave_size(state) + && stack_.size() < _sg_mc_max_depth) { /* We found a back-tracking point, let's loop */ - XBT_DEBUG("Back-tracking to state %d at depth %d", state->num, xbt_fifo_size(mc_stack) + 1); - xbt_fifo_unshift(mc_stack, state); + XBT_DEBUG("Back-tracking to state %d at depth %zi", + state->num, stack_.size() + 1); + stack_.push_back(state); - MC_replay(mc_stack); + simgrid::mc::replay(stack_); - XBT_DEBUG("Back-tracking to state %d at depth %d done", state->num, xbt_fifo_size(mc_stack)); + XBT_DEBUG("Back-tracking to state %d at depth %zi done", + state->num, stack_.size()); break; } else { - XBT_DEBUG("Delete state %d at depth %d", state->num, xbt_fifo_size(mc_stack) + 1); + XBT_DEBUG("Delete state %d at depth %zi", + state->num, stack_.size() + 1); MC_state_delete(state, !state->in_visited_states ? 1 : 0); } - + } } } @@ -545,9 +541,6 @@ int CommunicationDeterminismChecker::run() // This will move somehwere else: simgrid::mc::Client::get()->handleMessages(); - /* Create exploration stack */ - mc_stack = xbt_fifo_new(); - this->prepare(); initial_global_state = std::unique_ptr(new s_mc_global_t());