arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.07056cs.DC
收藏

MAGNUS:在CPU上生成数据局部性以加速稀疏矩阵-矩阵乘法

MAGNUS: Generating Data Locality to Accelerate Sparse Matrix-Matrix Multiplication on CPUs

Jordi Wolfson-Pou, Jan Laukemann, Fabrizio Petrini

AI总结:

MAGNUS提出一种两级分层数据局部性优化算法,通过缓存友好分块和混合累加策略加速CPU上的稀疏矩阵-矩阵乘法,在SuiteSparse和随机矩阵上显著优于Intel MKL等基线并接近最优界限。

摘要:

稀疏通用矩阵-矩阵乘法(SpGEMM)是许多应用中的关键运算。当前的多线程实现基于Gustavson算法,由于累加器的缓存重用有限,在大矩阵上通常表现不佳。我们提出MAGNUS(Matrix Algebra for Gigantic NUmerical Systems,面向巨型数值系统的矩阵代数),这是一种在SpGEMM中最大化数据局部性的新算法。为了生成局部性,MAGNUS使用两级分层方法将中间乘积重排为离散的缓存友好块。累加器应用于每个块,其中块大小被选择为使累加器具有缓存效率。MAGNUS具有输入感知和系统感知能力:基于矩阵特征和目标系统规格,通过最小化必要数据结构的存储成本来计算最优块数。MAGNUS允许混合累加策略,其中每个块根据输入阈值使用不同的累加器。我们考虑两种累加器:AVX-512向量化双调排序算法和经典稠密累加。将MAGNUS的OpenMP实现与多个基线(包括Intel MKL)在三种Intel架构上的各种不同矩阵上进行了比较。对于来自SuiteSparse集合的矩阵,MAGNUS在大多数情况下比所有基线都快,并且通常比至少一个基线快一个数量级。对于大规模随机矩阵,MAGNUS可扩展到最大的矩阵规模,而基线则不能。此外,无论矩阵大小、结构和密度如何,MAGNUS都接近这些矩阵的最优界限。

英文摘要:

Sparse general matrix-matrix multiplication (SpGEMM) is a critical operation in many applications. Current multithreaded implementations are based on Gustavson's algorithm and often perform poorly on large matrices due to limited cache reuse by the accumulators. We present MAGNUS (Matrix Algebra for Gigantic NUmerical Systems), a novel algorithm to maximize data locality in SpGEMM. To generate locality, MAGNUS reorders the intermediate product into discrete cache-friendly chunks using a two-level hierarchical approach. The accumulator is applied to each chunk, where the chunk size is chosen such that the accumulator is cache-efficient. MAGNUS is input- and system-aware: based on the matrix characteristics and target system specifications, the optimal number of chunks is computed by minimizing the storage cost of the necessary data structures. MAGNUS allows for a hybrid accumulation strategy in which each chunk uses a different accumulator based on an input threshold. We consider two accumulators: an AVX-512 vectorized bitonic sorting algorithm and classical dense accumulation. An OpenMP implementation of MAGNUS is compared with several baselines, including Intel MKL, for a variety of different matrices on three Intel architectures. For matrices from the SuiteSparse collection, MAGNUS is faster than all the baselines in most cases and is often an order of magnitude faster than at least one baseline. For massive random matrices, MAGNUS scales to the largest matrix sizes, while the baselines do not. Furthermore, MAGNUS is close to the optimal bound for these matrices, regardless of the matrix size, structure, and density.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑