Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
handle_comm_pattern() defined in CommunicationDeterminismChecker class,
authorEhsan Azimi <eazimi@ehsan.irisa.fr>
Mon, 30 Nov 2020 16:34:23 +0000 (17:34 +0100)
committerEhsan Azimi <eazimi@ehsan.irisa.fr>
Mon, 30 Nov 2020 16:34:23 +0000 (17:34 +0100)
mc_api::get_comm_wait_raw_addr() and mc_api::get_comm_waitany_raw_addr()
are used in handle_comm_pattern()

src/mc/checker/CommunicationDeterminismChecker.cpp
src/mc/checker/CommunicationDeterminismChecker.hpp
src/mc/mc_comm_pattern.cpp
src/mc/mc_comm_pattern.hpp

index 42e0f62..4b56822 100644 (file)
@@ -372,7 +372,7 @@ void CommunicationDeterminismChecker::restoreState()
     /* TODO : handle test and testany simcalls */
     CallType call = MC_get_call_type(req);
     mcapi::get().handle_simcall(state->transition_);
-    MC_handle_comm_pattern(call, req, req_num, 1);
+    handle_comm_pattern(call, req, req_num, 1);
     mcapi::get().mc_wait_for_requests();
 
     /* Update statistics */
@@ -381,6 +381,31 @@ void CommunicationDeterminismChecker::restoreState()
   }
 }
 
+void CommunicationDeterminismChecker::handle_comm_pattern(simgrid::mc::CallType call_type, smx_simcall_t req, int value, int backtracking)
+{
+  using simgrid::mc::CallType;
+  switch(call_type) {
+    case CallType::NONE:
+      break;
+    case CallType::SEND:
+    case CallType::RECV:
+      get_comm_pattern(req, call_type, backtracking);
+      break;
+    case CallType::WAIT:
+    case CallType::WAITANY: {
+      simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr{nullptr};
+      if (call_type == CallType::WAIT)
+        comm_addr = mcapi::get().get_comm_wait_raw_addr(req);
+      else
+        comm_addr = mcapi::get().get_comm_waitany_raw_addr(req, value);
+      auto simcall_issuer = mcapi::get().simcall_get_issuer(req);
+      complete_comm_pattern(comm_addr, simcall_issuer->get_pid(), backtracking);
+    } break;
+  default:
+    xbt_die("Unexpected call type %i", (int)call_type);
+  }
+}
+
 void CommunicationDeterminismChecker::real_run()
 {
   std::unique_ptr<VisitedState> visited_state = nullptr;
@@ -422,7 +447,7 @@ void CommunicationDeterminismChecker::real_run()
       mcapi::get().handle_simcall(cur_state->transition_);
       /* After this call req is no longer useful */
 
-      MC_handle_comm_pattern(call, req, req_num, 0);
+      handle_comm_pattern(call, req, req_num, 0);
 
       /* Wait for requests (schedules processes) */
       mcapi::get().mc_wait_for_requests();
index 3d3a910..c8ca066 100644 (file)
@@ -30,6 +30,7 @@ private:
   void log_state() override;
   void deterministic_comm_pattern(int process, const PatternCommunication* comm, int backtracking);
   void restoreState();
+  void handle_comm_pattern(simgrid::mc::CallType call_type, smx_simcall_t req, int value, int backtracking);
 
 public:
   // These are used by functions which should be moved in CommunicationDeterminismChecker:
index 7dd9704..e3ead2c 100644 (file)
@@ -27,35 +27,4 @@ void MC_restore_communications_pattern(simgrid::mc::State* state)
 
   for (unsigned i = 0; i < MC_smx_get_maxpid(); i++)
     MC_patterns_copy(incomplete_communications_pattern[i], state->incomplete_comm_pattern_[i]);
-}
-
-void MC_handle_comm_pattern(simgrid::mc::CallType call_type, smx_simcall_t req, int value, int backtracking)
-{
-  // HACK, do not rely on the Checker implementation outside of it
-  auto* checker = static_cast<simgrid::mc::CommunicationDeterminismChecker*>(mc_model_checker->getChecker());
-
-  using simgrid::mc::CallType;
-  switch(call_type) {
-    case CallType::NONE:
-      break;
-    case CallType::SEND:
-    case CallType::RECV:
-      checker->get_comm_pattern(req, call_type, backtracking);
-      break;
-    case CallType::WAIT:
-    case CallType::WAITANY: {
-      simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr{nullptr};
-      if (call_type == CallType::WAIT)
-        comm_addr = remote(simcall_comm_wait__getraw__comm(req));
-
-      else {
-        simgrid::kernel::activity::ActivityImpl* addr;
-        addr = mc_model_checker->get_remote_simulation().read(remote(simcall_comm_waitany__getraw__comms(req) + value));
-        comm_addr = remote(static_cast<simgrid::kernel::activity::CommImpl*>(addr));
-      }
-      checker->complete_comm_pattern(comm_addr, MC_smx_simcall_get_issuer(req)->get_pid(), backtracking);
-    } break;
-  default:
-    xbt_die("Unexpected call type %i", (int)call_type);
-  }
-}
+}
\ No newline at end of file
index a408136..ca221ea 100644 (file)
@@ -61,9 +61,6 @@ static inline simgrid::mc::CallType MC_get_call_type(const s_smx_simcall* req)
   }
 }
 
-XBT_PRIVATE void MC_handle_comm_pattern(simgrid::mc::CallType call_type, smx_simcall_t request, int value,
-                                        int backtracking);
-
 XBT_PRIVATE void MC_restore_communications_pattern(simgrid::mc::State* state);
 
 #endif