Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Further cleanups in SMPI includes
[simgrid.git] / src / smpi / smpi_win.cpp
index 28f399f..0240e93 100644 (file)
@@ -1,11 +1,17 @@
-/* Copyright (c) 2007-2017. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2007-2017. 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. */
 
-#include "private.h"
-#include <vector>
+#include "src/smpi/private.h"
+#include "src/smpi/smpi_coll.hpp"
+#include "src/smpi/smpi_comm.hpp"
+#include "src/smpi/smpi_datatype.hpp"
+#include "src/smpi/smpi_info.hpp"
+#include "src/smpi/smpi_keyvals.hpp"
+#include "src/smpi/smpi_process.hpp"
+#include "src/smpi/smpi_request.hpp"
+#include "src/smpi/smpi_win.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_rma, smpi, "Logging specific to SMPI (RMA operations)");
 
@@ -559,9 +565,6 @@ int Win::wait(){
 }
 
 int Win::lock(int lock_type, int rank, int assert){
-  if(opened_!=0)
-    return MPI_ERR_WIN;
-
   MPI_Win target_win = connected_wins_[rank];
 
   if ((lock_type == MPI_LOCK_EXCLUSIVE && target_win->mode_ != MPI_LOCK_SHARED)|| target_win->mode_ == MPI_LOCK_EXCLUSIVE){
@@ -575,9 +578,10 @@ int Win::lock(int lock_type, int rank, int assert){
 
   target_win->lockers_.push_back(comm_->rank());
 
-  int finished = finish_comms();
+  int finished = finish_comms(rank);
   XBT_DEBUG("Win_lock %d - Finished %d RMA calls", rank, finished);
-
+  finished = target_win->finish_comms(rank_);
+  XBT_DEBUG("Win_lock target %d - Finished %d RMA calls", rank, finished);
   return MPI_SUCCESS;
 }
 
@@ -593,9 +597,6 @@ int Win::lock_all(int assert){
 }
 
 int Win::unlock(int rank){
-  if(opened_!=0)
-    return MPI_ERR_WIN;
-
   MPI_Win target_win = connected_wins_[rank];
   int target_mode = target_win->mode_;
   target_win->mode_= 0;
@@ -604,9 +605,10 @@ int Win::unlock(int rank){
     xbt_mutex_release(target_win->lock_mut_);
   }
 
-  int finished = finish_comms();
+  int finished = finish_comms(rank);
   XBT_DEBUG("Win_unlock %d - Finished %d RMA calls", rank, finished);
-
+  finished = target_win->finish_comms(rank_);
+  XBT_DEBUG("Win_unlock target %d - Finished %d RMA calls", rank, finished);
   return MPI_SUCCESS;
 }
 
@@ -683,7 +685,7 @@ int Win::finish_comms(int rank){
     std::vector<MPI_Request>* myreqqs = new std::vector<MPI_Request>();
     std::vector<MPI_Request>::iterator iter = reqqs->begin();
     while (iter != reqqs->end()){
-      if(((*iter)->src() == rank) || ((*iter)->dst() == rank)){
+      if(((*iter)!=MPI_REQUEST_NULL) && (((*iter)->src() == rank) || ((*iter)->dst() == rank))){
           myreqqs->push_back(*iter);
           iter = reqqs->erase(iter);
           size++;