Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
I'd like to turn process_data into a regular extension of Actor
[simgrid.git] / src / smpi / internals / smpi_global.cpp
index cfec9be..bc01be3 100644 (file)
@@ -79,9 +79,7 @@ std::map</* computation unit name */ std::string, papi_process_data> units2papi_
 std::unordered_map<std::string, double> location2speedup;
 
 static std::map</*process_id*/ simgrid::s4u::Actor const*, simgrid::smpi::ActorExt*> process_data;
-int process_count = 0;
 static int smpi_exit_status = 0;
-int smpi_universe_size = 0;
 extern double smpi_total_benched_time;
 xbt_os_timer_t global_timer;
 static std::vector<std::string> privatize_libs_paths;
@@ -108,11 +106,6 @@ static simgrid::config::Flag<double> smpi_init_sleep(
 void (*smpi_comm_copy_data_callback)(simgrid::kernel::activity::CommImpl*, void*,
                                      size_t) = &smpi_comm_copy_buffer_callback;
 
-int smpi_process_count()
-{
-  return process_count;
-}
-
 simgrid::smpi::ActorExt* smpi_process()
 {
   simgrid::s4u::ActorPtr me = simgrid::s4u::Actor::self();
@@ -254,7 +247,7 @@ static void smpi_check_options()
 }
 
 int smpi_enabled() {
-  return not process_data.empty();
+  return MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED;
 }
 
 void smpi_global_init()
@@ -267,9 +260,7 @@ void smpi_global_init()
   std::string filename = simgrid::config::get_value<std::string>("smpi/comp-adjustment-file");
   if (not filename.empty()) {
     std::ifstream fstream(filename);
-    if (not fstream.is_open()) {
-      xbt_die("Could not open file %s. Does it exist?", filename.c_str());
-    }
+    xbt_assert(fstream.is_open(), "Could not open file %s. Does it exist?", filename.c_str());
 
     std::string line;
     typedef boost::tokenizer< boost::escaped_list_separator<char>> Tokenizer;
@@ -609,9 +600,7 @@ static void smpi_init_privatization_dlopen(const std::string& executable)
           smpi_copy_file(libpath, target_lib, fdin_size2);
 
           std::string sedcommand = "sed -i -e 's/" + libname + "/" + target_lib + "/g' " + target_executable;
-          int ret                = system(sedcommand.c_str());
-          if (ret != 0)
-            xbt_die("error while applying sed command %s \n", sedcommand.c_str());
+          xbt_assert(system(sedcommand.c_str()) == 0, "error while applying sed command %s \n", sedcommand.c_str());
         }
       }
 
@@ -624,11 +613,11 @@ static void smpi_init_privatization_dlopen(const std::string& executable)
         for (const std::string& target_lib : target_libs)
           unlink(target_lib.c_str());
       }
-      if (handle == nullptr)
-        xbt_die("dlopen failed: %s (errno: %d -- %s)", dlerror(), saved_errno, strerror(saved_errno));
+      xbt_assert(handle != nullptr, "dlopen failed: %s (errno: %d -- %s)", dlerror(), saved_errno,
+                 strerror(saved_errno));
+
       smpi_entry_point_type entry_point = smpi_resolve_function(handle);
-      if (not entry_point)
-        xbt_die("Could not resolve entry point");
+      xbt_assert(entry_point, "Could not resolve entry point");
       smpi_run_entry_point(entry_point, executable, args);
     });
   };
@@ -638,13 +627,14 @@ static void smpi_init_privatization_no_dlopen(const std::string& executable)
 {
   if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP)
     smpi_prepare_global_memory_segment();
+
   // Load the dynamic library and resolve the entry point:
   void* handle = dlopen(executable.c_str(), RTLD_LAZY | RTLD_LOCAL);
-  if (handle == nullptr)
-    xbt_die("dlopen failed for %s: %s (errno: %d -- %s)", executable.c_str(), dlerror(), errno, strerror(errno));
+  xbt_assert(handle != nullptr, "dlopen failed for %s: %s (errno: %d -- %s)", executable.c_str(), dlerror(), errno,
+             strerror(errno));
   smpi_entry_point_type entry_point = smpi_resolve_function(handle);
-  if (not entry_point)
-    xbt_die("main not found in %s", executable.c_str());
+  xbt_assert(entry_point, "main not found in %s", executable.c_str());
+
   if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP)
     smpi_backup_global_memory_segment();
 
@@ -683,8 +673,6 @@ int smpi_main(const char* executable, int argc, char* argv[])
   SMPI_app_instance_register(smpi_default_instance_name.c_str(), nullptr,
                              process_data.size()); // This call has a side effect on process_count...
   MPI_COMM_WORLD = *smpi_deployment_comm_world(smpi_default_instance_name);
-  smpi_universe_size = process_count;
-
 
   /* Clean IO before the run */
   fflush(stdout);
@@ -718,7 +706,7 @@ int smpi_main(const char* executable, int argc, char* argv[])
 void SMPI_init(){
   simgrid::s4u::Actor::on_creation.connect([](simgrid::s4u::Actor& actor) {
     if (not actor.is_daemon()) {
-      process_data.insert({&actor, new simgrid::smpi::ActorExt(&actor, nullptr)});
+      process_data.insert({&actor, new simgrid::smpi::ActorExt(&actor)});
     }
   });
   simgrid::s4u::Actor::on_destruction.connect([](simgrid::s4u::Actor const& actor) {