Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support atomics with memory orders #2123

Open
bernhardmgruber opened this issue Sep 2, 2023 · 0 comments
Open

Support atomics with memory orders #2123

bernhardmgruber opened this issue Sep 2, 2023 · 0 comments

Comments

@bernhardmgruber
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant