Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/3519939.3523718acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article
Open access

Sequential reasoning for optimizing compilers under weak memory concurrency

Published: 09 June 2022 Publication History

Abstract

We formally show that sequential reasoning is adequate and sufficient for establishing soundness of various compiler optimizations under weakly consistent shared-memory concurrency. Concretely, we introduce a sequential model and show that behavioral refinement in that model entails contextual refinement in the Promising Semantics model, extended with non-atomic accesses for non-racy code. This is the first work to achieve such result for a full-fledged model with a variety of C11-style concurrency features. Central to our model is the lifting of the common data-race-freedom assumption, which allows us to validate irrelevant load introduction, a transformation that is commonly performed by compilers. As a proof of concept, we develop an optimizer for a toy concurrent language, and certify it (in Coq) while relying solely on the sequential model. We believe that the proposed approach provides useful means for compiler developers and validators, as well as a solid foundation for the development of certified optimizing compilers for weakly consistent shared-memory concurrency.

References

[1]
2022. Coq development and supplementary material for this paper. https://sf.snu.ac.kr/promising-seq
[2]
Mark Batty, Scott Owens, Susmit Sarkar, Peter Sewell, and Tjark Weber. 2011. Mathematizing C++ Concurrency. In POPL. ACM, New York, NY, USA. 55–66. isbn:978-1-4503-0490-0 https://doi.org/10.1145/1926385.1926394
[3]
Lennart Beringer, Gordon Stewart, Robert Dockins, and Andrew W. Appel. 2014. Verified Compilation for Shared-Memory C. In ESOP. Springer, Berlin, Heidelberg. 107–127. isbn:978-3-642-54833-8 https://doi.org/10.1007/978-3-642-54833-8_7
[4]
Sebastian Burckhardt, Madanlal Musuvathi, and Vasu Singh. 2010. Verifying Local Transformations on Relaxed Memory Models. In CC. Springer, Berlin, Heidelberg. 104–123. isbn:3-642-11969-7, 978-3-642-11969-9 https://doi.org/10.1007/978-3-642-11970-5_7
[5]
Soham Chakraborty and Viktor Vafeiadis. 2016. Validating Optimizations of Concurrent C/C++ Programs. In CGO. ACM, New York, NY, USA. 216–226. isbn:9781450337786 https://doi.org/10.1145/2854038.2854051
[6]
Soham Chakraborty and Viktor Vafeiadis. 2017. Formalizing the Concurrency Semantics of an LLVM Fragment. In CGO. IEEE Press, 100–110. isbn:9781509049318 https://doi.org/10.1109/CGO.2017.7863732
[7]
Soham Chakraborty and Viktor Vafeiadis. 2019. Grounding Thin-Air Reads with Event Structures. Proc. ACM Program. Lang., 3, POPL (2019), Article 70, Jan., 28 pages. issn:2475-1421 https://doi.org/10.1145/3290383
[8]
Minki Cho, Sung-Hwan Lee, Chung-Kil Hur, and Ori Lahav. 2021. Modular Data-Race-Freedom Guarantees in the Promising Semantics. In PLDI. ACM, New York, NY, USA. 867–882. isbn:9781450383912 https://doi.org/10.1145/3453483.3454082
[9]
Santiago Cuellar. 2020. Concurrent Permission Machine for Modular Proofs of Optimizing Compilers with Shared Memory Concurrency. Ph. D. Dissertation. Princeton University.
[10]
Santiago Cuellar, Nick Giannarakis, Jean-Marie Madiot, William Mansky, Lennart Beringer, Qinxiang Cao, and Andrew W Appel. 2020. Compiler Correctness for Concurrency: from concurrent separation logic to shared-memory assembly language. Department of Computer Science, Princeton University.
[11]
Mike Dodds, Mark Batty, and Alexey Gotsman. 2018. Compositional Verification of Compiler Optimisations on Relaxed Memory. In ESOP. Springer International Publishing, Cham. 1027–1055. isbn:978-3-319-89884-1 https://doi.org/10.1007/978-3-319-89884-1_36
[12]
Lennard Gäher, Michael Sammler, Simon Spies, Ralf Jung, Hoang-Hai Dang, Robbert Krebbers, Jeehoon Kang, and Derek Dreyer. 2022. Simuliris: A Separation Logic Framework for Verifying Concurrent Program Optimizations. Proc. ACM Program. Lang., 6, POPL (2022), Article 28, jan, 31 pages. https://doi.org/10.1145/3498689
[13]
Ronghui Gu, Zhong Shao, Jieung Kim, Xiongnan (Newman) Wu, Jérémie Koenig, Vilhelm Sjöberg, Hao Chen, David Costanzo, and Tahina Ramananandro. 2018. Certified Concurrent Abstraction Layers. In PLDI. ACM, New York, NY, USA. 646–661. isbn:9781450356985 https://doi.org/10.1145/3192366.3192381
[14]
Radha Jagadeesan, Alan Jeffrey, and James Riely. 2020. Pomsets with Preconditions: A Simple Model of Relaxed Memory. Proc. ACM Program. Lang., 4, OOPSLA (2020), Article 194, Nov., 30 pages. https://doi.org/10.1145/3428262
[15]
Alan Jeffrey and James Riely. 2019. On Thin Air Reads: Towards an Event Structures Model of Relaxed Memory. Logical Methods in Computer Science, 15, 1 (2019), https://doi.org/10.23638/LMCS-15(1:33)2019
[16]
Hanru Jiang, Hongjin Liang, Siyang Xiao, Junpeng Zha, and Xinyu Feng. 2019. Towards Certified Separate Compilation for Concurrent Programs. In PLDI. ACM, New York, NY, USA. 111–125. isbn:9781450367127 https://doi.org/10.1145/3314221.3314595
[17]
Ralf Jung, David Swasey, Filip Sieczkowski, Kasper Svendsen, Aaron Turon, Lars Birkedal, and Derek Dreyer. 2015. Iris: Monoids and Invariants as an Orthogonal Basis for Concurrent Reasoning. In POPL. ACM, New York, NY, USA. 637–650. isbn:9781450333009 https://doi.org/10.1145/2676726.2676980
[18]
Jeehoon Kang, Chung-Kil Hur, Ori Lahav, Viktor Vafeiadis, and Derek Dreyer. 2017. A Promising Semantics for Relaxed-Memory Concurrency. In POPL. ACM, New York, NY, USA. 175–189. isbn:978-1-4503-4660-3 https://doi.org/10.1145/3009837.3009850
[19]
Ori Lahav, Egor Namakonov, Jonas Oberhauser, Anton Podkopaev, and Viktor Vafeiadis. 2021. Making Weak Memory Models Fair. Proc. ACM Program. Lang., 5, OOPSLA (2021), Article 98, oct, 27 pages. https://doi.org/10.1145/3485475
[20]
Ori Lahav, Viktor Vafeiadis, Jeehoon Kang, Chung-Kil Hur, and Derek Dreyer. 2017. Repairing Sequential Consistency in C/C++11. In PLDI. ACM, New York, NY, USA. 618–632. isbn:978-1-4503-4988-8 https://doi.org/10.1145/3062341.3062352
[21]
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 PLDI. ACM, New York, NY, USA. 633–647. isbn:9781450349888 https://doi.org/10.1145/3062341.3062343
[22]
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 PLDI. ACM, New York, NY, USA. 362–376. isbn:9781450376136 https://doi.org/10.1145/3385412.3386010
[23]
Xavier Leroy. 2009. Formal Verification of a Realistic Compiler. Commun. ACM, 52, 7 (2009), July, 107–115. issn:0001-0782 https://doi.org/10.1145/1538788.1538814
[24]
Xavier Leroy. 2009. A Formally Verified Compiler Back-End. J. Autom. Reason., 43, 4 (2009), Dec., 363–446. issn:0168-7433 https://doi.org/10.1007/s10817-009-9155-4
[25]
Hongjin Liang, Xinyu Feng, and Ming Fu. 2012. A Rely-Guarantee-Based Simulation for Verifying Concurrent Program Transformations. In POPL. ACM, New York, NY, USA. 455–468. isbn:9781450310833 https://doi.org/10.1145/2103656.2103711
[26]
Hongjin Liang, Xinyu Feng, and Ming Fu. 2014. Rely-Guarantee-Based Simulation for Compositional Verification of Concurrent Program Transformations. ACM Trans. Program. Lang. Syst., 36, 1 (2014), Article 3, Mar., 55 pages. issn:0164-0925 https://doi.org/10.1145/2576235
[27]
2021. https://llvm.org/docs/Atomics.html
[28]
Nuno P. Lopes, Juneyoung Lee, Chung-Kil Hur, Zhengyang Liu, and John Regehr. 2021. Alive2: Bounded Translation Validation for LLVM. In PLDI. ACM, New York, NY, USA. 65–79. isbn:9781450383912 https://doi.org/10.1145/3453483.3454030
[29]
Evgenii Moiseenko, Anton Podkopaev, Ori Lahav, Orestis Melkonian, and Viktor Vafeiadis. 2020. Reconciling Event Structures with Modern Multiprocessors. In ECOOP. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, Dagstuhl, Germany. 5:1–5:26. isbn:978-3-95977-154-2 issn:1868-8969 https://doi.org/10.4230/LIPIcs.ECOOP.2020.5
[30]
Robin Morisset, Pankaj Pawan, and Francesco Zappa Nardelli. 2013. Compiler Testing via a Theory of Sound Optimisations in the C11/C++11 Memory Model. In PLDI. ACM, New York, NY, USA. 187–196. isbn:9781450320146 https://doi.org/10.1145/2491956.2491967
[31]
Scott Owens, Susmit Sarkar, and Peter Sewell. 2009. A Better x86 Memory Model: x86-TSO. In TPHOLs. Springer, Berlin, Heidelberg. 391–407. isbn:978-3-642-03358-2 https://doi.org/10.1007/978-3-642-03359-9_27
[32]
Marco Paviotti, Simon Cooksey, Anouk Paradis, Daniel Wright, Scott Owens, and Mark Batty. 2020. Modular Relaxed Dependencies in Weak Memory Concurrency. In ESOP. Springer, Cham. 599–625. https://doi.org/10.1007/978-3-030-44914-8_22
[33]
Gustavo Petri, Jan Vitek, and Suresh Jagannathan. 2015. Cooking the Books: Formalizing JMM Implementation Recipes. In ECOOP. 37, Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 445–469. isbn:978-3-939897-86-6 issn:1868-8969 https://doi.org/10.4230/LIPIcs.ECOOP.2015.445
[34]
Jean Pichon-Pharabod and Peter Sewell. 2016. A Concurrency Semantics for Relaxed Atomics that Permits Optimisation and Avoids Thin-Air Executions. In POPL. ACM, New York, NY, USA. 622–633. isbn:9781450335492 https://doi.org/10.1145/2837614.2837616
[35]
Anton Podkopaev, Ori Lahav, and Viktor Vafeiadis. 2017. Promising Compilation to ARMv8 POP. In ECOOP. 74, Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 22:1–22:28. isbn:978-3-95977-035-4 issn:1868-8969 https://doi.org/10.4230/LIPIcs.ECOOP.2017.22
[36]
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), Article 69, Jan., 31 pages. issn:2475-1421 https://doi.org/10.1145/3290382
[37]
Kasper Svendsen, Jean Pichon-Pharabod, Marko Doko, Ori Lahav, and Viktor Vafeiadis. 2018. A separation logic for a promising semantics. In ESOP. Springer International Publishing, Cham. 357–384. isbn:978-3-319-89884-1 https://doi.org/10.1007/978-3-319-89884-1_13
[38]
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 POPL. ACM, New York, NY, USA. 209–220. isbn:978-1-4503-3300-9 https://doi.org/10.1145/2676726.2676995
[39]
Viktor Vafeiadis and Francesco Zappa Nardelli. 2011. Verifying Fence Elimination Optimisations. In SAS (LNCS, Vol. 6887). Springer, Berlin, Heidelberg. 146–162. https://doi.org/10.1007/978-3-642-23702-7_14
[40]
Jaroslav Ševčík. 2011. Safe Optimisations for Shared-memory Concurrent Programs. In PLDI. ACM, New York, NY, USA. 306–316. isbn:978-1-4503-0663-8 https://doi.org/10.1145/1993498.1993534
[41]
Jaroslav Ševčík and David Aspinall. 2008. On Validity of Program Transformations in the Java Memory Model. In ECOOP. Springer-Verlag, Berlin, Heidelberg. 27–51. https://doi.org/10.1007/978-3-540-70592-5_3
[42]
Jaroslav Ševčík, Viktor Vafeiadis, Francesco Zappa Nardelli, Suresh Jagannathan, and Peter Sewell. 2011. Relaxed-Memory Concurrency and Verified Compilation. In POPL. ACM, New York, NY, USA. 43–54. isbn:9781450304900 https://doi.org/10.1145/1926385.1926393
[43]
Jaroslav Ševčík, Viktor Vafeiadis, Francesco Zappa Nardelli, Suresh Jagannathan, and Peter Sewell. 2013. CompCertTSO: A Verified Compiler for Relaxed-Memory Concurrency. J. ACM, 60, 3 (2013), Article 22, June, 50 pages. issn:0004-5411 https://doi.org/10.1145/2487241.2487248
[44]
Li-yao Xia, Yannick Zakowski, Paul He, Chung-Kil Hur, Gregory Malecha, Benjamin C. Pierce, and Steve Zdancewic. 2019. Interaction Trees: Representing Recursive and Impure Programs in Coq. Proc. ACM Program. Lang., 4, POPL (2019), Article 51, Dec., 32 pages. https://doi.org/10.1145/3371119

Cited By

View all
  • (2024)Compositional Semantics for Shared-Variable ConcurrencyProceedings of the ACM on Programming Languages10.1145/36563998:PLDI(543-566)Online publication date: 20-Jun-2024
  • (2024)An Axiomatic Basis for Computer Programming on the Relaxed Arm-A Architecture: The AxSL LogicProceedings of the ACM on Programming Languages10.1145/36328638:POPL(604-637)Online publication date: 5-Jan-2024
  • (2023)Putting Weak Memory in Order via a Promising Intermediate RepresentationProceedings of the ACM on Programming Languages10.1145/35912977:PLDI(1872-1895)Online publication date: 6-Jun-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PLDI 2022: Proceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation
June 2022
1038 pages
ISBN:9781450392655
DOI:10.1145/3519939
  • General Chair:
  • Ranjit Jhala,
  • Program Chair:
  • Işil Dillig
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 09 June 2022

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. Compiler Optimizations
  2. Operational Semantics
  3. Relaxed Memory Concurrency

Qualifiers

  • Research-article

Conference

PLDI '22
Sponsor:

Acceptance Rates

Overall Acceptance Rate 406 of 2,067 submissions, 20%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)177
  • Downloads (Last 6 weeks)33
Reflects downloads up to 10 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Compositional Semantics for Shared-Variable ConcurrencyProceedings of the ACM on Programming Languages10.1145/36563998:PLDI(543-566)Online publication date: 20-Jun-2024
  • (2024)An Axiomatic Basis for Computer Programming on the Relaxed Arm-A Architecture: The AxSL LogicProceedings of the ACM on Programming Languages10.1145/36328638:POPL(604-637)Online publication date: 5-Jan-2024
  • (2023)Putting Weak Memory in Order via a Promising Intermediate RepresentationProceedings of the ACM on Programming Languages10.1145/35912977:PLDI(1872-1895)Online publication date: 6-Jun-2023
  • (2023)Fair Operational SemanticsProceedings of the ACM on Programming Languages10.1145/35912537:PLDI(811-834)Online publication date: 6-Jun-2023

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media