DPC++ Runtime
Runtime libraries for oneAPI DPC++
|
|
Go to the documentation of this file.
21 template <
typename TransformedArgType,
int Dims,
typename KernelType>
22 class RoundedRangeKernel;
23 template <
typename TransformedArgType,
int Dims,
typename KernelType>
24 class RoundedRangeKernelWithKH;
26 template <
int dimensions>
class range;
27 template <
int dimensions,
bool with_offset>
class item;
32 template <
int dimensions = 1>
class id :
public detail::array<dimensions> {
34 using base = detail::array<dimensions>;
35 static_assert(dimensions >= 1 && dimensions <= 3,
36 "id can only be 1, 2, or 3 dimensional.");
37 template <
int N,
int val,
typename T>
40 #ifndef __SYCL_DISABLE_ID_TO_INT_CONV__
45 class __private_class;
47 template <
typename N,
typename T>
48 using EnableIfIntegral = detail::enable_if_t<std::is_integral<N>::value, T>;
49 template <
bool B,
typename T>
50 using EnableIfT = detail::conditional_t<B, T, __private_class>;
51 #endif // __SYCL_DISABLE_ID_TO_INT_CONV__
58 template <
int N = dimensions>
id(ParamTy<N, 1, size_t> dim0) :
base(dim0) {}
60 template <
int N = dimensions>
64 template <
int N = dimensions,
bool with_offset = true>
70 template <
int N = dimensions>
71 id(ParamTy<N, 2, size_t> dim0,
size_t dim1) :
base(dim0, dim1) {}
73 template <
int N = dimensions>
75 :
base(range_size.
get(0), range_size.
get(1)) {}
77 template <
int N = dimensions,
bool with_offset = true>
83 template <
int N = dimensions>
84 id(ParamTy<N, 3, size_t> dim0,
size_t dim1,
size_t dim2)
85 :
base(dim0, dim1, dim2) {}
87 template <
int N = dimensions>
89 :
base(range_size.
get(0), range_size.
get(1), range_size.
get(2)) {}
91 template <
int N = dimensions,
bool with_offset = true>
96 explicit operator
range<dimensions>()
const {
99 for (
int i = 0; i < dimensions; ++i) {
100 result[i] = this->
get(i);
105 #ifndef __SYCL_DISABLE_ID_TO_INT_CONV__
112 size_t Result = this->common_array[0];
116 #endif // __SYCL_DISABLE_ID_TO_INT_CONV__
119 #ifndef __SYCL_DISABLE_ID_TO_INT_CONV__
126 #if __cpp_impl_three_way_comparison < 201907
135 #define __SYCL_GEN_OPT(op) \
136 template <typename T> \
137 EnableIfIntegral<T, bool> operator op(const T &rhs) const { \
138 if (this->common_array[0] != rhs) \
139 return false op true; \
140 return true op true; \
142 template <typename T> \
143 friend EnableIfIntegral<T, bool> operator op(const T &lhs, \
144 const id<dimensions> &rhs) { \
145 if (lhs != rhs.common_array[0]) \
146 return false op true; \
147 return true op true; \
153 #undef __SYCL_GEN_OPT
155 #endif // __SYCL_DISABLE_ID_TO_INT_CONV__
158 #define __SYCL_GEN_OPT_BASE(op) \
159 friend id<dimensions> operator op(const id<dimensions> &lhs, \
160 const id<dimensions> &rhs) { \
161 id<dimensions> result; \
162 for (int i = 0; i < dimensions; ++i) { \
163 result.common_array[i] = lhs.common_array[i] op rhs.common_array[i]; \
168 #ifndef __SYCL_DISABLE_ID_TO_INT_CONV__
170 #define __SYCL_GEN_OPT(op) \
171 __SYCL_GEN_OPT_BASE(op) \
172 template <typename T> \
173 friend EnableIfIntegral<T, id<dimensions>> operator op( \
174 const id<dimensions> &lhs, const T &rhs) { \
175 id<dimensions> result; \
176 for (int i = 0; i < dimensions; ++i) { \
177 result.common_array[i] = lhs.common_array[i] op rhs; \
181 template <typename T> \
182 friend EnableIfIntegral<T, id<dimensions>> operator op( \
183 const T &lhs, const id<dimensions> &rhs) { \
184 id<dimensions> result; \
185 for (int i = 0; i < dimensions; ++i) { \
186 result.common_array[i] = lhs op rhs.common_array[i]; \
191 #define __SYCL_GEN_OPT(op) \
192 __SYCL_GEN_OPT_BASE(op) \
193 friend id<dimensions> operator op(const id<dimensions> &lhs, \
194 const size_t &rhs) { \
195 id<dimensions> result; \
196 for (int i = 0; i < dimensions; ++i) { \
197 result.common_array[i] = lhs.common_array[i] op rhs; \
201 friend id<dimensions> operator op(const size_t &lhs, \
202 const id<dimensions> &rhs) { \
203 id<dimensions> result; \
204 for (int i = 0; i < dimensions; ++i) { \
205 result.common_array[i] = lhs op rhs.common_array[i]; \
209 #endif // __SYCL_DISABLE_ID_TO_INT_CONV__
228 #undef __SYCL_GEN_OPT
229 #undef __SYCL_GEN_OPT_BASE
232 #define __SYCL_GEN_OPT(op) \
233 friend id<dimensions> &operator op(id<dimensions> &lhs, \
234 const id<dimensions> &rhs) { \
235 for (int i = 0; i < dimensions; ++i) { \
236 lhs.common_array[i] op rhs.common_array[i]; \
240 friend id<dimensions> &operator op(id<dimensions> &lhs, const size_t &rhs) { \
241 for (int i = 0; i < dimensions; ++i) { \
242 lhs.common_array[i] op rhs; \
258 #undef __SYCL_GEN_OPT
261 #define __SYCL_GEN_OPT(op) \
262 friend id<dimensions> operator op(const id<dimensions> &rhs) { \
263 id<dimensions> result; \
264 for (int i = 0; i < dimensions; ++i) { \
265 result.common_array[i] = (op rhs.common_array[i]); \
273 #undef __SYCL_GEN_OPT
276 #define __SYCL_GEN_OPT(op) \
277 friend id<dimensions> &operator op(id<dimensions> &rhs) { \
278 for (int i = 0; i < dimensions; ++i) { \
279 op rhs.common_array[i]; \
287 #undef __SYCL_GEN_OPT
290 #define __SYCL_GEN_OPT(op) \
291 friend id<dimensions> operator op(id<dimensions> &lhs, int) { \
292 id<dimensions> old_lhs; \
293 for (int i = 0; i < dimensions; ++i) { \
294 old_lhs.common_array[i] = lhs.common_array[i]; \
295 op lhs.common_array[i]; \
303 #undef __SYCL_GEN_OPT
308 template <
typename,
int,
typename>
314 template <
int dimensions>
318 for (
int i = 0; i < dimensions; ++i)
319 offset = offset * Range[i] + Offset[i] + Id[i];
328 size_t X = Index % Range[1];
329 size_t Y = Index / Range[1];
334 size_t D1D2 = Range[1] * Range[2];
335 size_t Z = Index / D1D2;
336 size_t ZRest = Index % D1D2;
337 size_t Y = ZRest / Range[2];
338 size_t X = ZRest % Range[2];
345 #ifdef __cpp_deduction_guides
347 id(
size_t,
size_t)->id<2>;
348 id(
size_t,
size_t,
size_t)->id<3>;
354 #ifdef __SYCL_DEVICE_ONLY__
357 throw sycl::exception(
359 "Free function calls are not supported on host");
363 namespace ext::oneapi::experimental {
365 #ifdef __SYCL_DEVICE_ONLY__
368 throw sycl::exception(
370 "Free function calls are not supported on host");
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
id(ParamTy< N, 2, const item< dimensions, with_offset >> &item)
#define __SYCL_INLINE_VER_NAMESPACE(X)
#define __SYCL_ALWAYS_INLINE
---— Error handling, matching OpenCL plugin semantics.
bool operator==(const Slab &Lhs, const Slab &Rhs)
A unique identifier of an item in an index space.
#define __SYCL_DEPRECATED(message)
typename std::enable_if< B, T >::type enable_if_t
Defines the iteration domain of either a single work-group in a parallel dispatch,...
id(ParamTy< N, 1, size_t > dim0)
constexpr tuple_element< I, tuple< Types... > >::type & get(sycl::detail::tuple< Types... > &Arg) noexcept
Identifies an instance of the function object executing at each point in a range.
size_t getOffsetForId(range< dimensions > Range, id< dimensions > Id, id< dimensions > Offset)
id(ParamTy< N, 1, const item< dimensions, with_offset >> &item)
id(ParamTy< N, 1, const range< dimensions >> &range_size)
id(ParamTy< N, 3, size_t > dim0, size_t dim1, size_t dim2)
#define __SYCL_ASSUME_INT(x)
id(ParamTy< N, 3, const item< dimensions, with_offset >> &item)
id< 3 > getDelinearizedId(const range< 3 > &Range, size_t Index)
id(ParamTy< N, 3, const range< dimensions >> &range_size)
bool operator==(const id< dimensions > &rhs) const
id(ParamTy< N, 2, const range< dimensions >> &range_size)
id(ParamTy< N, 2, size_t > dim0, size_t dim1)
#define __SYCL_GEN_OPT(op)