From 11b0b4436b34c1995072a837ff128924be89a76c Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Fri, 30 Aug 2024 12:38:28 +0200 Subject: [PATCH] Enable double finalize calls --- src/delegator.cpp | 18 ++++++++++++++++-- src/delegator.hpp | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/delegator.cpp b/src/delegator.cpp index b8a59f5..9f128db 100644 --- a/src/delegator.cpp +++ b/src/delegator.cpp @@ -276,12 +276,26 @@ void Delegator::Finalize() { if (!nesmik_on_) { return; } + // Check double finalize + if (did_finalize_) { + if (mpi_helper_->IsUsingMPI()) { + std::cout << "neSmiK Warning: neSmiK already finalized for rank: " + << mpi_helper_->getRankNumber() << std::endl; + } else { + std::cout << "neSmiK Warning: neSmiK already finalized" << std::endl; + } + + return; + } + switch (backend_selection_) { case BackendMode::NotProperlyNested: - return npn_annotation_strategy_->Finalize(); + npn_annotation_strategy_->Finalize(); break; case BackendMode::ProperlyNested: - return pn_annotation_strategy_->Finalize(); + pn_annotation_strategy_->Finalize(); break; } + + did_finalize_ = true; }; diff --git a/src/delegator.hpp b/src/delegator.hpp index a9f0055..57ab41d 100644 --- a/src/delegator.hpp +++ b/src/delegator.hpp @@ -28,6 +28,7 @@ class Delegator { inline static BackendMode backend_selection_; inline static bool nesmik_on_{false}; inline static bool did_initialize_{false}; + inline static bool did_finalize_{false}; inline static std::unique_ptr mpi_helper_; -- GitLab