19 #include <type_traits>
22 inline namespace _V1 {
25 template <
typename TransformedArgType,
int Dims,
typename KernelType>
26 class RoundedRangeKernel;
27 template <
typename TransformedArgType,
int Dims,
typename KernelType>
28 class RoundedRangeKernelWithKH;
30 template <
int Dimensions>
class range;
31 template <
int Dimensions,
bool with_offset>
class item;
43 "id can only be 1, 2, or 3 Dimensional.");
44 template <
int N,
int val,
typename T>
45 using ParamTy = std::enable_if_t<(N == val), T>;
47 #ifndef __SYCL_DISABLE_ID_TO_INT_CONV__
52 class __private_class;
54 template <
typename N,
typename T>
55 using EnableIfIntegral = std::enable_if_t<std::is_integral_v<N>, T>;
56 template <
bool B,
typename T>
57 using EnableIfT = std::conditional_t<B, T, __private_class>;
65 template <
int N = Dimensions>
id(ParamTy<N, 1, size_t> dim0) :
base(dim0) {}
67 template <
int N = Dimensions>
71 template <
int N = Dimensions,
bool with_offset = true>
77 template <
int N = Dimensions>
78 id(ParamTy<N, 2, size_t> dim0,
size_t dim1) :
base(dim0, dim1) {}
80 template <
int N = Dimensions>
82 :
base(range_size.
get(0), range_size.
get(1)) {}
84 template <
int N = Dimensions,
bool with_offset = true>
90 template <
int N = Dimensions>
91 id(ParamTy<N, 3, size_t> dim0,
size_t dim1,
size_t dim2)
92 :
base(dim0, dim1, dim2) {}
94 template <
int N = Dimensions>
96 :
base(range_size.
get(0), range_size.
get(1), range_size.
get(2)) {}
98 template <
int N = Dimensions,
bool with_offset = true>
102 #ifndef __SYCL_DISABLE_ID_TO_INT_CONV__
116 #ifndef __SYCL_DISABLE_ID_TO_INT_CONV__
123 #if __cpp_impl_three_way_comparison < 201907
132 #define __SYCL_GEN_OPT(op) \
133 template <typename T> \
134 EnableIfIntegral<T, bool> operator op(const T &rhs) const { \
135 if (this->common_array[0] != rhs) \
136 return false op true; \
137 return true op true; \
139 template <typename T> \
140 friend EnableIfIntegral<T, bool> operator op(const T &lhs, \
141 const id<Dimensions> &rhs) { \
142 if (lhs != rhs.common_array[0]) \
143 return false op true; \
144 return true op true; \
150 #undef __SYCL_GEN_OPT
155 #define __SYCL_GEN_OPT_BASE(op) \
156 friend id<Dimensions> operator op(const id<Dimensions> &lhs, \
157 const id<Dimensions> &rhs) { \
158 id<Dimensions> result; \
159 for (int i = 0; i < Dimensions; ++i) { \
160 result.common_array[i] = lhs.common_array[i] op rhs.common_array[i]; \
165 #ifndef __SYCL_DISABLE_ID_TO_INT_CONV__
167 #define __SYCL_GEN_OPT(op) \
168 __SYCL_GEN_OPT_BASE(op) \
169 template <typename T> \
170 friend EnableIfIntegral<T, id<Dimensions>> operator op( \
171 const id<Dimensions> &lhs, const T &rhs) { \
172 id<Dimensions> result; \
173 for (int i = 0; i < Dimensions; ++i) { \
174 result.common_array[i] = lhs.common_array[i] op rhs; \
178 template <typename T> \
179 friend EnableIfIntegral<T, id<Dimensions>> operator op( \
180 const T &lhs, const id<Dimensions> &rhs) { \
181 id<Dimensions> result; \
182 for (int i = 0; i < Dimensions; ++i) { \
183 result.common_array[i] = lhs op rhs.common_array[i]; \
188 #define __SYCL_GEN_OPT(op) \
189 __SYCL_GEN_OPT_BASE(op) \
190 friend id<Dimensions> operator op(const id<Dimensions> &lhs, \
191 const size_t &rhs) { \
192 id<Dimensions> result; \
193 for (int i = 0; i < Dimensions; ++i) { \
194 result.common_array[i] = lhs.common_array[i] op rhs; \
198 friend id<Dimensions> operator op(const size_t &lhs, \
199 const id<Dimensions> &rhs) { \
200 id<Dimensions> result; \
201 for (int i = 0; i < Dimensions; ++i) { \
202 result.common_array[i] = lhs op rhs.common_array[i]; \
225 #undef __SYCL_GEN_OPT
226 #undef __SYCL_GEN_OPT_BASE
229 #define __SYCL_GEN_OPT(op) \
230 friend id<Dimensions> &operator op(id<Dimensions> &lhs, \
231 const id<Dimensions> &rhs) { \
232 for (int i = 0; i < Dimensions; ++i) { \
233 lhs.common_array[i] op rhs.common_array[i]; \
237 friend id<Dimensions> &operator op(id<Dimensions> &lhs, const size_t &rhs) { \
238 for (int i = 0; i < Dimensions; ++i) { \
239 lhs.common_array[i] op rhs; \
255 #undef __SYCL_GEN_OPT
258 #define __SYCL_GEN_OPT(op) \
259 friend id<Dimensions> operator op(const id<Dimensions> &rhs) { \
260 id<Dimensions> result; \
261 for (int i = 0; i < Dimensions; ++i) { \
262 result.common_array[i] = (op rhs.common_array[i]); \
270 #undef __SYCL_GEN_OPT
273 #define __SYCL_GEN_OPT(op) \
274 friend id<Dimensions> &operator op(id<Dimensions> &rhs) { \
275 for (int i = 0; i < Dimensions; ++i) { \
276 op rhs.common_array[i]; \
284 #undef __SYCL_GEN_OPT
287 #define __SYCL_GEN_OPT(op) \
288 friend id<Dimensions> operator op(id<Dimensions> &lhs, int) { \
289 id<Dimensions> old_lhs; \
290 for (int i = 0; i < Dimensions; ++i) { \
291 old_lhs.common_array[i] = lhs.common_array[i]; \
292 op lhs.common_array[i]; \
300 #undef __SYCL_GEN_OPT
304 template <
int Dimensions>
309 offset = offset * Range[i] + Offset[i] + Id[i];
318 size_t X = Index % Range[1];
319 size_t Y = Index / Range[1];
324 size_t D1D2 = Range[1] * Range[2];
325 size_t Z = Index / D1D2;
326 size_t ZRest = Index % D1D2;
327 size_t Y = ZRest / Range[2];
328 size_t X = ZRest % Range[2];
335 #ifdef __cpp_deduction_guides
337 id(
size_t,
size_t)->
id<2>;
338 id(
size_t,
size_t,
size_t)->
id<3>;
bool operator==(const array< dimensions > &rhs) const
size_t common_array[dimensions]
size_t get(int dimension) const
A unique identifier of an item in an index space.
id(ParamTy< N, 2, size_t > dim0, size_t dim1)
id(ParamTy< N, 3, const range< Dimensions >> &range_size)
id(ParamTy< N, 3, const item< Dimensions, with_offset >> &item)
id(ParamTy< N, 2, const range< Dimensions >> &range_size)
id(ParamTy< N, 3, size_t > dim0, size_t dim1, size_t dim2)
static constexpr int dimensions
id(ParamTy< N, 1, const range< Dimensions >> &range_size)
id(ParamTy< N, 1, size_t > dim0)
id(ParamTy< N, 1, const item< Dimensions, with_offset >> &item)
id(ParamTy< N, 2, const item< Dimensions, with_offset >> &item)
bool operator==(const id< Dimensions > &rhs) const
Identifies an instance of the function object executing at each point in a range.
#define __SYCL_ASSUME_INT(x)
#define __SYCL_ALWAYS_INLINE
#define __SYCL_GEN_OPT(op)
id< 1 > getDelinearizedId(const range< 1 > &, size_t Index)
size_t getOffsetForId(range< Dimensions > Range, id< Dimensions > Id, id< Dimensions > Offset)
class __SYCL_EBO __SYCL_SPECIAL_CLASS Dimensions