# Compiling a Calculus for Relaxed Memory: Practical constraint-based   low-level concurrency

**Authors:** Michael J. Sullivan, Karl Crary, and Salil Joshi

arXiv: 1904.05389 · 2019-04-12

## TL;DR

This paper introduces rmc-compiler, a Clang/LLVM-based tool that compiles RMC-extended C/C++, enabling explicit memory ordering constraints and leveraging control/data dependencies for improved performance on relaxed-memory architectures.

## Contribution

It presents a practical compiler implementation for RMC, modeling compilation as an SMT problem, and demonstrates performance benefits on ARM and POWER architectures.

## Key findings

- Modest performance improvements on data structure benchmarks.
- Significant improvements on read-mostly list test.
- Effective use of control and data dependencies for memory ordering.

## Abstract

Crary and Sullivan's Relaxed Memory Calculus (RMC) proposed a new declarative approach for writing low-level shared memory concurrent programs in the presence of modern relaxed-memory multi-processor architectures and optimizing compilers. In RMC, the programmer explicitly specifies constraints on the order of execution of operations and on the visibility of memory writes. These constraints are then enforced by the compiler, which has a wide degree of latitude in how to accomplish its goals.   We present rmc-compiler, a Clang and LLVM-based compiler for RMC-extended C and C++. In addition to using barriers to enforce ordering, rmc-compiler can take advantage of control and data dependencies, something that is beyond the abilities of current C/C++ compilers. In rmc-compiler, RMC compilation is modeled as an SMT problem with a cost term; the solution with the minimum cost determines the compilation strategy. In testing on ARM and POWER devices, RMC performs quite well, with modest performance improvements relative to C++11 on most of our data structure benchmarks and (on some architectures) dramatic improvements on a read-mostly list test that heavily benefits from use of data dependencies for ordering.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1904.05389/full.md

## Figures

6 figures with captions in the complete paper: https://tomesphere.com/paper/1904.05389/full.md

## References

28 references — full list in the complete paper: https://tomesphere.com/paper/1904.05389/full.md

---
Source: https://tomesphere.com/paper/1904.05389