NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Improving SpGEMM Performance Through Matrix-Reordering and Cluster-wise Computation

Abdullah Al Raqibul Islam, Helen Xu, Dong Dai, Aydin BuluçSC 2025

Abstract

Sparse matrix-sparse matrix multiplication (SpGEMM) is a foundational operation in graph analytics, deep learning, and scientific simulations. Despite its importance, SpGEMM is notoriously memory-bound due to irregular memory access patterns that lead to poor cache utilization. This paper introduces a hierarchical clustering framework designed to enhance temporal locality. By employing a fast, SpGEMM-based similarity search and a novel "CSR_Cluster" storage format, the framework groups similar rows to maximize data reuse. Experimental results across 110 diverse matrices demonstrate a 1.39× average speedup, with preprocessing overhead significantly lower than prior state-of-the-art reordering methods.

1. Introduction

SpGEMM serves as the computational engine for various high-level algorithms, including triangle counting in graphs and multi-grid solvers in scientific computing. The standard approach to SpGEMM, often based on Gustavson’s algorithm, involves iterating through the rows of a matrix $A$ and fetching corresponding rows of a matrix $B$. However, the performance of this operation is frequently limited by the memory subsystem rather than the processor's arithmetic throughput. When consecutive rows in $A$ possess non-zero elements in disparate columns, the system is forced to fetch unrelated rows of $B$, leading to constant cache "thrashing."

While row reordering is a known strategy to improve locality, existing high-quality algorithms (such as those based on graph partitioning) often incur a preprocessing cost 100× greater than the multiplication itself. This makes them impractical for scenarios where the multiplication is performed only a few times. This paper addresses this gap by proposing a low-overhead clustering and execution model.

2. The Hierarchical Clustering Framework

The proposed solution shifts the focus from simple row reordering to a integrated model of clustering and specialized computation. The framework consists of three primary components:

To group similar rows efficiently, the authors utilize the SpGEMM operation itself. By performing a symbolic multiplication of $A \times A^T$ (treating all non-zero values as 1), the system can identify rows that share the most non-zero columns. This approach provides a structural measure of similarity that is more accurate than traditional Locality-Sensitive Hashing (LSH) and fast enough to remain practical as a preprocessing step.

2.2 The CSR_Cluster Storage Format

Standard storage formats like Compressed Sparse Row (CSR) do not inherently exploit row similarity. The authors introduce "CSR_Cluster," a format that explicitly groups similar rows into clusters. Within these clusters, non-zero elements are stored collectively by column. This format not only facilitates better access patterns but also reduces memory footprint by storing fewer column indices compared to standard CSR.

2.3 Cluster-wise Execution

The SpGEMM kernel is redesigned to operate on these clusters rather than individual rows. When a row of matrix $B$ is loaded into the cache, the execution logic ensures it is immediately utilized for all rows within the current cluster of $A$ that require it. This strategy maximizes temporal locality and ensures that rows of $B$ are not evicted prematurely.

3. Experimental Evaluation

The framework was evaluated using 110 matrices from the SuiteSparse Matrix Collection, focusing on square matrices with 8 million to 10 billion non-zeros to ensure the data exceeded L2 cache capacity while fitting within system memory. The study tested two primary workloads: matrix squaring ($A^2$) and multiplying a sparse matrix by a "tall-skinny" matrix (common in graph-based Breadth-First Searches).

3.1 Performance and Efficiency

The hierarchical clustering approach achieved a geomean speedup of 1.39× across the test suite, with peak performance reaching 4.68×. Notably, the method improved performance on 70% of all tested inputs.

3.2 Preprocessing Overhead

A critical advantage of this framework is its low overhead. For 90% of the tested matrices, the cost of clustering was amortized in fewer than 20 SpGEMM iterations. In contrast, traditional graph-based reordering (GP) often requires hundreds of iterations to reach a break-even point, making the hierarchical approach far more suitable for dynamic or one-off computations.

4. Key Insights

  • Format Over Order: The research suggests that reordering rows is insufficient on its own; the hardware requires a data layout (like CSR_Cluster) that explicitly prevents the cache from evicting shared data.
  • The Preprocessing Pareto Frontier: Hierarchical clustering occupies a "sweet spot" in the trade-off between preprocessing time and execution speedup, offering better performance than simple degree-based reordering while remaining significantly faster than complex graph partitioning.
  • Versatility: The framework is modular, allowing users to layer cluster-wise computation on top of other reordering algorithms like METIS or RCM to further enhance performance.

5. Conclusion and Future Work

This work demonstrates that SpGEMM performance can be significantly improved by aligning data storage and execution logic with the underlying structural similarity of the matrices. While currently optimized for multi-core CPUs using OpenMP, the logic of CSR_Cluster and hierarchical grouping provides a roadmap for future GPU implementations. Future research may also explore predictive modeling to automatically select the optimal combination of reordering and clustering based on a matrix's specific sparsity "fingerprint."

Summary updated

BibTeX
@inproceedings{islam2025improving,
  author = {Abdullah Al Raqibul Islam and Helen Xu and Dong Dai and Aydin Buluç},
  title = {{Improving SpGEMM Performance Through Matrix-Reordering and Cluster-wise Computation}},
  booktitle = {SC},
  year = {2025},
}
Figure