18#ifndef ROOT_TMVA_Executor
19#define ROOT_TMVA_Executor
39 template<
class F,
class...
T>
40 using noReferenceCond =
typename std::enable_if<
"Function can't return a reference" &&
41 !(std::is_reference<
typename std::result_of<
F(
T...)>
::type>::value)>
::type;
58 ::Error(
"Executor",
"Cannot have TMVA in multi-threads mode when ROOT is built without IMT");
76 if ( nthreads != 1 ) {
80 ::Error(
"Executor",
"Cannot have TMVA in multi-threads mode when ROOT is built without IMT");
93 Info(
"GetThreadExecutor",
"Creating a TThread executor with a pool with a defult size of %d",
fMTExecImpl->GetPoolSize());
109 template<
class Function>
114 template<
class Function,
class T>
119 template<
class Function,
class INTEGER>
126 template<
class F,
class Cond = noReferenceCond<F>>
127 auto Map(
F func,
unsigned nTimes) -> std::vector<
typename std::result_of<
F()>
::type> {
131 template<
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
138 template<
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
141 else return fSeqExecImpl->MapReduce(func, args, redfunc);
143 template<
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
146 else return fSeqExecImpl->MapReduce(func, args, redfunc);
150 template<
class T,
class R>
151 auto Reduce(
const std::vector<T> &objs,
R redfunc) ->
decltype(redfunc(objs)) {
160 std::unique_ptr<ROOT::TSequentialExecutor>
fMTExecImpl;
#define R(a, b, c, d, e, f, g, h, i)
void Info(const char *location, const char *msgfmt,...)
void Error(const char *location, const char *msgfmt,...)
Double_t(* Function)(Double_t)
A pseudo container class which is a generator of indices.
This class provides a simple interface to execute the same task multiple times in parallel,...
void Foreach(Function func, unsigned int nTimes, unsigned nChunks=0)
wrap TExecutor::Foreach
auto MapReduce(F func, ROOT::TSeq< INTEGER > args, R redfunc, unsigned nChunks) -> typename std::result_of< F(INTEGER)>::type
std::unique_ptr< ROOT::TSequentialExecutor > fSeqExecImpl
typename std::enable_if<"Function can't return a reference" &&!(std::is_reference< typename std::result_of< F(T...)>::type >::value)>::type noReferenceCond
auto Reduce(const std::vector< T > &objs, R redfunc) -> decltype(redfunc(objs))
Wrap Reduce function.
unsigned int GetPoolSize() const
auto MapReduce(F func, ROOT::TSeq< INTEGER > args, R redfunc) -> typename std::result_of< F(INTEGER)>::type
Wrap TExecutor::MapReduce functions.
auto Map(F func, ROOT::TSeq< INTEGER > args) -> std::vector< typename std::result_of< F(INTEGER)>::type >
void Foreach(Function func, std::vector< T > &args, unsigned nChunks=0)
Executor()
Default constructor of TMVA Executor class if ROOT::EnableIMplicitMT has not been called then by defa...
std::unique_ptr< ROOT::TThreadExecutor > fMTExecImpl
void Foreach(Function func, ROOT::TSeq< INTEGER > args, unsigned nChunks=0)
Executor(int nthreads)
Constructor of TMVA Executor class Explicit specify the number of threads.
ROOT::TThreadExecutor * GetMultiThreadExecutor()
auto Map(F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
Wrap TExecutor::Map functions.
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
create variable transformations