From 8abfdfcbb9fe7fe2e6eea1214478f62e30e4db18 Mon Sep 17 00:00:00 2001 From: Ivan Martianov Date: Fri, 12 Jul 2024 16:02:54 +0100 Subject: [PATCH] [RNG] Workaround for get_multi_ptr with AdaptiveCPP (#535) --- examples/rng/device/include/rng_example_helper.hpp | 10 ++++++++++ src/rng/backends/mklcpu/cpu_common.hpp | 9 +++++++-- .../rng/device/include/rng_device_test_common.hpp | 8 ++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/rng/device/include/rng_example_helper.hpp b/examples/rng/device/include/rng_example_helper.hpp index ad0fdea03..0bcf114b4 100644 --- a/examples/rng/device/include/rng_example_helper.hpp +++ b/examples/rng/device/include/rng_example_helper.hpp @@ -29,12 +29,22 @@ struct has_member_code_meta().get_multi_ template ::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 ::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(); +#else + return acc.get_pointer(); +#endif }; #endif // _RNG_EXAMPLE_HELPER_HPP__ diff --git a/src/rng/backends/mklcpu/cpu_common.hpp b/src/rng/backends/mklcpu/cpu_common.hpp index b5e10585c..cbd6cae59 100644 --- a/src/rng/backends/mklcpu/cpu_common.hpp +++ b/src/rng/backends/mklcpu/cpu_common.hpp @@ -56,9 +56,14 @@ class kernel_name {}; template class kernel_name_usm {}; -template -T *get_raw_ptr(sycl::accessor acc) { +template +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().get_raw(); +#else + return acc.get_pointer(); +#endif } } // namespace mklcpu diff --git a/tests/unit_tests/rng/device/include/rng_device_test_common.hpp b/tests/unit_tests/rng/device/include/rng_device_test_common.hpp index e6f2b5026..6b014f0ec 100644 --- a/tests/unit_tests/rng/device/include/rng_device_test_common.hpp +++ b/tests/unit_tests/rng/device/include/rng_device_test_common.hpp @@ -112,12 +112,20 @@ struct has_member_code_meta().get_multi_ template ::value>::type* = nullptr> auto get_multi_ptr(T acc) { +#ifndef __HIPSYCL__ return acc.get_multi_ptr(); +#else + return acc.get_pointer(); +#endif }; template ::value>::type* = nullptr> auto get_multi_ptr(T acc) { +#ifndef __HIPSYCL__ return acc.template get_multi_ptr(); +#else + return acc.get_pointer(); +#endif }; template