[论文解读] Efficient Synchronization Primitives for GPUs
本文提出了一组高性能的同步原语——屏障、互斥锁和信号量——专门针对GPU进行优化,通过最大限度减少原子操作(其速度远慢于普通内存访问)来实现。作者提出了一种GPU内存系统抽象,对Tesla和Fermi GPU进行基准测试以指导实现,并在高竞争环境下实现相较于自旋锁基线的高达70倍性能提升,同时提供一个高层级、可移植的库,能够根据GPU架构自动适应。
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.
研究动机与目标
- 解决尽管GPU在复杂、控制密集型工作负载中应用日益广泛,但缺乏高性能、GPU优化的同步原语的问题。
- 识别并克服将现有CPU同步模式应用于GPU架构时的局限性。
- 为GPU内存系统建立性能模型,以指导同步原语的高效实现。
- 开发一个可移植的高层级同步原语库,能够根据GPU架构自动选择最优实现方式。
- 基于GPU特性与竞争程度,提供使用自旋等待与睡眠等待策略的指导原则。
提出的方法
- 设计一种机器抽象,根据内存系统行为(特别是原子访问与非易失性内存访问速度之比)对GPU进行分类。
- 在Tesla和Fermi GPU上实现并基准测试一整套内存系统测试,以识别性能瓶颈并指导原语设计。
- 通过尽可能用非原子操作替代原子操作,优化同步原语以减少延迟。
- 设计一个高层级C++库抽象,提供类似CPU风格的语义(如lock()、unlock()),并支持多种底层实现方式。
- 在互斥锁中引入退避策略,在信号量中引入睡眠等待机制,以降低高竞争工作负载下的竞争开销。
- 通过抽象进行外推,预测未来GPU性能,特别是在不同竞争程度和原子操作速度提升情况下的表现。
实验结果
研究问题
- RQ1GPU上原子访问与非易失性内存访问的性能特征与CPU有何不同?这些差异如何影响同步原语的设计?
- RQ2在GPU同步中,自旋等待与睡眠等待策略的最优平衡点是什么?该平衡如何依赖于GPU架构与竞争程度?
- RQ3能否设计出在现代GPU上最小化原子操作、同时保持正确性与高性能的同步原语?
- RQ4如何构建一个可移植的高层级同步库,使其能根据GPU的内存系统特性自动选择最佳实现方式?
- RQ5随着原子操作速度相对于非易失性内存加载速度的提升,未来GPU上可预期的性能提升幅度是多少?
主要发现
- 在Tesla GPU上,FA互斥锁比自旋锁快近40倍,证明了退避机制与原子操作减少的有效性。
- 在Fermi GPU上,向自旋锁添加退避机制可使性能提升近40%,凸显了面向竞争的架构设计的重要性。
- 在Tesla上,睡眠信号量比自旋锁信号量快逾3倍,在Fermi上则快逾70倍,表明在高竞争环境下睡眠等待机制具有显著优势。
- 原子访问与非易失性访问速度之比是关键影响因素——在Fermi上,该比值约为10:1,严重制约了自旋原语的性能。
- 作者预测,随着原子操作速度趋近非易失性内存访问速度,退避机制将成为实现高性能的主导因素。
- 若硬件原生支持全局屏障(如__syncblocks()),将能进一步提升FFT和位域排序等算法的性能,并可无缝集成到该库中。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。