Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MPI init: inline a function and various small cleanups
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 31 Jul 2019 16:35:02 +0000 (18:35 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 31 Jul 2019 16:35:02 +0000 (18:35 +0200)
src/smpi/include/private.hpp
src/smpi/internals/smpi_actor.cpp
src/smpi/internals/smpi_memory.cpp

index 97e81b0..62da58d 100644 (file)
@@ -27,7 +27,7 @@ constexpr unsigned MPI_REQ_ACCUMULATE     = 0x400;
 constexpr unsigned MPI_REQ_GENERALIZED    = 0x800;
 constexpr unsigned MPI_REQ_COMPLETE       = 0x1000;
 
 constexpr unsigned MPI_REQ_GENERALIZED    = 0x800;
 constexpr unsigned MPI_REQ_COMPLETE       = 0x1000;
 
-enum class SmpiProcessState { UNINITIALIZED, INITIALIZING, INITIALIZED, FINALIZED };
+enum class SmpiProcessState { UNINITIALIZED, INITIALIZING, INITIALIZED /*(=MPI_Init called)*/, FINALIZED };
 
 constexpr int COLL_TAG_REDUCE         = -112;
 constexpr int COLL_TAG_SCATTER        = -223;
 
 constexpr int COLL_TAG_REDUCE         = -112;
 constexpr int COLL_TAG_SCATTER        = -223;
@@ -101,7 +101,6 @@ enum class SharedMallocType { NONE, LOCAL, GLOBAL };
 extern XBT_PRIVATE SharedMallocType smpi_cfg_shared_malloc; // Whether to activate shared malloc
 
 XBT_PRIVATE void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor);
 extern XBT_PRIVATE SharedMallocType smpi_cfg_shared_malloc; // Whether to activate shared malloc
 
 XBT_PRIVATE void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor);
-XBT_PRIVATE void smpi_really_switch_data_segment(simgrid::s4u::ActorPtr actor);
 
 XBT_PRIVATE void smpi_prepare_global_memory_segment();
 XBT_PRIVATE void smpi_backup_global_memory_segment();
 
 XBT_PRIVATE void smpi_prepare_global_memory_segment();
 XBT_PRIVATE void smpi_backup_global_memory_segment();
index 41bca6b..0b8ff88 100644 (file)
@@ -213,7 +213,7 @@ void ActorExt::init()
   simgrid::s4u::ActorPtr self = simgrid::s4u::Actor::self();
   // cheinrich: I'm not sure what the impact of the SMPI_switch_data_segment on this call is. I moved
   // this up here so that I can set the privatized region before the switch.
   simgrid::s4u::ActorPtr self = simgrid::s4u::Actor::self();
   // cheinrich: I'm not sure what the impact of the SMPI_switch_data_segment on this call is. I moved
   // this up here so that I can set the privatized region before the switch.
-  ActorExt* ext = smpi_process_remote(self);
+  ActorExt* ext = smpi_process();
   // if we are in MPI_Init and argc handling has already been done.
   if (ext->initialized())
     return;
   // if we are in MPI_Init and argc handling has already been done.
   if (ext->initialized())
     return;
index 5b927e8..de20019 100644 (file)
@@ -57,8 +57,7 @@ static void smpi_get_executable_global_size()
 {
   char buffer[PATH_MAX];
   char* full_name = realpath(xbt_binary_name, buffer);
 {
   char buffer[PATH_MAX];
   char* full_name = realpath(xbt_binary_name, buffer);
-  if (full_name == nullptr)
-    xbt_die("Could not resolve binary file name");
+  xbt_assert(full_name != nullptr, "Could not resolve real path of binary file '%s'", xbt_binary_name);
 
   std::vector<simgrid::xbt::VmMap> map = simgrid::xbt::get_memory_map(getpid());
   for (auto i = map.begin(); i != map.end() ; ++i) {
 
   std::vector<simgrid::xbt::VmMap> map = simgrid::xbt::get_memory_map(getpid());
   for (auto i = map.begin(); i != map.end() ; ++i) {
@@ -111,23 +110,16 @@ static void* asan_safe_memcpy(void* dest, void* src, size_t n)
 #define asan_safe_memcpy(dest, src, n) memcpy(dest, src, n)
 #endif
 
 #define asan_safe_memcpy(dest, src, n) memcpy(dest, src, n)
 #endif
 
-/** Map a given SMPI privatization segment (make a SMPI process active) */
-void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor)
-{
-  if (smpi_loaded_page == actor->get_pid()) // no need to switch, we've already loaded the one we want
-    return;
-
-  // So the job:
-  smpi_really_switch_data_segment(actor);
-}
-
-/** Map a given SMPI privatization segment (make a SMPI process active)  even if SMPI thinks it is already active
+/** Map a given SMPI privatization segment (make a SMPI process active)
  *
  *  When doing a state restoration, the state of the restored variables  might not be consistent with the state of the
  *  virtual memory. In this case, we to change the data segment.
  */
  *
  *  When doing a state restoration, the state of the restored variables  might not be consistent with the state of the
  *  virtual memory. In this case, we to change the data segment.
  */
-void smpi_really_switch_data_segment(simgrid::s4u::ActorPtr actor)
+void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor)
 {
 {
+  if (smpi_loaded_page == actor->get_pid()) // no need to switch, we've already loaded the one we want
+    return;
+
   if (smpi_data_exe_size == 0) // no need to switch
     return;
 
   if (smpi_data_exe_size == 0) // no need to switch
     return;