Skip to content

[SYCL][NFC] Rename PtrValueType to DecoratedType #3173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions sycl/include/CL/sycl/access/access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,30 +147,30 @@ template <> struct TargetToAS<access::target::constant_buffer> {
};

template <typename ElementType, access::address_space addressSpace>
struct PtrValueType;
struct DecoratedType;

template <typename ElementType>
struct PtrValueType<ElementType, access::address_space::private_space> {
struct DecoratedType<ElementType, access::address_space::private_space> {
using type = __OPENCL_PRIVATE_AS__ ElementType;
};

template <typename ElementType>
struct PtrValueType<ElementType, access::address_space::global_space> {
struct DecoratedType<ElementType, access::address_space::global_space> {
using type = __OPENCL_GLOBAL_AS__ ElementType;
};

template <typename ElementType>
struct PtrValueType<ElementType, access::address_space::global_device_space> {
struct DecoratedType<ElementType, access::address_space::global_device_space> {
using type = __OPENCL_GLOBAL_DEVICE_AS__ ElementType;
};

template <typename ElementType>
struct PtrValueType<ElementType, access::address_space::global_host_space> {
struct DecoratedType<ElementType, access::address_space::global_host_space> {
using type = __OPENCL_GLOBAL_HOST_AS__ ElementType;
};

template <typename ElementType>
struct PtrValueType<ElementType, access::address_space::constant_space> {
struct DecoratedType<ElementType, access::address_space::constant_space> {
// 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
Expand All @@ -184,7 +184,7 @@ struct PtrValueType<ElementType, access::address_space::constant_space> {
};

template <typename ElementType>
struct PtrValueType<ElementType, access::address_space::local_space> {
struct DecoratedType<ElementType, access::address_space::local_space> {
using type = __OPENCL_LOCAL_AS__ ElementType;
};

Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ class accessor :
using AccessorSubscript =
typename AccessorCommonT::template AccessorSubscript<Dims>;

using ConcreteASPtrType = typename detail::PtrValueType<DataT, AS>::type *;
using ConcreteASPtrType = typename detail::DecoratedType<DataT, AS>::type *;

using RefType = detail::const_if_const_AS<AS, DataT> &;
using ConstRefType = const DataT &;
Expand Down Expand Up @@ -1792,7 +1792,7 @@ class accessor<DataT, Dimensions, AccessMode, access::target::local,
using AccessorSubscript =
typename AccessorCommonT::template AccessorSubscript<Dims>;

using ConcreteASPtrType = typename detail::PtrValueType<DataT, AS>::type *;
using ConcreteASPtrType = typename detail::DecoratedType<DataT, AS>::type *;

using RefType = detail::const_if_const_AS<AS, DataT> &;
using PtrType = detail::const_if_const_AS<AS, DataT> *;
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class atomic {

private:
#ifdef __SYCL_DEVICE_ONLY__
typename detail::PtrValueType<T, addressSpace>::type *Ptr;
typename detail::DecoratedType<T, addressSpace>::type *Ptr;
#else
std::atomic<T> *Ptr;
#endif
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/generic_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ template <typename T> class TryToGetVectorT {
template <typename T> class TryToGetPointerVecT {
static T check(...);
template <typename A>
static typename PtrValueType<
static typename DecoratedType<
typename TryToGetVectorT<typename TryToGetElementType<A>::type>::type,
A::address_space>::type *
check(const A &);
Expand Down
33 changes: 17 additions & 16 deletions sycl/include/CL/sycl/multi_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ template <typename ElementType, access::address_space Space> class multi_ptr {

// Implementation defined pointer and reference types that correspond to
// SYCL/OpenCL interoperability types for OpenCL C functions
using pointer_t = typename detail::PtrValueType<ElementType, Space>::type *;
using pointer_t = typename detail::DecoratedType<ElementType, Space>::type *;
using const_pointer_t =
typename detail::PtrValueType<ElementType, Space>::type const *;
using reference_t = typename detail::PtrValueType<ElementType, Space>::type &;
typename detail::DecoratedType<ElementType, Space>::type const *;
using reference_t =
typename detail::DecoratedType<ElementType, Space>::type &;
using const_reference_t =
typename detail::PtrValueType<ElementType, Space>::type &;
typename detail::DecoratedType<ElementType, Space>::type &;

static constexpr access::address_space address_space = Space;

Expand Down Expand Up @@ -224,7 +225,7 @@ template <typename ElementType, access::address_space Space> class multi_ptr {
!std::is_const<ET>::value,
void>::type,
Space>() const {
using ptr_t = typename detail::PtrValueType<void, Space> *;
using ptr_t = typename detail::DecoratedType<void, Space> *;
return multi_ptr<void, Space>(reinterpret_cast<ptr_t>(m_Pointer));
}

Expand All @@ -236,14 +237,14 @@ template <typename ElementType, access::address_space Space> class multi_ptr {
std::is_const<ET>::value,
const void>::type,
Space>() const {
using ptr_t = typename detail::PtrValueType<const void, Space> *;
using ptr_t = typename detail::DecoratedType<const void, Space> *;
return multi_ptr<const void, Space>(reinterpret_cast<ptr_t>(m_Pointer));
}

// Implicit conversion to multi_ptr<const ElementType, Space>
operator multi_ptr<const ElementType, Space>() const {
using ptr_t =
typename detail::PtrValueType<const ElementType, Space>::type *;
typename detail::DecoratedType<const ElementType, Space>::type *;
return multi_ptr<const ElementType, Space>(
reinterpret_cast<ptr_t>(m_Pointer));
}
Expand Down Expand Up @@ -293,7 +294,7 @@ template <typename ElementType, access::address_space Space> class multi_ptr {
Space == access::address_space::global_host_space)>>
explicit
operator multi_ptr<ElementType, access::address_space::global_space>() const {
using global_pointer_t = typename detail::PtrValueType<
using global_pointer_t = typename detail::DecoratedType<
ElementType, access::address_space::global_space>::type *;
return multi_ptr<ElementType, access::address_space::global_space>(
reinterpret_cast<global_pointer_t>(m_Pointer));
Expand All @@ -307,7 +308,7 @@ template <typename ElementType, access::address_space Space> class multi_ptr {
_Space == Space && Space == access::address_space::global_space>>
void prefetch(size_t NumElements) const {
size_t NumBytes = NumElements * sizeof(ElementType);
using ptr_t = typename detail::PtrValueType<char, Space>::type const *;
using ptr_t = typename detail::DecoratedType<char, Space>::type const *;
__spirv_ocl_prefetch(reinterpret_cast<ptr_t>(m_Pointer), NumBytes);
}

Expand All @@ -323,9 +324,9 @@ template <access::address_space Space> class multi_ptr<void, Space> {

// Implementation defined pointer types that correspond to
// SYCL/OpenCL interoperability types for OpenCL C functions
using pointer_t = typename detail::PtrValueType<void, Space>::type *;
using pointer_t = typename detail::DecoratedType<void, Space>::type *;
using const_pointer_t =
typename detail::PtrValueType<void, Space>::type const *;
typename detail::DecoratedType<void, Space>::type const *;

static constexpr access::address_space address_space = Space;

Expand Down Expand Up @@ -420,14 +421,14 @@ template <access::address_space Space> class multi_ptr<void, Space> {
template <typename ElementType>
explicit operator multi_ptr<ElementType, Space>() const {
using elem_pointer_t =
typename detail::PtrValueType<ElementType, Space>::type *;
typename detail::DecoratedType<ElementType, Space>::type *;
return multi_ptr<ElementType, Space>(
static_cast<elem_pointer_t>(m_Pointer));
}

// Implicit conversion to multi_ptr<const void, Space>
operator multi_ptr<const void, Space>() const {
using ptr_t = typename detail::PtrValueType<const void, Space>::type *;
using ptr_t = typename detail::DecoratedType<const void, Space>::type *;
return multi_ptr<const void, Space>(reinterpret_cast<ptr_t>(m_Pointer));
}

Expand All @@ -444,9 +445,9 @@ class multi_ptr<const void, Space> {

// Implementation defined pointer types that correspond to
// SYCL/OpenCL interoperability types for OpenCL C functions
using pointer_t = typename detail::PtrValueType<const void, Space>::type *;
using pointer_t = typename detail::DecoratedType<const void, Space>::type *;
using const_pointer_t =
typename detail::PtrValueType<const void, Space>::type const *;
typename detail::DecoratedType<const void, Space>::type const *;

static constexpr access::address_space address_space = Space;

Expand Down Expand Up @@ -544,7 +545,7 @@ class multi_ptr<const void, Space> {
template <typename ElementType>
explicit operator multi_ptr<const ElementType, Space>() const {
using elem_pointer_t =
typename detail::PtrValueType<const ElementType, Space>::type *;
typename detail::DecoratedType<const ElementType, Space>::type *;
return multi_ptr<const ElementType, Space>(
static_cast<elem_pointer_t>(m_Pointer));
}
Expand Down