diff --git a/core/imt/src/RTaskArena.cxx b/core/imt/src/RTaskArena.cxx index 477dfc932b6ab..883cee96d870f 100644 --- a/core/imt/src/RTaskArena.cxx +++ b/core/imt/src/RTaskArena.cxx @@ -6,6 +6,7 @@ #include #include #include "tbb/task_arena.h" +#include "tbb/global_control.h" ////////////////////////////////////////////////////////////////////////// /// @@ -75,6 +76,10 @@ RTaskArenaWrapper::RTaskArenaWrapper(unsigned maxConcurrency) : fTBBArena(new tb Warning("RTaskArenaWrapper", "CPU Bandwith Control Active. Proceeding with %d threads accordingly", bcCpus); maxConcurrency = bcCpus; } + if (maxConcurrency > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) { + Warning("RTaskArenaWrapper", "tbb::global_control is active, limiting the number of parallel workers" + "from this task arena available for execution."); + } fTBBArena->initialize(maxConcurrency); fNWorkers = maxConcurrency; ROOT::EnableThreadSafety(); diff --git a/core/imt/src/TThreadExecutor.cxx b/core/imt/src/TThreadExecutor.cxx index 13397af671845..b9e5ae99aa286 100644 --- a/core/imt/src/TThreadExecutor.cxx +++ b/core/imt/src/TThreadExecutor.cxx @@ -155,6 +155,12 @@ TThreadExecutor::TThreadExecutor(UInt_t nThreads) void TThreadExecutor::ParallelFor(unsigned int start, unsigned int end, unsigned step, const std::function &f) { + if (GetPoolSize() > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) { + Warning("TThreadExecutor::ParallelFor", + "tbb::global_control is limiting the number of parallel workers." + " Proceeding with %zu threads this time", + tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)); + } fTaskArenaW->Access().execute([&] { tbb::this_task_arena::isolate([&] { tbb::parallel_for(start, end, step, f); @@ -171,6 +177,12 @@ void TThreadExecutor::ParallelFor(unsigned int start, unsigned int end, unsigned double TThreadExecutor::ParallelReduce(const std::vector &objs, const std::function &redfunc) { + if (GetPoolSize() > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) { + Warning("TThreadExecutor::ParallelReduce", + "tbb::global_control is limiting the number of parallel workers." + " Proceeding with %zu threads this time", + tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)); + } return fTaskArenaW->Access().execute([&] { return ROOT::Internal::ParallelReduceHelper(objs, redfunc); }); }