@@ -20,7 +20,9 @@ namespace sycl {
20
20
template <typename T, typename AllocatorT, typename BinaryOperation>
21
21
std::enable_if_t <has_known_identity<BinaryOperation, T>::value,
22
22
ext::oneapi::detail::reduction_impl<
23
- T, BinaryOperation, 1 , false , access::placeholder::true_t >>
23
+ T, BinaryOperation, 0 , 1 ,
24
+ ext::oneapi::detail::default_reduction_algorithm<
25
+ false , access::placeholder::true_t , 1 >>>
24
26
reduction (buffer<T, 1 , AllocatorT> Var, handler &CGH, BinaryOperation,
25
27
const property_list &PropList = {}) {
26
28
bool InitializeToIdentity =
@@ -35,7 +37,9 @@ reduction(buffer<T, 1, AllocatorT> Var, handler &CGH, BinaryOperation,
35
37
template <typename T, typename AllocatorT, typename BinaryOperation>
36
38
std::enable_if_t <!has_known_identity<BinaryOperation, T>::value,
37
39
ext::oneapi::detail::reduction_impl<
38
- T, BinaryOperation, 1 , false , access::placeholder::true_t >>
40
+ T, BinaryOperation, 0 , 1 ,
41
+ ext::oneapi::detail::default_reduction_algorithm<
42
+ false , access::placeholder::true_t , 1 >>>
39
43
reduction (buffer<T, 1 , AllocatorT>, handler &, BinaryOperation,
40
44
const property_list &PropList = {}) {
41
45
// TODO: implement reduction that works even when identity is not known.
@@ -49,9 +53,11 @@ reduction(buffer<T, 1, AllocatorT>, handler &, BinaryOperation,
49
53
// / the given USM pointer \p Var, handler \p CGH, reduction operation
50
54
// / \p Combiner, and optional reduction properties.
51
55
template <typename T, typename BinaryOperation>
52
- std::enable_if_t <
53
- has_known_identity<BinaryOperation, T>::value,
54
- ext::oneapi::detail::reduction_impl<T, BinaryOperation, 1 , true >>
56
+ std::enable_if_t <has_known_identity<BinaryOperation, T>::value,
57
+ ext::oneapi::detail::reduction_impl<
58
+ T, BinaryOperation, 0 , 1 ,
59
+ ext::oneapi::detail::default_reduction_algorithm<
60
+ true , access::placeholder::false_t , 1 >>>
55
61
reduction (T *Var, BinaryOperation, const property_list &PropList = {}) {
56
62
bool InitializeToIdentity =
57
63
PropList.has_property <property::reduction::initialize_to_identity>();
@@ -64,9 +70,11 @@ reduction(T *Var, BinaryOperation, const property_list &PropList = {}) {
64
70
// / The reduction algorithm may be less efficient for this variant as the
65
71
// / reduction identity is not known statically and it is not provided by user.
66
72
template <typename T, typename BinaryOperation>
67
- std::enable_if_t <
68
- !has_known_identity<BinaryOperation, T>::value,
69
- ext::oneapi::detail::reduction_impl<T, BinaryOperation, 1 , true >>
73
+ std::enable_if_t <!has_known_identity<BinaryOperation, T>::value,
74
+ ext::oneapi::detail::reduction_impl<
75
+ T, BinaryOperation, 0 , 1 ,
76
+ ext::oneapi::detail::default_reduction_algorithm<
77
+ true , access::placeholder::false_t , 1 >>>
70
78
reduction (T *, BinaryOperation, const property_list &PropList = {}) {
71
79
// TODO: implement reduction that works even when identity is not known.
72
80
(void )PropList;
@@ -79,8 +87,10 @@ reduction(T *, BinaryOperation, const property_list &PropList = {}) {
79
87
// / reduction identity value \p Identity, reduction operation \p Combiner,
80
88
// / and optional reduction properties.
81
89
template <typename T, typename AllocatorT, typename BinaryOperation>
82
- ext::oneapi::detail::reduction_impl<T, BinaryOperation, 1 , false ,
83
- access::placeholder::true_t >
90
+ ext::oneapi::detail::reduction_impl<
91
+ T, BinaryOperation, 0 , 1 ,
92
+ ext::oneapi::detail::default_reduction_algorithm<
93
+ false , access::placeholder::true_t , 1 >>
84
94
reduction (buffer<T, 1 , AllocatorT> Var, handler &CGH, const T &Identity,
85
95
BinaryOperation Combiner, const property_list &PropList = {}) {
86
96
bool InitializeToIdentity =
@@ -92,13 +102,72 @@ reduction(buffer<T, 1, AllocatorT> Var, handler &CGH, const T &Identity,
92
102
// / the given USM pointer \p Var, reduction identity value \p Identity,
93
103
// / binary operation \p Combiner, and optional reduction properties.
94
104
template <typename T, typename BinaryOperation>
95
- ext::oneapi::detail::reduction_impl<T, BinaryOperation, 1 , true >
105
+ ext::oneapi::detail::reduction_impl<
106
+ T, BinaryOperation, 0 , 1 ,
107
+ ext::oneapi::detail::default_reduction_algorithm<
108
+ true , access::placeholder::false_t , 1 >>
96
109
reduction (T *Var, const T &Identity, BinaryOperation Combiner,
97
110
const property_list &PropList = {}) {
98
111
bool InitializeToIdentity =
99
112
PropList.has_property <property::reduction::initialize_to_identity>();
100
113
return {Var, Identity, Combiner, InitializeToIdentity};
101
114
}
102
115
116
+ #if __cplusplus >= 201703L
117
+ // / Constructs a reduction object using the reduction variable referenced by
118
+ // / the given sycl::span \p Span, reduction operation \p Combiner, and
119
+ // / optional reduction properties.
120
+ template <typename T, size_t Extent, typename BinaryOperation>
121
+ std::enable_if_t <Extent != dynamic_extent &&
122
+ has_known_identity<BinaryOperation, T>::value,
123
+ ext::oneapi::detail::reduction_impl<
124
+ T, BinaryOperation, 1 , Extent,
125
+ ext::oneapi::detail::default_reduction_algorithm<
126
+ true , access::placeholder::false_t , 1 >>>
127
+ reduction (span<T, Extent> Span, BinaryOperation,
128
+ const property_list &PropList = {}) {
129
+ bool InitializeToIdentity =
130
+ PropList.has_property <property::reduction::initialize_to_identity>();
131
+ return {Span, InitializeToIdentity};
132
+ }
133
+
134
+ // / Constructs a reduction object using the reduction variable referenced by
135
+ // / the given sycl::span \p Span, reduction operation \p Combiner, and
136
+ // / optional reduction properties.
137
+ // / The reduction algorithm may be less efficient for this variant as the
138
+ // / reduction identity is not known statically and it is not provided by user.
139
+ template <typename T, size_t Extent, typename BinaryOperation>
140
+ std::enable_if_t <Extent != dynamic_extent &&
141
+ !has_known_identity<BinaryOperation, T>::value,
142
+ ext::oneapi::detail::reduction_impl<
143
+ T, BinaryOperation, 1 , Extent,
144
+ ext::oneapi::detail::default_reduction_algorithm<
145
+ true , access::placeholder::false_t , 1 >>>
146
+ reduction (span<T, Extent> Span, BinaryOperation,
147
+ const property_list &PropList = {}) {
148
+ // TODO: implement reduction that works even when identity is not known.
149
+ (void )PropList;
150
+ throw runtime_error (" Identity-less reductions with unknown identity are not "
151
+ " supported yet." ,
152
+ PI_INVALID_VALUE);
153
+ }
154
+
155
+ // / Constructs a reduction object using the reduction variable referenced by
156
+ // / the given sycl::span \p Span, reduction identity value \p Identity,
157
+ // / reduction operation \p Combiner, and optional reduction properties.
158
+ template <typename T, size_t Extent, typename BinaryOperation>
159
+ std::enable_if_t <Extent != dynamic_extent,
160
+ ext::oneapi::detail::reduction_impl<
161
+ T, BinaryOperation, 1 , Extent,
162
+ ext::oneapi::detail::default_reduction_algorithm<
163
+ true , access::placeholder::false_t , 1 >>>
164
+ reduction (span<T, Extent> Span, const T &Identity, BinaryOperation Combiner,
165
+ const property_list &PropList = {}) {
166
+ bool InitializeToIdentity =
167
+ PropList.has_property <property::reduction::initialize_to_identity>();
168
+ return {Span, Identity, Combiner, InitializeToIdentity};
169
+ }
170
+ #endif
171
+
103
172
} // namespace sycl
104
173
} // __SYCL_INLINE_NAMESPACE(cl)
0 commit comments