高级检索

    基于缓存数据重用的稀疏矩阵向量乘序列优化

    Optimizing Sequences of Sparse Matrix-Vector Multiplications via Cache Data Reuse

    • 摘要: 稀疏线性方程组求解等高性能计算应用常常涉及稀疏矩阵向量乘(SpMV)序列AxA2x, …, Asx的计算. 上述SpMV序列操作又称为稀疏矩阵幂函数MPK(matrix power kernel). 由于MPK执行多次SpMV且稀疏矩阵保持不变,在缓存(cache)中重用稀疏矩阵,可避免每次执行SpMV均从主存加载A,从而缓解SpMV访存受限问题,提升MPK性能. 但在cache数据重用会导致相邻SpMV操作之间的数据依赖,现有MPK优化多针对单次SpMV调用,或在实现数据重用时引入过多额外开销. 提出了cache感知的MPK(cache-aware MPK,Ca-MPK),基于稀疏矩阵的依赖图,设计了体系结构感知的递归划分方法,将依赖图划分为适合cache大小的子图/子矩阵,通过构建分割子图解耦数据依赖,根据特定顺序在子矩阵上调度执行SpMV,实现cache数据重用. 测试结果表明,Ca-MPK相对于Intel OneMKL库和最新MPK实现,平均性能提升分别多达约1.57倍和1.40倍.

       

      Abstract: Many high performance computing (HPC) applications such as solving sparse linear systems involve the calculation of sequences of Sparse Matrix-Vector Multiplications (SpMV) like Ax, A2x, …, Asx, which is known as the sparse Matrix Power Kernel (MPK). Since MPK calls SpMV using the same sparse matrix, reusing the matrix elements in cache, instead of repeatedly loading them from main memory, can potentially alleviate the memory-constrained problem for SpMV and enhance the performance of MPK. However, reusing the matrix introduces data dependencies between subsequent SpMVs. Prior work mainly either focus on optimizing an individual SpMV invocation, or introduce significant overheads for cache data reuse in MPK. This paper proposes a Cache-aware MPK (Ca-MPK) to optimize MPK via cache data reuse. Based on the dependency graph of a sparse matrix, an architecture-aware recursive partitioning of the graph is designed to obtain subgraphs/submatrices which are fit into cache. Separating subgraphs (i.e., separators) are constructed to decouple data dependencies among subgraphs. Then cache data reuse is achieved by executing sequences of SpMVs on subgraphs with a specified order. Performance evaluation demonstrates that Ca-MPK outperforms the MPK implementations based on the Intel OneMKL library and the state-of-the-art approach, with an average speedup of up to about 1.57 times and 1.40 times, respectively.

       

    /

    返回文章
    返回