From 0bcabfa815f10ec8063e36154d30d48be2ddc5b4 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Wed, 2 Oct 2024 08:02:56 +0200 Subject: [PATCH 1/4] Added an eviroment variable to write all the regions, even though we might not enable tracing on them --- .../extrae_partial_tracer.cpp | 28 +++++++++++++++++++ .../extrae_partial_tracer.hpp | 6 ++++ 2 files changed, 34 insertions(+) diff --git a/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp b/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp index d2efb16..c70e682 100644 --- a/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp +++ b/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp @@ -79,12 +79,28 @@ void ExtraePartialTracer::Init() noexcept { << job.stop_at << "}" << std::endl; } } + if (mpi_helper_.IsRankNumber(0) && + write_all_regions_.getValue().value_or(false)) { + std::cout << "neSmiK Partial Tracer: Writing all regions even though " + "tracing might be off" + << std::endl; + } } void ExtraePartialTracer::RegionStart( const ProperlyNestedRegionInformation ®ion) noexcept { const std::string region_name = std::string(region.name); + if (write_all_regions_.getValue().value_or(false)) { + if (is_shutdown_) { + start(); + type_stack_strategy_->RegionStart(region); + shutdown(); + } else { + type_stack_strategy_->RegionStart(region); + } + } + // A bit costly maybe if there is a lot of jobs, but much easier than keeping // a tree or hashmap around std::vector matching_jobs; @@ -134,6 +150,18 @@ void ExtraePartialTracer::RegionStopLast( const ProperlyNestedRegionInformation ®ion) noexcept { const std::string region_name = std::string(region.name); + if (write_all_regions_.getValue().value_or(false)) { + if (write_all_regions_.getValue().value_or(false)) { + if (is_shutdown_) { + start(); + type_stack_strategy_->RegionStopLast(region); + shutdown(); + } else { + type_stack_strategy_->RegionStopLast(region); + } + } + } + if (!is_shutdown_) { std::cout << "Region stop last " << region.name << std::endl; type_stack_strategy_->RegionStopLast(region); diff --git a/src/backends/extrae_partial_tracer/extrae_partial_tracer.hpp b/src/backends/extrae_partial_tracer/extrae_partial_tracer.hpp index b4cbe5a..d613fd7 100644 --- a/src/backends/extrae_partial_tracer/extrae_partial_tracer.hpp +++ b/src/backends/extrae_partial_tracer/extrae_partial_tracer.hpp @@ -42,6 +42,12 @@ class ExtraePartialTracer : public ProperlyNestedAnnotationStrategy { "EXTRAE_WRITE_CONFIG_FILE", "Write corresponding Paraver .cfg file if set to True", false); + EnvironmentVariable write_all_regions_ = + EnvironmentVariable("PARTIAL_TRACER_ADD_ALL_REGIONS", + "Write all regions into the trace, even though " + "extrae might not be tracing for all of them", + false); + MPIHelper mpi_helper_; std::unordered_map region_counter_starts_; std::unordered_map region_counter_stops_; -- GitLab From 801d9cf8111004267388f264532e37c2187c8229 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Wed, 2 Oct 2024 09:50:10 +0200 Subject: [PATCH 2/4] correct logic --- .../extrae_partial_tracer.cpp | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp b/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp index c70e682..9e1593f 100644 --- a/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp +++ b/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp @@ -91,16 +91,6 @@ void ExtraePartialTracer::RegionStart( const ProperlyNestedRegionInformation ®ion) noexcept { const std::string region_name = std::string(region.name); - if (write_all_regions_.getValue().value_or(false)) { - if (is_shutdown_) { - start(); - type_stack_strategy_->RegionStart(region); - shutdown(); - } else { - type_stack_strategy_->RegionStart(region); - } - } - // A bit costly maybe if there is a lot of jobs, but much easier than keeping // a tree or hashmap around std::vector matching_jobs; @@ -144,27 +134,28 @@ void ExtraePartialTracer::RegionStart( if (!is_shutdown_) { type_stack_strategy_->RegionStart(region); } + // If were not running but env is set, we still add it to the trace + if (is_shutdown_ && write_all_regions_.getValue().value_or(false)) { + start(); + type_stack_strategy_->RegionStart(region); + shutdown(); + } } void ExtraePartialTracer::RegionStopLast( const ProperlyNestedRegionInformation ®ion) noexcept { const std::string region_name = std::string(region.name); - if (write_all_regions_.getValue().value_or(false)) { - if (write_all_regions_.getValue().value_or(false)) { - if (is_shutdown_) { - start(); - type_stack_strategy_->RegionStopLast(region); - shutdown(); - } else { - type_stack_strategy_->RegionStopLast(region); - } - } + // We add because were not shutdown + if (!is_shutdown_) { + type_stack_strategy_->RegionStopLast(region); } - if (!is_shutdown_) { - std::cout << "Region stop last " << region.name << std::endl; + // If were shutdown we still add it if the env is set + if (is_shutdown_ && write_all_regions_.getValue().value_or(false)) { + start(); type_stack_strategy_->RegionStopLast(region); + shutdown(); } std::vector matching_jobs; -- GitLab From 2e97768bfc18b057a659b8df403c58a628fd549d Mon Sep 17 00:00:00 2001 From: VALENTIN SEITZ Date: Wed, 2 Oct 2024 16:09:21 +0200 Subject: [PATCH 3/4] Apply 4 suggestion(s) to 1 file(s) Co-authored-by: JOAN VINYALS YLLA CATALA --- .../extrae_partial_tracer.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp b/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp index 9e1593f..66a668f 100644 --- a/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp +++ b/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp @@ -81,8 +81,8 @@ void ExtraePartialTracer::Init() noexcept { } if (mpi_helper_.IsRankNumber(0) && write_all_regions_.getValue().value_or(false)) { - std::cout << "neSmiK Partial Tracer: Writing all regions even though " - "tracing might be off" + std::cout << "neSmiK Extrae::PartialTracer: Tracing neSmiK regions events " + "even though tracing might be off for that region." << std::endl; } } @@ -105,7 +105,7 @@ void ExtraePartialTracer::RegionStart( if (matching_jobs.size() > 1) { std::cout << "neSmiK Extrae::PartialTracer: Found multiple matching jobs, please " - "dont duplicate region names with the same start iteration" + "don't duplicate region names with the same start iteration" << std::endl; Terminator::exit(); } @@ -133,9 +133,9 @@ void ExtraePartialTracer::RegionStart( // if were running call extrae backend if (!is_shutdown_) { type_stack_strategy_->RegionStart(region); - } - // If were not running but env is set, we still add it to the trace - if (is_shutdown_ && write_all_regions_.getValue().value_or(false)) { + } else + // If we are not running but env is set, we still add it to the trace + if (write_all_regions_.getValue().value_or(false)) { start(); type_stack_strategy_->RegionStart(region); shutdown(); @@ -149,10 +149,9 @@ void ExtraePartialTracer::RegionStopLast( // We add because were not shutdown if (!is_shutdown_) { type_stack_strategy_->RegionStopLast(region); - } - + } else // If were shutdown we still add it if the env is set - if (is_shutdown_ && write_all_regions_.getValue().value_or(false)) { + if (write_all_regions_.getValue().value_or(false)) { start(); type_stack_strategy_->RegionStopLast(region); shutdown(); -- GitLab From 18f597bb7daded46bfcaf7aed209487352916e88 Mon Sep 17 00:00:00 2001 From: JOAN VINYALS YLLA CATALA Date: Wed, 2 Oct 2024 16:15:02 +0200 Subject: [PATCH 4/4] Clang format --- .../extrae_partial_tracer.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp b/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp index 66a668f..79f0691 100644 --- a/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp +++ b/src/backends/extrae_partial_tracer/extrae_partial_tracer.cpp @@ -134,12 +134,12 @@ void ExtraePartialTracer::RegionStart( if (!is_shutdown_) { type_stack_strategy_->RegionStart(region); } else - // If we are not running but env is set, we still add it to the trace - if (write_all_regions_.getValue().value_or(false)) { - start(); - type_stack_strategy_->RegionStart(region); - shutdown(); - } + // If we are not running but env is set, we still add it to the trace + if (write_all_regions_.getValue().value_or(false)) { + start(); + type_stack_strategy_->RegionStart(region); + shutdown(); + } } void ExtraePartialTracer::RegionStopLast( @@ -150,12 +150,12 @@ void ExtraePartialTracer::RegionStopLast( if (!is_shutdown_) { type_stack_strategy_->RegionStopLast(region); } else - // If were shutdown we still add it if the env is set - if (write_all_regions_.getValue().value_or(false)) { - start(); - type_stack_strategy_->RegionStopLast(region); - shutdown(); - } + // If were shutdown we still add it if the env is set + if (write_all_regions_.getValue().value_or(false)) { + start(); + type_stack_strategy_->RegionStopLast(region); + shutdown(); + } std::vector matching_jobs; for (const auto &job : jobs_) { -- GitLab