![]() |
hpx::parallel::v1::reduce
// In header: <hpx/parallel/detail/reduce.hpp> template<typename ExPolicy, typename InIter, typename T> unspecified reduce(ExPolicy && policy, InIter first, InIter last, T init);
Returns GENERALIZED_SUM(+, init, *first, ..., *(first + (last - first) - 1)).
![]() |
Note |
---|---|
Complexity: O(last - first) applications of the operator+(). |
The reduce operations in the parallel reduce algorithm invoked with an execution policy object of type sequential_execution_policy
execute in sequential order in the calling thread.
The reduce operations in the parallel copy_if algorithm invoked with an execution policy object of type parallel_execution_policy
or task_execution_policy
are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
![]() |
Note |
---|---|
GENERALIZED_SUM(+, a1, ..., aN) is defined as follows:
|
The difference between reduce and accumulate is that the behavior of reduce may be non-deterministic for non-associative or non-commutative binary predicate.
Parameters: |
|
||||||||
Template Parameters: |
|
||||||||
Returns: |
The reduce algorithm returns a hpx::future<T> if the execution policy is of type task_execution_policy and returns T otherwise. The reduce algorithm returns the result of the generalized sum (applying operator+()) over the elements given by the input range [first, last). |