Template Function concore::v1::conc_reduce(It, It, Value, const BinaryOp&, const ReductionOp&, task_group, partition_hints)¶
Defined in File conc_reduce.hpp
Function Documentation¶
-
template<typename
It, typenameValue, typenameBinaryOp, typenameReductionOp>
Valueconcore::v1::conc_reduce(It first, It last, Value identity, const BinaryOp &op, const ReductionOp &reduction, task_group grp, partition_hints hints)¶ A concurrent reduce algorithm.
This implements a reduce operation (similar to
std::accumulate) but does it by exposing concurrent computations. In order for this to be well defined, the given operation and reduction functors must be able to properly run in parallel on different parts of the input collection.- Parameters
first: Iterator pointing to the first element in a collectionlast: Iterator pointing to the last element in a collection (1 past the end)identity: The identity value; the starting point of the reduceop: Binary functor that is applied to the elementsreduction: Binary functor that reduces the valuesgrp: Group in which to execute the taskshints: Hints that may be passed to thework: The work to be applied to be executed for the elements (when not usingf)
- Template Parameters
It: The type of the iterator to useValue: The type of the value used for computationBinaryOp: The type of function used by the operation that applies to elementsReductionOp: The type of function used by the reduction operationWorkType: The type of a work object to be used (when not usingopandreduction)
The operation is called exactly once for each element. The reduction is called each time we need to combine the results of two computations.
This generates internal tasks by spawning and waiting for those tasks to complete. If the user spawns other tasks during the execution of an iteration, those tasks would also be waited on.
One can cancel the execution of the tasks by passing a task_group object in, and canceling that task_group.
One can also provide hints to the implementation to fine-tune the algorithms to better fit the data it operates on. Please note however that the implementation may completely ignore all the hints it was provided.
- Warning
If the iterations are not completely independent, this results in undefined behavior.
- See
partition_hints, partition_method, conc_for(), task_group