LP-GEMM:将布局传播整合到GEMM操作中
LP-GEMM: Integrating Layout Propagation into GEMM Operations
AI总结:
本文提出LP-GEMM,通过分解GEMM内核实现布局传播,减少冗余数据打包,提升顺序GEMM操作性能,实验显示在x86和RISC-V架构上平均提速2.25倍。
摘要:
在科学计算和现代机器学习工作负载中,依赖性序列通用矩阵乘法(GEMM)往往主导执行时间。尽管最先进的BLAS库对单个GEMM调用进行优化,但受限于BLAS API,每个调用都需要独立打包输入矩阵并恢复输出到标准内存布局。在顺序GEMM中,这些限制导致冗余打包和解包,浪费计算资源。本文提出LP-GEMM,一种分解GEMM内核的方法,使布局传播跨顺序GEMM操作。该方法在不牺牲BLAS语义正确性的前提下消除不必要的数据重新打包。我们在x86(AVX-512)和RISC-V(RVV 1.0)架构上评估了LP-GEMM,针对MLP-like和Attention-like工作负载。结果显示,相比OpenBLAS在Intel x86上的平均提速2.25倍,与供应商优化库如Intel MKL具有竞争力。我们通过实现一个独立的C++版本Llama-3.2推理路径,仅使用BLAS级GEMM调用,证明了该方法在微基准测试之外的实用性。这些结果证实,利用操作之间的数据布局传播可以显著提升性能。
英文摘要:
In Scientific Computing and modern Machine Learning (ML) workloads, sequences of dependent General Matrix Multiplications (GEMMs) often dominate execution time. While state-of-the-art BLAS libraries aggressively optimize individual GEMM calls, they remain constrained by the BLAS API, which requires each call to independently pack input matrices and restore outputs to a canonical memory layout. In sequential GEMMs, these constraints cause redundant packing and unpacking, wasting valuable computational resources. This paper introduces LP-GEMM, a decomposition of the GEMM kernel that enables packing-layout propagation across sequential GEMM operations. This approach eliminates unnecessary data repacking while preserving full BLAS semantic correctness at the boundaries. We evaluate LP-GEMM on x86 (AVX-512) and RISC-V (RVV 1.0) architectures across MLP-like and Attention-like workloads. Our results show average speedups of 2.25x over OpenBLAS on Intel x86 for sequential GEMMs and competitive gains relative to vendor-optimized libraries such as Intel MKL. We demonstrate the practicality of the approach beyond microbenchmarks by implementing a standalone C++ version of the Llama-3.2 inference path using exclusively BLAS-level GEMM calls. These results confirm that leveraging data layout propagation between operations can significantly boost performance.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。