Template:cpp/atomic/sequentially-consistent-cpp11

Formally,

Each operation B that loads from atomic variable M, observes one of the following:
 * the result of the last operation A that modified M, which appears before B in the single total order
 * OR, if there was such an A, B may observe the result of some modification on M that is not and does not happen-before A
 * OR, if there wasn't such an A, B may observe the result of some unrelated modification of M that is not

If there was a atomic_thread_fence operation X sequenced-before B, then B observes one of the following:
 * the last modification of M that appears before X in the single total order
 * some unrelated modification of M that appears later in M's modification order

For a pair of atomic operations on M called A and B, where A writes and B reads M's value, if there are two atomic_thread_fences X and Y, and if A is sequenced-before X, Y is sequenced-before B, and X appears before Y in the Single Total Order, then B observes either:
 * the effect of A
 * some unrelated modification of M that appears after A in M's modification order

For a pair of atomic modifications of M called A and B, B occurs after A in M's modification order if
 * there is a atomic_thread_fence X such that A is sequenced-before X and X appears before B in the Single Total Order
 * or, there is a atomic_thread_fence Y such that Y is sequenced-before B and A appears before Y in the Single Total Order
 * or, there are atomic_thread_fences X and Y such that A is sequenced-before X, Y is sequenced-before B, and X appears before Y in the Single Total Order.

Note that this means that: @1@ as soon as atomic operations that are not tagged enter the picture, the sequential consistency is lost @2@ the sequentially-consistent fences are only establishing total ordering for the fences themselves, not for the atomic operations in the general case (sequenced-before is not a cross-thread relationship, unlike happens-before)