From 9d5b713b15c81fb2b2d40419993f47de5c7d48b8 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Mon, 7 Jun 2021 20:57:48 +0200 Subject: [PATCH] catch if MPI_Win_fence was only called once (not enough) when MPI_Win_free is called. --- src/smpi/bindings/smpi_pmpi_win.cpp | 4 ++++ src/smpi/include/smpi_win.hpp | 1 + src/smpi/mpi/smpi_win.cpp | 3 +-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/smpi/bindings/smpi_pmpi_win.cpp b/src/smpi/bindings/smpi_pmpi_win.cpp index 15e008f309..7a85bf2db4 100644 --- a/src/smpi/bindings/smpi_pmpi_win.cpp +++ b/src/smpi/bindings/smpi_pmpi_win.cpp @@ -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; diff --git a/src/smpi/include/smpi_win.hpp b/src/smpi/include/smpi_win.hpp index 5a6f3a142d..d7d1880055 100644 --- a/src/smpi/include/smpi_win.hpp +++ b/src/smpi/include/smpi_win.hpp @@ -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, diff --git a/src/smpi/mpi/smpi_win.cpp b/src/smpi/mpi/smpi_win.cpp index 8eebb2118b..216a200d1c 100644 --- a/src/smpi/mpi/smpi_win.cpp +++ b/src/smpi/mpi/smpi_win.cpp @@ -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(); -- 2.20.1