Memory ordering
Memory ordering is the set of rules governing the permitted ordering and visibility of memory operations across concurrent execution contexts.
C++ Concurrency in Action, Second Edition
The constraints governing how memory operations are ordered and observed across threads in the C++ memory model.
- How it is used
- Governs what atomic operations make observable across threads, particularly when publishing data or implementing lock-free structures.
- How deep it goes
- Works through contrasting ordering models and a lock-free stack’s success and retry paths, including the relationships each path requires.
- Examples
- Contrasts two-flag thread examples with a release-acquire flag handoff and a reference-counted lock-free stack.
- What you can do after
- Apply it via `std::atomic` memory-order arguments by deriving required happens-before relationships before weakening success or retry paths.
Read how C++ Concurrency in Action, Second Edition explains memory ordering →
GPU Programming with Triton
Memory ordering semantics specify which memory operations may be reordered around an atomic operation and when their effects become visible.
- How it is used
- Controls ordering constraints and visibility around atomic operations.
- How deep it goes
- Defines four ordering choices and explains relaxed and default acquire-release behavior, without detailing each option individually.
- Examples
- Uses simple accumulation and Split-K GEMM to illustrate when relaxed ordering is sufficient.
- What you can do after
- Configure Triton atomic ordering for accumulation patterns that do not require surrounding memory accesses to be ordered.
Read how GPU Programming with Triton explains memory ordering →
Latency
Memory ordering is the set of rules governing the observable order in which memory operations become effective across concurrent execution contexts.
- How it is used
- Controls visibility and ordering in lock-free and wait-free concurrent algorithms.
- How deep it goes
- Explains CPU reordering, barrier roles, ordering modes, and a runnable invariant-violation example.
- Examples
- Uses Rust atomics, a value-and-done flag pair, repeated execution, and sorted output to expose an invariant violation.
- What you can do after
- Apply it via Rust or C++ atomic APIs to publish data safely between concurrent threads.
Also covered in
- Embedded Software with RustIn early access (MEAP)
Related concepts
- sequential consistencyconfigures · Sequential consistency is a memory model in which participating operations appear in a single total order that preserves each thread’s program order.
- data raceaddresses · A data race is a concurrent access to shared data in which at least one access is a write and the accesses are not adequately synchronized.
- atomicityconfigures · Atomicity is the property that an operation or group of operations takes effect as an indivisible whole, without observable partial effects.
- std::memory_orderimplemented by · `std::memory_order` is a C++ standard library enumeration whose values specify memory-ordering constraints for atomic operations.
Questions about memory ordering
What is memory ordering?
Memory ordering is the set of rules governing the permitted ordering and visibility of memory operations across concurrent execution contexts.
Which Manning books explain memory ordering?
C++ Concurrency in Action, Second Edition, GPU Programming with Triton and Latency.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


