In the C++11 standard, section 1.10/5 mentions, but does not formally define the terms acquire operation
, release operation
, and consume operation
. It then goes on in Section 29 to use these terms to describe the actions of certain memory orderings, atomic operations, and memory fences. For instance, 29.3/1 on "Order and Consistency" states:
memory_order_release, memory_order_acq_rel, and memory_order_seq_cst: a store operation performs a release operation [emphasis added] on the affected memory location.
This type of language is repeated throughout section 29, but it bothers me a bit that all meanings for the memory_order
enumerations are based on operation types that themselves do not seem to be formalized by the standard, yet must have some commonly agreed-to meaning for them to be effective as definitions.
Put a different way, if I said "A bar is a flipped foo", the concrete meaning of bar and foo are ambiguous since neither term is formally defined. Only their relative natures are defined.
Does the C++11 standard, or some other C++11 standards committee document formally define what exactly an acquire operation
, release operation
, etc. is, or are these simply commonly understood terms? If the latter, is there a good reference that is considered an industry standard for the meaning of these operations? I specifically ask because hardware memory consistency models are not created equal, and therefore I'm figuring there must be some commonly agreed-to reference that allows those implementing compilers, etc. to properly translate the semantics of these operations into native assembly commands.
Essentially memory_order_acq_rel provides read and write orderings relative to the atomic variable, while memory_order_seq_cst provides read and write ordering globally. That is, the sequentially consistent operations are visible in the same order across all threads.
An operation has acquire semantics if other processors will always see its effect before any subsequent operation's effect. An operation has release semantics if other processors will see every preceding operation's effect before the effect of the operation itself.
There's an informal summarized definition given in one of the notes:
performing a release operation on
A
forces prior side effects on other memory locations to become visible to other threads that later perform a consume or an acquire operation onA
.
Besides that, the behavior of acquire and release operations is fully defined in 1.10, specifically in how they contribute to happens-before relationships. Any definition apart from behavior is useless.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With