diff --git a/src/backends/wrappers/extrae/extrae_wrapper.cpp b/src/backends/wrappers/extrae/extrae_wrapper.cpp index 45fe235976f72d6aface796daf5dc8de624aec03..735d87f89bb381bda5ffd3acacb21ab259cfa1c4 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 1849c1d6df043c5e75181467fb3a8e3eb9b7632b..6fd0ce59681f4249b65b676c4d1980f821f1dc8e 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);