Memory Models for C/C++ Programmers
Manuel P\"oter, Jesper Larsson Tr\"aff

TL;DR
This paper introduces the importance of memory models in concurrent programming, discusses well-known models including C++11, and explains how to write correct, portable, and efficient concurrent code leveraging modern architectures.
Contribution
It provides a clear overview of memory models, with a focus on the C++11 model, and explains how to utilize relaxed memory models for efficient concurrent programming.
Findings
Overview of various memory models from sequential consistency to modern CPU architectures.
Detailed explanation of the C++11 memory model and its practical use.
Guidance on writing correct and portable concurrent code using memory models.
Abstract
The memory model is the crux of the concurrency semantics of shared-memory systems. It defines the possible values that a read operation is allowed to return for any given set of write operations performed by a concurrent program, thereby defining the basic semantics of shared variables. It is therefore impossible to meaningfully reason about a program or any part of the programming language implementation without an unambiguous memory model. This note provides a brief introduction into the topic of memory models, explaining why it is essential for concurrent programs and covering well known memory models from sequential consistency to those of the x86 and ARM/POWER CPUs. Section 4 is fully dedicated to the C++11 memory model, explaining how it can be used to write concurrent code that is not only correct and portable, but also efficient by utilizing the relaxed memory models of…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsParallel Computing and Optimization Techniques · Embedded Systems Design Techniques · Distributed systems and fault tolerance
