Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
We can start the recv requests directly now, and don't have to wait for a synchro.
[simgrid.git] / src / smpi / smpi_win.cpp
index 4db32e7..6237780 100644 (file)
@@ -14,7 +14,7 @@ namespace smpi{
 std::unordered_map<int, smpi_key_elem> Win::keyvals_;
 int Win::keyval_id_=0;
 
-Win::Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated): base_(base), size_(size), disp_unit_(disp_unit), assert_(0), info_(info), comm_(comm), allocated_(allocated){
+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();
   XBT_DEBUG("Creating window");
@@ -130,6 +130,10 @@ int Win::disp_unit(){
   return disp_unit_;
 }
 
+int Win::dynamic(){
+  return dynamic_;
+}
+
 void Win::set_info(MPI_Info info){
   if(info_!= MPI_INFO_NULL)
     info->ref();
@@ -157,18 +161,15 @@ 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;
     xbt_mutex_release(mut_);
   }
+
+  if(assert==MPI_MODE_NOSUCCEED)//there should be no ops after this one, tell we are closed.
+    opened_=0;
   assert_ = assert;
 
   MSG_barrier_wait(bar_);
@@ -214,7 +215,7 @@ int Win::put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
     xbt_mutex_release(recv_win->mut_);
     //start send
     sreq->start();
-
+    rreq->start();
     //push request to sender's win
     xbt_mutex_acquire(mut_);
     requests_->push_back(sreq);
@@ -320,7 +321,7 @@ int Win::accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da
     xbt_mutex_release(recv_win->mut_);
     //start send
     sreq->start();
-
+    rreq->start();
     //push request to sender's win
     xbt_mutex_acquire(mut_);
     requests_->push_back(sreq);
@@ -549,12 +550,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();