X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/727c068cd59669e79c6779f9ff93ec4ac91f7522..a2f1b23687f04169144f4ffb4f20dc4fc5c28395:/src/smpi/colls/alltoall-ring-light-barrier.c diff --git a/src/smpi/colls/alltoall-ring-light-barrier.c b/src/smpi/colls/alltoall-ring-light-barrier.c index 2508ed1bc2..f90144525a 100644 --- a/src/smpi/colls/alltoall-ring-light-barrier.c +++ b/src/smpi/colls/alltoall-ring-light-barrier.c @@ -22,20 +22,21 @@ ****************************************************************************/ int -smpi_coll_tuned_alltoall_ring_light_barrier(void * send_buff, int send_count, - MPI_Datatype send_type, void * recv_buff, - int recv_count, MPI_Datatype recv_type, - MPI_Comm comm) +smpi_coll_tuned_alltoall_ring_light_barrier(void *send_buff, int send_count, + MPI_Datatype send_type, + void *recv_buff, int recv_count, + MPI_Datatype recv_type, + MPI_Comm comm) { MPI_Aint send_chunk, recv_chunk; MPI_Status s; int i, src, dst, rank, num_procs, next_dst, next_src; - int tag = 1, success = 1; /*, failure = 0;*/ + int tag = 1, success = 1; /*, failure = 0; */ char send_sync = 'a', recv_sync = 'b'; - char * send_ptr = (char *) send_buff; - char * recv_ptr = (char *) recv_buff; - + char *send_ptr = (char *) send_buff; + char *recv_ptr = (char *) recv_buff; + MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &num_procs); MPI_Type_extent(send_type, &send_chunk); @@ -45,28 +46,25 @@ smpi_coll_tuned_alltoall_ring_light_barrier(void * send_buff, int send_count, recv_chunk *= recv_count; MPI_Sendrecv(send_ptr + rank * send_chunk, send_count, send_type, rank, tag, - recv_ptr + rank * recv_chunk, recv_count, recv_type, rank, tag, - comm, &s); + recv_ptr + rank * recv_chunk, recv_count, recv_type, rank, tag, + comm, &s); + + for (i = 1; i < num_procs; i++) { + src = (rank - i + num_procs) % num_procs; + dst = (rank + i) % num_procs; + + MPI_Sendrecv(send_ptr + dst * send_chunk, send_count, send_type, + dst, tag, recv_ptr + src * recv_chunk, recv_count, + recv_type, src, tag, comm, &s); - for (i = 1; i < num_procs; i++) - { - src = (rank - i + num_procs) % num_procs; - dst = (rank + i) % num_procs; - - MPI_Sendrecv(send_ptr + dst * send_chunk, send_count, send_type, - dst, tag, recv_ptr + src * recv_chunk, recv_count, - recv_type, src, tag, comm, &s); + if ((i + 1) < num_procs) { + next_src = (rank - (i + 1) + num_procs) % num_procs; + next_dst = (rank + (i + 1) + num_procs) % num_procs; + MPI_Sendrecv(&send_sync, 1, MPI_CHAR, next_src, tag, + &recv_sync, 1, MPI_CHAR, next_dst, tag, comm, &s); - if ((i + 1) < num_procs) - { - next_src = (rank - (i + 1) + num_procs) % num_procs; - next_dst = (rank + (i + 1) + num_procs) % num_procs; - MPI_Sendrecv(&send_sync, 1, MPI_CHAR, next_src, tag, - &recv_sync, 1, MPI_CHAR, next_dst, tag, - comm, &s); - - } } + } return success; }