Skip to content

Commit

Permalink
[SYCL] APIs cleanup (#13443)
Browse files Browse the repository at this point in the history
Deprecated a few APIs which are not in SYCL 2020 spec:
- `accessor::get_multi_ptr()` should be available only when `AccessTarget ==
target::device`.
- `marray<DataT, N>::operator++/--`should be available only when
`DataT != bool`.

Updated `multi_ptr::get_pointer()` to use correct type alias in accordance with KhronosGroup/SYCL-Docs#549

---------

Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
  • Loading branch information
HPS-1 authored Apr 25, 2024
1 parent 628ede6 commit a36e9f8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
19 changes: 15 additions & 4 deletions sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2402,9 +2402,9 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
typename = std::enable_if_t<(AccessTarget_ == access::target::device)>>
__SYCL2020_DEPRECATED(
"accessor::get_pointer() is deprecated, please use get_multi_ptr()")
global_ptr<DataT> get_pointer() const noexcept {
return global_ptr<DataT>(
const_cast<typename detail::DecoratedType<DataT, AS>::type *>(
global_ptr<value_type> get_pointer() const noexcept {
return global_ptr<value_type>(
const_cast<typename detail::DecoratedType<value_type, AS>::type *>(
getPointerAdjusted()));
}

Expand All @@ -2415,7 +2415,18 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
return constant_ptr<DataT>(getPointerAdjusted());
}

template <access::decorated IsDecorated>
template <access::decorated IsDecorated,
access::target AccessTarget_ = AccessTarget,
std::enable_if_t<AccessTarget_ == access::target::device, int> = 0>
accessor_ptr<IsDecorated> get_multi_ptr() const noexcept {
return accessor_ptr<IsDecorated>(getPointerAdjusted());
}

template <access::decorated IsDecorated,
access::target AccessTarget_ = AccessTarget,
std::enable_if_t<AccessTarget_ != access::target::device, int> = 0>
__SYCL_DEPRECATED(
"accessor::get_multi_ptr() is deprecated for non-device accessors")
accessor_ptr<IsDecorated> get_multi_ptr() const noexcept {
return accessor_ptr<IsDecorated>(getPointerAdjusted());
}
Expand Down
29 changes: 27 additions & 2 deletions sycl/include/sycl/marray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,36 @@ template <typename Type, std::size_t NumElements> class marray {
#endif

#define __SYCL_UOP(UOP, OPASSIGN) \
friend marray &operator UOP(marray &Lhs) { \
template <typename T = DataT> \
friend std::enable_if_t< \
!std::is_same_v<typename std::remove_cv<T>::type, bool>, marray> \
&operator UOP(marray & Lhs) { \
Lhs OPASSIGN 1; \
return Lhs; \
} \
friend marray operator UOP(marray &Lhs, int) { \
template <typename T = DataT> \
friend std::enable_if_t< \
!std::is_same_v<typename std::remove_cv<T>::type, bool>, marray> \
operator UOP(marray & Lhs, int) { \
marray Ret(Lhs); \
Lhs OPASSIGN 1; \
return Ret; \
} \
template <typename T = DataT> \
__SYCL_DEPRECATED( \
"++ and -- operators are deprecated for marray<bool, ...>") \
friend std::enable_if_t< \
std::is_same_v<typename std::remove_cv<T>::type, bool>, marray> \
&operator UOP(marray & Lhs) { \
Lhs OPASSIGN 1; \
return Lhs; \
} \
template <typename T = DataT> \
__SYCL_DEPRECATED( \
"++ and -- operators are deprecated for marray<bool, ...>") \
friend std::enable_if_t< \
std::is_same_v<typename std::remove_cv<T>::type, bool>, marray> \
operator UOP(marray & Lhs, int) { \
marray Ret(Lhs); \
Lhs OPASSIGN 1; \
return Ret; \
Expand Down

0 comments on commit a36e9f8

Please sign in to comment.