@@ -90,30 +90,25 @@ template <typename T>
90
90
inline constexpr bool is_device_copyable_v = is_device_copyable<T>::value;
91
91
namespace detail {
92
92
#ifdef __SYCL_DEVICE_ONLY__
93
- // Checks that the fields of the type T with indices 0 to (NumFieldsToCheck -
94
- // 1) are device copyable.
95
- template <typename T, unsigned NumFieldsToCheck>
96
- struct CheckFieldsAreDeviceCopyable
97
- : CheckFieldsAreDeviceCopyable<T, NumFieldsToCheck - 1 > {
98
- using FieldT = decltype (__builtin_field_type(T, NumFieldsToCheck - 1 ));
99
- static_assert (is_device_copyable_v<FieldT>,
100
- " The specified type is not device copyable" );
93
+ template <typename T, typename > struct CheckFieldsAreDeviceCopyable ;
94
+ template <typename T, typename > struct CheckBasesAreDeviceCopyable ;
95
+
96
+ template <typename T, unsigned ... FieldIds>
97
+ struct CheckFieldsAreDeviceCopyable <T, std::index_sequence<FieldIds...>> {
98
+ static_assert (
99
+ ((is_device_copyable_v<decltype (__builtin_field_type(T, FieldIds))> &&
100
+ ...)),
101
+ " The specified type is not device copyable" );
101
102
};
102
103
103
- template <typename T> struct CheckFieldsAreDeviceCopyable <T, 0 > {};
104
-
105
- // Checks that the base classes of the type T with indices 0 to
106
- // (NumFieldsToCheck - 1) are device copyable.
107
- template <typename T, unsigned NumBasesToCheck>
108
- struct CheckBasesAreDeviceCopyable
109
- : CheckBasesAreDeviceCopyable<T, NumBasesToCheck - 1 > {
110
- using BaseT = decltype (__builtin_base_type(T, NumBasesToCheck - 1 ));
111
- static_assert (is_device_copyable_v<BaseT>,
112
- " The specified type is not device copyable" );
104
+ template <typename T, unsigned ... BaseIds>
105
+ struct CheckBasesAreDeviceCopyable <T, std::index_sequence<BaseIds...>> {
106
+ static_assert (
107
+ ((is_device_copyable_v<decltype (__builtin_base_type(T, BaseIds))> &&
108
+ ...)),
109
+ " The specified type is not device copyable" );
113
110
};
114
111
115
- template <typename T> struct CheckBasesAreDeviceCopyable <T, 0 > {};
116
-
117
112
// All the captures of a lambda or functor of type FuncT passed to a kernel
118
113
// must be is_device_copyable, which extends to bases and fields of FuncT.
119
114
// Fields are captures of lambda/functors and bases are possible base classes
@@ -127,8 +122,10 @@ template <typename T> struct CheckBasesAreDeviceCopyable<T, 0> {};
127
122
// is currently/temporarily supported only to not break older SYCL programs.
128
123
template <typename FuncT>
129
124
struct CheckDeviceCopyable
130
- : CheckFieldsAreDeviceCopyable<FuncT, __builtin_num_fields(FuncT)>,
131
- CheckBasesAreDeviceCopyable<FuncT, __builtin_num_bases(FuncT)> {};
125
+ : CheckFieldsAreDeviceCopyable<
126
+ FuncT, std::make_index_sequence<__builtin_num_fields(FuncT)>>,
127
+ CheckBasesAreDeviceCopyable<
128
+ FuncT, std::make_index_sequence<__builtin_num_bases(FuncT)>> {};
132
129
133
130
template <typename TransformedArgType, int Dims, typename KernelType>
134
131
class RoundedRangeKernel ;
0 commit comments