Interaction with host code#
When a kernel runs on a device that has either
sycl::aspect::usm_atomic_host_allocations or
sycl::aspect::usm_atomic_shared_allocations, the
device code and the host code can concurrently access
the same memory. This has a ramification on the atomic
operations because it is possible for device code and
host code to perform atomic operations on the same
object M in this shared memory. It also has a ramification
on the fence operations because the C++ core language defines
the semantics of these fence operations in relation to atomic
operations on some shared object M. The following paragraphs
specify the guarantees that the SYCL implementation provides
when the application performs atomic or fence operations in
device code using the memory scope sycl::memory_scope::system.
Atomic operations in device code using
sycl::atomic_refon an object M are guaranteed to be atomic with respect to atomic operations in host code usingstd::atomic_refon that same object M.Fence operations in device code using
sycl::atomic_fencesynchronize with fence operations in host code usingstd::atomic_thread_fenceif the fence operations shared the same atomic object M and follow the rules for fence synchronization defined in the C++ core language.Fence operations in device code using
sycl::atomic_fencesynchronize with atomic operations in host code usingstd::atomic_refif the operations share the same atomic object M and follow the rules for fence synchronization defined in the C++ core language.Atomic operations in device code using
sycl::atomic_refsynchronize with fence operations in host code usingstd::atomic_thread_fenceif the operations share the same atomic object M and follow the rules for fence synchronization defined in the C++ core language.
See also
SYCL Specification Section 4.15.5