28#include <initializer_list>
68 template<
class F,
class R,
class Cond = noReferenceCond<F>>
69 auto MapReduce(
F func,
unsigned nTimes,
R redfunc,
unsigned nChunks) ->
typename std::result_of<
F()>
::type;
70 template<
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
72 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
73 auto MapReduce(
F func, std::initializer_list<T> args,
R redfunc,
unsigned nChunks) ->
typename std::result_of<
F(T)>
::type;
74 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
75 auto MapReduce(
F func, std::vector<T> &args,
R redfunc,
unsigned nChunks) ->
typename std::result_of<
F(T)>
::type;
76 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
77 auto MapReduce(
F func,
const std::vector<T> &args,
R redfunc,
unsigned nChunks) ->
typename std::result_of<
F(T)>
::type;
88 template<
class F,
class Cond = noReferenceCond<F>>
89 auto MapImpl(
F func,
unsigned nTimes) -> std::vector<
typename std::result_of<
F()>
::type>;
90 template<
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
92 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
93 auto MapImpl(
F func, std::vector<T> &args) -> std::vector<
typename std::result_of<
F(T)>
::type>;
94 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
95 auto MapImpl(
F func,
const std::vector<T> &args) -> std::vector<
typename std::result_of<
F(T)>
::type>;
103# define R__EXECUTOR_THREAD ROOT::TThreadExecutor
105# define R__EXECUTOR_THREAD Unused_t
108# define R__EXECUTOR_PROCESS ROOT::TProcessExecutor
110# define R__EXECUTOR_PROCESS Unused_t
117#undef R__EXECUTOR_THREAD
118#undef R__EXECUTOR_PROCESS
122 template<
class F,
class CONTAINER>
124 using type =
typename std::result_of<
F(
typename CONTAINER::value_type)>
::type;
135 template<
class F,
class T>
137 std::vector<typename MapRetType<F, typename std::decay<T>::type>
::type> res;
161template<
class F,
class Cond>
163 return ResolveExecutorAndMap(func, nTimes);
171template<
class F,
class INTEGER,
class Cond>
173 return ResolveExecutorAndMap(func, args);
181template<
class F,
class T,
class Cond>
183 return ResolveExecutorAndMap(func, args);
191template<
class F,
class T,
class Cond>
193 return ResolveExecutorAndMap(func, args);
207template<
class F,
class R,
class Cond>
210 return fThreadExecutor->MapReduce(func, nTimes, redfunc, nChunks);
212 return Reduce(Map(func, nTimes), redfunc);
226template<
class F,
class INTEGER,
class R,
class Cond>
229 return fThreadExecutor->MapReduce(func, args, redfunc, nChunks);
231 return Reduce(Map(func, args), redfunc);
245template<
class F,
class T,
class R,
class Cond>
248 return fThreadExecutor->MapReduce(func, args, redfunc, nChunks);
250 return Reduce(Map(func, args), redfunc);
264template<
class F,
class T,
class R,
class Cond>
267 return fThreadExecutor->MapReduce(func, args, redfunc, nChunks);
269 return Reduce(Map(func, args), redfunc);
283template<
class F,
class T,
class R,
class Cond>
286 return fThreadExecutor->MapReduce(func, args, redfunc, nChunks);
288 return Reduce(Map(func, args), redfunc);
298 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