You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AFAIU the atomics that alpaka exhibt a relaxed memory order. That is, performing an atomic operation in alpaka does neither synchronize with other atomic operatons, nor give any guarantee on the visibility of preceding/subsequent ordinary loads and stores. We effectively assume a weakly-ordered memory model. Any synchchronization of loads and stores requires the use of explicit memory fences in addition to relaxed atomic operations. This is not how C++ does atomics since C++11.
In C++11 (and C11, Rust, etc.) atomic operations can be configured on their effect on the visible order of memory operations. This configuraiton is the memory order. CUDA's libc++ started to offer such configurable atomics a while back, see for example the definition of atomic_ref. I have not found a similar feature in HIP yet. SYCL has those: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#_memory_ordering
For the efficient implementation of certain synchronization primitives, e.g. locks, or certain lock-free data structures, e.g. lock-free queues, atomics with various memory orders are a necessity. To that end, I wonder when and how those should be supported in alpaka. I am mostly leaning towards a class type similar to std::atomic_ref, but I am open to suggestions.
The text was updated successfully, but these errors were encountered:
AFAIU the atomics that alpaka exhibt a relaxed memory order. That is, performing an atomic operation in alpaka does neither synchronize with other atomic operatons, nor give any guarantee on the visibility of preceding/subsequent ordinary loads and stores. We effectively assume a weakly-ordered memory model. Any synchchronization of loads and stores requires the use of explicit memory fences in addition to relaxed atomic operations. This is not how C++ does atomics since C++11.
In C++11 (and C11, Rust, etc.) atomic operations can be configured on their effect on the visible order of memory operations. This configuraiton is the memory order. CUDA's libc++ started to offer such configurable atomics a while back, see for example the definition of atomic_ref. I have not found a similar feature in HIP yet. SYCL has those: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#_memory_ordering
For the efficient implementation of certain synchronization primitives, e.g. locks, or certain lock-free data structures, e.g. lock-free queues, atomics with various memory orders are a necessity. To that end, I wonder when and how those should be supported in alpaka. I am mostly leaning towards a class type similar to
std::atomic_ref
, but I am open to suggestions.The text was updated successfully, but these errors were encountered: