- //As the tag will be used for ordering of the operations, substract count from it (to avoid collisions with other SMPI tags, SMPI_RMA_TAG is set below all the other ones we use )
- //prepare send_request
-
- MPI_Request sreq = Request::rma_send_init(origin_addr, origin_count, origin_datatype,
- smpi_process()->index(), comm_->group()->index(target_rank), SMPI_RMA_TAG-3-count_, comm_, op);
-
- //prepare receiver request
- MPI_Request rreq = Request::rma_recv_init(recv_addr, target_count, target_datatype,
- smpi_process()->index(), comm_->group()->index(target_rank), SMPI_RMA_TAG-3-count_, recv_win->comm_, op);
-
- count_++;
-
- //start send
- sreq->start();
- //push request to receiver's win
- xbt_mutex_acquire(recv_win->mut_);
- recv_win->requests_->push_back(rreq);
- rreq->start();
- xbt_mutex_release(recv_win->mut_);
-
- if(request!=nullptr){
- *request=sreq;
- }else{
- xbt_mutex_acquire(mut_);
- requests_->push_back(sreq);
- xbt_mutex_release(mut_);
- }
+ // As the tag will be used for ordering of the operations, subtract count from it (to avoid collisions with other
+ // SMPI tags, SMPI_RMA_TAG is set below all the other ones we use)
+ // prepare send_request
+
+ MPI_Request sreq = Request::rma_send_init(origin_addr, origin_count, origin_datatype, comm_->rank(), target_rank,
+ SMPI_RMA_TAG - 3 - count_, comm_, op);
+
+ // prepare receiver request
+ MPI_Request rreq = Request::rma_recv_init(recv_addr, target_count, target_datatype, recv_win->comm_->rank(),
+ recv_win->comm_->group()->rank(comm_->group()->actor(target_rank)),
+ SMPI_RMA_TAG - 3 - count_, recv_win->comm_, op);
+
+ count_++;
+
+ // start send
+ sreq->start();
+ // push request to receiver's win
+ recv_win->mut_->lock();
+ recv_win->requests_.push_back(rreq);
+ rreq->start();
+ recv_win->mut_->unlock();
+
+ if (request != nullptr) {
+ *request = sreq;
+ } else {
+ mut_->lock();
+ requests_.push_back(sreq);
+ mut_->unlock();
+ }