Abstract
This paper proposes a versatile high-performance execution model, inspired by systolic arrays, for memory-bound regular kernels running on CUDA-enabled GPUs. We formulate a systolic model that shifts partial sums by CUDA warp primitives for the computation. We also employ register files as a cache resource in order to operate the entire model efficiently. We demonstrate the effectiveness and versatility of the proposed model for a wide variety of stencil kernels that appear commonly in HPC, and also convolution kernels (increasingly important in deep learning workloads). Our algorithm outperforms the top reported state-of-the-art stencil implementations, including implementations with sophisticated temporal and spatial blocking techniques, on the two latest Nvidia architectures: Tesla V100 and P100. For 2D convolution of general filter sizes and shapes, our algorithm is on average 2.5x faster than Nvidia's NPP on V100 and P100 GPUs.
The Memory Bottleneck in Regular Kernels
Many critical high-performance computing (HPC) and deep learning tasks involve "memory-bound regular kernels," such as stencils for fluid dynamics or convolutions for image processing. On modern GPUs, these kernels are typically bottlenecked by the speed of data movement rather than raw mathematical throughput.
The standard optimization strategy is to use shared memory (a user-managed scratchpad) to reuse data. However, as GPU architectures have evolved, shared memory has become a secondary bottleneck. This research identifies a faster, larger, but harder-to-use resource: register files. On the Nvidia V100, the register file per Streaming Multiprocessor (SM) is 256KB—more than 2.7× larger and significantly faster than shared memory. The challenge lies in the fact that registers are private to a single thread; there is no built-in way for one thread to read another's registers directly. This paper introduces a method to build a high-performance "virtual cache" and communication network using these registers.
The Software Systolic Array Model (SSAM)
The authors propose the Software Systolic Array Model (SSAM), which treats a CUDA warp (a group of 32 threads) as a 2D grid of processing elements. The model relies on four key pillars:
- Register Caching: Instead of loading data into shared memory, data is loaded directly into thread-local registers. A "sliding window" approach allows threads to reuse data across multiple output points.
- Intra-Warp Communication: To exchange data between threads, the model uses warp shuffle primitives (
__shfl_up_sync). This allows registers to behave like a systolic array, where partial sums are shifted horizontally across threads in a single clock cycle, bypassing the shared memory hardware entirely. - Overlapped Blocking: To handle "halos" (the edges of data blocks that neighbors need), the authors use an overlapped blocking scheme that eliminates complex branching logic, keeping the GPU's Single Instruction, Multiple Threads (SIMT) units perfectly synchronized.
- Vertical vs. Horizontal Optimization: The model recognizes that moving data "vertically" (within a thread's own registers) is essentially free, while "horizontal" movement (between threads) is the cost to minimize.
Performance and Key Results
The model was evaluated using standard computational motifs, including 2D convolutions with filter sizes up to $20\times20$ and a diverse set of 2D and 3D stencils (e.g., 2d5pt, 3d7pt, and Poisson solvers). Comparisons were made against industry standards including Nvidia NPP, cuDNN, cuFFT, Halide, and ArrayFire.
- Convolution Performance: SSAM is on average 2.5× faster than Nvidia’s NPP library and up to 1.5× faster than ArrayFire on Tesla V100 and P100 GPUs.
- Stencil Efficiency: SSAM consistently outperformed state-of-the-art stencil-specific libraries (like StencilGen and Bricks) and auto-tuning frameworks (like Halide), especially for high-order stencils where data reuse is most intense.
- Latency Reduction: The performance model demonstrated that SSAM reduces the latency of computing a single output element by avoiding the store-load cycle required by shared memory.
Conclusion and Future Work
SSAM effectively creates a "virtual" hardware systolic array with the flexibility of general-purpose CUDA registers. While highly effective, the authors acknowledge that mapping new kernels to SSAM currently requires manual tuning of register usage and shuffle patterns. Future work will focus on integrating SSAM into polyhedral compilers and Domain Specific Languages (DSLs) like Halide to automatically generate optimized code from high-level descriptions, as well as extending the model to 4D convolutions for advanced deep learning workloads.
Summary updated