News for hackers. Stuff that matters.
Re:What's up with this new memory_order_consume memory order? by bno1 on Wednesday May 24, 2023 @08:52AM (#36057302)
> Note that an acquire load of p would have prohibited this reordering, since acquire loads block all future memory access, even if unrelated to the value being acquired.

I don't really get this part. The docs for acquire say:

> memory_order_acquire A load operation with this memory order performs the acquire operation on the affected memory location: no reads or writes in the current thread can be reordered before this load. All writes in other threads that release the same atomic variable are visible in the current thread

The prefetch is already ordered before the load in the same thread.

Re:What's up with this new memory_order_consume memory order? by brickteacup on Wednesday May 24, 2023 @08:58AM (#36057374)
`sample_consume_allowed` is an example of a transformation that the compiler is permitted to apply to the original function `sample_consume`. if the original function had used `acquire` instead of `consume` then the reordering of the v2 load before the p load wouldn't've been allowed
Re:What's up with this new memory_order_consume memory order? by bno1 on Wednesday May 24, 2023 @09:23AM (#36057672)
Thank you, makes sense now