TL;DR
This paper introduces a family of high-performance parallel algorithms for SpKAdd, the operation of summing a collection of $k$ sparse matrices. By moving beyond suboptimal pairwise additions and introducing a novel "sliding hash" technique that optimizes for CPU cache locality, the authors achieved a 2x speedup in distributed sparse matrix-matrix multiplication (SpGEMM) on large-scale supercomputers.
What Problem Does This Paper Address?
While adding two sparse matrices is a staple of scientific computing (found in MATLAB, Python’s SciPy, and Intel MKL), adding a large collection of them is an overlooked bottleneck. This operation, termed SpKAdd, is critical for:
- Distributed SpGEMM: Where processors must sum intermediate products.
- Deep Learning: Specifically the "sparse allreduce" problem, where gradient updates are sparsified to save communication bandwidth.
- Finite Element Methods: Assembling local element matrices into a global system.
The "naive" approach is to add matrices incrementally (A + B, then + C, etc.). However, this is computationally expensive and creates massive data movement. Existing libraries often lack a unified, work-efficient "k-way" addition routine that scales well on modern multi-core processors.
Methods
The authors systematically evaluated several data structures for k-way column merging:
- 2-way Tree Merging: Instead of a linear chain, matrices are added in a balanced binary tree, reducing complexity to $O(ndk \log k)$.
- Heaps: Using a min-heap to track the smallest row index across $k$ columns.
- Sparse Accumulator (SPA): Using a dense array to accumulate values. It's fast but has a massive memory footprint that can exceed 100GB for very large matrices.
- Hash Tables: Using a hash table to accumulate non-zeros. This is work-efficient and generally faster than heaps.
- The "Sliding Hash" (Novel): This is the paper's primary algorithmic contribution. Standard hash tables can suffer from performance degradation if they grow larger than the CPU's Last Level Cache (LLC). The sliding hash partitions the matrix rows into "chunks" that fit entirely within the cache, processing one chunk across all matrices before moving to the next. This ensures that random memory accesses stay "local" and fast.
Datasets
The algorithms were stress-tested using both synthetic and massive real-world datasets:
- Synthetic: Erdős-Rényi (ER) matrices (uniform distribution) and R-MAT matrices (power-law distribution, mimicking social networks).
- Real-World Protein Networks:
- Eukarya: 3M rows/cols, 360M non-zeros.
- Isolates: 35M rows/cols, 17B non-zeros.
- Metaclust50: 282M rows/cols, 37B non-zeros.
Key Insights and Ideas
- Cache is King: The transition from a standard hash to a "sliding hash" demonstrates that for sparse operations, memory latency and cache misses are often bigger bottlenecks than raw operation counts.
- The Density Paradox: For skewed matrices (like R-MAT), 2-way tree additions can actually outperform hash-based methods for small $k$. This is because a few very dense columns dominate the computation, and simply "streaming" those dense columns is more efficient than hashing thousands of sparse entries into a table.
- Parallelism without Locks: The algorithms are designed to be "embarrassingly parallel" by partitioning the work by matrix columns. Each thread manages its own private data structures (like a private hash table), eliminating the need for expensive thread synchronization or locks.
Key Results
- Theoretical Bounds: The hash-based SpKAdd attains the theoretical lower bounds for both computational complexity and I/O complexity.
- Hardware Performance: On an Intel Skylake processor, the sliding hash significantly outperformed all other methods when the number of matrices ($k$) or the density ($d$) caused the working set to exceed the 32MB L3 cache.
- Supercomputer Scaling: The authors integrated their hash-based SpKAdd into the CombBLAS library. When running a distributed SpGEMM on 2,048 nodes of a Cray XC40 supercomputer, the new algorithm made the overall computation 2x faster than the previous state-of-the-art implementation.
Limitations and Future Work
The current study assumes that all input matrices fit within the system's main memory (RAM). In scenarios involving truly "Big Data" or streaming applications where matrices arrive in a continuous flow, this assumption might break.
The authors suggest that streaming SpKAdd algorithms—which could process matrices as they arrive or handle out-of-core data (stored on disk)—represent the next logical step for this research. Additionally, further optimizations could be explored for GPU architectures, which have different cache hierarchies than the CPUs tested here.
Summary updated