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

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.

[1]  Hans-Juergen Boehm,et al.  Foundations of the C++ concurrency memory model , 2008, PLDI '08.

[2]  Viktor Vafeiadis,et al.  Common Compiler Optimisations are Invalid in the C11 Memory Model and what we can do about it , 2015, POPL.

[3]  Radha Jagadeesan,et al.  Generative Operational Semantics for Relaxed Memory Models , 2010, ESOP.

[4]  David Aspinall,et al.  On Validity of Program Transformations in the Java Memory Model , 2008, ECOOP.

[5]  Satish Narayanasamy,et al.  A case for an SC-preserving compiler , 2011, PLDI '11.

[6]  Jeremy Manson,et al.  The Java memory model , 2005, POPL '05.

[7]  Gérard Boudol,et al.  A Theory of Speculative Computation , 2010, ESOP.

[8]  Peter Sewell,et al.  The Problem of Programming Language Concurrency Semantics , 2015, ESOP.

[9]  Jade Alglave,et al.  Synchronising C/C++ and POWER , 2012, PLDI.

[10]  Alexey Gotsman,et al.  Library abstraction for C/C++ concurrency , 2013, POPL.

[11]  Hans-Juergen Boehm,et al.  Outlawing ghosts: avoiding out-of-thin-air results , 2014, MSPC@PLDI.

[12]  Jan Vitek,et al.  Plan B: a buffered memory model for Java , 2013, POPL.

[13]  Jade Alglave,et al.  Understanding POWER multiprocessors , 2011, PLDI '11.

[14]  Viktor Vafeiadis,et al.  Relaxed separation logic: a program logic for C11 concurrency , 2013, OOPSLA.

[15]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[16]  Peter Sewell,et al.  Clarifying and compiling C/C++ concurrency: from C++11 to POWER , 2012, POPL '12.

[17]  Jaroslav Sevcík Safe optimisations for shared-memory concurrent programs , 2011, PLDI '11.

[18]  Yang Zhang,et al.  An Operational Approach to Happens-Before Memory Model , 2013, 2013 International Symposium on Theoretical Aspects of Software Engineering.

[19]  Radha Jagadeesan,et al.  A theory of memory models , 2007, PPOPP.

[20]  Tom Ridge,et al.  Lem: reusable engineering of real-world semantics , 2014, ICFP.

[21]  Glynn Winskel,et al.  Petri Nets, Event Structures and Domains , 1979, Semantics of Concurrent Computation.

[22]  Satish Narayanasamy,et al.  End-to-end sequential consistency , 2012, 2012 39th Annual International Symposium on Computer Architecture (ISCA).

[23]  Alexander Knapp,et al.  The Java Memory Model: Operationally, Denotationally, Axiomatically , 2007, ESOP.

[24]  Peter Sewell,et al.  Mathematizing C++ concurrency , 2011, POPL '11.