|
Go to the source code of this file.
Functions | |
template<typename Fn , typename Rn , typename V > | |
V | WorkParallelReduceN (const V &identity, size_t n, Fn &&loopCallback, Rn &&reductionCallback, size_t grainSize) |
Recursively splits the range [0, n ) into subranges, which are then reduced by invoking loopCallback in parallel. | |
template<typename Fn , typename Rn , typename V > | |
V | WorkParallelReduceN (const V &identity, size_t n, Fn &&loopCallback, Rn &&reductionCallback) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This overload does not accept a grain size parameter and instead attempts to automatically deduce a grain size that is optimal for the current resource utilization and provided workload. | |
V WorkParallelReduceN | ( | const V & | identity, |
size_t | n, | ||
Fn && | loopCallback, | ||
Rn && | reductionCallback | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This overload does not accept a grain size parameter and instead attempts to automatically deduce a grain size that is optimal for the current resource utilization and provided workload.
V WorkParallelReduceN | ( | const V & | identity, |
size_t | n, | ||
Fn && | loopCallback, | ||
Rn && | reductionCallback, | ||
size_t | grainSize | ||
) |
Recursively splits the range [0, n
) into subranges, which are then reduced by invoking loopCallback
in parallel.
Each invocation of loopCallback
returns a single value that is the result of joining the elements in the respective subrange. These values are then further joined using the binary operator reductionCallback
, until only a single value remains. This single value is then the result of joining all elements over the entire range [0, n
).
The loopCallback
must be of the form:
V LoopCallback(size_t begin, size_t end, const V &identity);
The reductionCallback
must be of the form:
V ReductionCallback(const V &lhs, const V &rhs);
For example, the following code reduces an array of mesh points into a single bounding box:
grainSize
specifies a minimum amount of work to be done per-thread. There is overhead to launching a task and a typical guideline is that you want to have at least 10,000 instructions to count for the overhead of launching that task.