-/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
mode_=0;
comm->add_rma_win(this);
+ comm->ref();
Colls::allgather(&(connected_wins_[rank_]), sizeof(MPI_Win), MPI_BYTE, connected_wins_, sizeof(MPI_Win),
MPI_BYTE, comm);
comm_->remove_rma_win(this);
Colls::barrier(comm_);
+ Comm::unref(comm_);
+
if (rank_ == 0)
MSG_barrier_destroy(bar_);
xbt_mutex_destroy(mut_);
return MPI_ERR_ARG;
void* recv_addr = static_cast<void*> ( static_cast<char*>(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
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;
// 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_++;
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;
}
size = 0;
std::vector<MPI_Request> myreqqs;
std::vector<MPI_Request>::iterator iter = reqqs->begin();
+ int proc_id = comm_->group()->actor(rank)->get_pid();
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++;
return size;
}
-
+int Win::shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr)
+{
+ MPI_Win target_win = rank != MPI_PROC_NULL ? connected_wins_[rank] : nullptr;
+ for (int i = 0; not target_win && i < comm_->size(); i++) {
+ if (connected_wins_[i]->size_ > 0)
+ target_win = connected_wins_[i];
+ }
+ if (target_win) {
+ *size = target_win->size_;
+ *disp_unit = target_win->disp_unit_;
+ *static_cast<void**>(baseptr) = target_win->base_;
+ } else {
+ *size = 0;
+ *static_cast<void**>(baseptr) = xbt_malloc(0);
+ }
+ return MPI_SUCCESS;
+}
}
}