Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Oops, this has to be secured by the mutex
[simgrid.git] / src / smpi / smpi_win.cpp
index ce5db55b1a48f65cacb618272f765676c143b0a9..bd90414d695889d4cf2dccc0a529c0920ebe7bf0 100644 (file)
@@ -161,13 +161,7 @@ int Win::fence(int assert)
     int size = static_cast<int>(reqs->size());
     // start all requests that have been prepared by another process
     if (size > 0) {
-      for (const auto& req : *reqs) {
-        if (req && (req->flags() & PREPARED))
-          req->start();
-      }
-
       MPI_Request* treqs = &(*reqs)[0];
-
       Request::waitall(size, treqs, MPI_STATUSES_IGNORE);
     }
     count_=0;
@@ -215,13 +209,13 @@ int Win::put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
     MPI_Request rreq = Request::rma_recv_init(recv_addr, target_count, target_datatype, smpi_process()->index(),
         comm_->group()->index(target_rank), SMPI_RMA_TAG+1, recv_win->comm_, MPI_OP_NULL);
 
+    //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_);
-    //start send
-    sreq->start();
-
     //push request to sender's win
     xbt_mutex_acquire(mut_);
     requests_->push_back(sreq);
@@ -321,13 +315,14 @@ int Win::accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da
         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_);
-    //start send
-    sreq->start();
-
     //push request to sender's win
     xbt_mutex_acquire(mut_);
     requests_->push_back(sreq);
@@ -360,7 +355,8 @@ int Win::get_accumulate( void *origin_addr, int origin_count, MPI_Datatype origi
 
   get(result_addr, result_count, result_datatype, target_rank,
               target_disp, target_count, target_datatype);
-  accumulate(origin_addr, origin_count, origin_datatype, target_rank,
+  if(op!=MPI_NO_OP)
+    accumulate(origin_addr, origin_count, origin_datatype, target_rank,
               target_disp, target_count, target_datatype, op);
 
   return MPI_SUCCESS;
@@ -556,12 +552,6 @@ int Win::finish_comms(){
   std::vector<MPI_Request> *reqqs = requests_;
   int size = static_cast<int>(reqqs->size());
   if (size > 0) {
-    // start all requests that have been prepared by another process
-    for (const auto& req : *reqqs) {
-      if (req && (req->flags() & PREPARED))
-        req->start();
-    }
-
     MPI_Request* treqs = &(*reqqs)[0];
     Request::waitall(size, treqs, MPI_STATUSES_IGNORE);
     reqqs->clear();