X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a2f1b23687f04169144f4ffb4f20dc4fc5c28395..64d0f9debf71f140a2faa41d2ee6e4892ba37bb9:/src/smpi/colls/bcast-scatter-LR-allgather.c diff --git a/src/smpi/colls/bcast-scatter-LR-allgather.c b/src/smpi/colls/bcast-scatter-LR-allgather.c index db265a657d..ebd55391ac 100644 --- a/src/smpi/colls/bcast-scatter-LR-allgather.c +++ b/src/smpi/colls/bcast-scatter-LR-allgather.c @@ -1,4 +1,4 @@ -#include "colls.h" +#include "colls_private.h" /***************************************************************************** @@ -71,11 +71,11 @@ smpi_coll_tuned_bcast_scatter_LR_allgather(void *buff, int count, int i, src, dst, rank, num_procs; int mask, relative_rank, curr_size, recv_size, send_size, nbytes; int scatter_size, left, right, next_src, *recv_counts, *disps; - int tag = 1, success = 0, failure = 1; + int tag = 1; - MPI_Comm_rank(comm, &rank); - MPI_Comm_size(comm, &num_procs); - MPI_Type_extent(data_type, &extent); + rank = smpi_comm_rank(comm); + num_procs = smpi_comm_size(comm); + extent = smpi_datatype_get_extent(data_type); nbytes = extent * count; @@ -97,9 +97,9 @@ smpi_coll_tuned_bcast_scatter_LR_allgather(void *buff, int count, curr_size = 0; // this process doesn't receive any data // because of uneven division else { - MPI_Recv((char *) buff + relative_rank * scatter_size, recv_size, + smpi_mpi_recv((char *) buff + relative_rank * scatter_size, recv_size, MPI_BYTE, src, tag, comm, &status); - MPI_Get_count(&status, MPI_BYTE, &curr_size); + curr_size = smpi_mpi_get_count(&status, MPI_BYTE); } break; } @@ -121,7 +121,7 @@ smpi_coll_tuned_bcast_scatter_LR_allgather(void *buff, int count, dst = rank + mask; if (dst >= num_procs) dst -= num_procs; - MPI_Send((char *) buff + scatter_size * (relative_rank + mask), + smpi_mpi_send((char *) buff + scatter_size * (relative_rank + mask), send_size, MPI_BYTE, dst, tag, comm); curr_size -= send_size; @@ -131,19 +131,8 @@ smpi_coll_tuned_bcast_scatter_LR_allgather(void *buff, int count, } // done scatter now do allgather - recv_counts = (int *) malloc(sizeof(int) * num_procs); - if (!recv_counts) { - printf("bcast-scatter-LR-allgather:95: cannot allocate memory\n"); - MPI_Finalize(); - exit(failure); - } - - disps = (int *) malloc(sizeof(int) * num_procs); - if (!disps) { - printf("bcast-scatter-LR-allgather:103: cannot allocate memory\n"); - MPI_Finalize(); - exit(failure); - } + recv_counts = (int *) xbt_malloc(sizeof(int) * num_procs); + disps = (int *) xbt_malloc(sizeof(int) * num_procs); for (i = 0; i < num_procs; i++) { recv_counts[i] = nbytes - i * scatter_size; @@ -164,7 +153,7 @@ smpi_coll_tuned_bcast_scatter_LR_allgather(void *buff, int count, next_src = left; for (i = 1; i < num_procs; i++) { - MPI_Sendrecv((char *) buff + disps[(src - root + num_procs) % num_procs], + smpi_mpi_sendrecv((char *) buff + disps[(src - root + num_procs) % num_procs], recv_counts[(src - root + num_procs) % num_procs], MPI_BYTE, right, tag, (char *) buff + @@ -179,5 +168,5 @@ smpi_coll_tuned_bcast_scatter_LR_allgather(void *buff, int count, free(recv_counts); free(disps); - return success; + return MPI_SUCCESS; }