Skip to content

Commit 48414c7

Browse files
[SYCL] Fix c++14 mode compilation after #6343 (#6497)
Some reduction code is used on non-reduction path and must be available in C++14 even though the rest of the feature is guarded to be available in C++17 and above only.
1 parent b7bfe39 commit 48414c7

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

sycl/include/sycl/ext/oneapi/reduction.hpp

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
#pragma once
1010

11-
#if __cplusplus >= 201703L
12-
// Entire feature is dependent on C++17.
13-
1411
#include <sycl/accessor.hpp>
1512
#include <sycl/atomic.hpp>
1613
#include <sycl/atomic_ref.hpp>
@@ -23,6 +20,41 @@
2320

2421
#include <tuple>
2522

23+
__SYCL_INLINE_NAMESPACE(cl) {
24+
namespace sycl {
25+
namespace ext {
26+
namespace oneapi {
27+
namespace detail {
28+
29+
/// Base non-template class which is a base class for all reduction
30+
/// implementation classes. It is needed to detect the reduction classes.
31+
class reduction_impl_base {};
32+
33+
/// Predicate returning true if all template type parameters except the last one
34+
/// are reductions.
35+
template <typename FirstT, typename... RestT> struct AreAllButLastReductions {
36+
static constexpr bool value =
37+
std::is_base_of<reduction_impl_base,
38+
std::remove_reference_t<FirstT>>::value &&
39+
AreAllButLastReductions<RestT...>::value;
40+
};
41+
42+
/// Helper specialization of AreAllButLastReductions for one element only.
43+
/// Returns true if the template parameter is not a reduction.
44+
template <typename T> struct AreAllButLastReductions<T> {
45+
static constexpr bool value =
46+
!std::is_base_of<reduction_impl_base, std::remove_reference_t<T>>::value;
47+
};
48+
} // namespace detail
49+
} // namespace oneapi
50+
} // namespace ext
51+
} // namespace sycl
52+
} // __SYCL_INLINE_NAMESPACE(cl)
53+
54+
#if __cplusplus >= 201703L
55+
// Entire feature is dependent on C++17. We still have to make the trait above
56+
// available as queue shortcuts use them unconditionally, including on
57+
// non-reduction path.
2658
__SYCL_INLINE_NAMESPACE(cl) {
2759
namespace sycl {
2860
namespace ext {
@@ -456,10 +488,6 @@ class reducer<
456488
marray<T, Extent> MValue;
457489
};
458490

459-
/// Base non-template class which is a base class for all reduction
460-
/// implementation classes. It is needed to detect the reduction classes.
461-
class reduction_impl_base {};
462-
463491
/// Templated class for common functionality of all reduction implementation
464492
/// classes.
465493
template <typename T, class BinaryOperation> class reduction_impl_common {
@@ -713,22 +741,6 @@ class reduction_impl_algo : public reduction_impl_common<T, BinaryOperation> {
713741
/// User's accessor/USM pointer to where the reduction must be written.
714742
RedOutVar MRedOut;
715743
};
716-
717-
/// Predicate returning true if all template type parameters except the last one
718-
/// are reductions.
719-
template <typename FirstT, typename... RestT> struct AreAllButLastReductions {
720-
static constexpr bool value =
721-
std::is_base_of<reduction_impl_base,
722-
std::remove_reference_t<FirstT>>::value &&
723-
AreAllButLastReductions<RestT...>::value;
724-
};
725-
726-
/// Helper specialization of AreAllButLastReductions for one element only.
727-
/// Returns true if the template parameter is not a reduction.
728-
template <typename T> struct AreAllButLastReductions<T> {
729-
static constexpr bool value =
730-
!std::is_base_of<reduction_impl_base, std::remove_reference_t<T>>::value;
731-
};
732744
/// This class encapsulates the reduction variable/accessor,
733745
/// the reduction operator and an optional operator identity.
734746
template <typename T, class BinaryOperation, int Dims, size_t Extent,

0 commit comments

Comments
 (0)