Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill smpi_process_count(), use smpi_get_universe_size() instead
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 28 Jul 2019 23:55:25 +0000 (01:55 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 29 Jul 2019 00:05:25 +0000 (02:05 +0200)
process_count was probably the original name while universe_size was
added to implement MPI_Attr_get(MPI_UNIVERSE_SIZE). Merge both to sort
things out.

While I'm at it, move all of it to smpi_deployment to reduce the
amount of globals made visible to more than one module.

src/smpi/bindings/smpi_pmpi_comm.cpp
src/smpi/include/private.hpp
src/smpi/internals/smpi_actor.cpp
src/smpi/internals/smpi_deployment.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/plugins/sampi_loadbalancer.cpp

index 73e4379..cc75503 100644 (file)
@@ -288,6 +288,7 @@ int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
   static int zero = 0;
   static int tag_ub = INT_MAX;
   static int last_used_code = MPI_ERR_LASTCODE;
+  static int universe_size;
 
   if (comm==MPI_COMM_NULL){
     *flag = 0;
@@ -303,7 +304,8 @@ int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
     return MPI_SUCCESS;
   case MPI_UNIVERSE_SIZE:
     *flag = 1;
-    *static_cast<int**>(attr_value) = &smpi_universe_size;
+    universe_size                   = smpi_get_universe_size();
+    *static_cast<int**>(attr_value) = &universe_size;
     return MPI_SUCCESS;
   case MPI_LASTUSEDCODE:
     *flag = 1;
index 2c805a5..97e81b0 100644 (file)
@@ -71,7 +71,7 @@ typedef SMPI_Dist_Graph_topology* MPIR_Dist_Graph_Topology;
 
 XBT_PRIVATE simgrid::smpi::ActorExt* smpi_process();
 XBT_PRIVATE simgrid::smpi::ActorExt* smpi_process_remote(simgrid::s4u::ActorPtr actor);
-XBT_PRIVATE int smpi_process_count();
+XBT_PRIVATE int smpi_get_universe_size();
 
 XBT_PRIVATE void smpi_deployment_register_process(const std::string& instance_id, int rank,
                                                   simgrid::s4u::ActorPtr actor);
@@ -455,7 +455,6 @@ struct s_smpi_privatization_region_t {
 typedef s_smpi_privatization_region_t* smpi_privatization_region_t;
 
 extern XBT_PRIVATE int smpi_loaded_page;
-extern XBT_PRIVATE int smpi_universe_size;
 XBT_PRIVATE smpi_privatization_region_t smpi_init_global_memory_segment_process();
 
 /**
index 3a5af91..c4c7e81 100644 (file)
@@ -221,8 +221,8 @@ int ActorExt::sampling()
 
 void ActorExt::init()
 {
-  xbt_assert(smpi_process_count() != 0, "SimGrid was not initialized properly before entering MPI_Init. "
-                                        "Aborting, please check compilation process and use smpirun.");
+  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::ActorPtr proc = simgrid::s4u::Actor::self();
   // cheinrich: I'm not sure what the impact of the SMPI_switch_data_segment on this call is. I moved
index c733182..828c52b 100644 (file)
@@ -14,6 +14,8 @@ namespace simgrid {
 namespace smpi {
 namespace app {
 
+static int universe_size = 0;
+
 class Instance {
 public:
   Instance(const std::string& name, int max_no_processes, MPI_Comm comm, simgrid::s4u::Barrier* finalization_barrier)
@@ -28,6 +30,8 @@ public:
     //  FIXME : using MPI_Attr_put with MPI_UNIVERSE_SIZE is forbidden and we make it a no-op (which triggers a warning
     //  as MPI_ERR_ARG is returned). Directly calling Comm::attr_put breaks for now, as MPI_UNIVERSE_SIZE,is <0
     //  instance.comm_world->attr_put<simgrid::smpi::Comm>(MPI_UNIVERSE_SIZE, reinterpret_cast<void*>(instance.size));
+
+    universe_size += max_no_processes;
   }
 
   const std::string name;
@@ -43,7 +47,6 @@ public:
 using simgrid::smpi::app::Instance;
 
 static std::map<std::string, Instance> smpi_instances;
-extern int process_count; // How many processes have been allocated over all instances?
 
 /** @ingroup smpi_simulation
  * @brief Registers a running instance of a MPI program.
@@ -69,8 +72,6 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_
 
   Instance instance(std::string(name), num_processes, MPI_COMM_NULL, new simgrid::s4u::Barrier(num_processes));
 
-  process_count+=num_processes;
-
   smpi_instances.insert(std::pair<std::string, Instance>(name, instance));
 }
 
@@ -108,3 +109,8 @@ void smpi_deployment_cleanup_instances(){
   }
   smpi_instances.clear();
 }
+
+int smpi_get_universe_size()
+{
+  return simgrid::smpi::app::universe_size;
+}
index cfec9be..2019b2c 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();
@@ -683,8 +676,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);
index 72a68ca..dc5dfaa 100644 (file)
@@ -50,7 +50,7 @@ public:
   void kernel(simgrid::xbt::ReplayAction&)
   {
     static std::map<simgrid::s4u::ActorPtr, int> migration_call_counter;
-    static simgrid::s4u::Barrier smpilb_bar(smpi_process_count());
+    static simgrid::s4u::Barrier smpilb_bar(smpi_get_universe_size());
     simgrid::s4u::Host* cur_host = simgrid::s4u::this_actor::get_host();
     simgrid::s4u::Host* migrate_to_host;