[论文解读] Automating the Last-Mile for High Performance Dense Linear Algebra
本文提出一种分析性、模型驱动的方法,用于自动生成高性能SIMD微内核,专注于密集线性代数中的Gemm核核心外积计算。通过建模指令级并行性和寄存器使用,该方法在无需经验调优的情况下生成具有竞争力的微内核,在多种架构上实现了95–100%的OpenBLAS性能,同时保持了TLB效率。
High performance dense linear algebra (DLA) libraries often rely on a general matrix multiply (Gemm) kernel that is implemented using assembly or with vector intrinsics. In particular, the real-valued Gemm kernels provide the overwhelming fraction of performance for the complex-valued Gemm kernels, along with the entire level-3 BLAS and many of the real and complex LAPACK routines. Thus,achieving high performance for the Gemm kernel translates into a high performance linear algebra stack above this kernel. However, it is a monumental task for a domain expert to manually implement the kernel for every library-supported architecture. This leads to the belief that the craft of a Gemm kernel is more dark art than science. It is this premise that drives the popularity of autotuning with code generation in the domain of DLA. This paper, instead, focuses on an analytical approach to code generation of the Gemm kernel for different architecture, in order to shed light on the details or voo-doo required for implementing a high performance Gemm kernel. We distill the implementation of the kernel into an even smaller kernel, an outer-product, and analytically determine how available SIMD instructions can be used to compute the outer-product efficiently. We codify this approach into a system to automatically generate a high performance SIMD implementation of the Gemm kernel. Experimental results demonstrate that our approach yields generated kernels with performance that is competitive with kernels implemented manually or using empirical search.
研究动机与目标
- 为解决手动实现架构特定Gemm微内核的‘最后一公里’挑战,该挑战传统上被视为需要专家级汇编语言调优的‘黑暗艺术’。
- 从经验性自动调优转向对微内核性能的分析性建模,特别关注外积计算和指令级并行性。
- 生成在避免寄存器溢出的同时保持高性能的微内核,从而避免破坏更大规模Gemm算法中的TLB缺失避免机制。
- 证明分析性建模能够生成与手动优化实现(如OpenBLAS中的实现)相媲美、适用于多样化架构的微内核。
提出的方法
- 将微内核分解为表示外积计算的原子‘单元更新’,并通过分析模型对其性能进行分析。
- 通过分析SIMD指令如何调度以最小化获取/解码阶段和执行阶段的瓶颈,对指令级并行性进行建模。
- 通过在软件流水中改变N-更新重叠来分析性评估寄存器压力和溢出,使用PAPI测量性能和TLB缺失次数。
- 使用静态调度模型估算每个微内核变体的运行时间,从而在无需经验搜索的情况下选择最优配置。
- 将生成的微内核嵌入GotoBLAS/BLIS算法中,以确保数据移动效率和最小的TLB缺失次数。
- 该方法生成的微内核可无缝集成到更大的Gemm软件栈中,且不破坏其性能特征,特别是TLB行为。
实验结果
研究问题
- RQ1分析性模型是否能够在不依赖经验调优的情况下准确预测SIMD优化Gemm微内核的性能?
- RQ2微内核中的寄存器溢出如何影响GotoBLAS/BLIS框架中TLB缺失率和整体Gemm性能?
- RQ3针对外积计算,何种指令调度策略能最大化SIMD单元利用率并最小化流水线瓶颈?
- RQ4基于模型的代码生成系统是否能够生成与专家优化实现(如OpenBLAS中的实现)相媲美微内核?
主要发现
- 分析性模型成功识别出高性能微内核配置,而无需进行详尽搜索或自动调优。
- 生成的微内核在多种架构上实现了95–100%的OpenBLAS性能,证明其与专家调优内核具有极强的竞争力。
- 寄存器溢出不仅因内存延迟而显著降低整体Gemm性能,还通过增加TLB缺失次数破坏了算法对TLB效率的设计。
- 非均匀的N-更新大小会导致性能下降,原因在于更大的指令簇会成为获取和解码阶段的瓶颈。
- 基于模型的方法保留了GotoBLAS/BLIS算法的TLB缺失避免特性,这对端到端性能至关重要。
- 在Xeon Phi等SMP系统上并行化时,生成的微内核性能扩展特性与OpenBLAS相似,表明其具备良好的可移植性和性能可移植性。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。