From d7af42144958e6dc42d42e2bcfb890402b53ba15 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 3 Mar 2017 13:24:28 +0100 Subject: [PATCH] fix a few minor smells --- src/smpi/smpi_base.cpp | 17 ++++++++++------- src/smpi/smpi_rma.cpp | 35 ++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/smpi/smpi_base.cpp b/src/smpi/smpi_base.cpp index aeb6422897..bac438a320 100644 --- a/src/smpi/smpi_base.cpp +++ b/src/smpi/smpi_base.cpp @@ -1338,7 +1338,8 @@ void smpi_mpi_allreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype da void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) { int system_tag = -888; - MPI_Aint lb = 0, dataext = 0; + MPI_Aint lb = 0; + MPI_Aint dataext = 0; int rank = smpi_comm_rank(comm); int size = smpi_comm_size(comm); @@ -1397,7 +1398,8 @@ void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp void smpi_mpi_exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) { int system_tag = -888; - MPI_Aint lb = 0, dataext = 0; + MPI_Aint lb = 0; + MPI_Aint dataext = 0; int recvbuf_is_empty=1; int rank = smpi_comm_rank(comm); int size = smpi_comm_size(comm); @@ -1419,6 +1421,7 @@ void smpi_mpi_exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat } // Wait for completion of all comms. smpi_mpi_startall(size - 1, requests); + if(smpi_op_is_commute(op)){ for (int other = 0; other < size - 1; other++) { index = smpi_mpi_waitany(size - 1, requests, MPI_STATUS_IGNORE); @@ -1439,11 +1442,11 @@ void smpi_mpi_exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat for (int other = 0; other < size - 1; other++) { smpi_mpi_wait(&(requests[other]), MPI_STATUS_IGNORE); if(index < rank) { - if(recvbuf_is_empty){ - smpi_datatype_copy(tmpbufs[other], count, datatype, recvbuf, count, datatype); - recvbuf_is_empty=0; - } else - smpi_op_apply(op, tmpbufs[other], recvbuf, &count, &datatype); + if (recvbuf_is_empty) { + smpi_datatype_copy(tmpbufs[other], count, datatype, recvbuf, count, datatype); + recvbuf_is_empty = 0; + } else + smpi_op_apply(op, tmpbufs[other], recvbuf, &count, &datatype); } } } diff --git a/src/smpi/smpi_rma.cpp b/src/smpi/smpi_rma.cpp index 30278c8acc..159bbc1c9a 100644 --- a/src/smpi/smpi_rma.cpp +++ b/src/smpi/smpi_rma.cpp @@ -28,13 +28,11 @@ typedef struct s_smpi_mpi_win{ MPI_Win smpi_mpi_win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm){ - MPI_Win win; - int comm_size = smpi_comm_size(comm); - int rank=smpi_comm_rank(comm); + int rank = smpi_comm_rank(comm); XBT_DEBUG("Creating window"); - win = xbt_new(s_smpi_mpi_win_t, 1); + MPI_Win win = xbt_new(s_smpi_mpi_win_t, 1); win->base = base; win->size = size; win->disp_unit = disp_unit; @@ -278,17 +276,18 @@ int smpi_mpi_win_start(MPI_Group group, int assert, MPI_Win win){ must complete, without further dependencies. */ //naive, blocking implementation. - int i=0,j=0; - int size = smpi_group_size(group); - MPI_Request* reqs = xbt_new0(MPI_Request, size); - - while(j!=size){ - int src=smpi_group_index(group,j); - if(src!=smpi_process_index()&& src!=MPI_UNDEFINED){ - reqs[i]=smpi_irecv_init(nullptr, 0, MPI_CHAR, src,SMPI_RMA_TAG+4, MPI_COMM_WORLD); - i++; - } - j++; + int i = 0; + int j = 0; + int size = smpi_group_size(group); + MPI_Request* reqs = xbt_new0(MPI_Request, size); + + while (j != size) { + int src = smpi_group_index(group, j); + if (src != smpi_process_index() && src != MPI_UNDEFINED) { + reqs[i] = smpi_irecv_init(nullptr, 0, MPI_CHAR, src, SMPI_RMA_TAG + 4, MPI_COMM_WORLD); + i++; + } + j++; } size=i; smpi_mpi_startall(size, reqs); @@ -305,7 +304,8 @@ int smpi_mpi_win_start(MPI_Group group, int assert, MPI_Win win){ int smpi_mpi_win_post(MPI_Group group, int assert, MPI_Win win){ //let's make a synchronous send here - int i=0,j=0; + int i = 0; + int j = 0; int size = smpi_group_size(group); MPI_Request* reqs = xbt_new0(MPI_Request, size); @@ -336,7 +336,8 @@ int smpi_mpi_win_complete(MPI_Win win){ xbt_die("Complete called on already opened MPI_Win"); XBT_DEBUG("Entering MPI_Win_Complete"); - int i=0,j=0; + int i = 0; + int j = 0; int size = smpi_group_size(win->group); MPI_Request* reqs = xbt_new0(MPI_Request, size); -- 2.20.1