Taming the complexities of the C11 and OpenCL memory models

We study how the C11 memory model can be simplified and how it can be extended. Our first contribution is to propose a mild st rengthening of the model that enables the rules pertaining to sequentially-co nsistent (SC) operations to be significantly simplified. We eliminate one of the total o rders that candidate executions must range over, leading to a model that is signifi ca tly faster to simulate. Our endeavours to simplify the C11 memory model are pa ticularly timely, now that it provides a foundation for memory models of more ex otic languages – such as OpenCL 2.0, an extension of C for programming hetero geneous systems composed of CPUs, GPUs and other devices. Our second con tribution is the first mechanised formalisation of the OpenCL 2.0 memory mode l, extending our simplified C11 model. Our C11 and OpenCL memory model formali sations are expressed in the.cat language of Alglave et al., the native input format of the herd memory model simulator. Originally designed for the efficie nt simulation of hardware memory models, we have extended h rd to support language-level memory models.

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

[2]  Derek Hower,et al.  HRF-Relaxed: Adapting HRF to the Complexities of Industrial Heterogeneous Memory Models , 2015, TACO.

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

[4]  David A. Wood,et al.  Heterogeneous-race-free memory models , 2014, ASPLOS.

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

[6]  Susmit Sarkar,et al.  Nitpicking c++ concurrency , 2011, PPDP.

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

[8]  Jade Alglave,et al.  Fences in Weak Memory Models , 2010, CAV.

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

[10]  Brian Demsky,et al.  CDSchecker: checking concurrent data structures written with C/C++ atomics , 2013, OOPSLA.

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

[12]  Francesco Zappa Nardelli,et al.  Compiler testing via a theory of sound optimisations in the C11/C++11 memory model , 2013, PLDI.

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

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

[15]  Alfred Tarski,et al.  Relational selves as self-affirmational resources , 2008 .

[16]  Mark John Batty,et al.  The C11 and C++11 concurrency model , 2015 .

[17]  Ganesh Gopalakrishnan,et al.  GPU Concurrency: Weak Behaviours and Programming Assumptions , 2015, ASPLOS.

[18]  Leslie Lamport,et al.  How to Make a Correct Multiprocess Program Execute Correctly on a Multiprocessor , 1997, IEEE Trans. Computers.