SSpMV: A Sparsity-Aware Framework for Adaptive Sparse Matrix–Vector Multiplication
Abstract
Sparse Matrix-Vector Multiplication (SpMV) is a fundamental sparse kernel in both scientific computing and artificial intelligence. However, the performance of existing SpMV algorithms is highly sensitive to diverse sparsity patterns, necessitating an adaptive framework that can effectively extract matrix structures and predict optimal configurations. In this work, we first analyze the performance of parallel SpMV algorithms in various formats. Based on the analysis, we propose Sparsity-aware SpMV (SSpMV), a framework that integrates handcrafted expert features with multimodal representations to automatically determine the optimal algorithm and parameters. At its core is MM-Adapter, a novel multimodal convolutional neural network designed for this selection task. The robustness of SSpMV is validated using a diverse dataset, consisting of nearly the entire SuiteSparse Collection supplemented by finite element matrices. On an Intel Xeon 5120 CPU, SSpMV achieves a selection accuracy of <inline-formula><tex-math notation="LaTeX">$81.05\%$</tex-math><alternatives><mml:math><mml:mn>81.05</mml:mn><mml:mi mathvariant="normal">%</mml:mi></mml:math><inline-graphic xlink:href="lin-ieq1-3730889.gif"/></alternatives></inline-formula> and a geometric speedup of <inline-formula><tex-math notation="LaTeX">$1.26{\boldsymbol{\times}}$</tex-math><alternatives><mml:math><mml:mn>1.26</mml:mn><mml:mrow><mml:mo mathvariant="bold">×</mml:mo></mml:mrow></mml:math><inline-graphic xlink:href="lin-ieq2-3730889.gif"/></alternatives></inline-formula> over the MKL spblas IE. Furthermore, on an NVIDIA A100 GPU, it yields <inline-formula><tex-math notation="LaTeX">$74.12\%$</tex-math><alternatives><mml:math><mml:mn>74.12</mml:mn><mml:mi mathvariant="normal">%</mml:mi></mml:math><inline-graphic xlink:href="lin-ieq3-3730889.gif"/></alternatives></inline-formula> accuracy and a <inline-formula><tex-math notation="LaTeX">$1.31{\boldsymbol{\times}}$</tex-math><alternatives><mml:math><mml:mn>1.31</mml:mn><mml:mrow><mml:mo mathvariant="bold">×</mml:mo></mml:mrow></mml:math><inline-graphic xlink:href="lin-ieq4-3730889.gif"/></alternatives></inline-formula> speedup over the cuSPARSE baseline.