18#ifndef ROOT_TMVA_Executor
19#define ROOT_TMVA_Executor
40 template<
class F,
class... T>
41 using noReferenceCond =
typename std::enable_if<
"Function can't return a reference" &&
42 !(std::is_reference<
typename std::result_of<
F(T...)>
::type>::value)>
::type;
59 ::Error(
"Executor",
"Cannot have TMVA in multi-threads mode when ROOT is built without IMT");
77 if ( nthreads != 1 ) {
81 ::Error(
"Executor",
"Cannot have TMVA in multi-threads mode when ROOT is built without IMT");
94 Info(
"GetThreadExecutor",
"Creating a TThread executor with a pool with a defult size of %d",
fMTExecImpl->GetPoolSize());
110 template<
class Function>
115 template<
class Function,
class T>
120 template<
class Function,
class INTEGER>
133 template<
class F,
class Cond = noReferenceCond<F>>
134 auto Map(
F func,
unsigned nTimes) -> std::vector<
typename std::result_of<
F()>
::type> {
138 template<
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
145 template<
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
148 else return fSeqExecImpl->MapReduce(func, args, redfunc);
150 template<
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
153 else return fSeqExecImpl->MapReduce(func, args, redfunc);
157 template<
class T,
class R>
158 auto Reduce(
const std::vector<T> &objs,
R redfunc) ->
decltype(redfunc(objs)) {
167 std::unique_ptr<ROOT::TSequentialExecutor>
fMTExecImpl;
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
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 threads,...
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