Parallel foreach loop.
More...
|
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...
|
|
Parallel foreach loop.
template<typename RAI , typename Function >
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
-
- 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
-
RAI | Random access iterator |
Function | Unary 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] | first | Random access iterator pointing to the first element of the range |
[in] | last | Random access iterator pointing to the last plus one element of the range |
[in] | unary | Unary function applied to each element in the range |
[in] | policy | embb::mtapi::ExecutionPolicy for the loop execution |
[in] | block_size | Lower 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 >
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
-
- 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
-
Integer | integer type |
Function | Unary 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] | first | First integer of the range |
[in] | last | Last plus one integer of the range |
[in] | stride | Stride between integers, can be omitted |
[in] | unary | Unary function applied to each element in the range |
[in] | policy | embb::mtapi::ExecutionPolicy for the loop execution |
[in] | block_size | Lower 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. |