Abstract
Despite many years of research, it has proven very difficult to develop a memory model for concurrent programming languages that adequately balances the conflicting desiderata of programmers, compilers, and hardware. In this paper, we propose the first relaxed memory model that (1) accounts for a broad spectrum of features from the C++11 concurrency model, (2) is implementable, in the sense that it provably validates many standard compiler optimizations and reorderings, as well as standard compilation schemes to x86-TSO and Power, (3) justifies simple invariant-based reasoning, thus demonstrating the absence of bad "out-of-thin-air" behaviors, (4) supports "DRF" guarantees, ensuring that programmers who use sufficient synchronization need not understand the full complexities of relaxed-memory semantics, and (5) defines the semantics of racy programs without relying on undefined behaviors, which is a prerequisite for applicability to type-safe languages like Java.
The key novel idea behind our model is the notion of *promises*: a thread may promise to execute a write in the future, thus enabling other threads to read from that write out of order. Crucially, to prevent out-of-thin-air behaviors, a promise step requires a thread-local certification that it will be possible to execute the promised write even in the absence of the promise. To establish confidence in our model, we have formalized most of our key results in Coq.
Supplemental Material
Available for Download
Coq formalization. See https://github.com/snu-sf/promising-coq for the latest version.
- Coq development and supplementary material for this paper available at: http://sf.snu.ac.kr/promise-concurrency.Google Scholar
- LLVM documentation. LLVM atomic instructions and concurrency guide. http://llvm.org/docs/Atomics.html.Google Scholar
- JSR 133. Java memory model and thread specification revision, 2004. http://jcp.org/jsr/detail/133.jsp.Google Scholar
- Sarita V. Adve and Mark D. Hill. Weak ordering—A new definition. In Proc. 17th Annual International Symposium on Computer Architecture, ISCA 1990, pages 2–14. ACM, 1990. Google Scholar
Digital Library
- Jade Alglave, Luc Maranget, and Michael Tautschnig. Herding cats: Modelling, simulation, testing, and data mining for weak memory. ACM Trans. Program. Lang. Syst., 36(2):7:1–7:74, July 2014. Google Scholar
Digital Library
- Mark Batty, Scott Owens, Susmit Sarkar, Peter Sewell, and Tjark Weber. Mathematizing C++ concurrency. In Proc. 38th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011, pages 55–66. ACM, 2011. Google Scholar
Digital Library
- Hans-Juergen Boehm and Brian Demsky. Outlawing ghosts: Avoiding out-of-thin-air results. In Proc. Workshop on Memory Systems Performance and Correctness, MSPC 2014, pages 7:1–7:6. ACM, 2014. Google Scholar
Digital Library
- Soham Chakraborty and Viktor Vafeiadis. Formalizing the concurrency semantics of an LLVM fragment. In Proc. 15th IEEE/ACM International Symposium on Code Generation and Optimization, CGO 2017, 2017.Google Scholar
Digital Library
- Karl Crary and Michael J. Sullivan. A calculus for relaxed memory. In Proc. 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, pages 623–636. ACM, 2015. Google Scholar
Digital Library
- Delphine Demange, Vincent Laporte, Lei Zhao, Suresh Jagannathan, David Pichardie, and Jan Vitek. Plan B: A buffered memory model for Java. In Proc. 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2013, pages 329–342. ACM, 2013. Google Scholar
Digital Library
- Shaked Flur, Kathryn E. Gray, Christopher Pulte, Susmit Sarkar, Ali Sezgin, Luc Maranget, Will Deacon, and Peter Sewell. Modelling the ARMv8 architecture, operationally: Concurrency and ISA. In Proc. 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, pages 608–621. ACM, 2016. Google Scholar
Digital Library
- James Gosling, Bill Joy, and Guy Steele. The Java language specification, Edition 1.0, August 1996. http://titanium.cs.berkeley. edu/doc/java-langspec-1.0/. Google Scholar
Digital Library
- ISO/IEC 14882:2011. Programming language C++, 2011.Google Scholar
- Radha Jagadeesan, Corin Pitcher, and James Riely. Generative operational semantics for relaxed memory models. In ESOP, pages 307–326, 2010. Google Scholar
Digital Library
- Alan Jeffrey and James Riely. On thin air reads: Towards an event structures model of relaxed memory. In Proc. IEEE Logic in Computer Science, LICS 2016, 2016. Google Scholar
Digital Library
- Khronos Group. The OpenCL specification, Version 2.1, 2015.Google Scholar
- Ori Lahav, Nick Giannarakis, and Viktor Vafeiadis. Taming releaseacquire consistency. In Proc. 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, pages 649–662. ACM, 2016. Google Scholar
Digital Library
- Ori Lahav and Viktor Vafeiadis. Explaining relaxed memory models with program transformations. In Proc. 21st International Symposium on Formal Methods, FM 2016, 2016.Google Scholar
Cross Ref
- Ori Lahav, Viktor Vafeiadis, Jeehoon Kang, Chung-Kil Hur, and Derek Dreyer. Repairing sequential consistency in C/C++11. Technical Report MPI-SWS-2016-011, MPI-SWS, November 2016.Google Scholar
- Andreas Lochbihler. Making the Java memory model safe. ACM Trans. Program. Lang. Syst., 35(4):12:1–12:65, 2014. Google Scholar
Digital Library
- Jeremy Manson, William Pugh, and Sarita V. Adve. The Java memory model. In Proc. 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2005, pages 378–391. ACM, 2005. Google Scholar
Digital Library
- Brian Norris and Brian Demsky. CDSchecker: Checking concurrent data structures written with C/C++ atomics. In Proc. 2013 ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages & Applications, OOPSLA 2013, pages 131–150. ACM, 2013. Google Scholar
Digital Library
- Scott Owens, Susmit Sarkar, and Peter Sewell. A better x86 memory model: x86-TSO. In Proc. 22nd International Conference on Theorem Proving in Higher Order Logics, TPHOLs 2009, pages 391–407. Springer, 2009. Google Scholar
Digital Library
- Jean Pichon-Pharabod and Peter Sewell. A concurrency semantics for relaxed atomics that permits optimisation and avoids thin-air executions. In Proc. 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, pages 622–633. ACM, 2016. Google Scholar
Digital Library
- Anton Podkopaev, Ilya Sergey, and Aleksandar Nanevski. Operational aspects of C/C++ concurrency. CoRR, abs/1606.01400, 2016.Google Scholar
- Jaroslav Ševˇcík and David Aspinall. On validity of program transformations in the Java memory model. In Proc. 22nd European Conference on Object-Oriented Programming, ECOOP 2008, volume 5142 of LNCS, pages 27–51. Springer, 2008. Google Scholar
Digital Library
- Jaroslav Ševˇcík, Viktor Vafeiadis, Francesco Zappa Nardelli, Suresh Jagannathan, and Peter Sewell. CompCertTSO: A verified compiler for relaxed-memory concurrency. J. ACM, 60(3):22, 2013. Google Scholar
Digital Library
- Viktor Vafeiadis, Thibaut Balabonski, Soham Chakraborty, Robin Morisset, and Francesco Zappa Nardelli. Common compiler optimisations are invalid in the C11 memory model and what we can do about it. In Proc. 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, pages 209–220. ACM, 2015. Google Scholar
Digital Library
- Yang Zhang and Xinyu Feng. An operational happens-before memory model. Frontiers of Computer Science, 10(1):54–81, 2016. Google Scholar
Digital Library
Index Terms
A promising semantics for relaxed-memory concurrency
Recommendations
A promising semantics for relaxed-memory concurrency
POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming LanguagesDespite many years of research, it has proven very difficult to develop a memory model for concurrent programming languages that adequately balances the conflicting desiderata of programmers, compilers, and hardware. In this paper, we propose the first ...
Promising 2.0: global optimizations in relaxed memory concurrency
PLDI 2020: Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and ImplementationFor more than fifteen years, researchers have tried to support global optimizations in a usable semantics for a concurrent programming language, yet this task has been proven to be very difficult because of (1) the infamous “out of thin air” problem, ...
Repairing sequential consistency in C/C++11
PLDI '17The C/C++11 memory model defines the semantics of concurrent memory accesses in C/C++, and in particular supports racy "atomic" accesses at a range of different consistency levels, from very weak consistency ("relaxed") to strong, sequential ...







Comments