diff --git a/src/delegator.cpp b/src/delegator.cpp index d95a378b2d4f9c0860632e128438721383c0671b..f231283bccc3e08f79271ce0ce21e6741a311c00 100644 --- a/src/delegator.cpp +++ b/src/delegator.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -59,10 +60,13 @@ void Delegator::InitProperlyNestedBackends(const std::string &backend) { void Delegator::Init(std::string_view nesting_mode, std::string_view backend_in) { + mpi_helper_ = std::make_unique(); std::string backend = std::string(backend_in); - std::cout << "NESMIK init called with: " << nesting_mode - << " and Backend: " << backend << std::endl; + if (mpi_helper_->IsRankNumber(0)) { + std::cout << "NESMIK init called with: " << nesting_mode + << " and Backend: " << backend << std::endl; + } // detect nesting mode requested by the user if (nesting_mode.compare("?") == 0) { @@ -73,25 +77,27 @@ void Delegator::Init(std::string_view nesting_mode, nesting_mode_ = NestingMode::NotProperlyNested; } - // Some debug output - switch (nesting_mode_) { - case NestingMode::Detection: - std::cout << "Selecting nesting mode to: " - << "detecting nesting behavior" << std::endl; - break; - case NestingMode::NotProperlyNested: - std::cout << "Selecting nesting mode to: " - << "non properly nested behavior" << std::endl; - break; - case NestingMode::ProperlyNested: - std::cout << "Selecting nesting mode to: " - << "assume properly nested behavior" << std::endl; - break; - case NestingMode::ProperlyNestedButOtherBackend: - std::cout << "Something went wrong when selecting the nesting mode" - << std::endl; - exit(1); - break; + if (mpi_helper_->IsRankNumber(0)) { + // Some debug output + switch (nesting_mode_) { + case NestingMode::Detection: + std::cout << "Selecting nesting mode to: " + << "detecting nesting behavior" << std::endl; + break; + case NestingMode::NotProperlyNested: + std::cout << "Selecting nesting mode to: " + << "non properly nested behavior" << std::endl; + break; + case NestingMode::ProperlyNested: + std::cout << "Selecting nesting mode to: " + << "assume properly nested behavior" << std::endl; + break; + case NestingMode::ProperlyNestedButOtherBackend: + std::cout << "Something went wrong when selecting the nesting mode" + << std::endl; + exit(1); + break; + } } if (stringsAreCaseInsensitiveEqual("ENV", std::string(backend))) { @@ -119,13 +125,14 @@ void Delegator::Init(std::string_view nesting_mode, // one InitProperlyNestedBackends(backend); if (pn_annotation_strategy_ == nullptr) { - std::cout - << "Could not find a matching ProperlyNested backend with name " - << backend << std::endl; - std::cout << "Now looking for a NonProperlyNested backend, as they " - "support ProperlyNested ones" - << std::endl; - + if (mpi_helper_->IsRankNumber(0)) { + std::cout + << "Could not find a matching ProperlyNested backend with name " + << backend << std::endl; + std::cout << "Now looking for a NonProperlyNested backend, as they " + "support ProperlyNested ones" + << std::endl; + } InitNonProperlyNestedBackends(backend); nesting_mode_ = NestingMode::ProperlyNestedButOtherBackend; } diff --git a/src/delegator.hpp b/src/delegator.hpp index 314056d616597b8ddfbeb7ab2d6abf8de604275f..021ea81a7fd44f7eddbd248fb505115a554c4690 100644 --- a/src/delegator.hpp +++ b/src/delegator.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include enum class NestingMode { @@ -25,6 +26,8 @@ class Delegator { inline static NestingMode nesting_mode_ = NestingMode::Detection; + inline static std::unique_ptr mpi_helper_; + public: static void Init(std::string_view nesting_mode, std::string_view backend); static void RegionStart(std::string_view name);