4#pragma GCC diagnostic push
5#pragma GCC diagnostic ignored "-Wshadow"
8#include "tbb/global_control.h"
10#pragma GCC diagnostic pop
127 return tbb::this_task_arena::isolate([&] {
157 const std::function<
void(
unsigned int i)> &
f)
159 if (
GetPoolSize() > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) {
160 Warning(
"TThreadExecutor::ParallelFor",
161 "tbb::global_control is limiting the number of parallel workers."
162 " Proceeding with %zu threads this time",
163 tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism));
166 tbb::this_task_arena::isolate([&] {
167 tbb::parallel_for(start, end, step,
f);
179 const std::function<
double(
double a,
double b)> &
redfunc)
181 if (
GetPoolSize() > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) {
182 Warning(
"TThreadExecutor::ParallelReduce",
183 "tbb::global_control is limiting the number of parallel workers."
184 " Proceeding with %zu threads this time",
185 tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism));
187 return fTaskArenaW->Access().execute([&] {
return ROOT::Internal::ParallelReduceHelper<double>(
objs,
redfunc); });
197 const std::function<
float(
float a,
float b)> &
redfunc)
199 if (
GetPoolSize() > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) {
200 Warning(
"TThreadExecutor::ParallelReduce",
201 "tbb::global_control is limiting the number of parallel workers."
202 " Proceeding with %zu threads this time",
203 tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism));
205 return fTaskArenaW->Access().execute([&] {
return ROOT::Internal::ParallelReduceHelper<float>(
objs,
redfunc); });
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
const_iterator begin() const
const_iterator end() const
void ParallelFor(unsigned start, unsigned end, unsigned step, const std::function< void(unsigned int i)> &f)
Execute a function in parallel over the indices of a loop.
unsigned GetPoolSize() const
Returns the number of worker threads in the task arena.
std::shared_ptr< ROOT::Internal::RTaskArenaWrapper > fTaskArenaW
Pointer to the TBB task arena wrapper.
TThreadExecutor(UInt_t nThreads=0u)
Class constructor.
double ParallelReduce(const std::vector< double > &objs, const std::function< double(double a, double b)> &redfunc)
"Reduce" in parallel an std::vector<double> into a single double value
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.