-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
compiler_fence SeqCst docs are incorrect #54962
Comments
Hmm, that's a good point, though the details are a little subtle. From the C++ reference:
I think what this translates into is that |
It actually depends on the other operation, does it not? TBH I have a hard time thinking in terms of reorderings; I usually think in terms of what actually happens in the underlying memory model. Some of these models can be fully characterized by the allowed reorderings, but not all of them can (as far as we know). And anyway, SC fences are broken in the C11 memory model and probably going to change in the next version, so...^^
On top of that, all |
@RalfJung I'm actually not entirely sure about that. Another store to the same memory location shouldn't be ordered before, but I don't see from the reference text why an unrelated store with I'd be happy for this to be rephrased this in terms of the memory model, but I'm not entirely sure how we'd even do that. Proposals welcome. I think talking about what can and cannot happen, with examples, is probably the most understandable way to present what the different orderings do. I left off the total order part because it didn't seem directly related to the original question. But you're right that it's a vital part of |
It says
The sequentially-consistent ordering consists of all This is the sole justification for the existence of |
Yes, good point. So how about we move the
|
Rollup merge of rust-lang#129856 - RalfJung:compiler_fence, r=thomcc compiler_fence documentation: emphasize synchronization, not reordering Our `fence` docs have at some point been update to explain that they are about synchronization, not about "preventing reordering". This updates the `compiler_fence` docs n the same vein, mostly by referring to the `fence` docs. The old docs make it sound like I can put a compiler_fence in the middle of a bunch of non-atomic operations and that would achieve any kind of guarantee. It does not, atomic operations are still required to do synchronization. I also slightly tweaked the `fence` docs, to put the synchronization first and the "prevent reordering" second. Cc `@rust-lang/opsem` `@chorman0773` `@m-ou-se` Fixes rust-lang#129189 Fixes rust-lang#54962
The documentation for
compiler_fence
withSeqCst
say "no re-ordering of reads and writes across this point is allowed". As I understand it,SeqCst
for a single thread doesn't give anything more thanAcqRel
. E.g., a store before the fence could be moved past a load after then fence. Is that correct?cc @jonhoo @RalfJung
The text was updated successfully, but these errors were encountered: