![]() |
Taskflow
3.2.0-Master-Branch
|
tf::syclFlow provides two template methods, tf::syclFlow::reduce and tf::syclFlow::uninitialized_reduce, for creating tasks to perform parallel reductions over a range of items.
The reduction task created by tf::syclFlow::reduce(I first, I last, T* result, C&& bop) performs parallel reduction over a range of elements specified by [first, last)
using the binary operator bop
and stores the reduced result in result
. It represents the parallel execution of the following reduction loop on a SYCL device:
The variable result
participates in the reduction loop and must be initialized with an initial value. The following code performs a parallel reduction to sum all the numbers in the given range with an initial value 1000
:
You can use tf::syclFlow::uninitialized_reduce to perform parallel reduction without any initial value. This method represents a parallel execution of the following reduction loop on a SYCL device that does not assum any initial value to reduce.
The variable result
is overwritten with the reduced value and no initial values participate in the reduction loop. The following code performs a parallel reduction to sum all the numbers in the given range without any initial value: