Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Initialize mmap-privatized segments earlier (before main).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 3 Jun 2021 11:07:08 +0000 (13:07 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 3 Jun 2021 11:36:44 +0000 (13:36 +0200)
Sometimes we may want to initiailze a global before MPI_Init.

src/smpi/internals/smpi_actor.cpp
src/smpi/internals/smpi_global.cpp

index 616c8a0..dc7e906 100644 (file)
@@ -216,21 +216,12 @@ void ActorExt::init()
   xbt_assert(smpi_get_universe_size() != 0, "SimGrid was not initialized properly before entering MPI_Init. "
                                             "Aborting, please check compilation process and use smpirun.");
 
-  simgrid::s4u::Actor* 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();
   // if we are in MPI_Init and argc handling has already been done.
   if (ext->initialized())
     return;
 
-  if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
-    /* Now using the segment index of this process  */
-    ext->set_privatized_region(smpi_init_global_memory_segment_process());
-    /* Done at the process's creation */
-    smpi_switch_data_segment(self);
-  }
-
+  simgrid::s4u::Actor* self = simgrid::s4u::Actor::self();
   ext->instance_id_ = self->get_property("instance_id");
   const int rank    = xbt_str_parse_int(self->get_property("rank"), "Cannot parse rank");
 
index 7fbb861..e256967 100644 (file)
@@ -506,8 +506,16 @@ static void smpi_init_privatization_no_dlopen(const std::string& executable)
 
   // Execute the same entry point for each simulated process:
   simgrid::s4u::Engine::get_instance()->register_default([entry_point, executable](std::vector<std::string> args) {
-    return std::function<void()>(
-        [entry_point, executable, args] { smpi_run_entry_point(entry_point, executable, args); });
+    return std::function<void()>([entry_point, executable, args] {
+      if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
+        simgrid::smpi::ActorExt* ext = smpi_process();
+        /* Now using the segment index of this process  */
+        ext->set_privatized_region(smpi_init_global_memory_segment_process());
+        /* Done at the process's creation */
+        smpi_switch_data_segment(simgrid::s4u::Actor::self());
+      }
+      smpi_run_entry_point(entry_point, executable, args);
+    });
   });
 }