Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mc_api::get_pattern_comm_data() defined,
authorEhsan Azimi <eazimi@ehsan.irisa.fr>
Fri, 27 Nov 2020 20:37:47 +0000 (21:37 +0100)
committerEhsan Azimi <eazimi@ehsan.irisa.fr>
Fri, 27 Nov 2020 20:37:47 +0000 (21:37 +0100)
it used by update_comm_pattern() in comm. deter. checker

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

index d041ad6..9ac7aa3 100644 (file)
@@ -97,25 +97,21 @@ static char* print_determinism_result(simgrid::mc::CommPatternDifference diff, i
 static void update_comm_pattern(simgrid::mc::PatternCommunication* comm_pattern,
                                 simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr)
 {
-  // // HACK, type punning
-  simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
-  mc_model_checker->get_remote_simulation().read(temp_comm, comm_addr);
-  const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
-
   auto src_proc = mcapi::get().get_src_actor(comm_addr);
   auto dst_proc = mcapi::get().get_dst_actor(comm_addr);
   comm_pattern->src_proc = src_proc->get_pid();
   comm_pattern->dst_proc = dst_proc->get_pid();
   comm_pattern->src_host = mcapi::get().get_actor_host_name(src_proc);
   comm_pattern->dst_host = mcapi::get().get_actor_host_name(dst_proc);
-  
-  if (comm_pattern->data.empty() && comm->src_buff_ != nullptr) {
-    size_t buff_size;
-    mc_model_checker->get_remote_simulation().read(&buff_size, remote(comm->dst_buff_size_));
-    comm_pattern->data.resize(buff_size);
-    mc_model_checker->get_remote_simulation().read_bytes(comm_pattern->data.data(), comm_pattern->data.size(),
-                                                         remote(comm->src_buff_));
-  }
+
+  if (comm_pattern->data.empty()) {
+    auto pattern_data = mcapi::get().get_pattern_comm_data(comm_addr);
+    if (pattern_data.data() != nullptr) {
+      auto data_size = pattern_data.size();
+      comm_pattern->data.resize(data_size);
+      memcpy(comm_pattern->data.data(), pattern_data.data(), data_size);
+    }
+   }
 }
 
 namespace simgrid {
index 8e305f4..29e895b 100644 (file)
@@ -266,6 +266,21 @@ std::vector<char> mc_api::get_pattern_comm_data(void* addr) const
   return buffer;
 }
 
+std::vector<char> mc_api::get_pattern_comm_data(mc::RemotePtr<kernel::activity::CommImpl> const& comm_addr) const
+{
+  simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
+  mc_model_checker->get_remote_simulation().read(temp_comm, comm_addr);
+  const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+  
+  std::vector<char> buffer {};
+  if (comm->src_buff_ != nullptr) {
+    buffer.resize(comm->src_buff_size_);
+    mc_model_checker->get_remote_simulation().read_bytes(buffer.data(), buffer.size(),
+                                                         remote(comm->src_buff_));
+  }
+  return buffer;
+}
+
 const char* mc_api::get_actor_host_name(smx_actor_t actor) const
 {
   const char* host_name = MC_smx_actor_get_host_name(actor);
index 15bd595..c6def81 100644 (file)
@@ -51,6 +51,7 @@ public:
   unsigned long get_pattern_comm_src_proc(void* addr) const;
   unsigned long get_pattern_comm_dst_proc(void* addr) const;
   std::vector<char> get_pattern_comm_data(void* addr) const;
+  std::vector<char> get_pattern_comm_data(mc::RemotePtr<kernel::activity::CommImpl> const& comm_addr) const;
   const char* get_actor_host_name(smx_actor_t actor) const;
   bool check_send_request_detached(smx_simcall_t const& simcall) const;
   smx_actor_t get_src_actor(mc::RemotePtr<kernel::activity::CommImpl> const& comm_addr) const;