Adding Explicit Load-Acquire and Store-Release Instructions to the RISC-V ISA

Bryce Adern, Zachary Susskind, Brendan SweeneyarXiv 2023 · DOI · arXiv

This research explores a critical evolution for the RISC-V architecture: the formal addition of explicit load-acquire (ld.aq) and store-release (st.rl) instructions. By formalizing these instructions and evaluating them through formal modeling, simulation, and proxy hardware studies, the authors argue that these "one-way" memory barriers are essential for both performance optimization and the long-term stability of the RISC-V ecosystem.

The Synchronization Gap in RISC-V

Modern processors utilize Weak Memory Ordering (WMO) to optimize performance by executing memory operations out of the order written in the source code. While beneficial for single-threaded speed, this creates challenges for multi-threaded programming where one thread must ensure another has completed specific data writes before proceeding.

Currently, RISC-V manages these dependencies using "fences"—bi-directional barriers that halt all reordering across the instruction. However, fences are often considered "heavyweight" because they block more reordering than is strictly necessary for many common synchronization patterns. Most patterns only require a one-way barrier:

  • Load-Acquire: Ensures subsequent reads/writes do not occur before this load.
  • Store-Release: Ensures previous reads/writes are finalized before this store.
Comparison of memory ordering scenarios: (Left) Incorrect reordering without synchronization, (Middle) Efficient ordering with proposed load-acquire/store-release, (Right) Heavyweight ordering with traditional fences.

Without these specific instructions in the RISC-V standard, hardware vendors may implement proprietary high-performance versions. This risks ABI (Application Binary Interface) fragmentation, where software compiled for one RISC-V implementation may not run optimally—or at all—on another.

Methodology

The researchers evaluated the proposed instructions through a three-pronged approach:

  1. Formal Modeling: They updated the herd toolsuite, which uses axiomatic models to define hardware behaviors, to include ld.aq and st.rl. This provided a mathematical verification of the instructions' behavior using assembly-level "litmus tests."
  2. Architectural Simulation: The team modified the gem5 simulator with custom RISC-V opcodes to test the integration of these instructions into a cycle-accurate CPU model.
  3. Proxy Performance Study: In the absence of native RISC-V hardware supporting these extensions, the researchers used an Apple M1 (AArch64) as a proxy. They modified the Clang compiler to create a "dumb" version that avoids ARM’s native acquire/release instructions, forcing the use of heavy fences instead. This allowed for a direct comparison between optimized and unoptimized synchronization on real silicon using production-grade lock-free benchmarks.

Key Findings and the "Performance Paradox"

The study revealed several critical insights into the current state of RISC-V development tools and the nuances of memory ordering:

  • Simulator Fidelity Issues: A significant discovery was that the popular gem5 simulator currently treats acquire/release operations as full fences internally. This limitation prevents researchers from accurately measuring the performance gains of these instructions in simulation, highlighting a need for better memory consistency modeling in the research community.
  • Compiler Overhead: The "dumb" compiler used in the proxy study emitted approximately 4.5x more data barriers than the standard compiler to achieve the same level of thread safety, illustrating the inefficiency of relying solely on traditional fences.
  • Contention vs. Ordering: On the M1 proxy, the researchers observed a "performance paradox" where the fence-heavy version occasionally outperformed the optimized version in high-contention scenarios. They attribute this to the relative immaturity of compiler support for these specific primitives compared to long-established fence implementations, as well as the high overhead of data movement between cores which can mask ordering benefits.

Conclusion

The authors emphasize that adding ld.aq and st.rl is a "ratification emergency." To prevent the RISC-V ecosystem from splintering into proprietary, incompatible synchronization implementations, these instructions must be formalized in the RISC-V Platform Specification. Future work will focus on improving simulator accuracy and testing on native RISC-V silicon as implementations become available.

Summary updated

BibTeX
@misc{adern2023adding,
  author = {Bryce Adern and Zachary Susskind and Brendan Sweeney},
  title = {{Adding Explicit Load-Acquire and Store-Release Instructions to the RISC-V ISA}},
  year = {2023},
  eprint = {2302.03732},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2302.03732},
}
Figure