skip to main content
article

A concurrency semantics for relaxed atomics that permits optimisation and avoids thin-air executions

Published:11 January 2016Publication History
Skip Abstract Section

Abstract

Despite much research on concurrent programming languages, especially for Java and C/C++, we still do not have a satisfactory definition of their semantics, one that admits all common optimisations without also admitting undesired behaviour. Especially problematic are the ``thin-air'' examples involving high-performance concurrent accesses, such as C/C++11 relaxed atomics. The C/C++11 model is in a per-candidate-execution style, and previous work has identified a tension between that and the fact that compiler optimisations do not operate over single candidate executions in isolation; rather, they operate over syntactic representations that represent all executions. In this paper we propose a novel approach that circumvents this difficulty. We define a concurrency semantics for a core calculus, including relaxed-atomic and non-atomic accesses, and locks, that admits a wide range of optimisation while still forbidding the classic thin-air examples. It also addresses other problems relating to undefined behaviour. The basic idea is to use an event-structure representation of the current state of each thread, capturing all of its potential executions, and to permit interleaving of execution and transformation steps over that to reflect optimisation (possibly dynamic) of the code. These are combined with a non-multi-copy-atomic storage subsystem, to reflect common hardware behaviour. The semantics is defined in a mechanised and executable form, and designed to be implementable above current relaxed hardware and strong enough to support the programming idioms that C/C++11 does for this fragment. It offers a potential way forward for concurrent programming language semantics, beyond the current C/C++11 and Java models.

References

  1. Programming Languages — C. 2011. ISO/IEC 9899:2011. http: //www.open-std.org/jtc1/sc22/wg14/docs/n1539.pdf.Google ScholarGoogle Scholar
  2. J. F. Bastien. N4455 No sane compiler would optimize atomics, Apr. 2015.Google ScholarGoogle Scholar
  3. available at http://www.open-std.org/jtc1/sc22/wg21/ docs/papers/2015/n4455.html.Google ScholarGoogle Scholar
  4. M. Batty, S. Owens, S. Sarkar, P. Sewell, and T. Weber. Mathematizing C++ concurrency. In POPL, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. M. Batty, K. Memarian, S. Owens, S. Sarkar, and P. Sewell. Clarifying and compiling C/C++ concurrency: from C++11 to POWER. In POPL, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. M. Batty, M. Dodds, and A. Gotsman. Library abstraction for C/C++ concurrency. In POPL, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. M. Batty, K. Memarian, K. Nienhuis, J. Pichon-Pharabod, and P. Sewell. The problem of programming language concurrency semantics. In ESOP, 2015.Google ScholarGoogle ScholarCross RefCross Ref
  8. P. Becker, editor. Programming Languages — C++. 2011. ISO/IEC 14882:2011. http://www.open-std.org/jtc1/sc22/wg21/docs/ papers/2011/n3242.pdf.Google ScholarGoogle Scholar
  9. H.-J. Boehm and S. Adve. Foundations of the C++ concurrency memory model. In PLDI, 2008.. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. H.-J. Boehm and B. Demsky. Outlawing ghosts: Avoiding out-of-thinair results. In Proc. MSPC, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. G. Boudol and G. Petri. A theory of speculative computation. In ESOP, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. P. Cenciarelli, A. Knapp, and E. Sibilio. The Java memory model: Operationally, denotationally, axiomatically. In ESOP, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. D. Demange, V. Laporte, L. Zhao, S. Jagannathan, D. Pichardie, and J. Vitek. Plan B: A buffered memory model for Java. In POPL, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. X. Feng. Presentation at Dagstuhl seminar 15191, May 2015.Google ScholarGoogle Scholar
  15. IBM. Power ISA version 2.06, 2009.Google ScholarGoogle Scholar
  16. R. Jagadeesan, C. Pitcher, and J. Riely. Generative operational semantics for relaxed memory models. In Proc. ESOP, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. A. Jeffrey and J. Riely. Event structures and refinement for relaxed memory. Slides presented at the Memory Model meeting, Cambridge, Sept. 2014.Google ScholarGoogle Scholar
  18. J. Manson, W. Pugh, and S. Adve. The Java memory model. In POPL, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. D. Marino, A. Singh, T. D. Millstein, M. Musuvathi, and S. Narayanasamy. A case for an sc-preserving compiler. In PLDI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. D. P. Mulligan, S. Owens, K. E. Gray, T. Ridge, and P. Sewell. Lem: reusable engineering of real-world semantics. In Proc. ICFP, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. M. Nielsen, G. D. Plotkin, and G. Winskel. Petri nets, event structures and domains. In Proceedings of Semantics of Concurrent Computation, 1979.. URL http://dx.doi.org/10.1007/BFb0022474. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. W. Pugh. Causality test cases. available at http://www.cs.umd.edu/ ~pugh/java/memoryModel/CausalityTestCases.html.Google ScholarGoogle Scholar
  23. V. A. Saraswat, R. Jagadeesan, M. M. Michael, and C. von Praun. A theory of memory models. In PPOPP, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. S. Sarkar, P. Sewell, J. Alglave, L. Maranget, and D. Williams. Understanding POWER multiprocessors. In PLDI, pages 175–186, June 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. S. Sarkar, K. Memarian, S. Owens, M. Batty, P. Sewell, L. Maranget, J. Alglave, and D. Williams. Synchronising C/C++ and POWER. In PLDI, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. J. Ševˇcík and D. Aspinall. On validity of program transformations in the Java memory model. In ECOOP, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. A. Singh, S. Narayanasamy, D. Marino, T. Millstein, and M. Musuvathi. End-to-end sequential consistency. In Proc. ISCA, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. V. Vafeiadis and C. Narayan. Relaxed separation logic: A program logic for C11 concurrency. In OOPSLA, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. V. Vafeiadis, T. Balabonski, S. Chakraborty, R. Morisset, and F. Zappa Nardelli. Common compiler optimisations are invalid in the C11 memory model and what we can do about it. In POPL, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. Ševˇcík. Safe optimisations for shared-memory concurrent programs. In PLDI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Y. Zhang and X. Feng. An operational approach to happens-before memory model. In TASE, pages 121–128, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A concurrency semantics for relaxed atomics that permits optimisation and avoids thin-air executions

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 51, Issue 1
          POPL '16
          January 2016
          815 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2914770
          • Editor:
          • Andy Gill
          Issue’s Table of Contents
          • cover image ACM Conferences
            POPL '16: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages
            January 2016
            815 pages
            ISBN:9781450335492
            DOI:10.1145/2837614

          Copyright © 2016 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 11 January 2016

          Check for updates

          Qualifiers

          • article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!