Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add reference to parent state: only use this creation in DFSexplorer
authormlaurent <mathieu.laurent@ens-rennes.fr>
Fri, 17 Mar 2023 15:55:22 +0000 (16:55 +0100)
committermlaurent <mathieu.laurent@ens-rennes.fr>
Fri, 17 Mar 2023 15:55:22 +0000 (16:55 +0100)
src/mc/api/State.cpp
src/mc/api/State.hpp
src/mc/explo/DFSExplorer.cpp

index 8894219..6577e1b 100644 (file)
@@ -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<Transition>()), 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<simgrid::mc::Snapshot>(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());
   }
 }
 
index 5eb96fe..06c6c56 100644 (file)
@@ -42,6 +42,10 @@ class XBT_PRIVATE State : public xbt::Extendable<State> {
   /** Snapshot of system state (if needed) */
   std::shared_ptr<Snapshot> 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<State> {
   
 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;
 
index 951a48a..761e136 100644 (file)
@@ -163,12 +163,7 @@ void DFSExplorer::run()
     /* Create the new expanded state (copy the state of MCed into our MCer data) */
     std::unique_ptr<State> 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<State>(get_remote_app(), state);
-    else
-      next_state = std::make_unique<State>(get_remote_app());
+    next_state = std::make_unique<State>(get_remote_app(), state);
 
     on_state_creation_signal(next_state.get(), get_remote_app());