From e486b4b929d187fb207d55f98ca8f0391787ba38 Mon Sep 17 00:00:00 2001 From: JOAN VINYALS YLLA CATALA Date: Mon, 16 Sep 2024 09:24:28 +0200 Subject: [PATCH] Add env variable to call Extrae_fini at neSmiK fini. --- src/backends/wrappers/extrae/extrae_wrapper.cpp | 7 ++++++- src/backends/wrappers/extrae/extrae_wrapper.hpp | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/backends/wrappers/extrae/extrae_wrapper.cpp b/src/backends/wrappers/extrae/extrae_wrapper.cpp index 45fe235..735d87f 100644 --- a/src/backends/wrappers/extrae/extrae_wrapper.cpp +++ b/src/backends/wrappers/extrae/extrae_wrapper.cpp @@ -105,7 +105,12 @@ void ExtraeWrapper::Finalize() { delete[] routine_c_names; } - if (did_init_extrae_) { + // We finalize depending if the use has defined the variable, otherwise we + // finalize extrae only if we had to initialize it. + bool have_to_finalize_extrae = + finalize_extrae_.getValue().value_or(did_init_extrae_); + + if (have_to_finalize_extrae) { // Assumption is that if we needed to initialize the lib we also need to // Finalize it Extrae_fini(); diff --git a/src/backends/wrappers/extrae/extrae_wrapper.hpp b/src/backends/wrappers/extrae/extrae_wrapper.hpp index 1849c1d..6fd0ce5 100644 --- a/src/backends/wrappers/extrae/extrae_wrapper.hpp +++ b/src/backends/wrappers/extrae/extrae_wrapper.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "extrae_types.hpp" @@ -20,6 +21,9 @@ class ExtraeWrapper { std::unordered_map type_to_value_map_; std::unordered_map string_to_value_; bool did_init_extrae_{false}; + EnvironmentVariable finalize_extrae_ = EnvironmentVariable( + "CALL_EXTRAE_FINALZIE", + "Enable it to tell neSmiK to call Extrae_fini upon finalization.", false); extrae_value getValueByName(extrae_type type, const std::string &name); -- GitLab