Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
RemotePtr in get_pattern_comm_dst_proc()
[simgrid.git] / src / mc / checker / CommunicationDeterminismChecker.cpp
index 644a8b3aaa4ad169b7f3b94ac1d9d0c61a6e7ce4..73df3d8cd3b6aee3c9758104c1a801890bb98603 100644 (file)
@@ -111,17 +111,18 @@ static char* print_determinism_result(simgrid::mc::CommPatternDifference diff, a
 }
 
 static void update_comm_pattern(simgrid::mc::PatternCommunication* comm_pattern,
-                                const simgrid::kernel::activity::CommImpl* comm_addr)
+                                simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> const& comm_addr)
 {
-  auto src_proc = api::get().get_src_actor(comm_addr);
-  auto dst_proc = api::get().get_dst_actor(comm_addr);
+  auto src_proc = api::get().get_src_actor(comm_addr.local());
+  auto dst_proc = api::get().get_dst_actor(comm_addr.local());
   comm_pattern->src_proc = src_proc->get_pid();
   comm_pattern->dst_proc = dst_proc->get_pid();
   comm_pattern->src_host = api::get().get_actor_host_name(src_proc);
   comm_pattern->dst_host = api::get().get_actor_host_name(dst_proc);
 
-  if (comm_pattern->data.empty())
+  if (comm_pattern->data.empty()) {
     comm_pattern->data = api::get().get_pattern_comm_data(comm_addr);
+  }
 }
 
 namespace simgrid {
@@ -190,15 +191,15 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, Ca
   if (call_type == CallType::SEND) {
     /* Create comm pattern */
     pattern->type      = PatternCommunicationType::send;
-    pattern->comm_addr = api::get().get_comm_isend_raw_addr(request);
-    pattern->rdv      = api::get().get_pattern_comm_rdv(pattern->comm_addr);
-    pattern->src_proc = api::get().get_pattern_comm_src_proc(pattern->comm_addr);
+    pattern->comm_addr = api::get().get_comm_isend_raw_addr(request).local();
+    pattern->rdv      = api::get().get_pattern_comm_rdv(remote(pattern->comm_addr));
+    pattern->src_proc = api::get().get_pattern_comm_src_proc(remote(pattern->comm_addr));
     pattern->src_host = Api::get().get_actor_host_name(issuer);
 
 #if HAVE_SMPI
     pattern->tag = api::get().get_smpi_request_tag(request, simgrid::simix::Simcall::COMM_ISEND);
 #endif
-    pattern->data = api::get().get_pattern_comm_data(pattern->comm_addr);
+    pattern->data = api::get().get_pattern_comm_data(remote(pattern->comm_addr));
 
 #if HAVE_SMPI
     auto send_detached = api::get().check_send_request_detached(request);
@@ -216,14 +217,14 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, Ca
 #endif
   } else if (call_type == CallType::RECV) {
     pattern->type = PatternCommunicationType::receive;
-    pattern->comm_addr = api::get().get_comm_isend_raw_addr(request);
+    pattern->comm_addr = api::get().get_comm_isend_raw_addr(request).local();
 
 #if HAVE_SMPI
     pattern->tag = api::get().get_smpi_request_tag(request, simgrid::simix::Simcall::COMM_IRECV);
 #endif
     auto comm_addr = pattern->comm_addr;
-    pattern->rdv = api::get().get_pattern_comm_rdv(comm_addr);
-    pattern->dst_proc = api::get().get_pattern_comm_dst_proc(comm_addr);
+    pattern->rdv = api::get().get_pattern_comm_rdv(remote(comm_addr));
+    pattern->dst_proc = api::get().get_pattern_comm_dst_proc(remote(comm_addr));
     pattern->dst_host = api::get().get_actor_host_name(issuer);
   } else
     xbt_die("Unexpected call_type %i", (int)call_type);
@@ -232,18 +233,18 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, Ca
   incomplete_communications_pattern[issuer->get_pid()].push_back(pattern.release());
 }
 
-void CommunicationDeterminismChecker::complete_comm_pattern(const kernel::activity::CommImpl* comm_addr, aid_t issuer,
+void CommunicationDeterminismChecker::complete_comm_pattern(RemotePtr<kernel::activity::CommImpl> const& comm_addr, aid_t issuer,
                                                             int backtracking)
 {
   /* Complete comm pattern */
   std::vector<PatternCommunication*>& incomplete_pattern = incomplete_communications_pattern[issuer];
   auto current_comm_pattern =
       std::find_if(begin(incomplete_pattern), end(incomplete_pattern),
-                   [&comm_addr](const PatternCommunication* comm) { return api::get().comm_addr_equal(comm->comm_addr, comm_addr); });
+                   [&comm_addr](const PatternCommunication* comm) { return api::get().comm_addr_equal(comm->comm_addr, comm_addr.local()); });
   if (current_comm_pattern == std::end(incomplete_pattern))
     xbt_die("Corresponding communication not found!");
 
-  update_comm_pattern(*current_comm_pattern, comm_addr);
+  update_comm_pattern(*current_comm_pattern, remote(comm_addr.local()));
   std::unique_ptr<PatternCommunication> comm_pattern(*current_comm_pattern);
   XBT_DEBUG("Remove incomplete comm pattern for process %ld at cursor %zd", issuer,
             std::distance(begin(incomplete_pattern), current_comm_pattern));
@@ -398,13 +399,13 @@ void CommunicationDeterminismChecker::handle_comm_pattern(simgrid::mc::CallType
       break;
     case CallType::WAIT:
     case CallType::WAITANY: {
-      const simgrid::kernel::activity::CommImpl* comm_addr = nullptr;
+      simgrid::kernel::activity::CommImpl* comm_addr = nullptr;
       if (call_type == CallType::WAIT)
         comm_addr = api::get().get_comm_wait_raw_addr(req);
       else
         comm_addr = api::get().get_comm_waitany_raw_addr(req, value);
       auto simcall_issuer = api::get().simcall_get_issuer(req);
-      complete_comm_pattern(comm_addr, simcall_issuer->get_pid(), backtracking);
+      complete_comm_pattern(remote(comm_addr), simcall_issuer->get_pid(), backtracking);
     } break;
   default:
     xbt_die("Unexpected call type %i", (int)call_type);