In scientific computing—ranging from climate modeling to machine learning—researchers frequently encounter large dense matrices. For a dataset with one million points, a standard dense representation requires $O(n^2)$ storage, or roughly a trillion entries, which exceeds the memory capacity of modern hardware. Hierarchical matrices address this by exploiting "data sparsity," recognizing that many blocks within these large matrices are low-rank and can be compressed.
This paper, published in 2019, presents a significant advancement in making hierarchical matrix operations practical for high-performance computing. By porting complex $\mathcal{H}^2$ matrix structures to GPUs, the authors demonstrate that massive, dense-like datasets can be handled with the efficiency of sparse methods, achieving $O(n)$ complexity for both storage and operations.
The $\mathcal{H}^2$ Matrix Framework
The authors focus on the $\mathcal{H}^2$ variant of hierarchical matrices, which utilizes nested bases to achieve optimal linear complexity. Unlike simpler hierarchical formats, $\mathcal{H}^2$ matrices share basis information across different levels of the hierarchy, significantly reducing the memory footprint and computational cost.
As shown in the conceptual overview, the structure consists of a row tree $\mathcal{U}$, a column tree $\mathcal{V}$, and a set of coupling matrices $\mathcal{S}$. While these structures are mathematically elegant, they are traditionally implemented using irregular trees and recursion—structures that CPUs handle reasonably well but which typically cause significant performance degradation on GPUs due to thread divergence and irregular memory access.
GPU-Optimized Implementation
To bridge the gap between irregular tree structures and the massive throughput of GPUs, the authors developed three technical pillars:
1. Flattened Tree Structures
Instead of using traditional pointers and recursion, the implementation represents the tree using three simple arrays: head, next, and parent. This "flattening" allows the GPU to process the tree level-by-level in a non-recursive, parallel fashion, ensuring that all threads in a warp perform similar work.
2. Marshaling Kernels
The core innovation lies in the use of specialized "marshaling kernels." Before executing heavy linear algebra operations, such as QR decomposition or matrix-vector products, these kernels gather irregularly laid-out data pointers into contiguous batches. This allows the system to utilize high-performance "batched" linear algebra routines (like those in CUBLAS or MAGMA) without actually moving heavy blocks of memory, as the marshaling only involves pointer arithmetic.
3. Kernel Streaming and Priorities
Tree operations often involve small matrix blocks at the upper levels that fail to saturate the GPU's compute units. The authors utilized CUDA stream priorities to overlap these latency-sensitive top-tree operations with the large, throughput-heavy dense block operations at the leaves, effectively hiding the overhead of the tree traversal.
Experimental Evaluation
The algorithms were evaluated using covariance matrices from spatial statistics (Gaussian processes) on 2D and 3D regular grids with up to $2^{20}$ (over 1 million) rows and columns. The results confirmed that the $\mathcal{H}^2$ implementation maintains theoretical $O(n)$ scaling in practice.
- Matrix-Vector Multiplication (HMV): The implementation achieved up to 550 GB/s, representing 78% of the theoretical peak bandwidth of a Pascal P100 GPU. For a problem with 1 million points, the operation finished in under 29ms, surpassing the results of the standard STREAM benchmark on the same hardware.
- Compression: The compression routine, involving complex SVD and QR operations, achieved over 850 GFLOPS/s while maintaining a prescribed accuracy (e.g., $10^{-7}$ for 2D problems).
Conclusion and Future Work
This work demonstrates that hierarchical matrices can be highly efficient on GPUs when the underlying data structures are properly adapted for parallel architectures. While the current implementation assumes a fixed rank for blocks at specific levels to simplify batching, future work will address variable-rank blocks and expand the library to include BLAS3 operations (matrix-matrix multiplication) and matrix inversion. This research paves the way for handling massive-scale dense linear algebra problems that were previously computationally intractable.
Summary updated