降低共享内存占用以利用Tensor Core的高吞吐量及其灵活API扩展库
Reducing shared memory footprint to leverage high throughput on Tensor Cores and its flexible API extension library
AI总结:
针对Tensor Core使用中共享内存带宽瓶颈问题,提出含灵活寄存器操控、无额外共享内存SGEMM仿真双组件的WMMA API扩展库,降低共享内存占用,在A100上实现超FP32 SIMT峰值且精度对标cuBLAS的单精度批量SGEMM性能。
摘要:
NVIDIA Tensor Core是一种混合精度矩阵乘法与加法计算单元,在NVIDIA A100 GPU上的理论峰值性能超过300 TFlop/s。NVIDIA提供了WMMA API,用于在自定义内核函数中调用Tensor Core。使用Tensor Core最常见的方式是从共享内存提供输入矩阵,因为共享内存的带宽高于全局内存。但由于Tensor Core的性能极高,共享内存与Tensor Core的字节每浮点运算(B/F)比值很小,因此降低共享内存占用对于高效使用Tensor Core至关重要。\n本文通过roofline模型(屋顶线模型)分析了Tensor Core上的简单矩阵乘法运算,发现使用WMMA API时,共享内存带宽可能成为性能瓶颈。为缓解这一问题,我们提出了一个WMMA API扩展库以提升计算吞吐量,该库包含两个组件。第一个组件支持灵活操控输入到Tensor Core的寄存器数组。我们评估了该库的性能提升效果,评估结果显示,我们的库减少了共享内存占用,并加快了Tensor Core的计算速度。第二个组件是无需额外共享内存即可在Tensor Core上实现SGEMM仿真的API。我们验证了使用该库在Tensor Core上实现的单精度仿真批量SGEMM,在A100 GPU上可达54.2 TFlop/s,性能超过FP32 SIMT Core的理论峰值,同时精度与cuBLAS处于同一水平。若没有我们的库在相同寄存器用量下实现的共享内存占用降低,这一吞吐量是无法达成的。
英文摘要:
NVIDIA Tensor Core is a mixed-precision matrix-matrix multiplication and addition computing unit, where the theoretical peak performance is more than 300 TFlop/s on NVIDIA A100 GPU. NVIDIA provides WMMA API for using Tensor Cores in custom kernel functions. The most common way to use Tensor Core is to supply the input matrices from shared memory, which has higher bandwidth than global memory. However, the Bytes-per-Flops (B/F) ratio of the shared memory and Tensor Cores is small since the performance of Tensor Cores is high. Thus, it is important to reduce the shared memory footprint for efficient Tensor Cores usage. In this paper, we analyze the simple matrix-matrix multiplication on Tensor Cores by the roofline model and figure out that the bandwidth of shared memory might be a limitation of the performance when using WMMA API. To alleviate this issue, we provide a WMMA API extension library to boost the throughput of the computation, which has two components. The first one allows for manipulating the array of registers input to Tensor Cores flexibly. We evaluate the performance improvement of this library. The outcome of our evaluation shows that our library reduces the shared memory footprint and speeds up the computation using Tensor Cores. The second one is an API for the SGEMM emulation on Tensor Cores without additional shared memory usage. We have demonstrated that the single-precision emulating batch SGEMM implementation on Tensor Cores using this library achieves 54.2 TFlop/s on A100 GPU, which outperforms the theoretical peak performance of FP32 SIMT Cores while achieving the same level of accuracy as cuBLAS. The achieved throughput can not be achieved without reducing the shared memory footprint done by our library with the same amount of register usage.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。