Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SMPI: simplify process creation
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 12 Apr 2017 05:44:06 +0000 (07:44 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 12 Apr 2017 05:53:04 +0000 (07:53 +0200)
finalization_barrier is either created when the processes are created
from smpirun, or taken from the instance if any. So there is no need
for a setter

This could be further simplified by making a default instance when
starting from smpirun. I just need to understand how to make this move
in the current swamp of corner cases...

src/smpi/smpi_global.cpp
src/smpi/smpi_process.cpp
src/smpi/smpi_process.hpp

index 7d5fa45..0da7f66 100644 (file)
@@ -294,14 +294,16 @@ void smpi_global_init()
 #endif
 
   int smpirun = 0;
+  msg_bar_t finalization_barrier = nullptr;
   if (process_count == 0){
     process_count = SIMIX_process_count();
     smpirun=1;
+    finalization_barrier = MSG_barrier_init(process_count);
   }
   smpi_universe_size = process_count;
   process_data       = new simgrid::smpi::Process*[process_count];
   for (int i = 0; i < process_count; i++) {
-    process_data[i] = new simgrid::smpi::Process(i);
+    process_data[i] = new simgrid::smpi::Process(i, finalization_barrier);
   }
   //if the process was launched through smpirun script we generate a global mpi_comm_world
   //if not, we let MPI_COMM_NULL, and the comm world will be private to each mpi instance
@@ -309,12 +311,9 @@ void smpi_global_init()
     group = new  simgrid::smpi::Group(process_count);
     MPI_COMM_WORLD = new  simgrid::smpi::Comm(group, nullptr);
     MPI_Attr_put(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, reinterpret_cast<void *>(process_count));
-    msg_bar_t bar = MSG_barrier_init(process_count);
 
-    for (int i = 0; i < process_count; i++) {
+    for (int i = 0; i < process_count; i++)
       group->set_mapping(i, i);
-      process_data[i]->set_finalization_barrier(bar);
-    }
   }
 }
 
index 4691886..92cd1d3 100644 (file)
@@ -32,7 +32,8 @@ static char *get_mailbox_name_small(char *str, int index)
 namespace simgrid{
 namespace smpi{
 
-Process::Process(int index)
+Process::Process(int index, msg_bar_t finalization_barrier)
+  : finalization_barrier_(finalization_barrier)
 {
   char name[MAILBOX_NAME_MAXLEN];
   mailbox_              = simgrid::s4u::Mailbox::byName(get_mailbox_name(name, index));
@@ -63,7 +64,6 @@ Process::Process(int index)
 
 void Process::set_data(int index, int* argc, char*** argv)
 {
-
     char* instance_id = (*argv)[1];
     comm_world_         = smpi_deployment_comm_world(instance_id);
     msg_bar_t bar = smpi_deployment_finalization_barrier(instance_id);
@@ -237,10 +237,6 @@ int Process::sampling()
   return sampling_;
 }
 
-void Process::set_finalization_barrier(msg_bar_t bar){
-  finalization_barrier_=bar;
-}
-
 msg_bar_t Process::finalization_barrier(){
   return finalization_barrier_;
 }
index 173e357..9cc8a2a 100644 (file)
@@ -33,8 +33,8 @@ class Process {
     int sampling_                   = 0; /* inside an SMPI_SAMPLE_ block? */
     char* instance_id_              = nullptr;
     bool replaying_                 = false; /* is the process replaying a trace */
-    msg_bar_t finalization_barrier_ = nullptr;
-    int return_value_               = 0;
+    msg_bar_t finalization_barrier_;
+    int return_value_ = 0;
     smpi_trace_call_location_t trace_call_loc_;
     smx_actor_t process_ = nullptr;
 #if HAVE_PAPI
@@ -43,7 +43,7 @@ class Process {
     papi_counter_t papi_counter_data_;
 #endif
   public:
-    explicit Process(int index);
+    explicit Process(int index, msg_bar_t barrier);
     void set_data(int index, int* argc, char*** argv);
     void finalize();
     int finalized();
@@ -70,7 +70,6 @@ class Process {
     void set_sampling(int s);
     int sampling();
     msg_bar_t finalization_barrier();
-    void set_finalization_barrier(msg_bar_t bar);
     int return_value();
     void set_return_value(int val);
     static void init(int *argc, char ***argv);