Embedded Multicore Building Blocks V1.0.0
Functions

Parallel foreach loop. More...

Functions

template<typename RAI , typename Function >
void embb::algorithms::ForEach (RAI first, RAI last, Function unary, const embb::mtapi::ExecutionPolicy &policy=embb::mtapi::ExecutionPolicy(), size_t block_size=0)
 Applies a unary function to the elements of a range in parallel. More...
 
template<typename Integer , typename Diff , typename Function >
void embb::algorithms::ForLoop (Integer first, Integer last, Diff stride=1, Function unary, const embb::mtapi::ExecutionPolicy &policy=embb::mtapi::ExecutionPolicy(), size_t block_size=0)
 Applies a unary function to the integers of a range in parallel. More...
 

Detailed Description

Parallel foreach loop.

Function Documentation

template<typename RAI , typename Function >
void embb::algorithms::ForEach ( RAI  first,
RAI  last,
Function  unary,
const embb::mtapi::ExecutionPolicy policy = embb::mtapi::ExecutionPolicy(),
size_t  block_size = 0 
)

Applies a unary function to the elements of a range in parallel.

The range consists of the elements from first to last, excluding the last element.

Exceptions
embb::base::ErrorExceptionif not enough MTAPI tasks can be created to satisfy the requirements of the algorithm.
Concurrency
Thread-safe if the elements in the range are not modified by another thread while the algorithm is executed.
Note
No guarantee is given on the order in which the function is applied to the elements.
For nested algorithms, the task limit may be exceeded. In that case, increase the task limit of the MTAPI node.
See also
embb::mtapi::ExecutionPolicy, ZipIterator
Template Parameters
RAIRandom access iterator
FunctionUnary function with argument of type std::iterator_traits<RAI>::value_type or an embb::mtapi::Job associated with an action function accepting a struct containing one member of type std::iterator_traits<RAI>::value_type as its argument buffer and a struct containing one member of type std::iterator_traits<RAI>::value_type as its result buffer.
Parameters
[in]firstRandom access iterator pointing to the first element of the range
[in]lastRandom access iterator pointing to the last plus one element of the range
[in]unaryUnary function applied to each element in the range
[in]policyembb::mtapi::ExecutionPolicy for the loop execution
[in]block_sizeLower bound for partitioning the range of elements into blocks that are treated in parallel. Partitioning of a block stops if its size is less than or equal to block_size. The default value 0 means that the minimum block size is determined automatically depending on the number of elements in the range divided by the number of available cores.
template<typename Integer , typename Diff , typename Function >
void embb::algorithms::ForLoop ( Integer  first,
Integer  last,
Diff  stride = 1,
Function  unary,
const embb::mtapi::ExecutionPolicy policy = embb::mtapi::ExecutionPolicy(),
size_t  block_size = 0 
)

Applies a unary function to the integers of a range in parallel.

The range consists of the integers from first to last, excluding the last element, strided by stride.

Exceptions
embb::base::ErrorExceptionif not enough MTAPI tasks can be created to satisfy the requirements of the algorithm.
Concurrency
Thread-safe
Note
No guarantee is given on the order in which the function is applied to the integers.
For nested algorithms, the task limit may be exceeded. In that case, increase the task limit of the MTAPI node.
See also
embb::mtapi::ExecutionPolicy
Template Parameters
Integerinteger type
FunctionUnary function with argument of type std::iterator_traits<RAI>::value_type or an embb::mtapi::Job associated with an action function accepting a struct containing one member of type std::iterator_traits<RAI>::value_type as its argument buffer and a struct containing one member of type std::iterator_traits<RAI>::value_type as its result buffer.
Parameters
[in]firstFirst integer of the range
[in]lastLast plus one integer of the range
[in]strideStride between integers, can be omitted
[in]unaryUnary function applied to each element in the range
[in]policyembb::mtapi::ExecutionPolicy for the loop execution
[in]block_sizeLower bound for partitioning the range of integers into blocks that are treated in parallel. Partitioning of a block stops if its size is less than or equal to block_size. The default value 0 means that the minimum block size is determined automatically depending on the number of integers in the range divided by the number of available cores.