Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
catch if MPI_Win_fence was only called once (not enough) when MPI_Win_free is called.
authorAugustin Degomme <adegomme@users.noreply.github.com>
Mon, 7 Jun 2021 18:57:48 +0000 (20:57 +0200)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Mon, 7 Jun 2021 21:27:42 +0000 (23:27 +0200)
src/smpi/bindings/smpi_pmpi_win.cpp
src/smpi/include/smpi_win.hpp
src/smpi/mpi/smpi_win.cpp

index 15e008f..7a85bf2 100644 (file)
@@ -99,6 +99,10 @@ int PMPI_Win_detach(MPI_Win win, const void* base)
 int PMPI_Win_free( MPI_Win* win){
   CHECK_NULL(1, MPI_ERR_WIN, win)
   CHECK_WIN(1, (*win))
+  if ((*win)->opened() == 1){
+    XBT_WARN("Attempt to destroy a MPI_Win too early -missing MPI_Win_fence ?");
+    return MPI_ERR_WIN;
+  }
   const SmpiBenchGuard suspend_bench;
   delete *win;
   return MPI_SUCCESS;
index 5a6f3a1..d7d1880 100644 (file)
@@ -72,6 +72,7 @@ public:
   void* base() const;
   int disp_unit() const;
   int fence(int assert);
+  int opened() const {return opened_;}
   int put(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request=nullptr);
   int get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
index 8eebb21..216a200 100644 (file)
@@ -182,8 +182,7 @@ void Win::set_name(const char* name){
 int Win::fence(int assert)
 {
   XBT_DEBUG("Entering fence");
-  if (opened_ == 0)
-    opened_=1;
+  opened_++;
   if (not (assert & MPI_MODE_NOPRECEDE)) {
     // This is not the first fence => finalize what came before
     bar_->wait();