Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Dead code elimination.
[simgrid.git] / src / mc / explo / CommunicationDeterminismChecker.cpp
index e2b5d55..bd4fa6e 100644 (file)
@@ -4,8 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/activity/MailboxImpl.hpp"
-#include "src/mc/Session.hpp"
-#include "src/mc/explo/SafetyChecker.hpp"
+#include "src/mc/explo/DFSExplorer.hpp"
 #include "src/mc/mc_config.hpp"
 #include "src/mc/mc_exit.hpp"
 #include "src/mc/mc_forward.hpp"
@@ -15,8 +14,6 @@
 
 #include <cstdint>
 
-using api = simgrid::mc::Api;
-
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_comm_determinism, mc, "Logging specific to MC communication determinism detection");
 
 namespace simgrid {
@@ -78,7 +75,7 @@ struct CommDetExtension {
 
   void exploration_start()
   {
-    const unsigned long maxpid = api::get().get_maxpid();
+    const unsigned long maxpid = Api::get().get_maxpid();
 
     initial_communications_pattern.resize(maxpid);
     incomplete_communications_pattern.resize(maxpid);
@@ -93,24 +90,22 @@ simgrid::xbt::Extension<simgrid::mc::Exploration, CommDetExtension> CommDetExten
 /********** State Extension ***********/
 
 class StateCommDet {
-  CommDetExtension* checker_;
-
 public:
   std::vector<std::vector<simgrid::mc::PatternCommunication>> incomplete_comm_pattern_;
   std::vector<unsigned> communication_indices_;
 
   static simgrid::xbt::Extension<simgrid::mc::State, StateCommDet> EXTENSION_ID;
-  explicit StateCommDet(CommDetExtension* checker) : checker_(checker)
+  explicit StateCommDet(CommDetExtension* checker)
   {
-    const unsigned long maxpid = api::get().get_maxpid();
+    const unsigned long maxpid = Api::get().get_maxpid();
     for (unsigned long i = 0; i < maxpid; i++) {
       std::vector<simgrid::mc::PatternCommunication> res;
-      for (auto const& comm : checker_->incomplete_communications_pattern[i])
+      for (auto const& comm : checker->incomplete_communications_pattern[i])
         res.push_back(comm->dup());
       incomplete_comm_pattern_.push_back(std::move(res));
     }
 
-    for (auto const& list_process_comm : checker_->initial_communications_pattern)
+    for (auto const& list_process_comm : checker->initial_communications_pattern)
       this->communication_indices_.push_back(list_process_comm.index_comm);
   }
 };
@@ -141,7 +136,7 @@ void CommDetExtension::restore_communications_pattern(const simgrid::mc::State*
     initial_communications_pattern[i].index_comm =
         state->extension<simgrid::mc::StateCommDet>()->communication_indices_[i];
 
-  const unsigned long maxpid = api::get().get_maxpid();
+  const unsigned long maxpid = Api::get().get_maxpid();
   for (unsigned long i = 0; i < maxpid; i++) {
     incomplete_communications_pattern[i].clear();
     for (simgrid::mc::PatternCommunication const& comm :
@@ -208,8 +203,8 @@ void CommDetExtension::enforce_deterministic_pattern(aid_t actor, const PatternC
       XBT_INFO("***** Non-send-deterministic communications pattern *****");
       XBT_INFO("*********************************************************");
       XBT_INFO("%s", send_diff.c_str());
-      session_singleton->log_state();
-      api::get().mc_exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
+      Api::get().get_session().log_state();
+      Api::get().mc_exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
     } else if (_sg_mc_comms_determinism && (not send_deterministic && not recv_deterministic)) {
       XBT_INFO("****************************************************");
       XBT_INFO("***** Non-deterministic communications pattern *****");
@@ -218,8 +213,8 @@ void CommDetExtension::enforce_deterministic_pattern(aid_t actor, const PatternC
         XBT_INFO("%s", send_diff.c_str());
       if (not recv_diff.empty())
         XBT_INFO("%s", recv_diff.c_str());
-      session_singleton->log_state();
-      api::get().mc_exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
+      Api::get().get_session().log_state();
+      Api::get().mc_exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
     }
   }
 }
@@ -292,8 +287,6 @@ void CommDetExtension::handle_comm_pattern(const Transition* transition)
 
   switch (transition->type_) {
     case Transition::Type::COMM_SEND:
-      get_comm_pattern(transition);
-      break;
     case Transition::Type::COMM_RECV:
       get_comm_pattern(transition);
       break;
@@ -331,18 +324,17 @@ Exploration* create_communication_determinism_checker(Session* session)
 
   auto extension = new CommDetExtension();
 
-  SafetyChecker::on_exploration_start([extension]() {
+  DFSExplorer::on_exploration_start([extension]() {
     XBT_INFO("Check communication determinism");
     extension->exploration_start();
   });
-  SafetyChecker::on_backtracking([extension]() { extension->initial_communications_pattern_done = true; });
-  SafetyChecker::on_state_creation([extension](State* state) { state->extension_set(new StateCommDet(extension)); });
+  DFSExplorer::on_backtracking([extension]() { extension->initial_communications_pattern_done = true; });
+  DFSExplorer::on_state_creation([extension](State* state) { state->extension_set(new StateCommDet(extension)); });
 
-  SafetyChecker::on_restore_system_state(
-      [extension](State* state) { extension->restore_communications_pattern(state); });
+  DFSExplorer::on_restore_system_state([extension](State* state) { extension->restore_communications_pattern(state); });
 
-  SafetyChecker::on_restore_initial_state([extension]() {
-    const unsigned long maxpid = api::get().get_maxpid();
+  DFSExplorer::on_restore_initial_state([extension]() {
+    const unsigned long maxpid = Api::get().get_maxpid();
     assert(maxpid == extension->incomplete_communications_pattern.size());
     assert(maxpid == extension->initial_communications_pattern.size());
     for (unsigned long j = 0; j < maxpid; j++) {
@@ -351,10 +343,10 @@ Exploration* create_communication_determinism_checker(Session* session)
     }
   });
 
-  SafetyChecker::on_transition_replay([extension](Transition* t) { extension->handle_comm_pattern(t); });
-  SafetyChecker::on_transition_execute([extension](Transition* t) { extension->handle_comm_pattern(t); });
+  DFSExplorer::on_transition_replay([extension](Transition* t) { extension->handle_comm_pattern(t); });
+  DFSExplorer::on_transition_execute([extension](Transition* t) { extension->handle_comm_pattern(t); });
 
-  SafetyChecker::on_log_state([extension]() {
+  DFSExplorer::on_log_state([extension]() {
     if (_sg_mc_comms_determinism) {
       if (extension->send_deterministic && not extension->recv_deterministic) {
         XBT_INFO("*******************************************************");
@@ -375,7 +367,7 @@ Exploration* create_communication_determinism_checker(Session* session)
     delete extension;
   });
 
-  return new SafetyChecker(session);
+  return new DFSExplorer(session);
 }
 
 } // namespace mc