@@ -20,7 +20,9 @@ namespace sycl {
2020template  <typename  T, typename  AllocatorT, typename  BinaryOperation>
2121std::enable_if_t <has_known_identity<BinaryOperation, T>::value,
2222                 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 >>>
2426reduction (buffer<T, 1 , AllocatorT> Var, handler &CGH, BinaryOperation,
2527          const  property_list &PropList = {}) {
2628  bool  InitializeToIdentity =
@@ -35,7 +37,9 @@ reduction(buffer<T, 1, AllocatorT> Var, handler &CGH, BinaryOperation,
3537template  <typename  T, typename  AllocatorT, typename  BinaryOperation>
3638std::enable_if_t <!has_known_identity<BinaryOperation, T>::value,
3739                 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 >>>
3943reduction (buffer<T, 1 , AllocatorT>, handler &, BinaryOperation,
4044          const  property_list &PropList = {}) {
4145  //  TODO: implement reduction that works even when identity is not known.
@@ -49,9 +53,11 @@ reduction(buffer<T, 1, AllocatorT>, handler &, BinaryOperation,
4953// / the given USM pointer \p Var, handler \p CGH, reduction operation
5054// / \p Combiner, and optional reduction properties.
5155template  <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 >>>
5561reduction (T *Var, BinaryOperation, const  property_list &PropList = {}) {
5662  bool  InitializeToIdentity =
5763      PropList.has_property <property::reduction::initialize_to_identity>();
@@ -64,9 +70,11 @@ reduction(T *Var, BinaryOperation, const property_list &PropList = {}) {
6470// / The reduction algorithm may be less efficient for this variant as the
6571// / reduction identity is not known statically and it is not provided by user.
6672template  <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 >>>
7078reduction (T *, BinaryOperation, const  property_list &PropList = {}) {
7179  //  TODO: implement reduction that works even when identity is not known.
7280  (void )PropList;
@@ -79,8 +87,10 @@ reduction(T *, BinaryOperation, const property_list &PropList = {}) {
7987// / reduction identity value \p Identity, reduction operation \p Combiner,
8088// / and optional reduction properties.
8189template  <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 >>
8494reduction (buffer<T, 1 , AllocatorT> Var, handler &CGH, const  T &Identity,
8595          BinaryOperation Combiner, const  property_list &PropList = {}) {
8696  bool  InitializeToIdentity =
@@ -92,13 +102,72 @@ reduction(buffer<T, 1, AllocatorT> Var, handler &CGH, const T &Identity,
92102// / the given USM pointer \p Var, reduction identity value \p Identity,
93103// / binary operation \p Combiner, and optional reduction properties.
94104template  <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 >>
96109reduction (T *Var, const  T &Identity, BinaryOperation Combiner,
97110          const  property_list &PropList = {}) {
98111  bool  InitializeToIdentity =
99112      PropList.has_property <property::reduction::initialize_to_identity>();
100113  return  {Var, Identity, Combiner, InitializeToIdentity};
101114}
102115
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+ 
103172} //  namespace sycl
104173} //  __SYCL_INLINE_NAMESPACE(cl)
0 commit comments