5 #pragma GCC diagnostic push
6 #pragma GCC diagnostic ignored "-Wshadow"
11 #if !defined(_MSC_VER)
12 #pragma GCC diagnostic pop
112 static T ParallelReduceHelper(
const std::vector<T> &objs,
const std::function<T(T a, T b)> &redfunc)
114 using BRange_t = tbb::blocked_range<decltype(objs.begin())>;
116 auto pred = [redfunc](BRange_t
const & range, T init) {
117 return std::accumulate(range.begin(), range.end(), init, redfunc);
120 BRange_t objRange(objs.begin(), objs.end());
122 return tbb::this_task_arena::isolate([&]{
123 return tbb::parallel_reduce(objRange, T{}, pred, redfunc);
137 TThreadExecutor::TThreadExecutor(): TThreadExecutor::TThreadExecutor(tbb::task_scheduler_init::default_num_threads()) {}
142 TThreadExecutor::TThreadExecutor(UInt_t nThreads)
144 fSched = ROOT::Internal::GetPoolManager(nThreads);
147 void TThreadExecutor::ParallelFor(
unsigned int start,
unsigned int end,
unsigned step,
const std::function<
void(
unsigned int i)> &f)
149 tbb::this_task_arena::isolate([&]{
150 tbb::parallel_for(start, end, step, f);
154 double TThreadExecutor::ParallelReduce(
const std::vector<double> &objs,
const std::function<
double(
double a,
double b)> &redfunc)
156 return ROOT::Internal::ParallelReduceHelper<double>(objs, redfunc);
159 float TThreadExecutor::ParallelReduce(
const std::vector<float> &objs,
const std::function<
float(
float a,
float b)> &redfunc)
161 return ROOT::Internal::ParallelReduceHelper<float>(objs, redfunc);
164 unsigned TThreadExecutor::GetPoolSize(){
165 return ROOT::Internal::TPoolManager::GetPoolSize();