C++: Strongly Happens Before?
13 days ago
- #Concurrency
- #Memory Model
- #C++
- The article discusses the concept of 'Strongly Happens Before' introduced in C++20 to address issues in the memory model.
- It presents a simple program with multiple threads using different memory orders (seq_cst, release, relaxed) to illustrate potential execution scenarios.
- The article explains modification order and coherence rules in C++ to analyze the program's behavior.
- It highlights a cycle in the execution graph that makes the program's behavior invalid under the 'happens before' relation but valid under 'strongly happens before'.
- The article explores why certain architectures like Power allow such executions and the trade-offs involved in fixing the standard versus implementations.
- It provides a detailed analysis of Power architecture's memory model and synchronization constructs (sync, lwsync).
- The article defines 'strongly happens before' and explains how it resolves the cycle in the execution graph.
- It concludes by emphasizing the complexity of mixing memory orders and provides resources for further reading.