X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/05736ee0ede974fcf9fb60a13a40c50d62fcc19d..d7af42144958e6dc42d42e2bcfb890402b53ba15:/src/smpi/smpi_rma.cpp?ds=sidebyside diff --git a/src/smpi/smpi_rma.cpp b/src/smpi/smpi_rma.cpp index 756adb3738..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); @@ -364,15 +365,17 @@ int smpi_mpi_win_complete(MPI_Win win){ size = static_cast(reqqs->size()); XBT_DEBUG("Win_complete - Finishing %d RMA calls", size); - // start all requests that have been prepared by another process - for (auto req: *reqqs){ - if (req && (req->flags & PREPARED)) - smpi_mpi_start(req); - } + if (size > 0) { + // start all requests that have been prepared by another process + for (const auto& req : *reqqs) { + if (req && (req->flags & PREPARED)) + smpi_mpi_start(req); + } - MPI_Request* treqs = size > 0 ? &(*reqqs)[0] : nullptr; - smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE); - reqqs->clear(); + MPI_Request* treqs = &(*reqqs)[0]; + smpi_mpi_waitall(size, treqs, MPI_STATUSES_IGNORE); + reqqs->clear(); + } xbt_mutex_release(win->mut); smpi_group_unuse(win->group); @@ -408,16 +411,17 @@ int smpi_mpi_win_wait(MPI_Win win){ size = static_cast(reqqs->size()); XBT_DEBUG("Win_wait - Finishing %d RMA calls", size); + if (size > 0) { + // start all requests that have been prepared by another process + for (const auto& req : *reqqs) { + if (req && (req->flags & PREPARED)) + smpi_mpi_start(req); + } - // start all requests that have been prepared by another process - for(auto req: *reqqs){ - if (req && (req->flags & PREPARED)) - smpi_mpi_start(req); + MPI_Request* treqs = &(*reqqs)[0]; + smpi_mpi_waitall(size, treqs, MPI_STATUSES_IGNORE); + reqqs->clear(); } - - MPI_Request* treqs = size > 0 ? &(*reqqs)[0] : nullptr; - smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE); - reqqs->clear(); xbt_mutex_release(win->mut); smpi_group_unuse(win->group);