Skip to content

Commit 75f6cd2

Browse files
[SYCL] Move AreAllButLastReductions to reduction_forward.hpp (#13100)
Otherwise, `<sycl/detail/core.hpp>` isn't enough to invoke non-reduction `parallel_for`.
1 parent ea7ba1b commit 75f6cd2

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

sycl/include/sycl/detail/reduction_forward.hpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,28 @@ template <typename KernelName,
6868
void reduction_parallel_for(handler &CGH, nd_range<Dims> NDRange,
6969
PropertiesT Properties, RestT... Rest);
7070

71-
template <typename T> struct IsReduction;
72-
template <typename FirstT, typename... RestT> struct AreAllButLastReductions;
71+
/// Base non-template class which is a base class for all reduction
72+
/// implementation classes. It is needed to detect the reduction classes.
73+
class reduction_impl_base {};
74+
75+
/// Predicate returning true if a type is a reduction.
76+
template <typename T> struct IsReduction {
77+
static constexpr bool value =
78+
std::is_base_of_v<reduction_impl_base, std::remove_reference_t<T>>;
79+
};
80+
81+
/// Predicate returning true if all template type parameters except the last one
82+
/// are reductions.
83+
template <typename FirstT, typename... RestT> struct AreAllButLastReductions {
84+
static constexpr bool value =
85+
IsReduction<FirstT>::value && AreAllButLastReductions<RestT...>::value;
86+
};
87+
88+
/// Helper specialization of AreAllButLastReductions for one element only.
89+
/// Returns true if the template parameter is not a reduction.
90+
template <typename T> struct AreAllButLastReductions<T> {
91+
static constexpr bool value = !IsReduction<T>::value;
92+
};
7393

7494
} // namespace detail
7595
} // namespace _V1

sycl/include/sycl/reduction.hpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,6 @@
6060

6161
namespace sycl {
6262
inline namespace _V1 {
63-
namespace detail {
64-
65-
/// Base non-template class which is a base class for all reduction
66-
/// implementation classes. It is needed to detect the reduction classes.
67-
class reduction_impl_base {};
68-
69-
/// Predicate returning true if a type is a reduction.
70-
template <typename T> struct IsReduction {
71-
static constexpr bool value =
72-
std::is_base_of_v<reduction_impl_base, std::remove_reference_t<T>>;
73-
};
74-
75-
/// Predicate returning true if all template type parameters except the last one
76-
/// are reductions.
77-
template <typename FirstT, typename... RestT> struct AreAllButLastReductions {
78-
static constexpr bool value =
79-
IsReduction<FirstT>::value && AreAllButLastReductions<RestT...>::value;
80-
};
81-
82-
/// Helper specialization of AreAllButLastReductions for one element only.
83-
/// Returns true if the template parameter is not a reduction.
84-
template <typename T> struct AreAllButLastReductions<T> {
85-
static constexpr bool value = !IsReduction<T>::value;
86-
};
87-
} // namespace detail
88-
8963
/// Class that is used to represent objects that are passed to user's lambda
9064
/// functions and representing users' reduction variable.
9165
/// The generic version of the class represents those reductions of those

sycl/test-e2e/AddressCast/dynamic_address_cast.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
// UNSUPPORTED: cpu, hip, cuda, accelerator
1313
// RUN: %{build} -o %t.out
1414
// RUN: %{run} %t.out
15-
#include <sycl/sycl.hpp>
15+
16+
#include <sycl/detail/core.hpp>
17+
18+
#include <sycl/ext/oneapi/experimental/address_cast.hpp>
1619

1720
int main() {
1821

sycl/test-e2e/AddressCast/static_address_cast.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
// UNSUPPORTED: hip, cuda
1111
// RUN: %{build} -o %t.out
1212
// RUN: %{run} %t.out
13-
#include <sycl/sycl.hpp>
13+
14+
#include <sycl/detail/core.hpp>
15+
16+
#include <sycl/ext/oneapi/experimental/address_cast.hpp>
1417

1518
int main() {
1619

0 commit comments

Comments
 (0)