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

atomic_ref based atomics are too strong #2172

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

atomic_ref based atomics are too strong #2172

bernhardmgruber opened this issue Sep 19, 2023 · 2 comments

Comments

@bernhardmgruber
Copy link
Member

The CPU atomic implementation using std::atomic_ref use a sequentially consistent memory ordering, which is a stronger guarantee than their CUDA counterparts, which are weakly ordered and always require explicit fences. Therefore, the CPU atomics should also be weakened to a relaxed memory order, potentially improving performance on CPUs.

@fwyzard
Copy link
Contributor

fwyzard commented Sep 19, 2023

I think on x86 they are the same, IIRC it is only ARM and Power that have weaker atomics.

@bernhardmgruber
Copy link
Member Author

From Hans Boehm's talk at CppCon:

image

We can still avoid a fence on x86 with weakly ordered atomics.

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

2 participants