From: Augustin Degomme Date: Mon, 10 Feb 2014 14:07:45 +0000 (+0100) Subject: Replace SMPI finalization by a barrier with synchronized messages. X-Git-Tag: v3_11_beta~63 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/443210f774474a3c90d8adeda01417dd0dc1fbf7 Replace SMPI finalization by a barrier with synchronized messages. This avoids to looping over sleep when communications are not finished, which was ugly and annoying for MC --- diff --git a/examples/smpi/energy/platform.xml b/examples/smpi/energy/platform.xml index ad57ccaf10..cb6d3325fc 100644 --- a/examples/smpi/energy/platform.xml +++ b/examples/smpi/energy/platform.xml @@ -12,5 +12,9 @@ + + + + diff --git a/examples/smpi/replay/smpi_replay.tesh b/examples/smpi/replay/smpi_replay.tesh index f2ce4605dc..4cbef48818 100644 --- a/examples/smpi/replay/smpi_replay.tesh +++ b/examples/smpi/replay/smpi_replay.tesh @@ -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.698548 2 2 -> 7 19.698548 1 2 > 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 diff --git a/examples/smpi/tracing/smpi_traced.tesh b/examples/smpi/tracing/smpi_traced.tesh index 203814333d..a12e36feb5 100644 --- a/examples/smpi/tracing/smpi_traced.tesh +++ b/examples/smpi/tracing/smpi_traced.tesh @@ -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.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 diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index 0ff30a4c9c..876889f687 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -99,11 +99,38 @@ void smpi_process_destroy(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 ); + } + } /**