X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0b7d1f86375fc32d181c2ab574eed9dadee72db6..a497c1d62e1064de5a4d765dc43cb9e71243ba95:/src/mc/mc_comm_determinism.cpp diff --git a/src/mc/mc_comm_determinism.cpp b/src/mc/mc_comm_determinism.cpp index 7745aa591f..3870c388c6 100644 --- a/src/mc/mc_comm_determinism.cpp +++ b/src/mc/mc_comm_determinism.cpp @@ -19,7 +19,7 @@ #include "src/mc/mc_private.h" #include "src/mc/mc_record.h" #include "src/mc/mc_smx.h" -#include "src/mc/mc_client.h" +#include "src/mc/Client.hpp" #include "src/mc/mc_exit.h" using simgrid::mc::remote; @@ -304,8 +304,7 @@ static void MC_pre_modelcheck_comm_determinism(void) int i; const int maxpid = MC_smx_get_maxpid(); - if (_sg_mc_visited > 0) - simgrid::mc::visited_states = simgrid::xbt::newDeleteDynar(); + simgrid::mc::visited_states.clear(); // Create initial_communications_pattern elements: initial_communications_pattern = xbt_dynar_new(sizeof(mc_list_comm_pattern_t), MC_list_comm_pattern_free_voidp); @@ -338,12 +337,26 @@ static void MC_pre_modelcheck_comm_determinism(void) xbt_fifo_unshift(mc_stack, initial_state); } +static inline +bool all_communications_are_finished() +{ + for (size_t current_process = 1; current_process < MC_smx_get_maxpid(); current_process++) { + xbt_dynar_t pattern = xbt_dynar_get_as( + incomplete_communications_pattern, current_process, xbt_dynar_t); + if (!xbt_dynar_is_empty(pattern)) { + XBT_DEBUG("Some communications are not finished, cannot stop the exploration ! State not visited."); + return false; + } + } + return true; +} + static int MC_modelcheck_comm_determinism_main(void) { char *req_str = nullptr; int value; - simgrid::mc::VisitedState* visited_state = nullptr; + std::unique_ptr visited_state = nullptr; smx_simcall_t req = nullptr; mc_state_t state = nullptr, next_state = NULL; @@ -393,7 +406,14 @@ static int MC_modelcheck_comm_determinism_main(void) /* Create the new expanded state */ next_state = MC_state_new(); - if ((visited_state = simgrid::mc::is_visited_state(next_state)) == nullptr) { + /* If comm determinism verification, we cannot stop the exploration if + some communications are not finished (at least, data are transfered). + These communications are incomplete and they cannot be analyzed and + compared with the initial pattern. */ + bool compare_snapshots = all_communications_are_finished() + && initial_global_state->initial_communications_pattern_done; + + if (_sg_mc_visited == 0 || (visited_state = simgrid::mc::is_visited_state(next_state, compare_snapshots)) == nullptr) { /* Get enabled processes and insert them in the interleave set of the next state */ for (auto& p : mc_model_checker->process().simix_processes()) @@ -432,8 +452,8 @@ static int MC_modelcheck_comm_determinism_main(void) visited_state = nullptr; /* Check for deadlocks */ - if (MC_deadlock_check()) { - MC_show_deadlock(nullptr); + if (mc_model_checker->checkDeadlock()) { + MC_show_deadlock(); return SIMGRID_MC_EXIT_DEADLOCK; } @@ -463,7 +483,6 @@ static int MC_modelcheck_comm_determinism_main(void) int MC_modelcheck_comm_determinism(void) { XBT_INFO("Check communication determinism"); - simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::none; mc_model_checker->wait_for_requests(); if (mc_mode == MC_MODE_CLIENT)