diff --git a/sycl/include/strata/sycl_doorbell.hpp b/sycl/include/strata/sycl_doorbell.hpp index d801c54e..0690c734 100644 --- a/sycl/include/strata/sycl_doorbell.hpp +++ b/sycl/include/strata/sycl_doorbell.hpp @@ -8,14 +8,32 @@ // goes through these two. #pragma once #include +#include #include namespace strata { using sys_atomic_u32 = sycl::atomic_ref; +// A system-scope atomic load of host USM is still served from the GPU's cache on an Arc Pro B60 (NEO 26.31, +// oneAPI 2026.1.1): a device spin never sees the host's store and runs to kSpinMax every time (bounded host/GPU +// ping-pong: 263 ms per round trip, 168 of 200 waits hit the bound). An explicit uncached L1+L3 read hint goes to +// memory every time: 2.4 us per round trip, 0 of 200. The acquire fence keeps the compiler from hoisting the load +// out of a spin loop. -DSTRATA_DOORBELL_ATOMIC_LOAD restores the atomic load. +#ifndef STRATA_DOORBELL_ATOMIC_LOAD +using doorbell_uncached_read = decltype(sycl::ext::oneapi::experimental::properties( + sycl::ext::intel::experimental::read_hint>)); +inline uint32_t sys_load(const volatile uint32_t* p) { + sycl::atomic_fence(sycl::memory_order::acquire, sycl::memory_scope::system); + sycl::ext::oneapi::experimental::annotated_ptr u(const_cast(p)); + return u[0]; +} +#else inline uint32_t sys_load(const volatile uint32_t* p) { return sys_atomic_u32(*const_cast(p)).load(); } +#endif inline void sys_store(volatile uint32_t* p, uint32_t v) { sys_atomic_u32(*const_cast(p)).store(v); sycl::atomic_fence(sycl::memory_order::release, sycl::memory_scope::system);