Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Replace SMPI finalization by a barrier with synchronized messages.
authorAugustin Degomme <degomme@idpann.imag.fr>
Mon, 10 Feb 2014 14:07:45 +0000 (15:07 +0100)
committerAugustin Degomme <degomme@idpann.imag.fr>
Mon, 10 Feb 2014 14:07:45 +0000 (15:07 +0100)
This avoids to looping over sleep when communications are not finished, which was ugly and annoying for MC

examples/smpi/energy/platform.xml
examples/smpi/replay/smpi_replay.tesh
examples/smpi/tracing/smpi_traced.tesh
src/smpi/smpi_global.c

index ad57cca..cb6d332 100644 (file)
@@ -12,5 +12,9 @@
   <host id="MyHost2" power="100.0Mf" >
         <prop id="power_per_state" value="95.0:200.0" />
   </host>
   <host id="MyHost2" power="100.0Mf" >
         <prop id="power_per_state" value="95.0:200.0" />
   </host>
+
+  <link id="link1" bandwidth="100kBps" latency="0"/>
+  <route src="MyHost1" dst="MyHost2"><link_ctn id="link1"/></route>
+  
 </AS>
 </platform>
 </AS>
 </platform>
index f2ce460..4cbef48 100644 (file)
@@ -213,13 +213,13 @@ $ tail -n +3 ./simgrid.trace
 > 13 19.691622 2 3
 > 12 19.695603 2 1 8
 > 12 19.698548 2 2 8
 > 13 19.691622 2 3
 > 12 19.695603 2 1 8
 > 12 19.698548 2 2 8
-> 13 19.698548 2 2
-> 7 19.698548 1 2
 > 12 19.699584 2 3 8
 > 12 19.699584 2 3 8
-> 13 19.699584 2 3
-> 7 19.699584 1 3
-> 13 19.705603 2 1
-> 7 19.705603 1 1
+> 13 19.703022 2 2
+> 7 19.703022 1 2
+> 13 19.703536 2 3
+> 7 19.703536 1 3
+> 13 19.703536 2 1
+> 7 19.703536 1 1
 
 
 $ rm -f ./simgrid.trace
 
 
 $ rm -f ./simgrid.trace
index 2038143..a12e36f 100644 (file)
@@ -58,7 +58,7 @@ $ ../../smpi_script/bin/smpirun -trace -trace-resource -trace-viva -trace-file s
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/TCP_gamma' to '4194304'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'smpi/cpu_threshold' to '-1'
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/TCP_gamma' to '4194304'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'smpi/cpu_threshold' to '-1'
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
-> [0.013981] [instr_config/INFO] No categories declared, ignoring generation of viva graph configuration
+> [0.011914] [instr_config/INFO] No categories declared, ignoring generation of viva graph configuration
 
 p Testing with parameters but without activating them with the safe switch (-trace)
 $ ../../smpi_script/bin/smpirun -trace-resource -trace-viva -trace-file smpi_traced.trace -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../msg/tracing/platform.xml -np 3 ./smpi_traced_simple --log=smpi_kernel.thres:warning
 
 p Testing with parameters but without activating them with the safe switch (-trace)
 $ ../../smpi_script/bin/smpirun -trace-resource -trace-viva -trace-file smpi_traced.trace -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../msg/tracing/platform.xml -np 3 ./smpi_traced_simple --log=smpi_kernel.thres:warning
index 0ff30a4..876889f 100644 (file)
@@ -99,11 +99,38 @@ void smpi_process_destroy(void)
  */
 void smpi_process_finalize(void)
 {
  */
 void smpi_process_finalize(void)
 {
-  // wait for all pending asynchronous comms to finish
-  if(!MC_is_active())
-  while (SIMIX_process_has_pending_comms(SIMIX_process_self())) {
-    simcall_process_sleep(0.01);
+  int i;
+  int size = smpi_comm_size(MPI_COMM_WORLD);
+  int rank = smpi_comm_rank(MPI_COMM_WORLD);
+  /* All non-root send & receive zero-length message. */
+  if (rank > 0) {
+    smpi_mpi_ssend (NULL, 0, MPI_BYTE, 0,
+                    COLL_TAG_BARRIER,
+                    MPI_COMM_WORLD);
+    smpi_mpi_recv (NULL, 0, MPI_BYTE, 0,
+                    COLL_TAG_BARRIER,
+                    MPI_COMM_WORLD, MPI_STATUS_IGNORE);
   }
   }
+  /* The root collects and broadcasts the messages. */
+  else {
+    MPI_Request* requests;
+    requests = (MPI_Request*)malloc( size * sizeof(MPI_Request) );
+    for (i = 1; i < size; ++i) {
+      requests[i] = smpi_mpi_irecv(NULL, 0, MPI_BYTE, MPI_ANY_SOURCE,
+                                   COLL_TAG_BARRIER, MPI_COMM_WORLD
+                                   );
+    }
+    smpi_mpi_waitall( size-1, requests+1, MPI_STATUSES_IGNORE );
+    for (i = 1; i < size; ++i) {
+      requests[i] = smpi_mpi_issend(NULL, 0, MPI_BYTE, i,
+                                   COLL_TAG_BARRIER,
+                                   MPI_COMM_WORLD
+                                   );
+    }
+    smpi_mpi_waitall( size-1, requests+1, MPI_STATUSES_IGNORE );
+    free( requests );
+  }
+
 }
 
 /**
 }
 
 /**