High-Performance GEMV on AMD Zen 3 via Architecture-Specific AVX2/FMA Optimization
Abstract
The General Matrix-Vector Multiply (GEMV) is a fundamental Level-2 BLAS operation appearing throughout scientific computing and numerical linear algebra. GEMV is inherently memory-bound, making effective cache use the dominant optimization factor.We present a hand-optimized GEMV kernel for AMD Zen 3, implemented using AVX2 (Advanced Vector Extensions 2) and FMA (fused multiply-add) intrinsics. Our single-threaded kernel (ZenGEMV) processes 4 rows simultaneously with dual accumulators per row, creating 8 independent FMA chains that fully saturate the Zen 3 pipeline. Benchmarked against OpenBLAS 0.3.31 and AOCL-BLAS 5.2.0 on an AMD Ryzen 5 5600, ZenGEMV achieves up to 1.37× speedup over OpenBLAS and 1.20× over AOCL-BLAS. Our parallel variant (ZenGEMV-P) achieves up to $3.22 \times$ speedup over OpenBLAS on small matrices.We analyse why dispatch overhead, suboptimal accumulator strategies, and generic design choices in general-purpose BLAS libraries leave performance gains available in architecture-specific workloads.