X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dc6b95dec8c8c9c6f6aba852061d2e469c21aca1..69aaa26fa5228c31e55086fa166479732a9cd1b7:/src/mc/checker/CommunicationDeterminismChecker.cpp diff --git a/src/mc/checker/CommunicationDeterminismChecker.cpp b/src/mc/checker/CommunicationDeterminismChecker.cpp index 5192439f62..9175947c95 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.cpp +++ b/src/mc/checker/CommunicationDeterminismChecker.cpp @@ -5,10 +5,10 @@ #include "src/mc/checker/CommunicationDeterminismChecker.hpp" #include "src/kernel/activity/MailboxImpl.hpp" +#include "src/mc/Session.hpp" #include "src/mc/mc_config.hpp" #include "src/mc/mc_exit.hpp" #include "src/mc/mc_private.hpp" -#include "src/mc/mc_request.hpp" #include @@ -59,7 +59,8 @@ static void restore_communications_pattern(simgrid::mc::State* state) for (size_t i = 0; i < initial_communications_pattern.size(); i++) initial_communications_pattern[i].index_comm = state->communication_indices_[i]; - for (unsigned long i = 0; i < api::get().get_maxpid(); i++) + const unsigned long maxpid = api::get().get_maxpid(); + for (unsigned long i = 0; i < maxpid; i++) patterns_copy(incomplete_communications_pattern[i], state->incomplete_comm_pattern_[i]); } @@ -235,8 +236,7 @@ void CommunicationDeterminismChecker::complete_comm_pattern(RemotePtrcomm_addr == comm_addr); }); - if (current_comm_pattern == std::end(incomplete_pattern)) - xbt_die("Corresponding communication not found!"); + xbt_assert(current_comm_pattern != std::end(incomplete_pattern), "Corresponding communication not found!"); update_comm_pattern(*current_comm_pattern, comm_addr); std::unique_ptr comm_pattern(*current_comm_pattern); @@ -254,7 +254,7 @@ void CommunicationDeterminismChecker::complete_comm_pattern(RemotePtr CommunicationDeterminismChecker::get_textual_trace() // std::vector trace; for (auto const& state : stack_) { smx_simcall_t req = &state->executed_req_; - trace.push_back(api::get().request_to_string(req, state->transition_.times_considered_, RequestType::executed)); + trace.push_back(api::get().request_to_string(req, state->transition_.times_considered_)); } return trace; } @@ -302,7 +302,7 @@ void CommunicationDeterminismChecker::log_state() // override void CommunicationDeterminismChecker::prepare() { - const auto maxpid = api::get().get_maxpid(); + const unsigned long maxpid = api::get().get_maxpid(); initial_communications_pattern.resize(maxpid); incomplete_communications_pattern.resize(maxpid); @@ -312,18 +312,19 @@ void CommunicationDeterminismChecker::prepare() XBT_DEBUG("********* Start communication determinism verification *********"); - /* Get an enabled actor and insert it in the interleave set of the initial state */ - auto actors = api::get().get_actors(); - for (auto& actor : actors) - if (api::get().actor_is_enabled(actor.copy.get_buffer()->get_pid())) - initial_state->mark_todo(actor.copy.get_buffer()); + /* Add all enabled actors to the interleave set of the initial state */ + for (auto& act : api::get().get_actors()) { + auto actor = act.copy.get_buffer(); + if (get_session().actor_is_enabled(actor->get_pid())) + initial_state->mark_todo(actor); + } stack_.push_back(std::move(initial_state)); } static inline bool all_communications_are_finished() { - auto maxpid = api::get().get_maxpid(); + const unsigned long maxpid = api::get().get_maxpid(); for (size_t current_actor = 1; current_actor < maxpid; current_actor++) { if (not incomplete_communications_pattern[current_actor].empty()) { XBT_DEBUG("Some communications are not finished, cannot stop the exploration! State not visited."); @@ -343,13 +344,12 @@ void CommunicationDeterminismChecker::restoreState() return; } - /* Restore the initial state */ - api::get().restore_initial_state(); + get_session().restore_initial_state(); - unsigned long n = api::get().get_maxpid(); - assert(n == incomplete_communications_pattern.size()); - assert(n == initial_communications_pattern.size()); - for (unsigned long j = 0; j < n; j++) { + const unsigned long maxpid = api::get().get_maxpid(); + assert(maxpid == incomplete_communications_pattern.size()); + assert(maxpid == initial_communications_pattern.size()); + for (unsigned long j = 0; j < maxpid; j++) { incomplete_communications_pattern[j].clear(); initial_communications_pattern[j].index_comm = 0; } @@ -395,7 +395,7 @@ void CommunicationDeterminismChecker::handle_comm_pattern(simgrid::mc::CallType case CallType::WAITANY: { RemotePtr comm_addr; if (call_type == CallType::WAIT) - comm_addr = api::get().get_comm_wait_raw_addr(req); + comm_addr = remote(simcall_comm_wait__getraw__comm(req)); else comm_addr = api::get().get_comm_waitany_raw_addr(req, value); auto simcall_issuer = api::get().simcall_get_issuer(req); @@ -430,7 +430,7 @@ void CommunicationDeterminismChecker::real_run() if (req != nullptr && visited_state == nullptr) { int req_num = cur_state->transition_.times_considered_; - XBT_DEBUG("Execute: %s", api::get().request_to_string(req, req_num, RequestType::simix).c_str()); + XBT_DEBUG("Execute: %s", api::get().request_to_string(req, req_num).c_str()); std::string req_str; if (dot_output != nullptr) @@ -467,11 +467,12 @@ void CommunicationDeterminismChecker::real_run() visited_state = nullptr; if (visited_state == nullptr) { - /* Get enabled actors and insert them in the interleave set of the next state */ - auto actors = api::get().get_actors(); - for (auto& actor : actors) - if (api::get().actor_is_enabled(actor.copy.get_buffer()->get_pid())) - next_state->mark_todo(actor.copy.get_buffer()); + /* Add all enabled actors to the interleave set of the next state */ + for (auto& act : api::get().get_actors()) { + auto actor = act.copy.get_buffer(); + if (get_session().actor_is_enabled(actor->get_pid())) + next_state->mark_todo(actor); + } if (dot_output != nullptr) fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", cur_state->num_, next_state->num_, req_str.c_str()); @@ -526,15 +527,15 @@ void CommunicationDeterminismChecker::real_run() void CommunicationDeterminismChecker::run() { XBT_INFO("Check communication determinism"); - api::get().session_initialize(); + get_session().take_initial_snapshot(); this->prepare(); this->real_run(); } -Checker* createCommunicationDeterminismChecker() +Checker* create_communication_determinism_checker(Session* session) { - return new CommunicationDeterminismChecker(); + return new CommunicationDeterminismChecker(session); } } // namespace mc