Abstract
Program logics and semantics tell a pleasant story about sequential composition: when executing (S1;S2), we first execute S1 then S2. To improve performance, however, processors execute instructions out of order, and compilers reorder programs even more dramatically. By design, single-threaded systems cannot observe these reorderings; however, multiple-threaded systems can, making the story considerably less pleasant. A formal attempt to understand the resulting mess is known as a “relaxed memory model.” Prior models either fail to address sequential composition directly, or overly restrict processors and compilers, or permit nonsense thin-air behaviors which are unobservable in practice.
To support sequential composition while targeting modern hardware, we enrich the standard event-based approach with preconditions and families of predicate transformers. When calculating the meaning of (S1; S2), the predicate transformer applied to the precondition of an event e from S2 is chosen based on the set of events in S1 upon which e depends. We apply this approach to two existing memory models.
Supplemental Material
- Jade Alglave, Will Deacon, Richard Grisenthwaite, Antoine Hacquard, and Luc Maranget. 2021. Armed Cats: Formal Concurrency Modelling at Arm. ACM Trans. Program. Lang. Syst., 43, 2 (2021), Article 8, July, 54 pages. issn:0164-0925 https://doi.org/10.1145/3458926 Google Scholar
Digital Library
- Jade Alglave, Luc Maranget, and Michael Tautschnig. 2014. Herding Cats: Modelling, Simulation, Testing, and Data Mining for Weak Memory. ACM Trans. Program. Lang. Syst., 36, 2 (2014), Article 7, July, 74 pages. issn:0164-0925 https://doi.org/10.1145/2627752 Google Scholar
Digital Library
- Mark Batty, Kayvan Memarian, Kyndylan Nienhuis, Jean Pichon-Pharabod, and Peter Sewell. 2015. The Problem of Programming Language Concurrency Semantics. In Programming Languages and Systems - 24th European Symposium on Programming, ESOP 2015, London, UK, April 11-18, 2015. Proceedings, Jan Vitek (Ed.) (Lecture Notes in Computer Science, Vol. 9032). Springer, 283–307. https://doi.org/10.1007/978-3-662-46669-8_12 Google Scholar
Cross Ref
- Mark Batty, Scott Owens, Susmit Sarkar, Peter Sewell, and Tjark Weber. 2011. Mathematizing C++ Concurrency. In Proceedings of the 38th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’11). ACM, New York, NY, USA. 55–66. isbn:978-1-4503-0490-0 https://doi.org/10.1145/1926385.1926394 Google Scholar
Digital Library
- Hans-J. Boehm and Brian Demsky. 2014. Outlawing Ghosts: Avoiding Out-of-thin-air Results. In Proceedings of the Workshop on Memory Systems Performance and Correctness (MSPC ’14). ACM, New York, NY, USA. Article 7, 6 pages. isbn:978-1-4503-2917-0 https://doi.org/10.1145/2618128.2618134 Google Scholar
Digital Library
- Stephen D. Brookes. 1996. Full Abstraction for a Shared-Variable Parallel Language. Inf. Comput., 127, 2 (1996), 145–163. https://doi.org/10.1006/inco.1996.0056 Google Scholar
Cross Ref
- Soham Chakraborty and Viktor Vafeiadis. 2019. Grounding thin-air reads with event structures. PACMPL, 3, POPL (2019), 70:1–70:28. https://doi.org/10.1145/3290383 Google Scholar
Digital Library
- Minki Cho, Sung-Hwan Lee, Chung-Kil Hur, and Ori Lahav. 2021. Modular data-race-freedom guarantees in the promising semantics. In PLDI ’21: 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, Virtual Event, Canada, June 20-25, 20211, Stephen N. Freund and Eran Yahav (Eds.). ACM, 867–882. https://doi.org/10.1145/3453483.3454082 Google Scholar
Digital Library
- Simon Cooksey, Sarah Harris, Mark Batty, Radu Grigore, and Mikolás Janota. 2019. PrideMM: Second Order Model Checking for Memory Consistency Models. In Formal Methods. FM 2019 International Workshops - Porto, Portugal, October 7-11, 2019, Revised Selected Papers, Part II, Emil Sekerinski, Nelma Moreira, José N. Oliveira, Daniel Ratiu, Riccardo Guidotti, Marie Farrell, Matt Luckcuck, Diego Marmsoler, José Campos, Troy Astarte, Laure Gonnord, Antonio Cerone, Luis Couto, Brijesh Dongol, Martin Kutrib, Pedro Monteiro, and David Delmas (Eds.) (Lecture Notes in Computer Science, Vol. 12233). Springer, 507–525. https://doi.org/10.1007/978-3-030-54997-8_31 Google Scholar
Digital Library
- Russ Cox. 2016. Go’s Memory Model. http://nil.csail.mit.edu/6.824/2016/notes/gomem.pdfGoogle Scholar
- Leonardo Mendonça de Moura and Nikolaj Bjørner. 2008. Z3: An Efficient SMT Solver. In Tools and Algorithms for the Construction and Analysis of Systems, 14th International Conference, TACAS 2008, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2008, Budapest, Hungary, March 29-April 6, 2008. Proceedings, C. R. Ramakrishnan and Jakob Rehof (Eds.) (Lecture Notes in Computer Science, Vol. 4963). Springer, 337–340. https://doi.org/10.1007/978-3-540-78800-3_24 Google Scholar
Cross Ref
- Edsger W. Dijkstra. 1975. Guarded Commands, Nondeterminacy and Formal Derivation of Programs. Commun. ACM, 18, 8 (1975), 453–457. https://doi.org/10.1145/360933.360975 Google Scholar
Digital Library
- Stephen Dolan, KC Sivaramakrishnan, and Anil Madhavapeddy. 2018. Bounding Data Races in Space and Time. In Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2018). ACM, New York, NY, USA. 242–255. isbn:978-1-4503-5698-5 https://doi.org/10.1145/3192366.3192421 Google Scholar
Digital Library
- William Ferreira, Matthew Hennessy, and Alan Jeffrey. 1996. A Theory of Weak Bisimulation for Core CML. In Proceedings of the 1996 ACM SIGPLAN International Conference on Functional Programming, ICFP 1996, Philadelphia, Pennsylvania, USA, May 24-26, 1996, Robert Harper and Richard L. Wexelblat (Eds.). ACM, 201–212. https://doi.org/10.1145/232627.232649 Google Scholar
Digital Library
- Jay L. Gischer. 1988. The equational theory of pomsets. Theoretical Computer Science, 61, 2 (1988), 199–224. issn:0304-3975 https://doi.org/10.1016/0304-3975(88)90124-7 Google Scholar
Digital Library
- C.A.R. Hoare. 1969. An Axiomatic Basis for Computer Programming. Commun. ACM, 12, 10 (1969), Oct., 576–580. issn:0001-0782 https://doi.org/10.1145/363235.363259 Google Scholar
Digital Library
- Radha Jagadeesan, Alan Jeffrey, and James Riely. 2020. Pomsets with preconditions: a simple model of relaxed memory. Proc. ACM Program. Lang., 4, OOPSLA (2020), 194:1–194:30. https://doi.org/10.1145/3428262 Google Scholar
Digital Library
- Radha Jagadeesan, Corin Pitcher, and James Riely. 2010. Generative Operational Semantics for Relaxed Memory Models. In Programming Languages and Systems, 19th European Symposium on Programming, ESOP 2010, Paphos, Cyprus, March 20-28, 2010. Proceedings, Andrew D. Gordon (Ed.) (Lecture Notes in Computer Science, Vol. 6012). Springer, 307–326. isbn:978-3-642-11956-9 https://doi.org/10.1007/978-3-642-11957-6_17 Google Scholar
Digital Library
- Alan Jeffrey and James Riely. 2016. On Thin Air Reads Towards an Event Structures Model of Relaxed Memory. In Proceedings of the 31st Annual ACM/IEEE Symposium on Logic in Computer Science, LICS ’16, New York, NY, USA, July 5-8, 2016, M. Grohe, E. Koskinen, and N. Shankar (Eds.). ACM, 759–767. isbn:978-1-4503-4391-6 https://doi.org/10.1145/2933575.2934536 Google Scholar
Digital Library
- Jeehoon Kang, Chung-Kil Hur, Ori Lahav, Viktor Vafeiadis, and Derek Dreyer. 2017. A promising semantics for relaxed-memory concurrency. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18-20, 2017, Giuseppe Castagna and Andrew D. Gordon (Eds.). ACM, 175–189. http://dl.acm.org/citation.cfm?id=3009850Google Scholar
Digital Library
- Ryan Kavanagh and Stephen Brookes. 2018. A denotational account of C11-style memory. CoRR, abs/1804.04214 (2018), 13 pages. arxiv:1804.04214. arxiv:1804.04214Google Scholar
- Ori Lahav, Viktor Vafeiadis, Jeehoon Kang, Chung-Kil Hur, and Derek Dreyer. 2017. Repairing sequential consistency in C/C++11. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2017, Barcelona, Spain, June 18-23, 2017, Albert Cohen and Martin T. Vechev (Eds.). ACM, 618–632. isbn:978-1-4503-4988-8 https://doi.org/10.1145/3062341.3062352 Google Scholar
Digital Library
- Leslie Lamport. 1979. How to Make a Multiprocessor Computer That Correctly Executes Multiprocess Programs. IEEE Trans. Comput., 28, 9 (1979), Sept., 690–691. issn:0018-9340 https://doi.org/10.1109/TC.1979.1675439 Google Scholar
Digital Library
- Juneyoung Lee, Chung-Kil Hur, Ralf Jung, Zhengyang Liu, John Regehr, and Nuno P. Lopes. 2018. Reconciling high-level optimizations and low-level code in LLVM. Proc. ACM Program. Lang., 2, OOPSLA (2018), 125:1–125:28. https://doi.org/10.1145/3276495 Google Scholar
Digital Library
- Juneyoung Lee, Yoonseung Kim, Youngju Song, Chung-Kil Hur, Sanjoy Das, David Majnemer, John Regehr, and Nuno P. Lopes. 2017. Taming undefined behavior in LLVM. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2017, Barcelona, Spain, June 18-23, 2017, Albert Cohen and Martin T. Vechev (Eds.). ACM, 633–647. https://doi.org/10.1145/3062341.3062343 Google Scholar
Digital Library
- Sung-Hwan Lee, Minki Cho, Anton Podkopaev, Soham Chakraborty, Chung-Kil Hur, Ori Lahav, and Viktor Vafeiadis. 2020. Promising 2.0: global optimizations in relaxed memory concurrency. In Proceedings of the 41st ACM SIGPLAN International Conference on Programming Language Design and Implementation, PLDI 2020, London, UK, June 15-20, 2020, Alastair F. Donaldson and Emina Torlak (Eds.). ACM, 362–376. https://doi.org/10.1145/3385412.3386010 Google Scholar
Digital Library
- Lun Liu, Todd Millstein, and Madanlal Musuvathi. 2019. Accelerating Sequential Consistency for Java with Speculative Compilation. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2019). ACM, New York, NY, USA. 16–30. isbn:978-1-4503-6712-7 https://doi.org/10.1145/3314221.3314611 Google Scholar
Digital Library
- Lun Liu, Todd Millstein, and Madanlal Musuvathi. 2021. Safe-by-Default Concurrency for Modern Programming Languages. ACM Trans. Program. Lang. Syst., 43, 3 (2021), Article 10, Sept., 50 pages. issn:0164-0925 https://doi.org/10.1145/3462206 Google Scholar
Digital Library
- Jeremy Manson, William Pugh, and Sarita V. Adve. 2005. The Java Memory Model. SIGPLAN Not., 40, 1 (2005), Jan., 378–391. issn:0362-1340 https://doi.org/10.1145/1047659.1040336 Google Scholar
Digital Library
- Daniel Marino, Todd D. Millstein, Madanlal Musuvathi, Satish Narayanasamy, and Abhayendra Singh. 2015. The Silently Shifting Semicolon. In 1st Summit on Advances in Programming Languages, SNAPL 2015, May 3-6, 2015, Asilomar, California, USA, Thomas Ball, Rastislav Bodík, Shriram Krishnamurthi, Benjamin S. Lerner, and Greg Morrisett (Eds.) (LIPIcs, Vol. 32). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 177–189. https://doi.org/10.4230/LIPIcs.SNAPL.2015.177 Google Scholar
Cross Ref
- Ian A. Mason and Carolyn L. Talcott. 1992. References, Local Variables and Operational Reasoning. In Proceedings of the Seventh Annual Symposium on Logic in Computer Science (LICS ’92), Santa Cruz, California, USA, June 22-25, 1992. IEEE Computer Society, 186–197. https://doi.org/10.1109/LICS.1992.185532 Google Scholar
Cross Ref
- Paul E. McKenney, Alan Jeffrey, Ali Sezgin, and Tony Tye. 2016. Out-of-Thin-Air Execution is vacuous. http://wg21.link/p0422Google Scholar
- Robin Milner. 1977. Fully Abstract Models of Typed lambda-Calculi. Theor. Comput. Sci., 4, 1 (1977), 1–22. https://doi.org/10.1016/0304-3975(77)90053-6 Google Scholar
Cross Ref
- Peter O’Hearn. 2007. Resources, Concurrency, and Local Reasoning. Theor. Comput. Sci., 375, 1-3 (2007), April, 271–307. issn:0304-3975 https://doi.org/10.1016/j.tcs.2006.12.035 Google Scholar
Digital Library
- Marco Paviotti, Simon Cooksey, Anouk Paradis, Daniel Wright, Scott Owens, and Mark Batty. 2020. Modular Relaxed Dependencies in Weak Memory Concurrency. In Programming Languages and Systems - 29th European Symposium on Programming, ESOP 2020, Dublin, Ireland, April 25-30, 2020, Proceedings, Peter Müller (Ed.) (Lecture Notes in Computer Science, Vol. 12075). Springer, 599–625. https://doi.org/10.1007/978-3-030-44914-8_22 Google Scholar
Digital Library
- Jean Pichon-Pharabod and Peter Sewell. 2016. A Concurrency Semantics for Relaxed Atomics That Permits Optimisation and Avoids Thin-air Executions. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, New York, NY, USA. 622–633. isbn:978-1-4503-3549-2 https://doi.org/10.1145/2837614.2837616 Google Scholar
Digital Library
- Gordon D. Plotkin. 1977. LCF Considered as a Programming Language. Theor. Comput. Sci., 5, 3 (1977), 223–255. https://doi.org/10.1016/0304-3975(77)90044-5 Google Scholar
Cross Ref
- Vaughan R. Pratt. 1985. Some Constructions for Order-Theoretic Models of Concurrency. In Logics of Programs, Conference, Brooklyn College, New York, NY, USA, June 17-19, 1985, Proceedings, Rohit Parikh (Ed.) (Lecture Notes in Computer Science, Vol. 193). Springer, 269–283. https://doi.org/10.1007/3-540-15648-8_22 Google Scholar
Cross Ref
- William Pugh. 2004. Causality Test Cases. https://perma.cc/PJT9-XS8ZGoogle Scholar
- Jaroslav Sevčík. 2008. Program Transformations in Weak Memory Models. Laboratory for Foundations of Computer Science, University of Edinburgh.Google Scholar
- Jaroslav Sevčík and David Aspinall. 2008. On Validity of Program Transformations in the Java Memory Model. In ECOOP 2008 - Object-Oriented Programming, 22nd European Conference, Paphos, Cyprus, July 7-11, 2008, Proceedings, Jan Vitek (Ed.) (Lecture Notes in Computer Science, Vol. 5142). Springer, 27–51. isbn:978-3-540-70591-8 https://doi.org/10.1007/978-3-540-70592-5_3 Google Scholar
Digital Library
- Joel Spolsky. 2002. The Law of Leaky Abstractions. https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/Google Scholar
- Viktor Vafeiadis and Chinmay Narayan. 2013. Relaxed separation logic: a program logic for C11 concurrency. In Proceedings of the 2013 ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages & Applications, OOPSLA 2013, part of SPLASH 2013, Indianapolis, IN, USA, October 26-31, 2013, Antony L. Hosking, Patrick Th. Eugster, and Cristina V. Lopes (Eds.). ACM, 867–884. https://doi.org/10.1145/2509136.2509532 Google Scholar
Digital Library
- Conrad Watt, Christopher Pulte, Anton Podkopaev, Guillaume Barbier, Stephen Dolan, Shaked Flur, Jean Pichon-Pharabod, and Shu-yu Guo. 2020. Repairing and mechanising the JavaScript relaxed memory model. In Proceedings of the 41st ACM SIGPLAN International Conference on Programming Language Design and Implementation, PLDI 2020, London, UK, June 15-20, 2020, Alastair F. Donaldson and Emina Torlak (Eds.). ACM, 346–361. https://doi.org/10.1145/3385412.3385973 Google Scholar
Digital Library
- Conrad Watt, Andreas Rossberg, and Jean Pichon-Pharabod. 2019. Weakening WebAssembly. Proc. ACM Program. Lang., 3, OOPSLA (2019), 133:1–133:28. https://doi.org/10.1145/3360559 Google Scholar
Digital Library
Index Terms
The leaky semicolon: compositional semantic dependencies for relaxed-memory concurrency
Recommendations
Pomsets with preconditions: a simple model of relaxed memory
Relaxed memory models must simultaneously achieve efficient implementability and thread-compositional reasoning. Is that why they have become so complicated? We argue that the answer is no: It is possible to achieve these goals by combining an idea from ...
Safe optimisations for shared-memory concurrent programs
PLDI '11Current proposals for concurrent shared-memory languages, including C++ and C, provide sequential consistency only for programs without data races (the DRF guarantee). While the implications of such a contract for hardware optimisations are relatively ...
Safe optimisations for shared-memory concurrent programs
PLDI '11: Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and ImplementationCurrent proposals for concurrent shared-memory languages, including C++ and C, provide sequential consistency only for programs without data races (the DRF guarantee). While the implications of such a contract for hardware optimisations are relatively ...






Comments