Logo ROOT   6.08/07
Reference Guide
TThreadExecutor.cxx
Go to the documentation of this file.
2 #include "tbb/tbb.h"
3 
4 namespace ROOT{
5  TThreadExecutor::TThreadExecutor():fInitTBB(new tbb::task_scheduler_init()){
6  }
7 
8  TThreadExecutor::TThreadExecutor(size_t nThreads):fInitTBB(new tbb::task_scheduler_init(nThreads)){
9  }
10 
11  TThreadExecutor::~TThreadExecutor() {
12  fInitTBB->terminate();
13  }
14 
15  void TThreadExecutor::ParallelFor(unsigned int start, unsigned int end, const std::function<void(unsigned int i)> &f){
16  tbb::parallel_for(start, end, f);
17  }
18 
19  double TThreadExecutor::ParallelReduce(const std::vector<double> &objs, const std::function<double(double a, double b)> &redfunc){
20  return tbb::parallel_reduce(tbb::blocked_range<decltype(objs.begin())>(objs.begin(), objs.end()), double{},
21  [redfunc](tbb::blocked_range<decltype(objs.begin())> const & range, double init) {
22  return std::accumulate(range.begin(), range.end(), init, redfunc);
23  }, redfunc);
24  }
25 
26  float TThreadExecutor::ParallelReduce(const std::vector<float> &objs, const std::function<float(float a, float b)> &redfunc){
27  return tbb::parallel_reduce(tbb::blocked_range<decltype(objs.begin())>(objs.begin(), objs.end()), float{},
28  [redfunc](tbb::blocked_range<decltype(objs.begin())> const & range, float init) {
29  return std::accumulate(range.begin(), range.end(), init, redfunc);
30  }, redfunc);
31  }
32 }
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
TArc * a
Definition: textangle.C:12
double f(double x)
static Int_t init()
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630