[Paper Review] Efficient Synchronization Primitives for GPUs
This paper presents high-performance synchronization primitives—barriers, mutexes, and semaphores—specifically optimized for GPUs by minimizing atomic operations, which are significantly slower than regular memory accesses. The authors introduce a GPU memory system abstraction, benchmark Tesla and Fermi GPUs to guide implementation, and achieve up to 70× speedup over spin-lock baselines, especially under contention, with a high-level, portable library that adapts to GPU architecture.
In this paper, we revisit the design of synchronization primitives---specifically barriers, mutexes, and semaphores---and how they apply to the GPU. Previous implementations are insufficient due to the discrepancies in hardware and programming model of the GPU and CPU. We create new implementations in CUDA and analyze the performance of spinning on the GPU, as well as a method of sleeping on the GPU, by running a set of memory-system benchmarks on two of the most common GPUs in use, the Tesla- and Fermi-class GPUs from NVIDIA. From our results we define higher-level principles that are valid for generic many-core processors, the most important of which is to limit the number of atomic accesses required for a synchronization operation because atomic accesses are slower than regular memory accesses. We use the results of the benchmarks to critique existing synchronization algorithms and guide our new implementations, and then define an abstraction of GPUs to classify any GPU based on the behavior of the memory system. We use this abstraction to create suitable implementations of the primitives specifically targeting the GPU, and analyze the performance of these algorithms on Tesla and Fermi. We then predict performance on future GPUs based on characteristics of the abstraction. We also examine the roles of spin waiting and sleep waiting in each primitive and how their performance varies based on the machine abstraction, then give a set of guidelines for when each strategy is useful based on the characteristics of the GPU and expected contention.
Motivation & Objective
- To address the lack of high-performance, GPU-optimized synchronization primitives despite growing use of GPUs for complex, control-intensive workloads.
- To identify and overcome the limitations of existing CPU-based synchronization patterns when applied to GPU architectures.
- To develop a performance model for GPU memory systems that guides efficient implementation of synchronization primitives.
- To create a portable, high-level library of synchronization primitives that automatically selects optimal implementations based on GPU architecture.
- To provide guidelines for when to use spin-waiting versus sleep-waiting strategies based on GPU characteristics and contention levels.
Proposed method
- Design a machine abstraction to classify GPUs based on memory system behavior, particularly the ratio of atomic to volatile memory access speeds.
- Implement and benchmark a suite of memory-system tests on Tesla and Fermi GPUs to characterize performance bottlenecks and inform primitive design.
- Optimize synchronization primitives by replacing as many atomic operations as possible with non-atomic operations to reduce latency.
- Develop a high-level C++ library abstraction with familiar CPU-style semantics (e.g., lock(), unlock()) that supports multiple underlying implementations.
- Introduce a backoff strategy in mutexes and a sleep-waiting mechanism in semaphores to reduce contention overhead on high-contention workloads.
- Predict future GPU performance by extrapolating from the abstraction, especially under varying contention and atomic speed improvements.
Experimental results
Research questions
- RQ1How do the performance characteristics of atomic and volatile memory accesses on GPUs differ from those on CPUs, and how do they affect synchronization primitive design?
- RQ2What is the optimal balance between spin-waiting and sleep-waiting strategies in GPU synchronization, and how does it depend on GPU architecture and contention?
- RQ3Can synchronization primitives be designed to minimize atomic operations while maintaining correctness and performance on modern GPUs?
- RQ4How can a portable, high-level synchronization library be built that automatically selects the best implementation for a given GPU based on its memory system properties?
- RQ5What performance improvements can be expected on future GPUs as atomic operations become faster relative to volatile loads?
Key findings
- The FA mutex is nearly 40× faster than a spin lock on Tesla GPUs, demonstrating the effectiveness of backoff and reduced atomic usage.
- On Fermi GPUs, adding backoff to a spin lock improves performance by nearly 40%, highlighting the importance of contention-aware design.
- The sleeping semaphore is more than 3× faster than a spin-lock semaphore on Tesla and over 70× faster on Fermi, showing the benefit of sleep-waiting under high contention.
- The performance gap between atomic and volatile accesses is a critical factor—on Fermi, this ratio is approximately 10:1, severely impacting spinning primitives.
- The authors predict that as atomic operations approach volatile access speed, backoff mechanisms will become the dominant factor in achieving high performance.
- Hardware support for a global barrier (e.g., __syncblocks()) could further improve performance for algorithms like FFT and bitonic sort, and could be seamlessly integrated into the library.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.