Compiler optimisations and relaxed memory consistency models

Robin Morisset 1, 2
2 Parkas - Parallélisme de Kahn Synchrone
DI-ENS - Département d'informatique de l'École normale supérieure, CNRS - Centre National de la Recherche Scientifique, Inria de Paris
Abstract : Modern multiprocessors architectures and programming languages exhibit weakly consistent memories. Their behaviour is formalised by the memory model of the architecture or programming language; it precisely defines which write operation can be returned by each shared memory read. This is not always the latest store to the same variable, because of optimisations in the processors such as speculative execution of instructions, the complex effects of caches, and optimisations in the compilers. In this thesis we focus on the C11 memory model that is defined by the 2011 edition of the C standard. Our contributions are threefold. First, we focused on the theory surrounding the C11 model, formally studying which compiler optimisations it enables. We show that many common compiler optimisations are allowed, but, surprisingly, some important ones are forbidden. Secondly, building on our results, we developed a random testing methodology for detecting when mainstream compilers such as GCC or Clang perform an incorrect optimisation with respect to the memory model. We found several bugs in GCC, all promptly fixed. We also implemented a novel optimisation pass in LLVM, that looks for special instructions that restrict processor optimisations - called fence instructions - and eliminates the redundant ones. Finally, we developed a user-level scheduler for lightweight threads communicating through first-in first-out single-producer single-consumer queues. This programming model is known as Kahn process networks, and we show how to efficiently implement it, using C11 synchronisation primitives. This shows that despite its flaws, C11 can be usable in practice.
Document type :
Theses
Complete list of metadatas

Cited literature [49 references]  Display  Hide  Download

https://tel.archives-ouvertes.fr/tel-01823521
Contributor : Abes Star <>
Submitted on : Tuesday, June 26, 2018 - 10:19:05 AM
Last modification on : Monday, January 28, 2019 - 9:04:31 AM
Long-term archiving on : Wednesday, September 26, 2018 - 8:47:22 PM

File

Morisset-2017-These.pdf
Version validated by the jury (STAR)

Identifiers

  • HAL Id : tel-01823521, version 1

Collections

Citation

Robin Morisset. Compiler optimisations and relaxed memory consistency models. Other [cs.OH]. PSL Research University, 2017. English. ⟨NNT : 2017PSLEE050⟩. ⟨tel-01823521⟩

Share

Metrics

Record views

184

Files downloads

317