Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add explicit keyword to simgrid::mc::RemotePtr constructor.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 7 Dec 2017 15:35:14 +0000 (16:35 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 7 Dec 2017 16:01:55 +0000 (17:01 +0100)
src/mc/RegionSnapshot.cpp
src/mc/checker/CommunicationDeterminismChecker.cpp
src/mc/compare.cpp
src/mc/mc_comm_pattern.cpp
src/mc/mc_smx.cpp
src/mc/remote/RemoteClient.cpp
src/mc/remote/RemoteClient.hpp
src/mc/remote/RemotePtr.hpp

index 69a40e1..4ebfbe1 100644 (file)
@@ -137,8 +137,8 @@ RegionSnapshot sparse_region(RegionType region_type,
     "Not at the beginning of a page");
   size_t page_count = simgrid::mc::mmu::chunkCount(size);
 
     "Not at the beginning of a page");
   size_t page_count = simgrid::mc::mmu::chunkCount(size);
 
-  simgrid::mc::ChunkedData page_data(
-    mc_model_checker->page_store(), *process, permanent_addr, page_count);
+  simgrid::mc::ChunkedData page_data(mc_model_checker->page_store(), *process, RemotePtr<void>(permanent_addr),
+                                     page_count);
 
   simgrid::mc::RegionSnapshot region(
     region_type, start_addr, permanent_addr, size);
 
   simgrid::mc::RegionSnapshot region(
     region_type, start_addr, permanent_addr, size);
index 955a2f2..4fedf30 100644 (file)
@@ -194,13 +194,13 @@ void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_sim
         static_cast<simgrid::kernel::activity::CommImpl*>(temp_synchro.getBuffer());
 
     char* remote_name = mc_model_checker->process().read<char*>(
         static_cast<simgrid::kernel::activity::CommImpl*>(temp_synchro.getBuffer());
 
     char* remote_name = mc_model_checker->process().read<char*>(
-        (std::uint64_t)(synchro->mbox ? &synchro->mbox->name_ : &synchro->mbox_cpy->name_));
-    pattern->rdv = mc_model_checker->process().read_string(remote_name);
+        RemotePtr<char*>((uint64_t)(synchro->mbox ? &synchro->mbox->name_ : &synchro->mbox_cpy->name_)));
+    pattern->rdv      = mc_model_checker->process().read_string(RemotePtr<char>(remote_name));
     pattern->src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(synchro->src_proc))->pid;
     pattern->src_host = MC_smx_actor_get_host_name(issuer);
 
     pattern->src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(synchro->src_proc))->pid;
     pattern->src_host = MC_smx_actor_get_host_name(issuer);
 
-    simgrid::smpi::Request mpi_request =
-        mc_model_checker->process().read<simgrid::smpi::Request>((std::uint64_t)simcall_comm_isend__get__data(request));
+    simgrid::smpi::Request mpi_request = mc_model_checker->process().read<simgrid::smpi::Request>(
+        RemotePtr<simgrid::smpi::Request>((std::uint64_t)simcall_comm_isend__get__data(request)));
     pattern->tag = mpi_request.tag();
 
     if (synchro->src_buff != nullptr) {
     pattern->tag = mpi_request.tag();
 
     if (synchro->src_buff != nullptr) {
@@ -239,7 +239,7 @@ void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_sim
     mc_model_checker->process().read(
         &remote_name, remote(comm->mbox ? &simgrid::xbt::string::to_string_data(comm->mbox->name_).data
                                         : &simgrid::xbt::string::to_string_data(comm->mbox_cpy->name_).data));
     mc_model_checker->process().read(
         &remote_name, remote(comm->mbox ? &simgrid::xbt::string::to_string_data(comm->mbox->name_).data
                                         : &simgrid::xbt::string::to_string_data(comm->mbox_cpy->name_).data));
-    pattern->rdv = mc_model_checker->process().read_string(remote_name);
+    pattern->rdv      = mc_model_checker->process().read_string(RemotePtr<char>(remote_name));
     pattern->dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->dst_proc))->pid;
     pattern->dst_host = MC_smx_actor_get_host_name(issuer);
   } else
     pattern->dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->dst_proc))->pid;
     pattern->dst_host = MC_smx_actor_get_host_name(issuer);
   } else
index ab4bc29..4cdf76a 100644 (file)
@@ -344,9 +344,9 @@ int mmalloc_compare_heap(
 
   // This is in snapshot do not use them directly:
   const malloc_info* heapinfos1 = snapshot1->read<malloc_info*>(
 
   // This is in snapshot do not use them directly:
   const malloc_info* heapinfos1 = snapshot1->read<malloc_info*>(
-    (std::uint64_t)heapinfo_address, simgrid::mc::ProcessIndexMissing);
+      RemotePtr<malloc_info*>((std::uint64_t)heapinfo_address), simgrid::mc::ProcessIndexMissing);
   const malloc_info* heapinfos2 = snapshot2->read<malloc_info*>(
   const malloc_info* heapinfos2 = snapshot2->read<malloc_info*>(
-    (std::uint64_t)heapinfo_address, simgrid::mc::ProcessIndexMissing);
+      RemotePtr<malloc_info*>((std::uint64_t)heapinfo_address), simgrid::mc::ProcessIndexMissing);
 
   while (i1 < state.heaplimit) {
 
 
   while (i1 < state.heaplimit) {
 
index 48608a8..3e7a729 100644 (file)
@@ -85,7 +85,7 @@ void MC_handle_comm_pattern(
   case MC_CALL_TYPE_WAIT:
   case MC_CALL_TYPE_WAITANY:
     {
   case MC_CALL_TYPE_WAIT:
   case MC_CALL_TYPE_WAITANY:
     {
-    simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr = nullptr;
+    simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr{nullptr};
     if (call_type == MC_CALL_TYPE_WAIT)
       comm_addr = remote(static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req)));
 
     if (call_type == MC_CALL_TYPE_WAIT)
       comm_addr = remote(static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req)));
 
index bcdec8b..9cc4241 100644 (file)
@@ -41,13 +41,13 @@ static void MC_process_refresh_simix_actor_dynar(simgrid::mc::RemoteClient* proc
   process->read_bytes(&dynar, sizeof(dynar), remote_dynar);
 
   smx_actor_t* data = static_cast<smx_actor_t*>(::operator new(dynar.elmsize * dynar.used));
   process->read_bytes(&dynar, sizeof(dynar), remote_dynar);
 
   smx_actor_t* data = static_cast<smx_actor_t*>(::operator new(dynar.elmsize * dynar.used));
-  process->read_bytes(data, dynar.elmsize * dynar.used, dynar.data);
+  process->read_bytes(data, dynar.elmsize * dynar.used, simgrid::mc::RemotePtr<void>(dynar.data));
 
   // Load each element of the vector from the MCed process:
   for (unsigned int i = 0; i < dynar.used; ++i) {
 
     simgrid::mc::ActorInformation info;
 
   // Load each element of the vector from the MCed process:
   for (unsigned int i = 0; i < dynar.used; ++i) {
 
     simgrid::mc::ActorInformation info;
-    info.address  = data[i];
+    info.address  = simgrid::mc::RemotePtr<simgrid::simix::ActorImpl>(data[i]);
     info.hostname = nullptr;
     process->read_bytes(&info.copy, sizeof(info.copy), remote(data[i]));
     target.push_back(std::move(info));
     info.hostname = nullptr;
     process->read_bytes(&info.copy, sizeof(info.copy), remote(data[i]));
     target.push_back(std::move(info));
@@ -71,8 +71,7 @@ void RemoteClient::refresh_simix()
   static_assert(sizeof(simix_global) == sizeof(simgrid::simix::Global*),
     "Bad size for simix_global");
 
   static_assert(sizeof(simix_global) == sizeof(simgrid::simix::Global*),
     "Bad size for simix_global");
 
-  RemotePtr<simgrid::simix::Global> simix_global_p =
-    this->read_variable<simgrid::simix::Global*>("simix_global");
+  RemotePtr<simgrid::simix::Global> simix_global_p{this->read_variable<simgrid::simix::Global*>("simix_global")};
 
   // simix_global = REMOTE(*simix_global)
   Remote<simgrid::simix::Global> simix_global =
 
   // simix_global = REMOTE(*simix_global)
   Remote<simgrid::simix::Global> simix_global =
index 0172d70..7f8877f 100644 (file)
@@ -443,7 +443,7 @@ const void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr<v
                                      ReadOptions options) const
 {
   if (process_index != simgrid::mc::ProcessIndexDisabled) {
                                      ReadOptions options) const
 {
   if (process_index != simgrid::mc::ProcessIndexDisabled) {
-    std::shared_ptr<simgrid::mc::ObjectInformation> const& info = this->find_object_info_rw((void*)address.address());
+    std::shared_ptr<simgrid::mc::ObjectInformation> const& info = this->find_object_info_rw(address);
 // Segment overlap is not handled.
 #if HAVE_SMPI
     if (info.get() && this->privatized(*info)) {
 // Segment overlap is not handled.
 #if HAVE_SMPI
     if (info.get() && this->privatized(*info)) {
index 1f3809e..b681e59 100644 (file)
@@ -44,7 +44,7 @@ namespace mc {
 class ActorInformation {
 public:
   /** MCed address of the process */
 class ActorInformation {
 public:
   /** MCed address of the process */
-  RemotePtr<simgrid::simix::ActorImpl> address = nullptr;
+  RemotePtr<simgrid::simix::ActorImpl> address{nullptr};
   Remote<simgrid::simix::ActorImpl> copy;
 
   /** Hostname (owned by `mc_modelchecker->hostnames`) */
   Remote<simgrid::simix::ActorImpl> copy;
 
   /** Hostname (owned by `mc_modelchecker->hostnames`) */
index d92eb7a..d6d763b 100644 (file)
@@ -81,9 +81,10 @@ template <class T> class RemotePtr {
 
 public:
   RemotePtr() : address_(0) {}
 
 public:
   RemotePtr() : address_(0) {}
-  RemotePtr(std::uint64_t address) : address_(address) {}
-  RemotePtr(T* address) : address_((std::uintptr_t)address) {}
-  RemotePtr(Remote<T*> p) : RemotePtr(*p.getBuffer()) {}
+  explicit RemotePtr(std::nullptr_t) : address_(0) {}
+  explicit RemotePtr(std::uint64_t address) : address_(address) {}
+  explicit RemotePtr(T* address) : address_((std::uintptr_t)address) {}
+  explicit RemotePtr(Remote<T*> p) : RemotePtr(*p.getBuffer()) {}
   std::uint64_t address() const { return address_; }
 
   /** Turn into a local pointer
   std::uint64_t address() const { return address_; }
 
   /** Turn into a local pointer
@@ -94,6 +95,11 @@ public:
   operator bool() const { return address_; }
   bool operator!() const { return not address_; }
   operator RemotePtr<void>() const { return RemotePtr<void>(address_); }
   operator bool() const { return address_; }
   bool operator!() const { return not address_; }
   operator RemotePtr<void>() const { return RemotePtr<void>(address_); }
+  RemotePtr<T>& operator=(std::nullptr_t)
+  {
+    address_ = 0;
+    return *this;
+  }
   RemotePtr<T> operator+(std::uint64_t n) const { return RemotePtr<T>(address_ + n * sizeof(T)); }
   RemotePtr<T> operator-(std::uint64_t n) const { return RemotePtr<T>(address_ - n * sizeof(T)); }
   RemotePtr<T>& operator+=(std::uint64_t n)
   RemotePtr<T> operator+(std::uint64_t n) const { return RemotePtr<T>(address_ + n * sizeof(T)); }
   RemotePtr<T> operator-(std::uint64_t n) const { return RemotePtr<T>(address_ - n * sizeof(T)); }
   RemotePtr<T>& operator+=(std::uint64_t n)