-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Implement multi_ptr default to be legacy to avoid code break with SYCL 1.2.1 #10174
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
Changes from all commits
ee35dcf
cdf33b8
c4979ad
9f7eaa8
c53daaf
2d31f5d
e2acc2f
ac12601
9e048c8
6c4b172
33e6e5a
30b80bc
97e3a67
30a4d7d
39c87c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -662,6 +662,7 @@ class multi_ptr<void, Space, DecorateAddress> { | |
template <typename ElementType, access::address_space Space> | ||
class multi_ptr<ElementType, Space, access::decorated::legacy> { | ||
public: | ||
using value_type = ElementType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not actually part of the spec, even after the changes from the mentioned spec PR. I have made a comment on it: https://github.com/KhronosGroup/SYCL-Docs/pull/432/files#r1251095640, but we should not add interfaces that aren't part of the spec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks @steffenlarsen. I agree with you on above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good catch, the PR used |
||
using element_type = | ||
std::conditional_t<std::is_same_v<ElementType, half>, | ||
sycl::detail::half_impl::BIsRepresentationT, | ||
|
@@ -773,9 +774,8 @@ class multi_ptr<ElementType, Space, access::decorated::legacy> { | |
Space == access::address_space::ext_intel_global_device_space)>> | ||
multi_ptr(accessor<ElementType, dimensions, Mode, access::target::device, | ||
isPlaceholder, PropertyListT> | ||
Accessor) { | ||
m_Pointer = detail::cast_AS<pointer_t>(Accessor.get_pointer()); | ||
} | ||
Accessor) | ||
: multi_ptr(detail::cast_AS<pointer_t>(Accessor.get_pointer().get())) {} | ||
|
||
// Only if Space == local_space || generic_space | ||
template < | ||
|
@@ -891,6 +891,10 @@ class multi_ptr<ElementType, Space, access::decorated::legacy> { | |
|
||
// Returns the underlying OpenCL C pointer | ||
pointer_t get() const { return m_Pointer; } | ||
pointer_t get_decorated() const { return m_Pointer; } | ||
std::add_pointer_t<element_type> get_raw() const { | ||
return reinterpret_cast<std::add_pointer_t<element_type>>(get()); | ||
} | ||
|
||
// Implicit conversion to the underlying pointer type | ||
operator ReturnPtr() const { return reinterpret_cast<ReturnPtr>(m_Pointer); } | ||
|
@@ -1003,6 +1007,7 @@ class multi_ptr<ElementType, Space, access::decorated::legacy> { | |
template <access::address_space Space> | ||
class multi_ptr<void, Space, access::decorated::legacy> { | ||
public: | ||
using value_type = void; | ||
using element_type = void; | ||
using difference_type = std::ptrdiff_t; | ||
|
||
|
@@ -1114,6 +1119,10 @@ class multi_ptr<void, Space, access::decorated::legacy> { | |
using ReturnPtr = detail::const_if_const_AS<Space, void> *; | ||
// Returns the underlying OpenCL C pointer | ||
pointer_t get() const { return m_Pointer; } | ||
pointer_t get_decorated() const { return m_Pointer; } | ||
std::add_pointer_t<element_type> get_raw() const { | ||
return reinterpret_cast<std::add_pointer_t<element_type>>(get()); | ||
} | ||
|
||
// Implicit conversion to the underlying pointer type | ||
operator ReturnPtr() const { return reinterpret_cast<ReturnPtr>(m_Pointer); }; | ||
|
@@ -1144,6 +1153,7 @@ class multi_ptr<void, Space, access::decorated::legacy> { | |
template <access::address_space Space> | ||
class multi_ptr<const void, Space, access::decorated::legacy> { | ||
public: | ||
using value_type = const void; | ||
using element_type = const void; | ||
using difference_type = std::ptrdiff_t; | ||
|
||
|
@@ -1256,6 +1266,10 @@ class multi_ptr<const void, Space, access::decorated::legacy> { | |
|
||
// Returns the underlying OpenCL C pointer | ||
pointer_t get() const { return m_Pointer; } | ||
pointer_t get_decorated() const { return m_Pointer; } | ||
std::add_pointer_t<element_type> get_raw() const { | ||
return reinterpret_cast<std::add_pointer_t<element_type>>(get()); | ||
} | ||
|
||
// Implicit conversion to the underlying pointer type | ||
operator const void *() const { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Discussed offline. The deprecated API tries to be in line with SYCL 1.2.1, which means returning a
DataT
pointer. However, with SYCL 2020 the value-type is changed to const when it is read-only. Instead of changing the internal representation,const_cast
for this deprecated API seemed like the lesser evil.