From 4ece358b93b8d6f463e61906fd087dd1ba3cbc7c Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Thu, 3 Mar 2022 21:25:25 +0100 Subject: [PATCH] put back s4u barrier for MC only (untested) --- src/smpi/include/smpi_win.hpp | 1 + src/smpi/mpi/smpi_win.cpp | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/smpi/include/smpi_win.hpp b/src/smpi/include/smpi_win.hpp index 5e18418b01..f020e8648c 100644 --- a/src/smpi/include/smpi_win.hpp +++ b/src/smpi/include/smpi_win.hpp @@ -28,6 +28,7 @@ class Win : public F2C, public Keyval { MPI_Comm comm_; std::vector requests_; s4u::MutexPtr mut_ = s4u::Mutex::create(); + s4u::Barrier* bar_ = nullptr; std::vector connected_wins_; std::string name_; int opened_ = 0; diff --git a/src/smpi/mpi/smpi_win.cpp b/src/smpi/mpi/smpi_win.cpp index 765d92f400..672063de57 100644 --- a/src/smpi/mpi/smpi_win.cpp +++ b/src/smpi/mpi/smpi_win.cpp @@ -3,6 +3,7 @@ /* 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 #include "smpi_win.hpp" #include "private.hpp" @@ -13,6 +14,7 @@ #include "smpi_keyvals.hpp" #include "smpi_request.hpp" #include "src/smpi/include/smpi_actor.hpp" +#include "src/mc/mc_replay.hpp" #include @@ -59,14 +61,24 @@ Win::Win(void* base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, colls::allgather(&connected_wins_[rank_], sizeof(MPI_Win), MPI_BYTE, connected_wins_.data(), sizeof(MPI_Win), MPI_BYTE, comm); - - colls::barrier(comm); + if (MC_is_active() || MC_record_replay_is_active()){ + if(rank_==0){ + bar_ = new s4u::Barrier(comm->size()); + } + colls::bcast(&bar_, sizeof(s4u::Barrier*), MPI_BYTE, 0, comm); + bar_->wait(); + }else{ + colls::barrier(comm); + } this->add_f(); } Win::~Win(){ //As per the standard, perform a barrier to ensure every async comm is finished - colls::barrier(comm_); + if (MC_is_active() || MC_record_replay_is_active()) + bar_->wait(); + else + colls::barrier(comm_); flush_local_all(); if (info_ != MPI_INFO_NULL) @@ -79,6 +91,9 @@ Win::~Win(){ colls::barrier(comm_); Comm::unref(comm_); + if (rank_ == 0) + delete bar_; + if (allocated_) xbt_free(base_); @@ -173,7 +188,10 @@ int Win::fence(int assert) opened_++; if (not (assert & MPI_MODE_NOPRECEDE)) { // This is not the first fence => finalize what came before - colls::barrier(comm_); + if (MC_is_active() || MC_record_replay_is_active()) + bar_->wait(); + else + colls::barrier(comm_); flush_local_all(); count_=0; } @@ -181,7 +199,10 @@ int Win::fence(int assert) if (assert & MPI_MODE_NOSUCCEED) // there should be no ops after this one, tell we are closed. opened_=0; assert_ = assert; - colls::barrier(comm_); + if (MC_is_active() || MC_record_replay_is_active()) + bar_->wait(); + else + colls::barrier(comm_); XBT_DEBUG("Leaving fence"); return MPI_SUCCESS; -- 2.20.1