Skip to content

Commit ead7383

Browse files
committed
disable reduce() algorithm if macro SYCL_REDUCTION_DETERMINISTIC is defined
Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent 8b9f826 commit ead7383

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

sycl/include/CL/sycl/ONEAPI/reduction.hpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ namespace detail {
2727

2828
using cl::sycl::detail::bool_constant;
2929
using cl::sycl::detail::enable_if_t;
30-
using cl::sycl::detail::is_sgenfloat;
31-
using cl::sycl::detail::is_sgeninteger;
3230
using cl::sycl::detail::queue_impl;
3331
using cl::sycl::detail::remove_AS;
3432

@@ -45,7 +43,7 @@ using IsReduOptForFastAtomicFetch =
4543
#ifdef SYCL_REDUCTION_DETERMINISTIC
4644
bool_constant<false>;
4745
#else
48-
bool_constant<is_sgeninteger<T>::value &&
46+
bool_constant<sycl::detail::is_sgeninteger<T>::value &&
4947
sycl::detail::IsValidAtomicType<T>::value &&
5048
(sycl::detail::IsPlus<T, BinaryOperation>::value ||
5149
sycl::detail::IsMinimum<T, BinaryOperation>::value ||
@@ -55,14 +53,23 @@ using IsReduOptForFastAtomicFetch =
5553
sycl::detail::IsBitAND<T, BinaryOperation>::value)>;
5654
#endif
5755

56+
// This type trait is used to detect if the group algorithm reduce() used with
57+
// operands of the type T and the operation BinaryOperation is available
58+
// for using in reduction.
59+
// The macro SYCL_REDUCTION_DETERMINISTIC prohibits using the reduce() algorithm
60+
// to produce stable results across same type devices.
5861
template <typename T, class BinaryOperation>
5962
using IsReduOptForFastReduce =
60-
bool_constant<((is_sgeninteger<T>::value &&
63+
#ifdef SYCL_REDUCTION_DETERMINISTIC
64+
bool_constant<false>;
65+
#else
66+
bool_constant<((sycl::detail::is_sgeninteger<T>::value &&
6167
(sizeof(T) == 4 || sizeof(T) == 8)) ||
62-
is_sgenfloat<T>::value) &&
68+
sycl::detail::is_sgenfloat<T>::value) &&
6369
(sycl::detail::IsPlus<T, BinaryOperation>::value ||
6470
sycl::detail::IsMinimum<T, BinaryOperation>::value ||
6571
sycl::detail::IsMaximum<T, BinaryOperation>::value)>;
72+
#endif
6673

6774
// std::tuple seems to be a) too heavy and b) not copyable to device now
6875
// Thus sycl::detail::tuple is used instead.

0 commit comments

Comments
 (0)