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.
- Programming Languages — C. 2011. ISO/IEC 9899:2011. http: //www.open-std.org/jtc1/sc22/wg14/docs/n1539.pdf.Google Scholar
- J. F. Bastien. N4455 No sane compiler would optimize atomics, Apr. 2015.Google Scholar
- available at http://www.open-std.org/jtc1/sc22/wg21/ docs/papers/2015/n4455.html.Google Scholar
- M. Batty, S. Owens, S. Sarkar, P. Sewell, and T. Weber. Mathematizing C++ concurrency. In POPL, 2011. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- M. Batty, M. Dodds, and A. Gotsman. Library abstraction for C/C++ concurrency. In POPL, 2013. Google Scholar
Digital Library
- M. Batty, K. Memarian, K. Nienhuis, J. Pichon-Pharabod, and P. Sewell. The problem of programming language concurrency semantics. In ESOP, 2015.Google Scholar
Cross Ref
- 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 Scholar
- H.-J. Boehm and S. Adve. Foundations of the C++ concurrency memory model. In PLDI, 2008.. Google Scholar
Digital Library
- H.-J. Boehm and B. Demsky. Outlawing ghosts: Avoiding out-of-thinair results. In Proc. MSPC, 2014. Google Scholar
Digital Library
- G. Boudol and G. Petri. A theory of speculative computation. In ESOP, 2010. Google Scholar
Digital Library
- P. Cenciarelli, A. Knapp, and E. Sibilio. The Java memory model: Operationally, denotationally, axiomatically. In ESOP, 2007. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- X. Feng. Presentation at Dagstuhl seminar 15191, May 2015.Google Scholar
- IBM. Power ISA version 2.06, 2009.Google Scholar
- R. Jagadeesan, C. Pitcher, and J. Riely. Generative operational semantics for relaxed memory models. In Proc. ESOP, 2010. Google Scholar
Digital Library
- A. Jeffrey and J. Riely. Event structures and refinement for relaxed memory. Slides presented at the Memory Model meeting, Cambridge, Sept. 2014.Google Scholar
- J. Manson, W. Pugh, and S. Adve. The Java memory model. In POPL, 2005. Google Scholar
Digital Library
- D. Marino, A. Singh, T. D. Millstein, M. Musuvathi, and S. Narayanasamy. A case for an sc-preserving compiler. In PLDI, 2011. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- W. Pugh. Causality test cases. available at http://www.cs.umd.edu/ ~pugh/java/memoryModel/CausalityTestCases.html.Google Scholar
- V. A. Saraswat, R. Jagadeesan, M. M. Michael, and C. von Praun. A theory of memory models. In PPOPP, 2007. Google Scholar
Digital Library
- S. Sarkar, P. Sewell, J. Alglave, L. Maranget, and D. Williams. Understanding POWER multiprocessors. In PLDI, pages 175–186, June 2011. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- J. Ševˇcík and D. Aspinall. On validity of program transformations in the Java memory model. In ECOOP, 2008. Google Scholar
Digital Library
- A. Singh, S. Narayanasamy, D. Marino, T. Millstein, and M. Musuvathi. End-to-end sequential consistency. In Proc. ISCA, 2012. Google Scholar
Digital Library
- V. Vafeiadis and C. Narayan. Relaxed separation logic: A program logic for C11 concurrency. In OOPSLA, 2013. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- J. Ševˇcík. Safe optimisations for shared-memory concurrent programs. In PLDI, 2011. Google Scholar
Digital Library
- Y. Zhang and X. Feng. An operational approach to happens-before memory model. In TASE, pages 121–128, 2013. Google Scholar
Digital Library
Index Terms
A concurrency semantics for relaxed atomics that permits optimisation and avoids thin-air executions
Recommendations
A concurrency semantics for relaxed atomics that permits optimisation and avoids thin-air executions
POPL '16: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesDespite 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 ...
Testing concurrent programs on relaxed memory models
ISSTA '11: Proceedings of the 2011 International Symposium on Software Testing and AnalysisHigh-performance concurrent libraries, such as lock-free data structures and custom synchronization primitives, are notoriously difficult to write correctly. Such code is often implemented without locks, instead using plain loads and stores and low-...
Relaxed separation logic: a program logic for C11 concurrency
OOPSLA '13We introduce relaxed separation logic (RSL), the first program logic for reasoning about concurrent programs running under the C11 relaxed memory model. From a user's perspective, RSL is an extension of concurrent separation logic (CSL) with proof rules ...






Comments