diff --git a/src/backends/default/default.cpp b/src/backends/default/default.cpp index d460168a6e98da4715be4adb45436dbd8ca111ed..e5a2b95ebf3e710d82171c614c962c09bf676800 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 9d8b8e48cc66a6e47ae93b4f3ace948d7fa4aaeb..8a1242f560768a343701d382757bc50305bc33b9 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/CMakeLists.txt b/src/backends/dlb/CMakeLists.txt index 3a432c46e8aa7f5fd8c72cbb1af8c0564424d8dd..593fa9d362c9fffb8b984a4bc19a49cea6e83b62 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/backends/dlb/dlb/dlb.cpp b/src/backends/dlb/dlb/dlb.cpp index 3a7b07607586db3695cda10274b34d6ccd5ded01..1150c5586a648ba477d0d3d1b76d0bc832a1c4d6 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 83201cc72914688be3da9a58e901e9fa182e28b2..b3647b12c04c2fc08beffa713dda898ef58060b2 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 cefe614e0ff6e776165b6b2c2a36dc360d7ee5af..1b7d1b34fe22b19569e61aa79fe9412cacd7cd6a 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 a1c7823364122d5e916c946842ad07b19be93d44..c341c755c586215f0fba62fffc5ee29e214178dd 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 ab690087a4e5dc3384a6d1b823aac0239b571477..5b850682a7841b7cc562692c47507a6d02290c7a 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"( @@ -198,13 +205,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 +247,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)); diff --git a/src/backends/extrae/extrae_type_stack.hpp b/src/backends/extrae/extrae_type_stack.hpp index 7906dd3f2d1abe1034e60aa118c52d8d96505414..49cecf907b8f86eacf7a443168e9c2ed2e9938f5 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/delegator.cpp b/src/delegator.cpp index f389174153ff5415bb0cf3a9898fbe140f19926d..2d123a965877849f3ed207dd3dba73614813f3b9 100644 --- a/src/delegator.cpp +++ b/src/delegator.cpp @@ -34,13 +34,18 @@ void Delegator::InitNonProperlyNestedBackends(const std::string_view backend) { npn_annotation_strategy_ = std::make_unique(); } #endif + else { + std::cout << "Could not find a matching properly nested backend with name" + << backend << " skipping." << std::endl; + } + } + // no backend supplied else { npn_annotation_strategy_ = std::make_unique(); 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 1e67cf03fd34c0f49493c10df2263bd92ee4e5ab..debeb4ae1daba81d798a2e9aedda2dda9a1b10e4 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::string_view backend); + static void diff --git a/src/strategies.hpp b/src/strategies.hpp index 7880da03221c022037e7d669e01674faf23ce86d..c8a7718ee1de898718b113d607b2ea13fc373341 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