skip to main content
research-article

Synchronising C/C++ and POWER

Published:11 June 2012Publication History
Skip Abstract Section

Abstract

Shared memory concurrency relies on synchronisation primitives: compare-and-swap, load-reserve/store-conditional (aka LL/SC), language-level mutexes, and so on. In a sequentially consistent setting, or even in the TSO setting of x86 and Sparc, these have well-understood semantics. But in the very relaxed settings of IBM®, POWER®, ARM, or C/C++, it remains surprisingly unclear exactly what the programmer can depend on.

This paper studies relaxed-memory synchronisation. On the hardware side, we give a clear semantic characterisation of the load-reserve/store-conditional primitives as provided by POWER multiprocessors, for the first time since they were introduced 20 years ago; we cover their interaction with relaxed loads, stores, barriers, and dependencies. Our model, while not officially sanctioned by the vendor, is validated by extensive testing, comparing actual implementation behaviour against an oracle generated from the model, and by detailed discussion with IBM staff. We believe the ARM semantics to be similar.

On the software side, we prove sound a proposed compilation scheme of the C/C++ synchronisation constructs to POWER, including C/C++ spinlock mutexes, fences, and read-modify-write operations, together with the simpler atomic operations for which soundness is already known from our previous work; this is a first step in verifying concurrent algorithms that use load-reserve/store-conditional with respect to a realistic semantics. We also build confidence in the C/C++ model in its own terms, fixing some omissions and contributing to the C standards committee adoption of the C++11 concurrency model.

References

  1. S. V. Adve andM. D. Hill. Weak ordering---a new definition. In Proc. ISCA, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. J. Alglave and L. Maranget. Stability in weak memory models. In Proc. CAV, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. J. Alglave, L. Maranget, S. Sarkar, and P. Sewell. Fences in weak memory models. In Proc. CAV, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. H.-J. Boehm and S.V. Adve. Foundations of the C++ concurrency memory model. In Proc. PLDI, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. P. Becker, editor. Programming Languages --- C++. 2011. ISO/IEC 14882:2011. A non-final but recent version is available at http://www.open-std.org/jtc1/sc22/ wg21/docs/papers/2011/n3242.pdf.Google ScholarGoogle Scholar
  6. M. Batty, K. Memarian, S. Owens, S. Sarkar, and P. Sewell. Clarifying and compiling C/C++ concurrency: from C++11 to POWER. In Proc. POPL, 2012. http://www.cl.cam.ac. uk/~pes20/cppppc/. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. H.-J. Boehm. Threads cannot be implemented as a library. In Proc. PLDI, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. M. Batty, S. Owens, S. Sarkar, P. Sewell, and T. Weber. Mathematizing C++ concurrency. In Proc. POPL, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Supplementary material. http://www.cl.cam.ac.uk/users/pes20/cppppc-supplemental.Google ScholarGoogle Scholar
  10. F. Corella, J. M. Stone, and C. M. Barton. A formal specification of the PowerPC shared memory architecture. Technical Report RC18638, IBM, 1993.Google ScholarGoogle Scholar
  11. M. Herlihy. A methodology for implementing highly concurrent data objects. TOPLAS, 15(5):745--770, Nov 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Intel. A formal specification of Intel Itanium processor family memory ordering. http://www.intel.com/design/itanium/downloads/251429.htm, October 2002.Google ScholarGoogle Scholar
  13. Programming Languages --- C. 2011. ISO/IEC 9899:2011. A non-final but recent version is available at http://www. open-std.org/jtc1/sc22/wg14/docs/n1539.pdf.Google ScholarGoogle Scholar
  14. E. H. Jensen, G. W. Hagensen, and J. M. Broughton. A new approach to exclusive data access in shared memory multiprocessors. (Technical Report UCRL-97663), Nov 1987.Google ScholarGoogle Scholar
  15. L. Lamport. How to make a multiprocessor computer that correctly executes multiprocess programs. IEEE Trans. Comput., C-28(9):690--691, 1979. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. P. E. McKenney. {patch rfc tip/core/rcu 0/28} preview of rcu changes for 3.3, November 2011. https://lkml.org/lkml/2011/11/2/363.Google ScholarGoogle Scholar
  17. M. M. Michael. Hazard pointers: Safe memory reclamation for lock-free objects. IEEE Trans. Parallel Distrib. Syst., 15:491--504, June 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. P. E. McKenney and R. Silvera. Example POWER implementation for C/C++ memory model. http: //www.rdrop.com/users/paulmck/scalability/paper/N2745r.2011.03.04a.html, 2011.Google ScholarGoogle Scholar
  19. S. Owens, P. Böhm, F. Zappa Nardelli, and P. Sewell. Lem: A lightweight tool for heavyweight semantics. In Proc. ITP, LNCS 6898, 2011. Rough Diamond" section. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. Parkinson, R. Bornat, and P. O'Hearn. Modular verification of a non-blocking stack. In Proc. POPL, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Power ISA Version 2.06. IBM, 2009.Google ScholarGoogle Scholar
  22. J. Ševčík. Safe optimisations for shared-memory concurrent programs. In Proc. PLDI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. D. Shasha and M. Snir. Efficient and correct execution of parallel programs that share memory. TOPLAS, 10:282--312, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. S. Sarkar, P. Sewell, J. Alglave, L.Maranget, and D. Williams. Understanding POWER multiprocessors. In PLDI, 2011 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Synchronising C/C++ and POWER

            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 47, Issue 6
              PLDI '12
              June 2012
              534 pages
              ISSN:0362-1340
              EISSN:1558-1160
              DOI:10.1145/2345156
              Issue’s Table of Contents
              • cover image ACM Conferences
                PLDI '12: Proceedings of the 33rd ACM SIGPLAN Conference on Programming Language Design and Implementation
                June 2012
                572 pages
                ISBN:9781450312059
                DOI:10.1145/2254064

              Copyright © 2012 ACM

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 11 June 2012

              Check for updates

              Qualifiers

              • research-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!