From: mlaurent Date: Fri, 17 Mar 2023 15:55:22 +0000 (+0100) Subject: Add reference to parent state: only use this creation in DFSexplorer X-Git-Tag: v3.34~318^2 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/28b9e83a90c238b71d27f5cb3c6596906a3d4641 Add reference to parent state: only use this creation in DFSexplorer --- diff --git a/src/mc/api/State.cpp b/src/mc/api/State.cpp index 8894219547..6577e1bf8c 100644 --- a/src/mc/api/State.cpp +++ b/src/mc/api/State.cpp @@ -25,35 +25,37 @@ State::State(RemoteApp& remote_app) : num_(++expended_states_) remote_app.get_remote_process_memory()); } -State::State(RemoteApp& remote_app, const State* previous_state) - : default_transition_(std::make_unique()), num_(++expended_states_) +State::State(RemoteApp& remote_app, const State* parent_state) + : num_(++expended_states_), parent_state_(parent_state) { remote_app.get_actors_status(actors_to_run_); - transition_ = default_transition_.get(); - /* Stateful model checking */ if ((_sg_mc_checkpoint > 0 && (num_ % _sg_mc_checkpoint == 0)) || _sg_mc_termination) system_state_ = std::make_shared(num_, remote_app.get_page_store(), remote_app.get_remote_process_memory()); - /* For each actor in the previous sleep set, keep it if it is not dependent with current transition. - * And if we kept it and the actor is enabled in this state, mark the actor as already done, so that - * it is not explored*/ - for (auto& [aid, transition] : previous_state->get_sleep_set()) { - - if (not previous_state->get_transition()->depends(&transition)) { - - sleep_set_.emplace(aid, transition); - if (actors_to_run_.count(aid) != 0) { - XBT_DEBUG("Actor %ld will not be explored, for it is in the sleep set", aid); - - actors_to_run_.at(aid).mark_done(); + + /* If we want sleep set reduction, copy the sleep set and eventually removes things from it */ + if (_sg_mc_sleep_set) { + /* For each actor in the previous sleep set, keep it if it is not dependent with current transition. + * And if we kept it and the actor is enabled in this state, mark the actor as already done, so that + * it is not explored*/ + for (auto& [aid, transition] : parent_state_->get_sleep_set()) { + + if (not parent_state_->get_transition()->depends(&transition)) { + + sleep_set_.emplace(aid, transition); + if (actors_to_run_.count(aid) != 0) { + XBT_DEBUG("Actor %ld will not be explored, for it is in the sleep set", aid); + + actors_to_run_.at(aid).mark_done(); + } + } else + XBT_DEBUG("Transition >>%s<< removed from the sleep set because it was dependent with >>%s<<", + transition.to_string().c_str(), parent_state_->get_transition()->to_string().c_str()); } - } else - XBT_DEBUG("Transition >>%s<< removed from the sleep set because it was dependent with >>%s<<", - transition.to_string().c_str(), previous_state->get_transition()->to_string().c_str()); } } diff --git a/src/mc/api/State.hpp b/src/mc/api/State.hpp index 5eb96feed8..06c6c5680f 100644 --- a/src/mc/api/State.hpp +++ b/src/mc/api/State.hpp @@ -42,6 +42,10 @@ class XBT_PRIVATE State : public xbt::Extendable { /** Snapshot of system state (if needed) */ std::shared_ptr system_state_; + /** Unique parent of this state. Required both for sleep set computation + and for guided model-checking */ + const State* parent_state_; + /* Sleep sets are composed of the actor and the corresponding transition that made it being added to the sleep * set. With this information, it is check whether it should be removed from it or not when exploring a new * transition */ @@ -49,7 +53,7 @@ class XBT_PRIVATE State : public xbt::Extendable { public: explicit State(RemoteApp& remote_app); - explicit State(RemoteApp& remote_app, const State* previous_state); + explicit State(RemoteApp& remote_app, const State* parent_state); /* Returns a positive number if there is another transition to pick, or -1 if not */ aid_t next_transition() const; diff --git a/src/mc/explo/DFSExplorer.cpp b/src/mc/explo/DFSExplorer.cpp index 951a48ac97..761e13637b 100644 --- a/src/mc/explo/DFSExplorer.cpp +++ b/src/mc/explo/DFSExplorer.cpp @@ -163,12 +163,7 @@ void DFSExplorer::run() /* Create the new expanded state (copy the state of MCed into our MCer data) */ std::unique_ptr next_state; - /* If we want sleep set reduction, pass the old state to the new state so it can - * both copy the sleep set and eventually removes things from it locally */ - if (_sg_mc_sleep_set) - next_state = std::make_unique(get_remote_app(), state); - else - next_state = std::make_unique(get_remote_app()); + next_state = std::make_unique(get_remote_app(), state); on_state_creation_signal(next_state.get(), get_remote_app());