From a6413bc400b04be1e049b66f66895f6b3d046c76 Mon Sep 17 00:00:00 2001 From: Josep Pocurull Date: Thu, 16 May 2024 17:29:46 +0200 Subject: [PATCH] First draft of extrae_value_stack (not working yet) --- src/backends/extrae/extrae_value_stack.cpp | 50 +++++++++++++++++++++- src/backends/extrae/extrae_value_stack.hpp | 10 +++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/backends/extrae/extrae_value_stack.cpp b/src/backends/extrae/extrae_value_stack.cpp index 90cef23..c90d7cc 100644 --- a/src/backends/extrae/extrae_value_stack.cpp +++ b/src/backends/extrae/extrae_value_stack.cpp @@ -2,15 +2,61 @@ void ExtraeValueStackStrategy::region_start( const SITRegionInformation ®ion) const noexcept { - // TODO + + extrae_value_t event_number; + extrae_type_t event_type = 7000; + char myExtrae_descriptio[] = "OpenFOAM Extrae Profiling"; + + // Check if there is already an event with that name + auto iter = event_history.find(region.name); + if (iter != event_history.end()) + { + event_number = iter->second; + } + else + { + // Update extrae defined events + + event_number = static_cast(event_history.size()); + event_history.insert(std::make_pair(name, event_number)); + + unsigned numEvents = event_history.size(); + + for (const auto& iter : event_history) + { + eventDescriptions.push_back(const_cast(iter.first.data())); + eventValues.push_back(iter.second); + } + +// Extrae_define_event_type +// ( +// &event_type, +// myExtrae_description, +// &numEvents, +// eventValues.data(), +// eventDescriptions.data() +// ); + } + + Extrae_event(event_type, event_number); + } void ExtraeValueStackStrategy::region_stop( const SITRegionInformation ®ion) const noexcept { // TODO + extrae_type_t event_type = 7000; + Extrae_event(event_type, 0); } void ExtraeValueStackStrategy::init() const noexcept { - // TODO + + //myExtrae_descriptio[] = "OpenFOAM Extrae Profiling"; + //event_type = 7000; + + if (event_history.empty()) // it has to be empty... + { + event_history.insert(std::make_pair("End", 0)); + } } void ExtraeValueStackStrategy::finalize() const noexcept { // TODO diff --git a/src/backends/extrae/extrae_value_stack.hpp b/src/backends/extrae/extrae_value_stack.hpp index 039c674..7fa7a77 100644 --- a/src/backends/extrae/extrae_value_stack.hpp +++ b/src/backends/extrae/extrae_value_stack.hpp @@ -1,8 +1,18 @@ #include "sit_strategy.hpp" +#include "extrae.h" +#include +#include + +static std::map event_history; +static std::vector eventValues; +static std::vector eventDescriptions; class ExtraeValueStackStrategy : public SITProfilingStrategy { + //char *myExtrae_description = NULL; + extrae_type_t event_type; public: + inline static const std::string_view name = "Extrae::ValueStack"; void region_start(const SITRegionInformation ®ion) const noexcept override; void region_stop(const SITRegionInformation ®ion) const noexcept override; -- GitLab