@@ -229,6 +229,18 @@ class accessor;
229
229
230
230
namespace detail {
231
231
232
+ template <typename ... Ts>
233
+ #ifndef __SYCL_DEVICE_ONLY__
234
+ [[noreturn]]
235
+ #endif
236
+ void cannot_be_called_on_host ([[maybe_unused]] const char *API,
237
+ Ts &&.../* ignore */ ) {
238
+ #ifndef __SYCL_DEVICE_ONLY__
239
+ std::fprintf (stderr, " %s cannot be called on host!\n " , API);
240
+ std::abort ();
241
+ #endif
242
+ }
243
+
232
244
// A helper structure which is shared between buffer accessor and accessor_impl
233
245
// TODO: Unify with AccessorImplDevice?
234
246
struct AccHostDataT {
@@ -2564,22 +2576,20 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
2564
2576
__SYCL2020_DEPRECATED (
2565
2577
" local_accessor::get_pointer() is deprecated, please use get_multi_ptr()" )
2566
2578
local_ptr<DataT> get_pointer () const noexcept {
2567
- #ifndef __SYCL_DEVICE_ONLY__
2568
- throw sycl::exception (
2569
- make_error_code (errc::invalid),
2570
- " get_pointer must not be called on the host for a local accessor" );
2571
- #endif
2579
+ #if __SYCL_DEVICE_ONLY__
2572
2580
return local_ptr<DataT>(local_acc::getQualifiedPtr ());
2581
+ #else
2582
+ detail::cannot_be_called_on_host (" local_accessor::get_pointer" );
2583
+ #endif
2573
2584
}
2574
2585
2575
2586
template <access::decorated IsDecorated>
2576
2587
accessor_ptr<IsDecorated> get_multi_ptr () const noexcept {
2577
- #ifndef __SYCL_DEVICE_ONLY__
2578
- throw sycl::exception (
2579
- make_error_code (errc::invalid),
2580
- " get_multi_ptr must not be called on the host for a local accessor" );
2581
- #endif
2588
+ #if __SYCL_DEVICE_ONLY__
2582
2589
return accessor_ptr<IsDecorated>(local_acc::getQualifiedPtr ());
2590
+ #else
2591
+ detail::cannot_be_called_on_host (" local_accessor::get_multi_ptr" );
2592
+ #endif
2583
2593
}
2584
2594
2585
2595
template <typename Property> bool has_property () const noexcept {
0 commit comments