Cache Optimization and Performance Modeling of Batched, Small, and Rectangular Matrix Multiplication on Intel, AMD, and Fujitsu Processors

Sameer Deshmukh, Rio Yokota, George Bosilca

Introduction

In modern high-performance computing (HPC), the use of low-rank approximations has become a standard technique for managing massive datasets. By representing large, dense matrices as products of several smaller, "skinny" matrices, researchers can significantly reduce memory footprints. However, this approach introduces a specific computational bottleneck: the need to perform thousands of simultaneous multiplications on very small, rectangular matrices (e.g., $8 \times 8$ or $16 \times 512$).

Standard Basic Linear Algebra Subprograms (BLAS) libraries, such as Intel MKL or AMD BLIS, are highly optimized for large-scale dense linear algebra but often struggle with these "tiny" batched operations. These libraries frequently suffer from high call overhead and fail to effectively utilize the CPU's cache hierarchy and SIMD (Single Instruction, Multiple Data) capabilities for small problem sizes. This paper presents a specialized methodology to bridge this performance gap across three major CPU architectures.

Methodology

The researchers moved away from the standard "black box" library approach, building a custom implementation from the ground up focused on four primary optimization pillars:

  1. Loop Redesign and Register Accumulation: The computation was restructured into six nested loops. This design allows the system to accumulate intermediate results directly within the CPU's vector registers. By keeping data in the registers as long as possible, the authors eliminated the expensive intermediate "store" and "load" operations to memory that typically plague small GEMM operations.
  2. Multi-Level Cache Blocking: The authors implemented a sophisticated packing strategy tailored to the cache hierarchy. Small matrices are packed into the shared L3 cache to maximize bandwidth, while the "skinny" matrices are packed into the per-core L2 and L1 caches to minimize access latency.
  3. The Execution-Cache-Memory (ECM) Model: Unlike the common "Roofline" model, which primarily considers peak FLOPS and memory bandwidth, the authors utilized the ECM model. This analytical tool predicts the exact number of clock cycles required for each instruction and cache transfer. This granular approach allowed the team to identify specific bottlenecks in instruction scheduling and port pressure that the Roofline model often overlooks.
  4. Architecture-Specific Micro-kernels: To ensure maximum efficiency, the authors developed custom assembly and intrinsics for three distinct instruction sets: AVX-512 (Intel), AVX2 (AMD), and ARM SVE (Fujitsu A64FX).

Experimental Setup

The implementation was evaluated using synthetic, randomly generated matrices, which is the standard for benchmarking linear algebra kernels where performance is a function of dimensions and memory layout rather than numerical values.

  • Dimensions: The study focused on block sizes of 512, 1024, and 2048, with ranks (the skinny dimension) of 8, 16, and 32.
  • Batch Sizes: Benchmarks typically utilized 10,000 to 20,000 independent multiplications to simulate real-world HPC workloads.

Key Results and Insights

The custom implementation demonstrated significant performance gains over state-of-the-art vendor libraries:

  • Throughput Gains: The algorithm consistently achieved over 2x the throughput of Intel MKL, AMD BLIS, and Fujitsu SSL-2 across a wide range of problem sizes.
  • Scaling Efficiency: On the Intel Xeon 6148, the methodology showed near-linear strong scaling. While Intel MKL's performance tended to plateau after 10 cores for these small sizes, the authors' method continued to scale efficiently across the entire socket.
  • Hardware Saturation: On the Fujitsu A64FX (the processor powering the Fugaku supercomputer), the implementation reached nearly the theoretical peak performance predicted by the ECM model. This suggests that the code is operating at the absolute limit of what the hardware allows.
  • ECM vs. Roofline: The study proved that for memory-bound kernels, the Roofline model is often too optimistic. The ECM model provided the necessary insight to show that cache latencies and instruction throughput—rather than raw bandwidth—were the primary limiting factors.

Limitations and Future Work

While highly effective for small matrices, the methodology has a "compute-bound" threshold. As the rank of the matrices increases (typically above 96), the problem shifts from being memory-bound to compute-bound. At this stage, the highly optimized Floating-Point Multiply-Add (FMA) loops in vendor libraries become more competitive, and the custom implementation's advantage diminishes.

Furthermore, the method is constrained by register pressure. The strategy relies on fitting the result matrix into a limited number of hardware registers. If matrix dimensions grow too large, the implementation must revert to traditional memory-based accumulation, which reduces the performance benefit.

Future research will focus on extending these optimized kernels to distributed-memory systems and integrating them into full-scale hierarchical matrix factorization libraries used in global-scale simulations.

Reference: Deshmukh, S., Yokota, R., & Bosilca, G. (2023). Cache Optimization and Performance Modeling of Batched, Small, and Rectangular Matrix Multiplication on Intel, AMD, and Fujitsu Processors. J. ACM, 1(1).

Summary updated

BibTeX
@article{deshmukh2023cache,
  author = {Sameer Deshmukh and Rio Yokota and George Bosilca},
  title = {{Cache Optimization and Performance Modeling of Batched, Small, and Rectangular Matrix Multiplication on Intel, AMD, and Fujitsu Processors}},
  journal = {ACM Trans. Math. Softw.},
  year = {2023},
  doi = {10.1145/3595178},
}
Figure