Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Mark some remote pointers as such
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 8 Apr 2016 09:50:09 +0000 (11:50 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 8 Apr 2016 09:50:09 +0000 (11:50 +0200)
src/mc/CommunicationDeterminismChecker.cpp
src/mc/Process.hpp
src/mc/RemotePtr.hpp
src/mc/mc_base.cpp
src/mc/mc_request.cpp
src/mc/mc_smx.cpp
src/mc/mc_smx.h

index 4588869..a5ddbc2 100644 (file)
@@ -96,8 +96,8 @@ static void update_comm_pattern(simgrid::mc::PatternCommunication* comm_pattern,
   s_smx_synchro_t comm;
   mc_model_checker->process().read(&comm, remote(comm_addr));
 
-  smx_process_t src_proc = MC_smx_resolve_process(comm.comm.src_proc);
-  smx_process_t dst_proc = MC_smx_resolve_process(comm.comm.dst_proc);
+  smx_process_t src_proc = MC_smx_resolve_process(simgrid::mc::remote(comm.comm.src_proc));
+  smx_process_t dst_proc = MC_smx_resolve_process(simgrid::mc::remote(comm.comm.dst_proc));
   comm_pattern->src_proc = src_proc->pid;
   comm_pattern->dst_proc = dst_proc->pid;
   comm_pattern->src_host = MC_smx_process_get_host_name(src_proc);
@@ -189,7 +189,7 @@ void MC_get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type
     char* remote_name = mc_model_checker->process().read<char*>(
       (std::uint64_t)(synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->name));
     pattern->rdv = mc_model_checker->process().read_string(remote_name);
-    pattern->src_proc = MC_smx_resolve_process(synchro.comm.src_proc)->pid;
+    pattern->src_proc = MC_smx_resolve_process(simgrid::mc::remote(synchro.comm.src_proc))->pid;
     pattern->src_host = MC_smx_process_get_host_name(issuer);
 
     struct s_smpi_mpi_request mpi_request =
@@ -235,7 +235,7 @@ void MC_get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type
     mc_model_checker->process().read(&remote_name,
       remote(synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->name));
     pattern->rdv = mc_model_checker->process().read_string(remote_name);
-    pattern->dst_proc = MC_smx_resolve_process(synchro.comm.dst_proc)->pid;
+    pattern->dst_proc = MC_smx_resolve_process(simgrid::mc::remote(synchro.comm.dst_proc))->pid;
     pattern->dst_host = MC_smx_process_get_host_name(issuer);
   } else
     xbt_die("Unexpected call_type %i", (int) call_type);
index b709c33..000da2b 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "src/mc/mc_forward.hpp"
 #include "src/mc/mc_base.h"
+#include "src/mc/RemotePtr.hpp"
 #include "src/mc/AddressSpace.hpp"
 #include "src/mc/mc_protocol.h"
 #include "src/mc/ObjectInformation.hpp"
@@ -44,7 +45,7 @@ namespace mc {
 class SimixProcessInformation {
 public:
   /** MCed address of the process */
-  void* address = nullptr;
+  RemotePtr<s_smx_process_t> address = nullptr;
   union {
     /** (Flat) Copy of the process data structure */
     struct s_smx_process copy;
index c9a931c..23d0372 100644 (file)
@@ -34,6 +34,11 @@ public:
   RemotePtr(T* address) : address_((std::uintptr_t)address) {}
   std::uint64_t address() const { return address_; }
 
+  /** Turn into a local pointer
+   *
+   (if the remote process is not, in fact, remote) */
+  T* local() { return (T*) address_; }
+
   operator bool() const
   {
     return address_;
index 5b7ce3b..1417283 100644 (file)
@@ -158,8 +158,8 @@ bool request_is_enabled(smx_simcall_t req)
     else
 #if HAVE_MC
       // TODO, *(mutex->owner) :/
-      return MC_smx_resolve_process(mutex->owner)->pid ==
-        MC_smx_resolve_process(req->issuer)->pid;
+      return MC_smx_resolve_process(simgrid::mc::remote(mutex->owner))->pid ==
+        MC_smx_resolve_process(simgrid::mc::remote(req->issuer))->pid;
 #else
       return mutex->owner->pid == req->issuer->pid;
 #endif
index 26b9d30..679df52 100644 (file)
@@ -290,8 +290,8 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       } else
         act = remote_act;
 
-      smx_process_t src_proc = MC_smx_resolve_process(act->comm.src_proc);
-      smx_process_t dst_proc = MC_smx_resolve_process(act->comm.dst_proc);
+      smx_process_t src_proc = MC_smx_resolve_process(simgrid::mc::remote(act->comm.src_proc));
+      smx_process_t dst_proc = MC_smx_resolve_process(simgrid::mc::remote(act->comm.dst_proc));
       args = bprintf("comm=%s [(%lu)%s (%s)-> (%lu)%s (%s)]", p,
                      src_proc ? src_proc->pid : 0,
                      src_proc ? MC_smx_process_get_host_name(src_proc) : "",
@@ -324,8 +324,8 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       type = "Test TRUE";
       p = pointer_to_string(remote_act);
 
-      smx_process_t src_proc = MC_smx_resolve_process(act->comm.src_proc);
-      smx_process_t dst_proc = MC_smx_resolve_process(act->comm.dst_proc);
+      smx_process_t src_proc = MC_smx_resolve_process(simgrid::mc::remote(act->comm.src_proc));
+      smx_process_t dst_proc = MC_smx_resolve_process(simgrid::mc::remote(act->comm.dst_proc));
       args = bprintf("comm=%s [(%lu)%s (%s) -> (%lu)%s (%s)]", p,
                      src_proc->pid,
                      MC_smx_process_get_name(src_proc),
@@ -390,7 +390,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
 
     args = bprintf("locked = %d, owner = %d, sleeping = %d",
       mutex.locked,
-      mutex.owner != nullptr ? (int) MC_smx_resolve_process(mutex.owner)->pid : -1,
+      mutex.owner != nullptr ? (int) MC_smx_resolve_process(simgrid::mc::remote(mutex.owner))->pid : -1,
       mutex_sleeping.count);
     break;
   }
@@ -520,8 +520,8 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       mc_model_checker->process().read_bytes(&synchro,
         sizeof(synchro), remote(remote_act));
 
-      smx_process_t src_proc = MC_smx_resolve_process(synchro.comm.src_proc);
-      smx_process_t dst_proc = MC_smx_resolve_process(synchro.comm.dst_proc);
+      smx_process_t src_proc = MC_smx_resolve_process(simgrid::mc::remote(synchro.comm.src_proc));
+      smx_process_t dst_proc = MC_smx_resolve_process(simgrid::mc::remote(synchro.comm.dst_proc));
       if (issuer->host)
         label = simgrid::xbt::string_printf("[(%lu)%s] Wait [(%lu)->(%lu)]",
                     issuer->pid,
index 4a28224..09981a5 100644 (file)
@@ -117,7 +117,7 @@ smx_process_t MC_smx_simcall_get_issuer(s_smx_simcall_t const* req)
     return req->issuer;
 
   // This is the address of the smx_process in the MCed process:
-  void* address = req->issuer;
+  auto address = simgrid::mc::remote(req->issuer);
 
   // Lookup by address:
   for (auto& p : mc_model_checker->process().simix_processes())
@@ -130,21 +130,24 @@ smx_process_t MC_smx_simcall_get_issuer(s_smx_simcall_t const* req)
   xbt_die("Issuer not found");
 }
 
-smx_process_t MC_smx_resolve_process(smx_process_t process_remote_address)
+smx_process_t MC_smx_resolve_process(
+  simgrid::mc::RemotePtr<s_smx_process_t> process_remote_address)
 {
   if (!process_remote_address)
     return nullptr;
   if (mc_mode == MC_MODE_CLIENT)
-    return process_remote_address;
+    return process_remote_address.local();
 
-  simgrid::mc::SimixProcessInformation* process_info = MC_smx_resolve_process_info(process_remote_address);
+  simgrid::mc::SimixProcessInformation* process_info =
+    MC_smx_resolve_process_info(process_remote_address);
   if (process_info)
     return &process_info->copy;
   else
     return nullptr;
 }
 
-simgrid::mc::SimixProcessInformation* MC_smx_resolve_process_info(smx_process_t process_remote_address)
+simgrid::mc::SimixProcessInformation* MC_smx_resolve_process_info(
+  simgrid::mc::RemotePtr<s_smx_process_t> process_remote_address)
 {
   if (mc_mode == MC_MODE_CLIENT)
     xbt_die("No process_info for local process is not enabled.");
index e2371e4..4582e85 100644 (file)
@@ -61,10 +61,12 @@ XBT_PRIVATE int MC_smpi_process_count(void);
 /* ***** Resolve (local/MCer structure from remote/MCed addresses) ***** */
 
 /** Get a local copy of the process from the process remote address */
-XBT_PRIVATE smx_process_t MC_smx_resolve_process(smx_process_t process_remote_address);
+XBT_PRIVATE smx_process_t MC_smx_resolve_process(
+  simgrid::mc::RemotePtr<s_smx_process_t> process_remote_address);
 
 /** Get the process info structure from the process remote address */
-XBT_PRIVATE simgrid::mc::SimixProcessInformation* MC_smx_resolve_process_info(smx_process_t process_remote_address);
+XBT_PRIVATE simgrid::mc::SimixProcessInformation* MC_smx_resolve_process_info(
+  simgrid::mc::RemotePtr<s_smx_process_t> process_remote_address);
 
 XBT_PRIVATE unsigned long MC_smx_get_maxpid(void);