18#ifndef ROOT_TMVA_Executor
19#define ROOT_TMVA_Executor
38 template <
typename F,
typename... Args>
42 template <
class F,
class... T>
43 using noReferenceCond =
typename std::enable_if_t<
"Function can't return a reference" &&
65 ::Error(
"Executor",
"Cannot have TMVA in multi-threads mode when ROOT is built without IMT");
83 if ( nthreads != 1 ) {
87 ::Error(
"Executor",
"Cannot have TMVA in multi-threads mode when ROOT is built without IMT");
100 Info(
"GetThreadExecutor",
"Creating a TThread executor with a pool with a default size of %d",
fMTExecImpl->GetPoolSize());
116 template<
class Function>
121 template<
class Function,
class T>
126 template<
class Function,
class INTEGER>
139 template <
class F,
class Cond = noReferenceCond<F>>
140 auto Map(
F func,
unsigned nTimes) -> std::vector<InvokeResult_t<F>>
145 template <
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
153 template <
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
157 else return fSeqExecImpl->MapReduce(func, args, redfunc);
159 template <
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
163 else return fSeqExecImpl->MapReduce(func, args, redfunc);
167 template<
class T,
class R>
168 auto Reduce(
const std::vector<T> &objs,
R redfunc) ->
decltype(redfunc(objs)) {
177 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.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 Map(F func, ROOT::TSeq< INTEGER > args) -> std::vector< InvokeResult_t< F, INTEGER > >
auto MapReduce(F func, ROOT::TSeq< INTEGER > args, R redfunc, unsigned nChunks) -> InvokeResult_t< F, INTEGER >
std::unique_ptr< ROOT::TSequentialExecutor > fSeqExecImpl
auto Map(F func, unsigned nTimes) -> std::vector< InvokeResult_t< F > >
Wrap TExecutor::Map functions.
auto MapReduce(F func, ROOT::TSeq< INTEGER > args, R redfunc) -> InvokeResult_t< F, INTEGER >
Wrap TExecutor::MapReduce functions.
auto Reduce(const std::vector< T > &objs, R redfunc) -> decltype(redfunc(objs))
Wrap Reduce function.
unsigned int GetPoolSize() const
typename std::enable_if_t<"Function can't return a reference" &&!(std::is_reference< InvokeResult_t< F, T... > >::value)> noReferenceCond
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
ROOT::TypeTraits::InvokeResult_t< F, Args... > InvokeResult_t
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()
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
create variable transformations