4#pragma GCC diagnostic push
5#pragma GCC diagnostic ignored "-Wshadow"
8#define TBB_PREVIEW_GLOBAL_CONTROL 1
9#include "tbb/global_control.h"
11#pragma GCC diagnostic pop
113 using BRange_t = tbb::blocked_range<
decltype(objs.begin())>;
115 auto pred = [redfunc](BRange_t
const & range,
T init) {
116 return std::accumulate(range.begin(), range.end(),
init, redfunc);
119 BRange_t objRange(objs.begin(), objs.end());
121 return tbb::this_task_arena::isolate([&] {
122 return tbb::parallel_reduce(objRange,
T{}, pred, redfunc);
146 if (
GetPoolSize() > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) {
147 Warning(
"TThreadExecutor::ParallelFor",
148 "tbb::global_control is limiting the number of parallel workers."
149 " Proceeding with %zu threads this time",
150 tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism));
153 tbb::this_task_arena::isolate([&] {
154 tbb::parallel_for(start, end, step,
f);
162 if (
GetPoolSize() > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) {
163 Warning(
"TThreadExecutor::ParallelReduce",
164 "tbb::global_control is limiting the number of parallel workers."
165 " Proceeding with %zu threads this time",
166 tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism));
168 return fTaskArenaW->Access().execute([&] {
return ROOT::Internal::ParallelReduceHelper<double>(objs, redfunc); });
174 if (
GetPoolSize() > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) {
175 Warning(
"TThreadExecutor::ParallelReduce",
176 "tbb::global_control is limiting the number of parallel workers."
177 " Proceeding with %zu threads this time",
178 tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism));
180 return fTaskArenaW->Access().execute([&] {
return ROOT::Internal::ParallelReduceHelper<float>(objs, redfunc); });
void Warning(const char *location, const char *msgfmt,...)
void ParallelFor(unsigned start, unsigned end, unsigned step, const std::function< void(unsigned int i)> &f)
std::shared_ptr< ROOT::Internal::RTaskArenaWrapper > fTaskArenaW
TThreadExecutor(UInt_t nThreads=0u)
Class constructor.
double ParallelReduce(const std::vector< double > &objs, const std::function< double(double a, double b)> &redfunc)
EvaluateInfo init(std::vector< RooRealProxy > parameters, std::vector< ArrayWrapper * > wrappers, std::vector< double * > arrays, size_t begin, size_t batchSize)
static T ParallelReduceHelper(const std::vector< T > &objs, const std::function< T(T a, T b)> &redfunc)
A helper function to implement the TThreadExecutor::ParallelReduce methods.
std::shared_ptr< ROOT::Internal::RTaskArenaWrapper > GetGlobalTaskArena(unsigned maxConcurrency=0)
Factory function returning a shared pointer to the instance of the global RTaskArenaWrapper.
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...