13 #ifdef __SYCL_DEVICE_ONLY__
15 #include <type_traits>
19 inline namespace _V1 {
55 "space is deprecated since SYCL 2020") =
67 "is deprecated since SYCL 2020") = 2
119 #ifdef __SYCL_DEVICE_ONLY__
120 #define __OPENCL_GLOBAL_AS__ __attribute__((opencl_global))
121 #ifdef __ENABLE_USM_ADDR_SPACE__
122 #define __OPENCL_GLOBAL_DEVICE_AS__ __attribute__((opencl_global_device))
123 #define __OPENCL_GLOBAL_HOST_AS__ __attribute__((opencl_global_host))
125 #define __OPENCL_GLOBAL_DEVICE_AS__ __attribute__((opencl_global))
126 #define __OPENCL_GLOBAL_HOST_AS__ __attribute__((opencl_global))
127 #endif // __ENABLE_USM_ADDR_SPACE__
128 #define __OPENCL_LOCAL_AS__ __attribute__((opencl_local))
129 #define __OPENCL_CONSTANT_AS__ __attribute__((opencl_constant))
130 #define __OPENCL_PRIVATE_AS__ __attribute__((opencl_private))
132 #define __OPENCL_GLOBAL_AS__
133 #define __OPENCL_GLOBAL_DEVICE_AS__
134 #define __OPENCL_GLOBAL_HOST_AS__
135 #define __OPENCL_LOCAL_AS__
136 #define __OPENCL_CONSTANT_AS__
137 #define __OPENCL_PRIVATE_AS__
145 #ifdef __ENABLE_USM_ADDR_SPACE__
146 template <>
struct TargetToAS<access::target::device> {
150 #endif // __ENABLE_USM_ADDR_SPACE__
157 template <>
struct TargetToAS<access::target::constant_buffer> {
159 access::address_space::constant_space;
162 template <
typename ElementType, access::address_space addressSpace>
165 template <
typename ElementType>
170 template <
typename ElementType>
175 template <
typename ElementType>
180 template <
typename ElementType>
182 access::address_space::ext_intel_global_device_space> {
186 template <
typename ElementType>
188 access::address_space::ext_intel_global_host_space> {
192 template <
typename ElementType>
199 #if defined(RESTRICT_WRITE_ACCESS_TO_CONSTANT_PTR)
206 template <
typename ElementType>
211 #ifdef __SYCL_DEVICE_ONLY__
212 template <
class T>
struct deduce_AS_impl {
220 #ifdef __ENABLE_USM_ADDR_SPACE__
230 #endif // __ENABLE_USM_ADDR_SPACE__
249 access::address_space::constant_space;
255 std::remove_pointer_t<std::remove_reference_t<std::remove_cv_t<T>>>> {
290 #ifdef __SYCL_DEVICE_ONLY__
295 #ifdef __ENABLE_USM_ADDR_SPACE__
304 #endif // __ENABLE_USM_ADDR_SPACE__
317 #endif // __SYCL_DEVICE_ONLY__
319 template <
typename T>
325 template <
typename ToT,
typename FromT>
inline ToT
cast_AS(FromT from) {
326 #ifdef __SYCL_DEVICE_ONLY__
330 #if defined(__NVPTX__) || defined(__AMDGCN__) || defined(__SYCL_NATIVE_CPU__)
337 using ToElemT = std::remove_pointer_t<remove_decoration_t<ToT>>;
339 return __SYCL_GenericCastToPtrExplicit_ToGlobal<ToElemT>(from);
341 return __SYCL_GenericCastToPtrExplicit_ToLocal<ToElemT>(from);
343 return __SYCL_GenericCastToPtrExplicit_ToPrivate<ToElemT>(from);
344 #ifdef __ENABLE_USM_ADDR_SPACE__
346 ext_intel_global_device_space ||
353 #endif // __ENABLE_USM_ADDR_SPACE__
355 return reinterpret_cast<ToT
>(from);
356 #endif // defined(__NVPTX__) || defined(__AMDGCN__)
358 #ifdef __ENABLE_USM_ADDR_SPACE__
368 #endif // __ENABLE_USM_ADDR_SPACE__
369 #endif // __SYCL_DEVICE_ONLY__
371 return reinterpret_cast<ToT
>(from);
377 #undef __OPENCL_GLOBAL_AS__
378 #undef __OPENCL_GLOBAL_DEVICE_AS__
379 #undef __OPENCL_GLOBAL_HOST_AS__
380 #undef __OPENCL_LOCAL_AS__
381 #undef __OPENCL_CONSTANT_AS__
382 #undef __OPENCL_PRIVATE_AS__