X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4b8e7f392b312b709f99f8f29ec47038d4eb274f..87ff63372b9588e7b6ca2a1faaecebad660bf8c4:/src/smpi/mpi/smpi_win.cpp diff --git a/src/smpi/mpi/smpi_win.cpp b/src/smpi/mpi/smpi_win.cpp index 39d2e8ae3f..212f0f5c0d 100644 --- a/src/smpi/mpi/smpi_win.cpp +++ b/src/smpi/mpi/smpi_win.cpp @@ -24,20 +24,20 @@ int Win::keyval_id_=0; Win::Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated, int dynamic): base_(base), size_(size), disp_unit_(disp_unit), assert_(0), info_(info), comm_(comm), allocated_(allocated), dynamic_(dynamic){ int comm_size = comm->size(); - rank_ = comm->rank(); + rank_ = comm->rank(); XBT_DEBUG("Creating window"); if(info!=MPI_INFO_NULL) info->ref(); - name_ = nullptr; - opened_ = 0; - group_ = MPI_GROUP_NULL; - requests_ = new std::vector(); - mut_=xbt_mutex_init(); - lock_mut_=xbt_mutex_init(); - atomic_mut_=xbt_mutex_init(); - connected_wins_ = new MPI_Win[comm_size]; + name_ = nullptr; + opened_ = 0; + group_ = MPI_GROUP_NULL; + requests_ = new std::vector(); + mut_ = xbt_mutex_init(); + lock_mut_ = xbt_mutex_init(); + atomic_mut_ = xbt_mutex_init(); + connected_wins_ = new MPI_Win[comm_size]; connected_wins_[rank_] = this; - count_ = 0; + count_ = 0; if(rank_==0){ bar_ = MSG_barrier_init(comm_size); } @@ -207,9 +207,9 @@ int Win::put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, return MPI_ERR_ARG; void* recv_addr = static_cast ( static_cast(recv_win->base_) + target_disp * recv_win->disp_unit_); - XBT_DEBUG("Entering MPI_Put to %d", target_rank); if (target_rank != comm_->rank()) { // This is not for myself, so we need to send messages + XBT_DEBUG("Entering MPI_Put to remote rank %d", target_rank); // prepare send_request MPI_Request sreq = // TODO cheinrich Check for rank / pid conversion @@ -239,6 +239,7 @@ int Win::put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, xbt_mutex_release(recv_win->mut_); }else{ + XBT_DEBUG("Entering MPI_Put from myself to myself, rank %d", target_rank); Datatype::copy(origin_addr, origin_count, origin_datatype, recv_addr, target_count, target_datatype); if(request!=nullptr) *request = MPI_REQUEST_NULL; @@ -339,7 +340,7 @@ int Win::accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da // prepare receiver request MPI_Request rreq = Request::rma_recv_init(recv_addr, target_count, target_datatype, recv_win->comm_->rank(), - target_rank, SMPI_RMA_TAG - 3 - count_, recv_win->comm_, op); + recv_win->comm_->group()->rank(comm_->group()->actor(target_rank)), SMPI_RMA_TAG - 3 - count_, recv_win->comm_, op); count_++; @@ -512,7 +513,7 @@ int Win::complete(){ XBT_DEBUG("Entering MPI_Win_Complete"); int i = 0; int j = 0; - int size = group_->size(); + int size = group_->size(); MPI_Request* reqs = xbt_new0(MPI_Request, size); while(j!=size){ @@ -634,9 +635,9 @@ int Win::unlock_all(){ int Win::flush(int rank){ MPI_Win target_win = connected_wins_[rank]; - int finished = finish_comms(rank); + int finished = finish_comms(rank_); XBT_DEBUG("Win_flush on local %d - Finished %d RMA calls", rank_, finished); - finished = target_win->finish_comms(rank_); + finished = target_win->finish_comms(rank); XBT_DEBUG("Win_flush on remote %d - Finished %d RMA calls", rank, finished); return MPI_SUCCESS; } @@ -693,8 +694,13 @@ int Win::finish_comms(int rank){ size = 0; std::vector myreqqs; std::vector::iterator iter = reqqs->begin(); + int proc_id = comm_->group()->actor(rank)->getPid(); while (iter != reqqs->end()){ - if(((*iter)!=MPI_REQUEST_NULL) && (((*iter)->src() == rank) || ((*iter)->dst() == rank))){ + // Let's see if we're either the destination or the sender of this request + // because we only wait for requests that we are responsible for. + // Also use the process id here since the request itself returns from src() + // and dst() the process id, NOT the rank (which only exists in the context of a communicator). + if (((*iter) != MPI_REQUEST_NULL) && (((*iter)->src() == proc_id) || ((*iter)->dst() == proc_id))) { myreqqs.push_back(*iter); iter = reqqs->erase(iter); size++;