diff --git a/sycl/include/CL/sycl/access/access.hpp b/sycl/include/CL/sycl/access/access.hpp index 005ab637eb264..fed4eaef6a385 100644 --- a/sycl/include/CL/sycl/access/access.hpp +++ b/sycl/include/CL/sycl/access/access.hpp @@ -127,7 +127,15 @@ struct PtrValueType { template struct PtrValueType { - using type = SYCL_CONSTANT_AS ElementType; + // Current implementation of address spaces handling leads to possibility + // of emitting incorrect (in terms of OpenCL) address space casts from + // constant to generic (and vise-versa). So, global address space is used here + // instead of constant to avoid incorrect address space casts in the produced + // device code. "const" qualifier is not used here because multi_ptr interface + // contains function members which return pure ElementType without qualifiers + // and adding const qualifier here will require adding const casts to + // multi_ptr methods to remove const qualifiers from underlying pointer type. + using type = SYCL_GLOBAL_AS ElementType; }; template diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index 83aa87d8258e5..caa1c998879cd 100644 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -193,12 +193,8 @@ class accessor_common { constexpr static bool IsAccessReadWrite = AccessMode == access::mode::read_write; - using RefType = typename std::conditional< - AS == access::address_space::constant_space, - typename detail::PtrValueType::type &, DataT &>::type; - using PtrType = typename std::conditional< - AS == access::address_space::constant_space, - typename detail::PtrValueType::type *, DataT *>::type; + using RefType = DataT &; + using PtrType = DataT *; using AccType = accessor; @@ -673,13 +669,9 @@ class accessor : using AccessorSubscript = typename AccessorCommonT::template AccessorSubscript; - using RefType = typename std::conditional< - AS == access::address_space::constant_space, - typename detail::PtrValueType::type &, DataT &>::type; + using RefType = DataT &; using ConcreteASPtrType = typename detail::PtrValueType::type *; - using PtrType = - typename std::conditional::type; + using PtrType = DataT *; template size_t getLinearIndex(id Id) const { @@ -1012,13 +1004,9 @@ class accessor; - using RefType = typename std::conditional< - AS == access::address_space::constant_space, - typename detail::PtrValueType::type &, DataT &>::type; + using RefType = DataT &; using ConcreteASPtrType = typename detail::PtrValueType::type *; - using PtrType = - typename std::conditional::type; + using PtrType = DataT *; #ifdef __SYCL_DEVICE_ONLY__ detail::LocalAccessorBaseDevice impl; diff --git a/sycl/include/CL/sycl/multi_ptr.hpp b/sycl/include/CL/sycl/multi_ptr.hpp index 62c4a32f92709..70e626b91e59e 100644 --- a/sycl/include/CL/sycl/multi_ptr.hpp +++ b/sycl/include/CL/sycl/multi_ptr.hpp @@ -70,21 +70,9 @@ template class multi_ptr { return *this; } -#ifdef __SYCL_ENABLE_INFER_AS__ - using ReturnPtr = - typename std::conditional::type; - using ReturnRef = - typename std::conditional::type; - using ReturnConstRef = - typename std::conditional::type; -#else using ReturnPtr = ElementType *; using ReturnRef = ElementType &; using ReturnConstRef = const ElementType &; -#endif ReturnRef operator*() const { return *reinterpret_cast(m_Pointer);