From 600c6c5d58ac48e19214f7d8f7489c39df0e1817 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Tue, 11 Jun 2024 15:57:04 +0200 Subject: [PATCH 1/4] refactored a bit --- src/backends/dlb/CMakeLists.txt | 2 +- src/delegator.cpp | 6 ++++++ src/delegator.hpp | 7 +++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/backends/dlb/CMakeLists.txt b/src/backends/dlb/CMakeLists.txt index 3a432c4..593fa9d 100644 --- a/src/backends/dlb/CMakeLists.txt +++ b/src/backends/dlb/CMakeLists.txt @@ -3,7 +3,7 @@ if(DLB_FOUND) target_include_directories(nesmik PRIVATE ${DLB_INCLUDE_DIRS}) target_link_libraries(nesmik PUBLIC ${DLB_LIBRARIES}) -target_compile_definitions(nesmik PRIVATE "ENABLE_DLB") +target_compile_defInitions(nesmik PRIVATE "ENABLE_DLB") add_subdirectory(dlb) add_subdirectory(dlb_talp_tree) diff --git a/src/delegator.cpp b/src/delegator.cpp index f389174..2cc1375 100644 --- a/src/delegator.cpp +++ b/src/delegator.cpp @@ -34,6 +34,12 @@ void Delegator::InitNonProperlyNestedBackends(const std::string_view backend) { npn_annotation_strategy_ = std::make_unique(); } #endif + else { + std::cout << "Could not find a matching backend with name" + << backend_string << " now selecting the Default" << std::endl; + } + } + // no backend supplied else { npn_annotation_strategy_ = std::make_unique(); diff --git a/src/delegator.hpp b/src/delegator.hpp index 1e67cf0..3151f52 100644 --- a/src/delegator.hpp +++ b/src/delegator.hpp @@ -24,10 +24,9 @@ public: static void Finalize(); private: - static std::vector SplitString(const std::string &str, - char delimiter); static void InitDetectionBackend(const std::string_view backend); static void InitNonProperlyNestedBackends(const std::string_view backend); static void InitProperlyNestedBackends(const std::string_view backend); -}; -#endif // NESMIK_DELEGATOR_HPP \ No newline at end of file + static void + InitDetectionBackend(const std::vector &init_strings); + static void -- GitLab From bd9c623554d64f90a299160d384b27f0030ed48f Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Tue, 11 Jun 2024 17:01:54 +0200 Subject: [PATCH 2/4] REfacrtreed even more --- src/delegator.cpp | 5 ++--- src/delegator.hpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/delegator.cpp b/src/delegator.cpp index 2cc1375..2d123a9 100644 --- a/src/delegator.cpp +++ b/src/delegator.cpp @@ -35,8 +35,8 @@ void Delegator::InitNonProperlyNestedBackends(const std::string_view backend) { } #endif else { - std::cout << "Could not find a matching backend with name" - << backend_string << " now selecting the Default" << std::endl; + std::cout << "Could not find a matching properly nested backend with name" + << backend << " skipping." << std::endl; } } // no backend supplied @@ -46,7 +46,6 @@ void Delegator::InitNonProperlyNestedBackends(const std::string_view backend) { std::cout << "Could not find a matching PNP backend with name" << backend << " now selecting the Default" << std::endl; } -} void Delegator::InitProperlyNestedBackends(const std::string_view backend) { if (backend.compare(PNDefault::name) == 0) { diff --git a/src/delegator.hpp b/src/delegator.hpp index 3151f52..debeb4a 100644 --- a/src/delegator.hpp +++ b/src/delegator.hpp @@ -28,5 +28,5 @@ private: static void InitNonProperlyNestedBackends(const std::string_view backend); static void InitProperlyNestedBackends(const std::string_view backend); static void - InitDetectionBackend(const std::vector &init_strings); + InitDetectionBackend(const std::string_view backend); static void -- GitLab From fac3e05e5af2db096259c8684c1e47d76f1a1210 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Thu, 13 Jun 2024 15:44:21 +0200 Subject: [PATCH 3/4] fixed some compiler warning :) --- src/backends/extrae/extrae_type_stack.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/backends/extrae/extrae_type_stack.cpp b/src/backends/extrae/extrae_type_stack.cpp index ab69008..4855f1e 100644 --- a/src/backends/extrae/extrae_type_stack.cpp +++ b/src/backends/extrae/extrae_type_stack.cpp @@ -198,13 +198,13 @@ void ExtraeTypeStackStrategy::Finalize() noexcept { // leaking memory a bit, but c vs c++ strings are not worth making it not // leaky? char **routine_c_names = new char *[numberOfRegionsRegistered]; - for (auto i = 0; i < numberOfRegionsRegistered; i++) { + for (std::size_t i = 0; i < numberOfRegionsRegistered; i++) { routine_c_names[i] = new char[routine_names[i].size() + 1]; std::strcpy(routine_c_names[i], routine_names[i].c_str()); } - for (auto level = 0; level <= regionStackData.historicMaxStackSize; level++) { + for (std::size_t level = 0; level <= regionStackData.historicMaxStackSize; level++) { extrae_type_t type = baseType+level; std::string description = "Level: " + std::to_string(level); Extrae_define_event_type(&type, const_cast(description.c_str()), @@ -240,8 +240,7 @@ void ExtraeTypeStackStrategy::Finalize() noexcept { outputFile << std::endl; // write seperate windows - for (auto level = 0; level <= regionStackData.historicMaxStackSize; level++) { - auto type = baseType+level; + for (std::size_t level = 0; level <= regionStackData.historicMaxStackSize; level++) { std::string windowName = "NESMIK Instrumentation Level: " + std::to_string(level); auto replacedEventType = std::regex_replace(paraverConfigLevelWindow, std::regex("NESMIK_REPLACE_EVENT_TYPE"), std::to_string(baseType+level)); -- GitLab From 44f269cc8ec155c8048ea9f0c7a94df5c02ee45c Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Thu, 13 Jun 2024 16:05:59 +0200 Subject: [PATCH 4/4] Add constructrs with sane defaults --- src/backends/default/default.cpp | 15 ++++++++++ src/backends/default/default.hpp | 2 ++ src/backends/dlb/dlb/dlb.cpp | 7 +++++ src/backends/dlb/dlb/dlb.hpp | 1 + .../dlb/dlb_talp_tree/dlb_talp_tree.cpp | 9 ++++++ .../dlb/dlb_talp_tree/dlb_talp_tree.hpp | 2 +- src/backends/extrae/extrae_type_stack.cpp | 7 +++++ src/backends/extrae/extrae_type_stack.hpp | 2 ++ src/strategies.hpp | 28 +++++++++++++++++++ 9 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/backends/default/default.cpp b/src/backends/default/default.cpp index d460168..e5a2b95 100644 --- a/src/backends/default/default.cpp +++ b/src/backends/default/default.cpp @@ -3,6 +3,14 @@ #include "default.hpp" + +PNDefault::PNDefault(){ + parallelism_descriptor_={ + .mpi_descriptor_ = MPIDescriptor::DontCare, + .thread_descriptor_ = ThreadDescriptor::Supported + }; +} + void PNDefault::RegionStart( const ProperlyNestedRegionInformation ®ion) noexcept { std::cout << "Region start: " << region.name << std::endl; @@ -22,6 +30,13 @@ void PNDefault::Finalize() noexcept { // NPN +NPNDefault::NPNDefault(){ + parallelism_descriptor_={ + .mpi_descriptor_ = MPIDescriptor::DontCare, + .thread_descriptor_ = ThreadDescriptor::Supported + }; +} + void NPNDefault::RegionStart( const NotProperlyNestedRegionInformation ®ion) noexcept { std::cout << "Region start: " << region.name << std::endl; diff --git a/src/backends/default/default.hpp b/src/backends/default/default.hpp index 9d8b8e4..8a1242f 100644 --- a/src/backends/default/default.hpp +++ b/src/backends/default/default.hpp @@ -4,6 +4,7 @@ class PNDefault : public ProperlyNestedAnnotationStrategy { public: + PNDefault(); inline static const std::string name = "Default"; void RegionStart(const ProperlyNestedRegionInformation &info_to_start) noexcept override; void RegionStopLast(const ProperlyNestedRegionInformation &info_to_stop) noexcept override; @@ -15,6 +16,7 @@ public: class NPNDefault : public NotProperlyNestedAnnotationStrategy { public: + NPNDefault(); inline static const std::string name = "Default"; virtual void RegionStart(const NotProperlyNestedRegionInformation &info_to_start) noexcept override; virtual void RegionStop(const NotProperlyNestedRegionInformation &info_to_stop) noexcept override; diff --git a/src/backends/dlb/dlb/dlb.cpp b/src/backends/dlb/dlb/dlb.cpp index 3a7b076..1150c55 100644 --- a/src/backends/dlb/dlb/dlb.cpp +++ b/src/backends/dlb/dlb/dlb.cpp @@ -3,6 +3,13 @@ #include "dlb_talp.h" #include + +DLBTalpStrategy::DLBTalpStrategy(){ + parallelism_descriptor_={ + .mpi_descriptor_ = MPIDescriptor::DontCare, + .thread_descriptor_ = ThreadDescriptor::Supported // Even though it makes no semantical sense + }; +} void DLBTalpStrategy::RegionStart( const NotProperlyNestedRegionInformation ®ion) noexcept { // we have to create a small std::string thing because we cannot assume that diff --git a/src/backends/dlb/dlb/dlb.hpp b/src/backends/dlb/dlb/dlb.hpp index 83201cc..b3647b1 100644 --- a/src/backends/dlb/dlb/dlb.hpp +++ b/src/backends/dlb/dlb/dlb.hpp @@ -6,6 +6,7 @@ class DLBTalpStrategy : public NotProperlyNestedAnnotationStrategy { public: + DLBTalpStrategy(); inline static const std::string name = "TALP"; virtual void RegionStart(const NotProperlyNestedRegionInformation ®ion) noexcept override; virtual void RegionStop(const NotProperlyNestedRegionInformation ®ion) noexcept override; diff --git a/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.cpp b/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.cpp index cefe614..1b7d1b3 100644 --- a/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.cpp +++ b/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.cpp @@ -8,6 +8,15 @@ #include #include + + +DLBTalpTreeStrategy::DLBTalpTreeStrategy(){ + parallelism_descriptor_={ + .mpi_descriptor_ = MPIDescriptor::Aware, + .thread_descriptor_ = ThreadDescriptor::Unsupported + }; +} + void DLBTalpTreeStrategy::RegionStart( const ProperlyNestedRegionInformation ®ion) noexcept { diff --git a/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.hpp b/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.hpp index a1c7823..c341c75 100644 --- a/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.hpp +++ b/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.hpp @@ -24,8 +24,8 @@ private: std::size_t current_region; std::map regions; - public: + DLBTalpTreeStrategy(); inline static const std::string_view name = "TALP-Tree"; void RegionStart(const ProperlyNestedRegionInformation ®ion) noexcept override; void RegionStopLast(const ProperlyNestedRegionInformation ®ion) noexcept override; diff --git a/src/backends/extrae/extrae_type_stack.cpp b/src/backends/extrae/extrae_type_stack.cpp index 4855f1e..5b85068 100644 --- a/src/backends/extrae/extrae_type_stack.cpp +++ b/src/backends/extrae/extrae_type_stack.cpp @@ -12,6 +12,13 @@ extern "C" { #include } +ExtraeTypeStackStrategy::ExtraeTypeStackStrategy(){ + parallelism_descriptor_={ + .mpi_descriptor_ = MPIDescriptor::Aware, + .thread_descriptor_ = ThreadDescriptor::Supported // i guess no test currently for this + }; +} + const std::string ExtraeTypeStackStrategy::paraverConfigHead = R"( diff --git a/src/backends/extrae/extrae_type_stack.hpp b/src/backends/extrae/extrae_type_stack.hpp index 7906dd3..49cecf9 100644 --- a/src/backends/extrae/extrae_type_stack.hpp +++ b/src/backends/extrae/extrae_type_stack.hpp @@ -31,6 +31,8 @@ private: static extrae_value get_value_by_region_name(const std::string &name); public: + + ExtraeTypeStackStrategy(); inline static const std::string_view name = "Extrae::TypeStack"; virtual void RegionStart(const ProperlyNestedRegionInformation ®ion) noexcept override; diff --git a/src/strategies.hpp b/src/strategies.hpp index 7880da0..c8a7718 100644 --- a/src/strategies.hpp +++ b/src/strategies.hpp @@ -4,6 +4,31 @@ #include #include #include +/* + Describes the Strategy behavior with respect to MPI. +*/ +enum class MPIDescriptor{ + DontCare, // Strategy doesnt know and doesnt care + Aware, // Strategy knows about MPI and can use the PMPI Interface to do e.g. reductions. + Required // Strategy requires MPI (should be safeguareded by build options) +}; + +/* + Describes the Strategy behavior with respect to any thread level parallelism + Mainly concerned if starting and stopping regions is supported from multiple threads +*/ +enum class ThreadDescriptor{ + Supported, + Unsupported +}; + +/* + Bundles the above enums into a nice struct +*/ +struct ParallelismDescriptor{ + MPIDescriptor mpi_descriptor_ = MPIDescriptor::DontCare; + ThreadDescriptor thread_descriptor_ = ThreadDescriptor::Unsupported; +}; struct ProperlyNestedRegionInformation { std::string_view name; @@ -23,6 +48,8 @@ public: virtual void RegionStopLast(const ProperlyNestedRegionInformation ®ion) noexcept = 0; virtual void Finalize() noexcept = 0; + + ParallelismDescriptor parallelism_descriptor_; }; class NotProperlyNestedAnnotationStrategy { @@ -34,6 +61,7 @@ public: virtual void RegionStop(const NotProperlyNestedRegionInformation ®ion) noexcept = 0; virtual void Finalize() noexcept = 0; + ParallelismDescriptor parallelism_descriptor_; }; #endif // NESMIK_STRATEGY_HPP \ No newline at end of file -- GitLab