From: Martin Quinson Date: Thu, 4 Aug 2022 19:10:48 +0000 (+0200) Subject: Pass the remote app as a parameter to all exploration signals X-Git-Tag: v3.32~93 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5b1ee8633a381a8704b7cb0b7c9c47d3e24d5f7a Pass the remote app as a parameter to all exploration signals When we'll have reforks in the future, the remote app may change during the exploration, so we don't want to seal the current remote app in the callback closure. We want to use the fresh one instead. --- diff --git a/src/mc/explo/CommunicationDeterminismChecker.cpp b/src/mc/explo/CommunicationDeterminismChecker.cpp index 109a220706..082b0eb386 100644 --- a/src/mc/explo/CommunicationDeterminismChecker.cpp +++ b/src/mc/explo/CommunicationDeterminismChecker.cpp @@ -329,18 +329,20 @@ Exploration* create_communication_determinism_checker(RemoteApp& remote_app) auto base = new DFSExplorer(remote_app); auto extension = new CommDetExtension(*base); - DFSExplorer::on_exploration_start([extension]() { + DFSExplorer::on_exploration_start([extension](RemoteApp&) { XBT_INFO("Check communication determinism"); extension->exploration_start(); }); - DFSExplorer::on_backtracking([extension]() { extension->initial_communications_pattern_done = true; }); - DFSExplorer::on_state_creation( - [extension, &remote_app](State* state) { state->extension_set(new StateCommDet(*extension, remote_app)); }); + DFSExplorer::on_backtracking([extension](RemoteApp&) { extension->initial_communications_pattern_done = true; }); + DFSExplorer::on_state_creation([extension](State* state, RemoteApp& remote_app) { + state->extension_set(new StateCommDet(*extension, remote_app)); + }); - DFSExplorer::on_restore_system_state( - [extension, &remote_app](State* state) { extension->restore_communications_pattern(state, remote_app); }); + DFSExplorer::on_restore_system_state([extension](State* state, RemoteApp& remote_app) { + extension->restore_communications_pattern(state, remote_app); + }); - DFSExplorer::on_restore_initial_state([extension, &remote_app]() { + DFSExplorer::on_restore_initial_state([extension](RemoteApp& remote_app) { const unsigned long maxpid = remote_app.get_maxpid(); assert(maxpid == extension->incomplete_communications_pattern.size()); assert(maxpid == extension->initial_communications_pattern.size()); @@ -350,10 +352,10 @@ Exploration* create_communication_determinism_checker(RemoteApp& remote_app) } }); - DFSExplorer::on_transition_replay([extension](Transition* t) { extension->handle_comm_pattern(t); }); - DFSExplorer::on_transition_execute([extension](Transition* t) { extension->handle_comm_pattern(t); }); + DFSExplorer::on_transition_replay([extension](Transition* t, RemoteApp&) { extension->handle_comm_pattern(t); }); + DFSExplorer::on_transition_execute([extension](Transition* t, RemoteApp&) { extension->handle_comm_pattern(t); }); - DFSExplorer::on_log_state([extension]() { + DFSExplorer::on_log_state([extension](RemoteApp&) { if (_sg_mc_comms_determinism) { if (extension->send_deterministic && not extension->recv_deterministic) { XBT_INFO("*******************************************************"); diff --git a/src/mc/explo/DFSExplorer.cpp b/src/mc/explo/DFSExplorer.cpp index a60383e420..edd9eee4be 100644 --- a/src/mc/explo/DFSExplorer.cpp +++ b/src/mc/explo/DFSExplorer.cpp @@ -26,17 +26,17 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dfs, mc, "DFS exploration algorithm of the mo namespace simgrid::mc { -xbt::signal DFSExplorer::on_exploration_start_signal; -xbt::signal DFSExplorer::on_backtracking_signal; +xbt::signal DFSExplorer::on_exploration_start_signal; +xbt::signal DFSExplorer::on_backtracking_signal; -xbt::signal DFSExplorer::on_state_creation_signal; +xbt::signal DFSExplorer::on_state_creation_signal; -xbt::signal DFSExplorer::on_restore_system_state_signal; -xbt::signal DFSExplorer::on_restore_initial_state_signal; -xbt::signal DFSExplorer::on_transition_replay_signal; -xbt::signal DFSExplorer::on_transition_execute_signal; +xbt::signal DFSExplorer::on_restore_system_state_signal; +xbt::signal DFSExplorer::on_restore_initial_state_signal; +xbt::signal DFSExplorer::on_transition_replay_signal; +xbt::signal DFSExplorer::on_transition_execute_signal; -xbt::signal DFSExplorer::on_log_state_signal; +xbt::signal DFSExplorer::on_log_state_signal; void DFSExplorer::check_non_termination(const State* current_state) { @@ -76,7 +76,7 @@ std::vector DFSExplorer::get_textual_trace() // override void DFSExplorer::log_state() // override { - on_log_state_signal(); + on_log_state_signal(get_remote_app()); XBT_INFO("DFS exploration ended. %ld unique states visited; %ld backtracks (%lu transition replays, %lu states " "visited overall)", State::get_expanded_states(), backtrack_count_, mc_model_checker->get_visited_states(), @@ -85,7 +85,7 @@ void DFSExplorer::log_state() // override void DFSExplorer::run() { - on_exploration_start_signal(); + on_exploration_start_signal(get_remote_app()); /* This function runs the DFS algorithm the state space. * We do so iteratively instead of recursively, dealing with the call stack manually. * This allows one to explore the call stack at will. */ @@ -140,7 +140,7 @@ void DFSExplorer::run() /* Actually answer the request: let's execute the selected request (MCed does one step) */ state->execute_next(next); - on_transition_execute_signal(state->get_transition()); + on_transition_execute_signal(state->get_transition(), get_remote_app()); // If there are processes to interleave and the maximum depth has not been // reached then perform one step of the exploration algorithm. @@ -149,7 +149,7 @@ void DFSExplorer::run() /* Create the new expanded state (copy the state of MCed into our MCer data) */ auto next_state = std::make_unique(get_remote_app()); - on_state_creation_signal(next_state.get()); + on_state_creation_signal(next_state.get(), get_remote_app()); if (_sg_mc_termination) this->check_non_termination(next_state.get()); @@ -188,7 +188,7 @@ void DFSExplorer::backtrack() { backtrack_count_++; XBT_VERB("Backtracking from %s", get_record_trace().to_string().c_str()); - on_backtracking_signal(); + on_backtracking_signal(get_remote_app()); stack_.pop_back(); get_remote_app().check_deadlock(); @@ -247,20 +247,20 @@ void DFSExplorer::restore_state() State* last_state = stack_.back().get(); if (const auto* system_state = last_state->get_system_state()) { Api::get().restore_state(system_state); - on_restore_system_state_signal(last_state); + on_restore_system_state_signal(last_state, get_remote_app()); return; } /* if no snapshot, we need to restore the initial state and replay the transitions */ get_remote_app().restore_initial_state(); - on_restore_initial_state_signal(); + on_restore_initial_state_signal(get_remote_app()); /* Traverse the stack from the state at position start and re-execute the transitions */ for (std::unique_ptr const& state : stack_) { if (state == stack_.back()) /* If we are arrived on the target state, don't replay the outgoing transition */ break; state->get_transition()->replay(); - on_transition_replay_signal(state->get_transition()); + on_transition_replay_signal(state->get_transition(), get_remote_app()); /* Update statistics */ mc_model_checker->inc_visited_states(); } diff --git a/src/mc/explo/DFSExplorer.hpp b/src/mc/explo/DFSExplorer.hpp index 0eaac540a5..161781bfc1 100644 --- a/src/mc/explo/DFSExplorer.hpp +++ b/src/mc/explo/DFSExplorer.hpp @@ -21,17 +21,17 @@ class XBT_PRIVATE DFSExplorer : public Exploration { ReductionMode reductionMode_ = ReductionMode::unset; long backtrack_count_ = 0; - static xbt::signal on_exploration_start_signal; - static xbt::signal on_backtracking_signal; + static xbt::signal on_exploration_start_signal; + static xbt::signal on_backtracking_signal; - static xbt::signal on_state_creation_signal; + static xbt::signal on_state_creation_signal; - static xbt::signal on_restore_system_state_signal; - static xbt::signal on_restore_initial_state_signal; - static xbt::signal on_transition_replay_signal; - static xbt::signal on_transition_execute_signal; + static xbt::signal on_restore_system_state_signal; + static xbt::signal on_restore_initial_state_signal; + static xbt::signal on_transition_replay_signal; + static xbt::signal on_transition_execute_signal; - static xbt::signal on_log_state_signal; + static xbt::signal on_log_state_signal; public: explicit DFSExplorer(RemoteApp& remote_app); @@ -41,31 +41,43 @@ public: void log_state() override; /** Called once when the exploration starts */ - static void on_exploration_start(std::function const& f) { on_exploration_start_signal.connect(f); } + static void on_exploration_start(std::function const& f) + { + on_exploration_start_signal.connect(f); + } /** Called each time that the exploration backtracks from a exploration end */ - static void on_backtracking(std::function const& f) { on_backtracking_signal.connect(f); } + static void on_backtracking(std::function const& f) + { + on_backtracking_signal.connect(f); + } /** Called each time that a new state is create */ - static void on_state_creation(std::function const& f) { on_state_creation_signal.connect(f); } + static void on_state_creation(std::function const& f) + { + on_state_creation_signal.connect(f); + } /** Called when rollbacking directly onto a previously checkpointed state */ - static void on_restore_system_state(std::function const& f) + static void on_restore_system_state(std::function const& f) { on_restore_system_state_signal.connect(f); } /** Called when the state to which we backtrack was not checkpointed state, forcing us to restore the initial state * before replaying some transitions */ - static void on_restore_initial_state(std::function const& f) { on_restore_initial_state_signal.connect(f); } + static void on_restore_initial_state(std::function const& f) + { + on_restore_initial_state_signal.connect(f); + } /** Called when replaying a transition that was previously executed, to reach a backtracked state */ - static void on_transition_replay(std::function const& f) + static void on_transition_replay(std::function const& f) { on_transition_replay_signal.connect(f); } /** Called when executing a new transition */ - static void on_transition_execute(std::function const& f) + static void on_transition_execute(std::function const& f) { on_transition_execute_signal.connect(f); } /** Called when displaying the statistics at the end of the exploration */ - static void on_log_state(std::function const& f) { on_log_state_signal.connect(f); } + static void on_log_state(std::function const& f) { on_log_state_signal.connect(f); } private: void check_non_termination(const State* current_state);