Abstract
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 the 60s (preconditions) with an idea from the 80s (pomsets), at least for X64 and ARMv8. We show that the resulting model (1) supports compositional reasoning for temporal safety properties, (2) supports all expected sequential compiler optimizations, (3) satisfies the DRF-SC criterion, and (4) compiles to X64 and ARMv8 microprocessors without requiring extra fences on relaxed accesses.
Supplemental Material
- Martín Abadi and Leslie Lamport. 1993. Composing Specifications. ACM Trans. Program. Lang. Syst. 15, 1 (Jan. 1993 ), 73-132. https://doi.org/10.1145/151646.151649 Google Scholar
Digital Library
- Sarita V. Adve and Mark D. Hill. 1990. Weak Ordering-A New Definition. In Proceedings of the 17th Annual International Symposium on Computer Architecture, Seattle, WA, USA, June 1990. ACM, 2-14. https://doi.org/10.1145/325164.325100 Google Scholar
Digital Library
- Sarita V. Adve and Mark D. Hill. 1993. A Unified Formalization of Four Shared-Memory Models. IEEE Trans. Parallel Distrib. Syst. 4, 6 ( 1993 ), 613-624. https://doi.org/10.1109/71.242161 Google Scholar
Digital Library
- Jade Alglave. 2010. A shared memory poetics. PhD thesis. Université Paris 7 and INRIA.Google Scholar
- Jade Alglave. 2019. This commit adds the Armv8 memory model for mixed-size accesses. https://github.com/herd/herdtools7/ commit/95785c747750be4a3b64adfab9d5f5ee0ead8240.Google Scholar
- 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, Article 7 ( July 2014 ), 74 pages. https://doi.org/10.1145/2627752 Google Scholar
Digital Library
- Mark Batty. 2015. The C11 and C++11 concurrency model. Ph.D. Dissertation. University of Cambridge, UK.Google Scholar
- Mark Batty. 2017. Compositional relaxed concurrency. Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences 375, 2104 (Oct. 2017 ), 13 pages. https://doi.org/10.1098/rsta. 2015.0406 Google Scholar
Cross Ref
- Mark Batty, Alastair F. Donaldson, and John Wickerson. 2016. Overhauling SC atomics in C11 and OpenCL. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, St. Petersburg, FL, USA, January 20-22, 2016, Rastislav Bodík and Rupak Majumdar (Eds.). ACM, 634-648. https://doi.org/10.1145/ 2837614.2837637 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 (Lecture Notes in Computer Science, Vol. 9032 ), Jan Vitek (Ed.). 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 (Austin, Texas, USA) ( POPL '11). ACM, New York, NY, USA, 55-66. https://doi.org/10.1145/1926385.1926394 Google Scholar
Digital Library
- Hans-J. Boehm. 2007. Memory Model Rationales. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2176.Google Scholar
- Hans-J. Boehm. 2018. Out-of-thin-air, revisited, again. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1217r0.Google Scholar
- 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 (Edinburgh, United Kingdom) (MSPC '14). ACM, New York, NY, USA, Article 7, 6 pages. https://doi.org/10.1145/2618128.2618134 Google Scholar
Digital Library
- Stephen Brookes. 2016. A denotational semantics for weak memory concurrency. http://www.cs.bham.ac.uk/~pbl/mgs2016/ brookesslides.pdf. Midlands Graduate School in the Foundations of Computing Science.Google Scholar
- Simon Castellan. 2016. Weak memory models using event structures. In Vingt-septièmes Journées Francophones des Langages Applicatifs (JFLA 2016 ). HAL-Inria, Saint-Malo, France, 39-53. https://hal.inria.fr/hal-01333582Google Scholar
- Pietro Cenciarelli, Alexander Knapp, and Eleonora Sibilio. 2007. The Java Memory Model: Operationally, Denotationally, Axiomatically. In Programming Languages and Systems, 16th European Symposium on Programming, ESOP 2007, Braga, Portugal, March 24-April 1, 2007, Proceedings (Lecture Notes in Computer Science, Vol. 4421 ), Rocco De Nicola (Ed.). Springer, 331-346. https://doi.org/10.1007/978-3-540-71316-6_23 Google Scholar
Cross Ref
- Soham Chakraborty and Viktor Vafeiadis. 2017. Formalizing the concurrency semantics of an LLVM fragment. In Proceedings of the 2017 International Symposium on Code Generation and Optimization, CGO 2017, Austin, TX, USA, February 4-8, 2017, Vijay Janapa Reddi, Aaron Smith, and Lingjia Tang (Eds.). ACM, 100-110. https://doi.org/10.5555/3049832.3049844 Google Scholar
Digital Library
- Soham Chakraborty and Viktor Vafeiadis. 2018. Private correspondence.Google Scholar
- 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
- Will Deacon. 2017. Formal memory model for Armv8.0 application level. https://github.com/herd/herdtools7/commit/ daa126680b6ecba97ba47b3e05bbaa51a89f27b7.Google Scholar
- Delphine Demange, Vincent Laporte, Lei Zhao, Suresh Jagannathan, David Pichardie, and Jan Vitek. 2013. Plan B: a bufered memory model for Java. In The 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '13, Rome, Italy-January 23-25, 2013, Roberto Giacobazzi and Radhia Cousot (Eds.). ACM, 329-342. https://doi.org/10.1145/2429069.2429110 Google Scholar
Digital Library
- Craig Disselkoen, Radha Jagadeesan, Alan Jefrey, and James Riely. 2019. The Code That Never Ran: Modeling Attacks on Speculative Evaluation. In 2019 IEEE Symposium on Security and Privacy, SP 2019, San Francisco, CA, USA, May 19-23, 2019. IEEE, 1238-1255. https://doi.org/10.1109/SP. 2019.00047 Google Scholar
Cross Ref
- 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 (Philadelphia, PA, USA) ( PLDI 2018). ACM, New York, NY, USA, 242-255. https://doi.org/10.1145/3192366.3192421 Google Scholar
Digital Library
- Brijesh Dongol, Radha Jagadeesan, and James Riely. 2019. Modular transactions: bounding mixed races in space and time. In Proceedings of the 24th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, PPoPP 2019, Washington, DC, USA, February 16-20, 2019, Jefrey K. Hollingsworth and Idit Keidar (Eds.). ACM, 82-93. https: //doi.org/10.1145/3293883.3295708 Google Scholar
Digital Library
- ECMA International. 2019. ECMAScript 2019 Language Specification. https://www.ecma-international. org/ecma-262/10.0/.Google Scholar
- Shaked Flur, Kathryn E. Gray, Christopher Pulte, Susmit Sarkar, Ali Sezgin, Luc Maranget, Will Deacon, and Peter Sewell. 2016. Modelling the ARMv8 architecture, operationally: concurrency and ISA. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, St. Petersburg, FL, USA, January 20-22, 2016, Rastislav Bodík and Rupak Majumdar (Eds.). ACM, 608-621. https://doi.org/10.1145/2837614.2837615 Google Scholar
Digital Library
- Shaked Flur, Susmit Sarkar, Christopher Pulte, Kyndylan Nienhuis, Luc Maranget, Kathryn E. Gray, Ali Sezgin, Mark Batty, and Peter Sewell. 2017. Mixed-size concurrency: ARM, POWER, C/C++ 11, and SC. 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, 429-442. https://doi.org/10.1145/3009837.3009839 Google Scholar
Digital Library
- Jay L. Gischer. 1988. The equational theory of pomsets. Theoretical Computer Science 61, 2 ( 1988 ), 199-224. 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 (Oct. 1969 ), 576-580. https: //doi.org/10.1145/363235.363259 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 (Lecture Notes in Computer Science, Vol. 6012 ), Andrew D. Gordon (Ed.). Springer, 307-326. https://doi.org/10.1007/978-3-642-11957-6_17 Google Scholar
Digital Library
- Alan Jefrey 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. https://doi.org/10.1145/2933575.2934536 Google Scholar
Digital Library
- Alan Jefrey and James Riely. 2019. On Thin Air Reads: Towards an Event Structures Model of Relaxed Memory. Logical Methods in Computer Science 15, 1 ( 2019 ), 25 pages. https://doi.org/10.23638/LMCS-15 ( 1 :33) 2019 Google Scholar
Cross Ref
- Jeehoon Kang, Chung-Kil Hur, Ori Lahav, Viktor Vafeiadis, and Derek Dreyer. 2017. A promising semantics for relaxedmemory 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
- Jeehoon Kang, Chung-Kil Hur, Ori Lahav, Viktor Vafeiadis, and Derek Dreyer. 2018. Private correspondence.Google Scholar
- Ryan Kavanagh and Stephen Brookes. 2019. A Denotational Semantics for SPARC TSO. Logical Methods in Computer Science 15, 2 ( 2019 ), 23 pages. https://doi.org/10.23638/LMCS-15 ( 2 :10) 2019 Google Scholar
Cross Ref
- Ori Lahav and Viktor Vafeiadis. 2016. Explaining Relaxed Memory Models with Program Transformations. In FM 2016: Formal Methods-21st International Symposium, Limassol, Cyprus, November 9-11, 2016, Proceedings (Lecture Notes in Computer Science, Vol. 9995 ), John S. Fitzgerald, Constance L. Heitmeyer, Stefania Gnesi, and Anna Philippou (Eds.). Springer, 479-495. https://doi.org/10.1007/978-3-319-48989-6_29 Google Scholar
Cross Ref
- 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. 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 (Sept. 1979 ), 690-691. https://doi.org/10.1109/TC. 1979.1675439 Google Scholar
Digital Library
- Leslie Lamport. 1986. On Interprocess Communication. Part I: Basic Formalism. Distributed Computing 1, 2 ( 1986 ), 77-85. https://doi.org/10.1007/BF01786227 Google Scholar
Cross Ref
- Orna Lichtenstein, Amir Pnueli, and Lenore D. Zuck. 1985. The Glory of the Past. In Proceedings of the Conference on Logic of Programs. Springer-Verlag, London, UK, UK, 196-218. https://doi.org/10.5555/648065.747612 Google Scholar
Digital Library
- Andreas Lochbihler. 2013. Making the Java memory model safe. ACM Trans. Program. Lang. Syst. 35, 4 ( 2013 ), 12 : 1-12 : 65. https://doi.org/10.1145/2518191 Google Scholar
Digital Library
- Jeremy Manson, William Pugh, and Sarita V. Adve. 2005. The Java Memory Model. SIGPLAN Not. 40, 1 (Jan. 2005 ), 378-391. https://doi.org/10.1145/1047659.1040336 Google Scholar
Digital Library
- Paul E. McKenney, Alan Jerfey, Ali Sezgin, and Tony Tye. 2016. 0422R0: Out-of-thin-air execution is vacuous. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0422r0.Google Scholar
- Robin Milner. 1999. Communicating and Mobile Systems: The-calculus. Cambridge University Press, New York, NY, USA.Google Scholar
- Jayadev Misra and K. Mani Chandy. 1981. Proofs of Networks of Processes. IEEE Trans. Software Eng. 7, 4 ( 1981 ), 417-426. https://doi.org/10.1109/TSE. 1981.230844 Google Scholar
Digital Library
- Evgenii Moiseenko, Anton Podkopaev, Ori Lahav, Orestis Melkonian, and Viktor Vafeiadis. 2019. Reconciling Event Structures with Modern Multiprocessors. CoRR abs/ 1911.06567 ( 2019 ), 34 pages. arXiv: 1911.06567 http://arxiv.org/abs/ 1911.06567 To appear in ECOOP 2020.Google Scholar
- Robin Morisset. 2017. Compiler optimisations and relaxed memory consistency models. Ph.D. Dissertation. PSL Research University, Paris, France. https://tel.archives-ouvertes.fr/tel-01823521Google Scholar
- 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 (Lecture Notes in Computer Science, Vol. 12075 ), Peter Müller (Ed.). Springer, 599-625. https://doi.org/10.1007/978-3-030-44914-8_22 Google Scholar
Cross Ref
- 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 (St. Petersburg, FL, USA) ( POPL '16). ACM, New York, NY, USA, 622-633. https://doi.org/10. 1145/2837614.2837616 Google Scholar
Digital Library
- Gordon D. Plotkin and Vaughan R. Pratt. 1996. Teams can see pomsets. In Partial Order Methods in Verification, Proceedings of a DIMACS Workshop, Princeton, New Jersey, USA, July 24-26, 1996 (DIMACS Series in Discrete Mathematics and Theoretical Computer Science, Vol. 29 ), Doron A. Peled, Vaughan R. Pratt, and Gerard J. Holzmann (Eds.). DIMACS/AMS, 117-128. https://doi.org/10.1090/dimacs/029/07 Google Scholar
Cross Ref
- Amir Pnueli. 1984. In Transition From Global to Modular Temporal Reasoning about Programs. In Logics and Models of Concurrent Systems-Conference proceedings, Colle-sur-Loup (near Nice), France, 8-19 October 1984 ( NATO ASI Series, Vol. 13 ), Krzysztof R. Apt (Ed.). Springer, 123-144. https://doi.org/10.1007/978-3-642-82453-1_5 Google Scholar
Cross Ref
- Anton Podkopaev, Ori Lahav, and Viktor Vafeiadis. 2019. Bridging the gap between programming languages and hardware weak memory models. Proc. ACM Program. Lang. 3, POPL ( 2019 ), 69 : 1-69 : 31. https://doi.org/10.1145/3290382 Google Scholar
Digital Library
- William Pugh. 1999. Fixing the Java Memory Model. In Proceedings of the ACM 1999 Conference on Java Grande, JAVA '99, San Francisco, CA, USA, June 12-14, 1999, Geofrey C. Fox, Klaus E. Schauser, and Marc Snir (Eds.). ACM, 89-98. https://doi.org/10.1145/304065.304106 Google Scholar
Digital Library
- William Pugh. 2004. Causality Test Cases. https://perma.cc/PJT9-XS8ZGoogle Scholar
- Christopher Pulte, Shaked Flur, Will Deacon, Jon French, Susmit Sarkar, and Peter Sewell. 2018. Simplifying ARM concurrency: multicopy-atomic axiomatic and operational models for ARMv8. PACMPL 2, POPL ( 2018 ), 19 : 1-19 : 29. https://doi.org/10. 1145/3158107 Google Scholar
Digital Library
- Christopher Pulte, Jean Pichon-Pharabod, Jeehoon Kang, Sung Hwan Lee, and Chung-Kil Hur. 2019. Promising-ARM/RISC-V: a simpler and faster operational concurrency model. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2019, Phoenix, AZ, USA, June 22-26, 2019, Kathryn S. McKinley and Kathleen Fisher (Eds.). ACM, 1-15. https://doi.org/10.1145/3314221.3314624 Google Scholar
Digital Library
- Vijay A. Saraswat, Radha Jagadeesan, Maged Michael, and Christoph von Praun. 2007. A Theory of Memory Models. In Proceedings of the 12th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (San Jose, California, USA) ( PPoPP '07). ACM, New York, NY, USA, 161-172. https://doi.org/10.1145/1229428.1229469 Google Scholar
Digital Library
- Jaroslav Sevčík. 2008. Program Transformations in Weak Memory Models. PhD thesis. Laboratory for Foundations of Computer Science, University of Edinburgh.Google Scholar
- Jaroslav Sevčík. 2011. Private correspondence.Google Scholar
- Eugene W. Stark. 1985. A Proof Technique for Rely/Guarantee Properties. In Foundations of Software Technology and Theoretical Computer Science, Fifth Conference, New Delhi, India, December 16-18, 1985, Proceedings (Lecture Notes in Computer Science, Vol. 206 ), S. N. Maheshwari (Ed.). Springer, 369-391. https://doi.org/10.1007/3-540-16042-6_21 Google Scholar
Cross Ref
- Kasper Svendsen, Jean Pichon-Pharabod, Marko Doko, Ori Lahav, and Viktor Vafeiadis. 2018. A Separation Logic for a Promising Semantics. In Programming Languages and Systems-27th European Symposium on Programming, ESOP 2018, Thessaloniki, Greece, April 14-20, 2018, Proceedings (Lecture Notes in Computer Science, Vol. 10801 ). Springer, 357-384. https://doi.org/10.1007/978-3-319-89884-1_13 Google Scholar
Cross Ref
- Viktor Vafeiadis, Thibaut Balabonski, Soham Chakraborty, Robin Morisset, and Francesco Zappa Nardelli. 2015. Common Compiler Optimisations are Invalid in the C11 Memory Model and what we can do about it. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, Mumbai, India, January 15-17, 2015, Sriram K. Rajamani and David Walker (Eds.). ACM, 209-220. https://doi.org/10.1145/2676726.2676995 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
Pomsets with preconditions: a simple model of relaxed memory
Recommendations
The leaky semicolon: compositional semantic dependencies for relaxed-memory concurrency
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 ...
Dynamic synthesis for relaxed memory models
PLDI '12: Proceedings of the 33rd ACM SIGPLAN Conference on Programming Language Design and ImplementationModern architectures implement relaxed memory models which may reorder memory operations or execute them non-atomically. Special instructions called memory fences are provided, allowing control of this behavior.
To implement a concurrent algorithm for a ...
Testing concurrent programs on relaxed memory models
ISSTA '11: Proceedings of the 2011 International Symposium on Software Testing and AnalysisHigh-performance concurrent libraries, such as lock-free data structures and custom synchronization primitives, are notoriously difficult to write correctly. Such code is often implemented without locks, instead using plain loads and stores and low-...






Comments