Skip to content

Commit

Permalink
[RNG] Workaround for get_multi_ptr with AdaptiveCPP (uxlfoundation#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMartyan authored Jul 12, 2024
1 parent bb1941d commit 8abfdfc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
10 changes: 10 additions & 0 deletions examples/rng/device/include/rng_example_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,22 @@ struct has_member_code_meta<T, std::void_t<decltype(std::declval<T>().get_multi_

template <typename T, typename std::enable_if<has_member_code_meta<T>::value>::type* = nullptr>
auto get_multi_ptr(T acc) {
// Workaround for AdaptiveCPP, as they do not yet support the get_multi_ptr function
#ifndef __HIPSYCL__
return acc.get_multi_ptr();
#else
return acc.get_pointer();
#endif
};

template <typename T, typename std::enable_if<!has_member_code_meta<T>::value>::type* = nullptr>
auto get_multi_ptr(T acc) {
// Workaround for AdaptiveCPP, as they do not yet support the get_multi_ptr function
#ifndef __HIPSYCL__
return acc.template get_multi_ptr<sycl::access::decorated::yes>();
#else
return acc.get_pointer();
#endif
};

#endif // _RNG_EXAMPLE_HELPER_HPP__
9 changes: 7 additions & 2 deletions src/rng/backends/mklcpu/cpu_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ class kernel_name {};
template <typename Engine, typename Distr>
class kernel_name_usm {};

template <typename T, sycl::access_mode AccMode>
T *get_raw_ptr(sycl::accessor<T, 1, AccMode> acc) {
template <typename Acc>
typename Acc::value_type *get_raw_ptr(Acc acc) {
// Workaround for AdaptiveCPP, as they do not yet support the get_multi_ptr function
#ifndef __HIPSYCL__
return acc.template get_multi_ptr<sycl::access::decorated::no>().get_raw();
#else
return acc.get_pointer();
#endif
}

} // namespace mklcpu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,20 @@ struct has_member_code_meta<T, std::void_t<decltype(std::declval<T>().get_multi_

template <typename T, typename std::enable_if<has_member_code_meta<T>::value>::type* = nullptr>
auto get_multi_ptr(T acc) {
#ifndef __HIPSYCL__
return acc.get_multi_ptr();
#else
return acc.get_pointer();
#endif
};

template <typename T, typename std::enable_if<!has_member_code_meta<T>::value>::type* = nullptr>
auto get_multi_ptr(T acc) {
#ifndef __HIPSYCL__
return acc.template get_multi_ptr<sycl::access::decorated::yes>();
#else
return acc.get_pointer();
#endif
};

template <typename T>
Expand Down

0 comments on commit 8abfdfc

Please sign in to comment.