Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ROOT::TThreadExecutor Class Reference

This class provides a simple interface to execute the same task multiple times in parallel threads, possibly with different arguments every time.

ROOT::TThreadExecutor::Map

This class inherits its interfaces from ROOT::TExecutorCRTP
, adapting them for multithreaded parallelism and extends them supporting:

  • Parallel Foreach operations.
  • Custom task granularity and partial reduction, by specifying reduction function and the number of chunks as extra parameters for the Map call. This is specially useful to reduce the size of intermediate results when dealing with a sizeable number of elements in the input data.

The two possible usages of the Map method are:

  • Map(F func, unsigned nTimes): func is executed nTimes with no arguments
  • Map(F func, T& args): func is executed on each element of the collection of arguments args

For either signature, func is executed as many times as needed by a pool of nThreads threads, where nThreads typically defaults to the number of cores.
A collection containing the result of each execution is returned.
Note: the user is responsible for the deletion of any object that might be created upon execution of func, returned objects included: ROOT::TThreadExecutor never deletes what it returns, it simply forgets it.

Parameters
funca callable object, such as a lambda expression, an std::function, a functor object or a function that takes zero arguments (for the first signature) or one (for the second signature).
argsa standard vector, a ROOT::TSeq of integer type or an initializer list for the second signature. An integer only for the first.

Note: in cases where the function to be executed takes more than zero/one argument but all are fixed except zero/one, the function can be wrapped in a lambda or via std::bind to give it the right signature.

Return value:

An std::vector. The elements in the container will be the objects returned by func.

Examples:

root[] ROOT::TThreadExecutor pool; auto hists = pool.Map(CreateHisto, 10);
root[] ROOT::TThreadExecutor pool(2); auto squares = pool.Map([](int a) { return a*a; }, {1,2,3});
#define a(i)
Definition RSha256.hxx:99
This class provides a simple interface to execute the same task multiple times in parallel threads,...
auto Map(F func, unsigned nTimes, R redfunc, unsigned nChunks) -> std::vector< InvokeResult_t< F > >
Execute a function nTimes in parallel, dividing the execution in nChunks and providing a result per c...

ROOT::TThreadExecutor::MapReduce

This set of methods behaves exactly like Map, but takes an additional function as a third argument. This function is applied to the set of objects returned by the corresponding Map execution to "squash" them into a single object. This function should be independent of the size of the vector returned by Map due to optimization of the number of chunks.

If this function is a binary operator, the "squashing" will be performed in parallel. This is exclusive to ROOT::TThreadExecutor and not any other ROOT::TExecutorCRTP-derived classes.
An integer can be passed as the fourth argument indicating the number of chunks we want to divide our work in. This may be useful to avoid the overhead introduced when running really short tasks.

Examples:

root[] ROOT::TThreadExecutor pool; auto ten = pool.MapReduce([]() { return 1; }, 10, [](const std::vector<int> &v) { return std::accumulate(v.begin(), v.end(), 0); })
root[] ROOT::TThreadExecutor pool; auto hist = pool.MapReduce(CreateAndFillHists, 10, PoolUtils::ReduceObjects);
Merge collection of TObjects.
Definition PoolUtils.h:35
auto MapReduce(F func, unsigned nTimes, R redfunc) -> InvokeResult_t< F >
Execute a function nTimes in parallel (Map) and accumulate the results into a single value (Reduce).

Definition at line 41 of file TThreadExecutor.hxx.

Public Member Functions

 TThreadExecutor (const TThreadExecutor &)=delete
 TThreadExecutor (UInt_t nThreads=0u)
 Class constructor.
template<class F, class T>
void Foreach (F func, const std::vector< T > &args, unsigned nChunks=0)
 Execute a function in parallel over the elements of a immutable vector, dividing the execution in nChunks.
template<class F, class INTEGER>
void Foreach (F func, ROOT::TSeq< INTEGER > args, unsigned nChunks=0)
 Execute a function in parallel over a sequence of indexes, dividing the execution in nChunks.
template<class F, class T>
void Foreach (F func, std::initializer_list< T > args, unsigned nChunks=0)
 Execute a function in parallel over the elements of an initializer_list, dividing the execution in nChunks.
template<class F, class T>
void Foreach (F func, std::vector< T > &args, unsigned nChunks=0)
 Execute a function in parallel over the elements of a vector, dividing the execution in nChunks.
template<class F>
void Foreach (F func, unsigned nTimes, unsigned nChunks=0)
 Execute a function without arguments several times in parallel, dividing the execution in nChunks.
unsigned GetPoolSize () const
 Returns the number of worker threads in the task arena.
auto Map (F func, unsigned nTimes) -> std::vector< InvokeResult_t< F > >
 Execute a function without arguments several times.
template<class F, class T, class R, class Cond = validMapReturnCond<F, T>>
auto Map (F func, const std::vector< T > &args, R redfunc, unsigned nChunks) -> std::vector< InvokeResult_t< F, T > >
 Execute a function in parallel over the elements of an immutable vector, dividing the execution in nChunks and providing a result per chunk.
template<class F, class INTEGER, class R, class Cond = validMapReturnCond<F, INTEGER>>
auto Map (F func, ROOT::TSeq< INTEGER > args, R redfunc, unsigned nChunks) -> std::vector< InvokeResult_t< F, INTEGER > >
 Execute a function in parallel over the elements of a sequence, dividing the execution in nChunks and providing a result per chunk.
template<class F, class T, class R, class Cond = validMapReturnCond<F, T>>
auto Map (F func, std::initializer_list< T > args, R redfunc, unsigned nChunks) -> std::vector< InvokeResult_t< F, T > >
 Execute a function in parallel over the elements of an initializer_list, dividing the execution in nChunks and providing a result per chunk.
template<class F, class T, class R, class Cond = validMapReturnCond<F, T>>
auto Map (F func, std::vector< T > &args, R redfunc, unsigned nChunks) -> std::vector< InvokeResult_t< F, T > >
 Execute a function in parallel over the elements of a vector, dividing the execution in nChunks and providing a result per chunk.
template<class F, class R, class Cond = validMapReturnCond<F>>
auto Map (F func, unsigned nTimes, R redfunc, unsigned nChunks) -> std::vector< InvokeResult_t< F > >
 Execute a function nTimes in parallel, dividing the execution in nChunks and providing a result per chunk.
auto MapReduce (F func, unsigned nTimes, R redfunc) -> InvokeResult_t< F >
 Execute a function without arguments several times (Map) and accumulate the results into a single value (Reduce).
template<class F, class T, class R, class Cond = validMapReturnCond<F, T>>
auto MapReduce (F func, const std::vector< T > &args, R redfunc) -> InvokeResult_t< F, T >
 Execute a function over the elements of an immutable vector in parallel (Map) and accumulate the results into a single value (Reduce).
template<class F, class T, class R, class Cond = validMapReturnCond<F, T>>
auto MapReduce (F func, const std::vector< T > &args, R redfunc, unsigned nChunks) -> InvokeResult_t< F, T >
 Execute a function in parallel over the elements of an immutable vector (Map) and accumulate the results into a single value (Reduce).
template<class F, class INTEGER, class R, class Cond = validMapReturnCond<F, INTEGER>>
auto MapReduce (F func, ROOT::TSeq< INTEGER > args, R redfunc, unsigned nChunks) -> InvokeResult_t< F, INTEGER >
 Execute a function in parallel over the elements of a vector (Map) and accumulate the results into a single value (Reduce).
template<class F, class T, class R, class Cond = validMapReturnCond<F, T>>
auto MapReduce (F func, std::initializer_list< T > args, R redfunc, unsigned nChunks) -> InvokeResult_t< F, T >
 Execute a function in parallel over the elements of an initializer_list (Map) and accumulate the results into a single value (Reduce).
template<class F, class T, class R, class Cond = validMapReturnCond<F, T>>
auto MapReduce (F func, std::vector< T > &args, R redfunc) -> InvokeResult_t< F, T >
 Execute a function over the elements of a vector in parallel (Map) and accumulate the results into a single value (Reduce).
template<class F, class T, class R, class Cond = validMapReturnCond<F, T>>
auto MapReduce (F func, std::vector< T > &args, R redfunc, unsigned nChunks) -> InvokeResult_t< F, T >
 Execute a function in parallel over the elements of a vector (Map) and accumulate the results into a single value (Reduce).
template<class F, class R, class Cond = validMapReturnCond<F>>
auto MapReduce (F func, unsigned nTimes, R redfunc) -> InvokeResult_t< F >
 Execute a function nTimes in parallel (Map) and accumulate the results into a single value (Reduce).
template<class F, class R, class Cond = validMapReturnCond<F>>
auto MapReduce (F func, unsigned nTimes, R redfunc, unsigned nChunks) -> InvokeResult_t< F >
 Execute a function in parallel over the elements of a vector (Map) and accumulate the results into a single value (Reduce).
TThreadExecutoroperator= (const TThreadExecutor &)=delete
T * Reduce (const std::vector< T * > &mergeObjs)
 "Reduce" an std::vector into a single object by using the object's Merge method.
template<class T, class BINARYOP>
auto Reduce (const std::vector< T > &objs, BINARYOP redfunc) -> decltype(redfunc(objs.front(), objs.front()))
 "Reduce" an std::vector into a single object in parallel by passing a binary function as the second argument defining the reduction operation.
template<class T, class R>
auto Reduce (const std::vector< T > &objs, R redfunc) -> decltype(redfunc(objs))

Protected Types

using InvokeResult_t
using validMapReturnCond
 type definition used in templated functions for not allowing mapping functions that return references or void.

Private Member Functions

TThreadExecutorDerived ()
template<class F, class T, class Cond = validMapReturnCond<F, T>>
auto MapImpl (F func, const std::vector< T > &args) -> std::vector< InvokeResult_t< F, T > >
 Execute a function over the elements of a vector in parallel.
template<class F, class INTEGER, class Cond = validMapReturnCond<F, INTEGER>>
auto MapImpl (F func, ROOT::TSeq< INTEGER > args) -> std::vector< InvokeResult_t< F, INTEGER > >
 Execute a function over a sequence of indexes in parallel.
template<class F, class T, class Cond = validMapReturnCond<F, T>>
auto MapImpl (F func, std::vector< T > &args) -> std::vector< InvokeResult_t< F, T > >
 Execute a function over the elements of a vector in parallel.
template<class F, class Cond = validMapReturnCond<F>>
auto MapImpl (F func, unsigned nTimes) -> std::vector< InvokeResult_t< F > >
 Execute a function without arguments several times in parallel.
void ParallelFor (unsigned start, unsigned end, unsigned step, const std::function< void(unsigned int i)> &f)
 Execute a function in parallel over the indices of a loop.
double ParallelReduce (const std::vector< double > &objs, const std::function< double(double a, double b)> &redfunc)
 "Reduce" in parallel an std::vector<double> into a single double value
float ParallelReduce (const std::vector< float > &objs, const std::function< float(float a, float b)> &redfunc)
 "Reduce" in parallel an std::vector<float> into a single float value
template<class T, class R>
auto SeqReduce (const std::vector< T > &objs, R redfunc) -> decltype(redfunc(objs))
 "Reduce", sequentially, an std::vector into a single object

Private Attributes

std::shared_ptr< ROOT::Internal::RTaskArenaWrapperfTaskArenaW = nullptr
 Pointer to the TBB task arena wrapper.
friend TExecutorCRTP

#include <ROOT/TThreadExecutor.hxx>

Inheritance diagram for ROOT::TThreadExecutor:
ROOT::TExecutorCRTP< TThreadExecutor >

Member Typedef Documentation

◆ InvokeResult_t

using ROOT::TExecutorCRTP< TThreadExecutor >::InvokeResult_t
protectedinherited

Definition at line 107 of file TExecutorCRTP.hxx.

◆ validMapReturnCond

using ROOT::TExecutorCRTP< TThreadExecutor >::validMapReturnCond
protectedinherited

type definition used in templated functions for not allowing mapping functions that return references or void.

The resulting vector elements must be assignable, references aren't.

Definition at line 112 of file TExecutorCRTP.hxx.

Constructor & Destructor Documentation

◆ TThreadExecutor() [1/2]

ROOT::TThreadExecutor::TThreadExecutor ( UInt_t nThreads = 0u)
explicit

Class constructor.

If the scheduler is active (e.g. because another TThreadExecutor is in flight, or ROOT::EnableImplicitMT() was called), work with the current pool of threads. If not, initialize the pool of threads, spawning nThreads. nThreads' default value, 0, initializes the pool with as many logical threads as are available in the system (see NLogicalCores in RTaskArenaWrapper.cxx).

At construction time, TThreadExecutor automatically enables ROOT's thread-safety locks as per calling ROOT::EnableThreadSafety().

Definition at line 148 of file TThreadExecutor.cxx.

◆ TThreadExecutor() [2/2]

ROOT::TThreadExecutor::TThreadExecutor ( const TThreadExecutor & )
delete

Member Function Documentation

◆ Derived()

TThreadExecutor & ROOT::TExecutorCRTP< TThreadExecutor >::Derived ( )
inlineprivateinherited

Definition at line 156 of file TExecutorCRTP.hxx.

◆ Foreach() [1/5]

template<class F, class T>
void ROOT::TThreadExecutor::Foreach ( F func,
const std::vector< T > & args,
unsigned nChunks = 0 )

Execute a function in parallel over the elements of a immutable vector, dividing the execution in nChunks.

Parameters
funcFunction to be executed on the elements of the vector passed as second parameter.
argsImmutable vector of elements passed as an argument to func.
nChunksNumber of chunks to split the input data for processing.

Definition at line 230 of file TThreadExecutor.hxx.

◆ Foreach() [2/5]

template<class F, class INTEGER>
void ROOT::TThreadExecutor::Foreach ( F func,
ROOT::TSeq< INTEGER > args,
unsigned nChunks = 0 )

Execute a function in parallel over a sequence of indexes, dividing the execution in nChunks.

Parameters
funcFunction to be executed. Must take an element of the sequence passed assecond argument as a parameter.
argsSequence of indexes to execute func on.
nChunksNumber of chunks to split the input data for processing.

Definition at line 168 of file TThreadExecutor.hxx.

◆ Foreach() [3/5]

template<class F, class T>
void ROOT::TThreadExecutor::Foreach ( F func,
std::initializer_list< T > args,
unsigned nChunks = 0 )

Execute a function in parallel over the elements of an initializer_list, dividing the execution in nChunks.

Parameters
funcFunction to be executed on the elements of the initializer_list passed as second parameter.
argsinitializer_list for a vector to apply func on.
nChunksNumber of chunks to split the input data for processing.

Definition at line 194 of file TThreadExecutor.hxx.

◆ Foreach() [4/5]

template<class F, class T>
void ROOT::TThreadExecutor::Foreach ( F func,
std::vector< T > & args,
unsigned nChunks = 0 )

Execute a function in parallel over the elements of a vector, dividing the execution in nChunks.

Parameters
funcFunction to be executed on the elements of the vector passed as second parameter.
argsVector of elements passed as an argument to func.
nChunksNumber of chunks to split the input data for processing.

Definition at line 206 of file TThreadExecutor.hxx.

◆ Foreach() [5/5]

template<class F>
void ROOT::TThreadExecutor::Foreach ( F func,
unsigned nTimes,
unsigned nChunks = 0 )

Execute a function without arguments several times in parallel, dividing the execution in nChunks.

Parameters
funcFunction to be executed.
nTimesNumber of times function should be called.
nChunksNumber of chunks to split the input data for processing.

Definition at line 145 of file TThreadExecutor.hxx.

◆ GetPoolSize()

unsigned ROOT::TThreadExecutor::GetPoolSize ( ) const

Returns the number of worker threads in the task arena.

Returns
the number of worker threads assigned to the task arena.

Definition at line 215 of file TThreadExecutor.cxx.

◆ Map() [1/6]

auto ROOT::TExecutorCRTP< TThreadExecutor >::Map ( F func,
unsigned nTimes )-> std::vector< InvokeResult_t< F > >
inherited

Execute a function without arguments several times.

Parameters
funcFunction to be executed.
nTimesNumber of times function should be called.
Returns
A vector with the results of the function calls. Functions that take arguments can be executed (with fixed arguments) by wrapping them in a lambda or with std::bind.

Definition at line 123 of file TExecutorCRTP.hxx.

◆ Map() [2/6]

template<class F, class T, class R, class Cond>
auto ROOT::TThreadExecutor::Map ( F func,
const std::vector< T > & args,
R redfunc,
unsigned nChunks ) -> std::vector< InvokeResult_t< F, T > >

Execute a function in parallel over the elements of an immutable vector, dividing the execution in nChunks and providing a result per chunk.

Definition at line 435 of file TThreadExecutor.hxx.

◆ Map() [3/6]

template<class F, class INTEGER, class R, class Cond>
auto ROOT::TThreadExecutor::Map ( F func,
ROOT::TSeq< INTEGER > args,
R redfunc,
unsigned nChunks ) -> std::vector< InvokeResult_t< F, INTEGER > >

Execute a function in parallel over the elements of a sequence, dividing the execution in nChunks and providing a result per chunk.

Definition at line 367 of file TThreadExecutor.hxx.

◆ Map() [4/6]

template<class F, class T, class R, class Cond>
auto ROOT::TThreadExecutor::Map ( F func,
std::initializer_list< T > args,
R redfunc,
unsigned nChunks ) -> std::vector< InvokeResult_t< F, T > >

Execute a function in parallel over the elements of an initializer_list, dividing the execution in nChunks and providing a result per chunk.

Definition at line 469 of file TThreadExecutor.hxx.

◆ Map() [5/6]

template<class F, class T, class R, class Cond>
auto ROOT::TThreadExecutor::Map ( F func,
std::vector< T > & args,
R redfunc,
unsigned nChunks ) -> std::vector< InvokeResult_t< F, T > >

Execute a function in parallel over the elements of a vector, dividing the execution in nChunks and providing a result per chunk.

Definition at line 401 of file TThreadExecutor.hxx.

◆ Map() [6/6]

template<class F, class R, class Cond>
auto ROOT::TThreadExecutor::Map ( F func,
unsigned nTimes,
R redfunc,
unsigned nChunks ) -> std::vector< InvokeResult_t< F > >

Execute a function nTimes in parallel, dividing the execution in nChunks and providing a result per chunk.

Definition at line 288 of file TThreadExecutor.hxx.

◆ MapImpl() [1/4]

template<class F, class T, class Cond>
auto ROOT::TThreadExecutor::MapImpl ( F func,
const std::vector< T > & args ) -> std::vector< InvokeResult_t< F, T > >
private

Execute a function over the elements of a vector in parallel.

Implementation of the Map method.

Definition at line 343 of file TThreadExecutor.hxx.

◆ MapImpl() [2/4]

template<class F, class INTEGER, class Cond>
auto ROOT::TThreadExecutor::MapImpl ( F func,
ROOT::TSeq< INTEGER > args ) -> std::vector< InvokeResult_t< F, INTEGER > >
private

Execute a function over a sequence of indexes in parallel.

Implementation of the Map method.

Definition at line 272 of file TThreadExecutor.hxx.

◆ MapImpl() [3/4]

template<class F, class T, class Cond>
auto ROOT::TThreadExecutor::MapImpl ( F func,
std::vector< T > & args ) -> std::vector< InvokeResult_t< F, T > >
private

Execute a function over the elements of a vector in parallel.

Implementation of the Map method.

Definition at line 319 of file TThreadExecutor.hxx.

◆ MapImpl() [4/4]

template<class F, class Cond>
auto ROOT::TThreadExecutor::MapImpl ( F func,
unsigned nTimes ) -> std::vector< InvokeResult_t< F > >
private

Execute a function without arguments several times in parallel.

Implementation of the Map method.

Definition at line 253 of file TThreadExecutor.hxx.

◆ MapReduce() [1/9]

auto ROOT::TExecutorCRTP< TThreadExecutor >::MapReduce ( F func,
unsigned nTimes,
R redfunc )-> InvokeResult_t< F >
inherited

Execute a function without arguments several times (Map) and accumulate the results into a single value (Reduce).

Parameters
funcFunction to be executed.
nTimesNumber of times function should be called.
Returns
A vector with the results of the function calls.
Parameters
redfuncReduction function to combine the results of the calls to func. Must return the same type as func.
Returns
A value result of "reducing" the vector returned by the Map operation into a single object.

Definition at line 137 of file TExecutorCRTP.hxx.

◆ MapReduce() [2/9]

template<class F, class T, class R, class Cond>
auto ROOT::TThreadExecutor::MapReduce ( F func,
const std::vector< T > & args,
R redfunc ) -> InvokeResult_t< F, T >

Execute a function over the elements of an immutable vector in parallel (Map) and accumulate the results into a single value (Reduce).

Definition at line 534 of file TThreadExecutor.hxx.

◆ MapReduce() [3/9]

template<class F, class T, class R, class Cond>
auto ROOT::TThreadExecutor::MapReduce ( F func,
const std::vector< T > & args,
R redfunc,
unsigned nChunks ) -> InvokeResult_t< F, T >

Execute a function in parallel over the elements of an immutable vector (Map) and accumulate the results into a single value (Reduce).

Benefits from partial reduction into nChunks intermediate results.

Definition at line 556 of file TThreadExecutor.hxx.

◆ MapReduce() [4/9]

template<class F, class INTEGER, class R, class Cond>
auto ROOT::TThreadExecutor::MapReduce ( F func,
ROOT::TSeq< INTEGER > args,
R redfunc,
unsigned nChunks ) -> InvokeResult_t< F, INTEGER >

Execute a function in parallel over the elements of a vector (Map) and accumulate the results into a single value (Reduce).

Benefits from partial reduction into nChunks intermediate results.

Definition at line 503 of file TThreadExecutor.hxx.

◆ MapReduce() [5/9]

template<class F, class T, class R, class Cond>
auto ROOT::TThreadExecutor::MapReduce ( F func,
std::initializer_list< T > args,
R redfunc,
unsigned nChunks ) -> InvokeResult_t< F, T >

Execute a function in parallel over the elements of an initializer_list (Map) and accumulate the results into a single value (Reduce).

Benefits from partial reduction into nChunks intermediate results.

Definition at line 515 of file TThreadExecutor.hxx.

◆ MapReduce() [6/9]

template<class F, class T, class R, class Cond>
auto ROOT::TThreadExecutor::MapReduce ( F func,
std::vector< T > & args,
R redfunc ) -> InvokeResult_t< F, T >

Execute a function over the elements of a vector in parallel (Map) and accumulate the results into a single value (Reduce).

Definition at line 525 of file TThreadExecutor.hxx.

◆ MapReduce() [7/9]

template<class F, class T, class R, class Cond>
auto ROOT::TThreadExecutor::MapReduce ( F func,
std::vector< T > & args,
R redfunc,
unsigned nChunks ) -> InvokeResult_t< F, T >

Execute a function in parallel over the elements of a vector (Map) and accumulate the results into a single value (Reduce).

Benefits from partial reduction into nChunks intermediate results.

Definition at line 545 of file TThreadExecutor.hxx.

◆ MapReduce() [8/9]

template<class F, class R, class Cond>
auto ROOT::TThreadExecutor::MapReduce ( F func,
unsigned nTimes,
R redfunc ) -> InvokeResult_t< F >

Execute a function nTimes in parallel (Map) and accumulate the results into a single value (Reduce).

Definition at line 481 of file TThreadExecutor.hxx.

◆ MapReduce() [9/9]

template<class F, class R, class Cond>
auto ROOT::TThreadExecutor::MapReduce ( F func,
unsigned nTimes,
R redfunc,
unsigned nChunks ) -> InvokeResult_t< F >

Execute a function in parallel over the elements of a vector (Map) and accumulate the results into a single value (Reduce).

Benefits from partial reduction into nChunks intermediate results.

Definition at line 492 of file TThreadExecutor.hxx.

◆ operator=()

TThreadExecutor & ROOT::TThreadExecutor::operator= ( const TThreadExecutor & )
delete

◆ ParallelFor()

void ROOT::TThreadExecutor::ParallelFor ( unsigned start,
unsigned end,
unsigned step,
const std::function< void(unsigned int i)> & f )
private

Execute a function in parallel over the indices of a loop.

Parameters
startStart index of the loop.
endEnd index of the loop.
stepStep size of the loop.
ffunction to execute.

Definition at line 160 of file TThreadExecutor.cxx.

◆ ParallelReduce() [1/2]

double ROOT::TThreadExecutor::ParallelReduce ( const std::vector< double > & objs,
const std::function< double(double a, double b)> & redfunc )
private

"Reduce" in parallel an std::vector<double> into a single double value

Parameters
objsA vector of elements to combine.
redfuncReduction function to combine the elements of the vector objs.
Returns
A value result of combining the vector elements into a single object of the same type.

Definition at line 182 of file TThreadExecutor.cxx.

◆ ParallelReduce() [2/2]

float ROOT::TThreadExecutor::ParallelReduce ( const std::vector< float > & objs,
const std::function< float(float a, float b)> & redfunc )
private

"Reduce" in parallel an std::vector<float> into a single float value

Parameters
objsA vector of elements to combine.
redfuncReduction function to combine the elements of the vector objs.
Returns
A value result of combining the vector elements into a single object of the same type.

Definition at line 200 of file TThreadExecutor.cxx.

◆ Reduce() [1/3]

T * ROOT::TExecutorCRTP< TThreadExecutor >::Reduce ( const std::vector< T * > & mergeObjs)
inherited

"Reduce" an std::vector into a single object by using the object's Merge method.

Parameters
mergeObjsA vector of ROOT objects implementing the Merge method
Returns
An object result of merging the vector elements into one.

Definition at line 151 of file TExecutorCRTP.hxx.

◆ Reduce() [2/3]

template<class T, class BINARYOP>
auto ROOT::TThreadExecutor::Reduce ( const std::vector< T > & objs,
BINARYOP redfunc ) -> decltype(redfunc(objs.front(), objs.front()))

"Reduce" an std::vector into a single object in parallel by passing a binary function as the second argument defining the reduction operation.

Parameters
objsA vector of elements to combine.
redfuncBinary reduction function to combine the elements of the vector objs.
Returns
A value result of combining the vector elements into a single object of the same type.

Definition at line 580 of file TThreadExecutor.hxx.

◆ Reduce() [3/3]

template<class T, class R>
auto ROOT::TThreadExecutor::Reduce ( const std::vector< T > & objs,
R redfunc ) -> decltype(redfunc(objs))

Definition at line 565 of file TThreadExecutor.hxx.

◆ SeqReduce()

template<class T, class R>
auto ROOT::TThreadExecutor::SeqReduce ( const std::vector< T > & objs,
R redfunc ) -> decltype(redfunc(objs))
private

"Reduce", sequentially, an std::vector into a single object

Parameters
objsA vector of elements to combine.
redfuncReduction function to combine the elements of the vector objs.
Returns
A value result of combining the vector elements into a single object of the same type.

Definition at line 594 of file TThreadExecutor.hxx.

Member Data Documentation

◆ fTaskArenaW

std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> ROOT::TThreadExecutor::fTaskArenaW = nullptr
private

Pointer to the TBB task arena wrapper.

Definition at line 133 of file TThreadExecutor.hxx.

◆ TExecutorCRTP

friend ROOT::TThreadExecutor::TExecutorCRTP
private

Definition at line 42 of file TThreadExecutor.hxx.


The documentation for this class was generated from the following files: