27#include <initializer_list>
67 template<
class F,
class R,
class Cond = noReferenceCond<F>>
68 auto MapReduce(
F func,
unsigned nTimes,
R redfunc,
unsigned nChunks) ->
typename std::result_of<
F()>
::type;
69 template<
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
71 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
72 auto MapReduce(
F func, std::initializer_list<T> args,
R redfunc,
unsigned nChunks) ->
typename std::result_of<
F(T)>
::type;
73 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
74 auto MapReduce(
F func, std::vector<T> &args,
R redfunc,
unsigned nChunks) ->
typename std::result_of<
F(T)>
::type;
75 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
76 auto MapReduce(
F func,
const std::vector<T> &args,
R redfunc,
unsigned nChunks) ->
typename std::result_of<
F(T)>
::type;
87 template<
class F,
class Cond = noReferenceCond<F>>
88 auto MapImpl(
F func,
unsigned nTimes) -> std::vector<
typename std::result_of<
F()>
::type>;
89 template<
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
91 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
92 auto MapImpl(
F func, std::vector<T> &args) -> std::vector<
typename std::result_of<
F(T)>
::type>;
93 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
94 auto MapImpl(
F func,
const std::vector<T> &args) -> std::vector<
typename std::result_of<
F(T)>
::type>;
102# define R__EXECUTOR_THREAD ROOT::TThreadExecutor
104# define R__EXECUTOR_THREAD Unused_t
107# define R__EXECUTOR_PROCESS ROOT::TProcessExecutor
109# define R__EXECUTOR_PROCESS Unused_t
116#undef R__EXECUTOR_THREAD
117#undef R__EXECUTOR_PROCESS
121 template<
class F,
class CONTAINER>
123 using type =
typename std::result_of<
F(
typename CONTAINER::value_type)>
::type;
134 template<
class F,
class T>
136 std::vector<typename MapRetType<F, typename std::decay<T>::type>
::type> res;
160template<
class F,
class Cond>
162 return ResolveExecutorAndMap(func, nTimes);
170template<
class F,
class INTEGER,
class Cond>
172 return ResolveExecutorAndMap(func, args);
180template<
class F,
class T,
class Cond>
182 return ResolveExecutorAndMap(func, args);
190template<
class F,
class T,
class Cond>
192 return ResolveExecutorAndMap(func, args);
206template<
class F,
class R,
class Cond>
209 return fThreadExecutor->MapReduce(func, nTimes, redfunc, nChunks);
211 return Reduce(Map(func, nTimes), redfunc);
225template<
class F,
class INTEGER,
class R,
class Cond>
228 return fThreadExecutor->MapReduce(func, args, redfunc, nChunks);
230 return Reduce(Map(func, args), redfunc);
244template<
class F,
class T,
class R,
class Cond>
247 return fThreadExecutor->MapReduce(func, args, redfunc, nChunks);
249 return Reduce(Map(func, args), redfunc);
263template<
class F,
class T,
class R,
class Cond>
266 return fThreadExecutor->MapReduce(func, args, redfunc, nChunks);
268 return Reduce(Map(func, args), redfunc);
282template<
class F,
class T,
class R,
class Cond>
285 return fThreadExecutor->MapReduce(func, args, redfunc, nChunks);
287 return Reduce(Map(func, args), redfunc);
297 unsigned poolSize{0u};
This class implements the interface to execute the same task multiple times, sequentially or in paral...
auto MapReduce(F func, unsigned nTimes, R redfunc, unsigned nChunks) -> typename std::result_of< F()>::type
Execute a function nTimes (Map) and accumulate the results into a single value (Reduce).
auto ResolveExecutorAndMap(F func, T &&args) -> std::vector< typename MapRetType< F, typename std::decay< T >::type >::type >
Function called from Map to select and execute the correct Executor according to the set Execution Po...
std::unique_ptr< R__EXECUTOR_THREAD > fThreadExecutor
std::unique_ptr< ROOT::TSequentialExecutor > fSequentialExecutor
ROOT::EExecutionPolicy Policy() const
Return the execution policy the executor is set to.
auto MapImpl(F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
Execute a function without arguments several times.
TExecutor(unsigned nWorkers=0)
Class constructor.
TExecutor & operator=(const TExecutor &)=delete
TExecutor(const TExecutor &)=delete
ROOT::EExecutionPolicy fExecPolicy
std::unique_ptr< R__EXECUTOR_PROCESS > fProcessExecutor
unsigned GetPoolSize() const
Return the number of pooled workers.
This class defines an interface to execute the same task multiple times, possibly in parallel and wit...
auto Map(F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
Execute a function without arguments several times.
T * Reduce(const std::vector< T * > &mergeObjs)
"Reduce" an std::vector into a single object by using the object's Merge method.
A pseudo container class which is a generator of indices.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
typename std::result_of< F()>::type type
Helper class to get the correct return type from the Map function, necessary to infer the ResolveExec...
typename std::result_of< F(typename CONTAINER::value_type)>::type type