通过仅编译器实现的分层数据重组与内建函数降级加速矩阵乘法
Fast Matrix Multiplication via Compiler-only Layered Data Reorganization and Intrinsic Lowering
AI总结:
本文首次在 LLVM 编译器中自动生成分层分块、打包与微内核方案,利用矩阵乘法内建函数实现可重定向的高性能矩阵乘法,在无矩阵引擎处理器上显著超越 PLuTo 并接近 OpenBLAS/Eigen,在 POWER10 MMA 上达到 BLAS 峰值性能的 96%。
摘要:
机器学习的复兴增加了对高性能基础线性代数子程序(BLAS)的需求,长期以来这些子程序依赖库在通用硬件上达到峰值性能。高性能 BLAS 实现依赖一种分层方法,包括用于数据(重)组织的分块层和打包层,以及执行实际计算的微内核。创建高性能微内核需要大量开发工作,为每种架构编写定制的汇编代码。最近 IBM 的 POWER10 MMA、Intel AMX 和 Arm ME 引入了矩阵引擎以提供高性能矩阵运算,使这一手工优化任务变得更加复杂。本文提出了一种仅使用编译器的替代方案,以替代高性能库的使用,据我们所知首次将分层方法的自动生成集成到生产编译器 LLVM 中。算法的模块化设计,例如使用 LLVM 的矩阵乘法内建函数作为分块层、打包层与微内核之间的清晰接口,使得代码生成易于重定向到多个加速器。内建函数的使用支持全面的性能研究。在没有硬件矩阵引擎的处理器上,分块和打包在小矩阵上性能比广泛使用的多面体优化器 PLuTo 快达 22 倍(Intel),在大矩阵上快 6 倍以上(POWER9)。该性能也接近高性能库,在大矩阵上仅比 OpenBLAS 慢 34%,与 Eigen 持平。在 POWER10 上使用 MMA 时,该方案在大矩阵上比向量扩展方案快 2.6 倍以上,与 Eigen 性能相当,并达到 BLAS 峰值性能的 96%。
英文摘要:
The resurgence of machine learning has increased the demand for high-performance basic linear algebra subroutines (BLAS), which have long depended on libraries to achieve peak performance on commodity hardware. High-performance BLAS implementations rely on a layered approach that consists of tiling and packing layers, for data (re)organization, and micro kernels that perform the actual computations. The creation of high-performance micro kernels requires significant development effort to write tailored assembly code for each architecture. This hand optimization task is complicated by the recent introduction of matrix engines by IBM's POWER10 MMA, Intel AMX, and Arm ME to deliver high-performance matrix operations. This paper presents a compiler-only alternative to the use of high-performance libraries by incorporating, to the best of our knowledge and for the first time, the automatic generation of the layered approach into LLVM, a production compiler. Modular design of the algorithm, such as the use of LLVM's matrix-multiply intrinsic for a clear interface between the tiling and packing layers and the micro kernel, makes it easy to retarget the code generation to multiple accelerators. The use of intrinsics enables a comprehensive performance study. In processors without hardware matrix engines, the tiling and packing delivers performance up to 22x (Intel), for small matrices, and more than 6x (POWER9), for large matrices, faster than PLuTo, a widely used polyhedral optimizer. The performance also approaches high-performance libraries and is only 34% slower than OpenBLAS and on-par with Eigen for large matrices. With MMA in POWER10 this solution is, for large matrices, over 2.6x faster than the vector-extension solution, matches Eigen performance, and achieves up to 96% of BLAS peak performance.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。