Synchronising C/C++ and POWER
Open Access
- 11 June 2012
- conference paper
- Published by Association for Computing Machinery (ACM)
- Vol. 47 (6) , 311-322
Abstract
International audienceShared 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 sanc-tioned 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, in-cluding 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 con-fidence in the C/C++ model in its own terms, fixing some omis-sions and contributing to the C standards committee adoption of the C++11 concurrency modelKeywords
This publication has 13 references indexed in Scilit:
- Clarifying and compiling C/C++ concurrency2012
- Understanding POWER multiprocessors2011
- Fences in Weak Memory Models2010
- Foundations of the C++ concurrency memory model2008
- Modular verification of a non-blocking stack2007
- Threads cannot be implemented as a library2005
- Hazard pointers: safe memory reclamation for lock-free objectsIEEE Transactions on Parallel and Distributed Systems, 2004
- A methodology for implementing highly concurrent data objectsACM Transactions on Programming Languages and Systems, 1993
- Weak ordering---a new definition1990
- Efficient and correct execution of parallel programs that share memoryACM Transactions on Programming Languages and Systems, 1988