Introduction
Sparse-dense matrix-matrix multiplication (SpDM) is a fundamental operation in various computational domains, including scientific simulations, graph analytics, and the emerging field of sparse deep learning. While theoretically more efficient than dense multiplication due to the high number of zero elements, achieving practical performance gains on GPUs is notoriously difficult. Researchers from Hong Kong Baptist University have addressed this by introducing GCOOSpDM, a GPU-accelerated algorithm utilizing a novel "Grouped Coordinate" (GCOO) storage format.
The Sparsity Challenge
GPUs are optimized for high-throughput, contiguous memory access. Sparse matrices, characterized by non-zero elements scattered across memory, force GPUs into "irregular" access patterns. This leads to high latency and underutilization of compute cores. Consequently, standard dense libraries like Nvidia’s cuBLAS often outperform sparse libraries like cuSPARSE unless the matrix sparsity exceeds 99%. This "sparsity tax" significantly limits the practical application of sparse neural networks and large-scale graph processing.
The GCOOSpDM Algorithm
To overcome these bottlenecks, the authors developed the GCOO format and a corresponding algorithm designed to maximize operational intensity and memory efficiency by leveraging the GPU's memory hierarchy.
The GCOOSpDM approach involves several key innovations:
- GCOO (Grouped Coordinate) Format: The sparse matrix is partitioned into groups based on column ranges, ensuring each group fits within the resources of a single GPU thread block.
- Shared Memory Exploitation: Sparse indices are loaded into the GPU's fast shared memory. This allows threads within a block to broadcast-read data, minimizing slow trips to global DRAM.
- Operational Intensity: The algorithm is structured to reuse dense matrix values. If multiple non-zero elements in a group share a row, the corresponding dense value is fetched once and stored in a register for multiple calculations.
- Coalesced Access: By storing dense matrices in column-major order, the algorithm ensures that concurrent memory requests from different threads target adjacent addresses, optimizing GPU bandwidth.
Experimental Evaluation
The algorithm was rigorously tested using two primary datasets:
- SuiteSparse Matrix Collection: 2,694 real-world matrices from diverse fields (e.g., quantum chemistry, economics) with sparsity levels between 98% and 99.9999%.
- Synthetic Matrices: 6,968 generated matrices used to evaluate scaling across dimensions (400 to 14,500) and uniform sparsity levels.
Results and Discussion
GCOOSpDM demonstrates a significant performance advantage over the industry-standard cuSPARSE library across multiple generations of GPU hardware.
Key findings include:
- Lowered Sparsity Threshold: While cuSPARSE typically requires >99.5% sparsity to outperform dense methods, GCOOSpDM achieves superior performance at just 98% sparsity.
- Consistent Speedups: The algorithm outperformed cuSPARSE on 78% to 90% of real-world matrices across Maxwell (GTX 980), Pascal (Titan X), and Pascal (Tesla P100) architectures.
- Peak Throughput: On the Tesla P100, GCOOSpDM achieved an average speedup of 1.68x, with peak performance reaching over 4x that of cuSPARSE.
- Scalability: The performance gap widens as matrix size increases, indicating that the grouped approach effectively manages large-scale data.
Instruction-level profiling using nvprof confirmed that GCOOSpDM successfully shifts the bottleneck from the L2 cache and DRAM to the L1 cache and shared memory, which offer significantly higher bandwidth.
Conclusion and Future Work
GCOOSpDM represents a major step forward in making sparse computations practical for a wider range of applications. While it excels on large, highly sparse matrices, it faces limitations with very small matrices (under 1500x1500) due to conversion overhead and specific patterns like strictly diagonal matrices. Future research will focus on an auto-tuning system to optimize group and thread block sizes dynamically and extending the GCOO format to sparse-sparse matrix multiplication.
Summary updated