Introduction
In modern scientific computing and machine learning, dense kernel matrices are ubiquitous. However, their $O(N^3)$ computational complexity makes direct manipulation infeasible for large-scale datasets. Hierarchical Matrix (HMatrix) approximations, such as Hierarchically Semi-Separable (HSS) structures, offer a solution by exploiting the low-rank properties of off-diagonal blocks. Despite their theoretical efficiency, existing libraries often suffer from poor memory locality and high synchronization overhead on parallel architectures, leading to idle CPU cores and cache misses.
MatRox addresses these challenges by introducing an Inspector-Executor framework that optimizes data storage and code execution for specific matrix structures, achieving significant speedups over state-of-the-art HMatrix libraries.
The MatRox Framework: Inspector-Executor Strategy
MatRox departs from monolithic library designs by adopting an Inspector-Executor approach. This modularity allows for "partial reuse," where expensive setup computations (like cluster tree generation) are preserved even if model parameters like accuracy are tuned.
The Inspector Phase
The Inspector analyzes the pointset and kernel function to determine the optimal hierarchical structure. It employs two key strategies:
- Blocking: Near-interaction computations are grouped into blocks. This ensures data remains in the CPU cache and eliminates the need for expensive atomic locks during parallel execution.
- Coarsening: A Load-Balanced level Coarsening (LBC) algorithm groups cluster tree nodes into sub-trees of equivalent work, minimizing idle time across CPU cores and ensuring all threads finish tasks simultaneously.
The Executor Phase
Rather than relying on generic function calls, MatRox generates specialized C++ code tailored to the specific matrix structure identified by the Inspector. This specialization enables low-level optimizations, such as loop peeling and direct parallel BLAS calls, which are often unavailable in general-purpose libraries.
Optimized Storage: The CDS Format
A core innovation of MatRox is the Compressed Data-Sparse (CDS) storage format. Standard formats often lead to fragmented memory access patterns that do not fit modern CPU caches. CDS reorders matrix sub-blocks in memory to match the exact sequence of access during computation.
By aligning the physical data layout with the computational traversal, MatRox significantly reduces memory latency. Empirical analysis showed a strong correlation ($R^2 = 0.81$) between this improved locality and overall performance gains.
Experimental Evaluation
MatRox was evaluated using 13 real-world datasets from the UCI Machine Learning Repository and various scientific computing domains, with sizes up to $N=100,000$ points.
Performance Results
- Raw Speed: MatRox-generated code for matrix-matrix multiplication outperformed GOFMM by 2.98x, SMASH by 1.60x, and STRUMPACK by 5.98x.
- Iterative Tuning: In scenarios requiring multiple accuracy adjustments (common in research), MatRox was 2.21x to 2.64x faster than GOFMM because it reuses previous computations from the Inspector phase.
- Scalability: On high-core-count systems like the 68-core Intel Knights Landing (KNL), MatRox demonstrated robust strong scaling, avoiding the performance degradation seen in competing libraries due to synchronization bottlenecks.
Conclusion
MatRox demonstrates that the primary bottleneck in parallel HMatrix approximations is often memory locality rather than raw floating-point throughput. By combining an Inspector-Executor model with the CDS storage format and specialized code generation, MatRox provides a high-performance, flexible framework for large-scale matrix computations. Future work will explore extending these locality optimizations to matrix inversion and LU factorization, as well as adapting the framework for GPU architectures.
Summary updated