You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sycl/doc/extensions/Reduction/Reduction.md
+22-5Lines changed: 22 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,21 @@ unspecified reduction(accessor<T>& var, BinaryOperation combiner);
22
22
23
23
template <class T, class BinaryOperation>
24
24
unspecified reduction(accessor<T>& var, const T& identity, BinaryOperation combiner);
25
+
26
+
template <class T, class BinaryOperation>
27
+
unspecified reduction(T* var, BinaryOperation combiner);
28
+
29
+
template <class T, class BinaryOperation>
30
+
unspecified reduction(T* var, const T& identity, BinaryOperation combiner);
31
+
32
+
template <class T, class Extent, class BinaryOperation>
33
+
unspecified reduction(span<T, Extent> var, BinaryOperation combiner);
34
+
35
+
template <class T, class Extent, class BinaryOperation>
36
+
unspecified reduction(span<T, Extent> var, const T& identity, BinaryOperation combiner);
25
37
```
26
38
27
-
The exact behavior of a reduction is specific to an implementation; the only interface exposed to the user is the pair of functions above, which construct an unspecified `reduction` object encapsulating the reduction variable, an optional operator identity and the reduction operator. For user-defined binary operations, an implementation should issue a compile-time warning if an identity is not specified and this is known to negatively impact performance (e.g. as a result of the implementation choosing a different reduction algorithm). For standard binary operations (e.g. `std::plus`) on arithmetic types, the implementation must determine the correct identity automatically in order to avoid performance penalties.
39
+
The exact behavior of a reduction is specific to an implementation; the only interface exposed to the user is the set of functions above, which construct an unspecified `reduction` object encapsulating the reduction variable, an optional operator identity and the reduction operator. For user-defined binary operations, an implementation should issue a compile-time warning if an identity is not specified and this is known to negatively impact performance (e.g. as a result of the implementation choosing a different reduction algorithm). For standard binary operations (e.g. `std::plus`) on arithmetic types, the implementation must determine the correct identity automatically in order to avoid performance penalties.
28
40
29
41
The dimensionality of the `accessor` passed to the `reduction` function specifies the dimensionality of the reduction variable: a 0-dimensional `accessor` represents a scalar reduction, and any other dimensionality represents an array reduction. Specifying an array reduction of size N is functionally equivalent to specifying N independent scalar reductions. The access mode of the accessor determines whether the reduction variable's original value is included in the reduction (i.e. for `access::mode::read_write` it is included, and for `access::mode::discard_write` it is not). Multiple reductions aliasing the same output results in undefined behavior.
30
42
@@ -33,22 +45,27 @@ The dimensionality of the `accessor` passed to the `reduction` function specifie
33
45
# `reducer` Objects
34
46
35
47
```c++
36
-
template <class T, class BinaryOperation, /* implementation-defined */>
48
+
// Exposition only
49
+
template <class T, class BinaryOperation, int Dimensions, /* implementation-defined */>
The `reducer` class is not user-constructible, and can only be constructed by an implementation given a `reduction` object. The `combine` function uses the specified `BinaryOperation` to combine the `partial` result with the value held (or referenced) by an instance of `reducer`, and is the only way to update the reducer value for user-supplied combination functions. Other convenience operators should be defined for standard combination functions (e.g. `+=` for `std::plus`).
0 commit comments