Revisiting Temporal Blocking Stencil Optimizations

Lingqi Zhang, Mohamed Wahib, Peng Chen, Jintao Meng, Xiao Wang, Toshio Endo, Satoshi Matsuoka · DOI

TL;DR

This paper introduces EBISU, a novel temporal blocking optimization for GPUs that leverages modern hardware features like large shared memory and hardware prefetching. By employing a low-occupancy, tile-by-tile execution strategy, EBISU achieves significant speedups (up to 2.53x, with a geometric mean of 1.49x) over existing state-of-the-art methods for stencil computations.

What Problem Does This Paper Address?

Iterative stencil computations are fundamental to many scientific applications, but their low computational intensity makes them memory-bound, especially on GPUs. Temporal blocking is a key optimization technique that improves data locality by processing multiple time steps together. However, existing temporal blocking methods often operate at high GPU occupancy, which can be conservative in resource utilization and limit the depth of temporal blocking. This paper addresses the challenge of effectively utilizing the increasingly large on-chip resources (like shared memory) of modern GPUs for temporal blocking, aiming to achieve deeper temporal blocking and better performance.

Methods

The core of this paper is the proposed EBISU (Epoch Temporal Blocking for Iterative Stencils, with Ultracompact parallelism) method. EBISU's design is guided by two main principles:

  1. Minimal Parallelism for Saturation: Instead of maximizing occupancy, EBISU aims to find the minimum parallelism (combination of thread count and instruction-level parallelism) that saturates the GPU. This frees up resources.
  2. Scalability in Resource Usage: The freed resources are then aggressively used to increase data reuse and reduce dependencies. This is achieved through techniques like:
  3. Device Tiling: Processing a single, large tile that occupies the entire GPU's on-chip memory, updating it over many time steps to amortize loading/storing overheads.
  4. Circular Multi-Queue (CMQ): A data structure designed to manage deep temporal blocking efficiently, allowing seamless transitions between time steps and optimized on-chip memory usage.
  5. Prefetching (PRE): Utilizing asynchronous shared memory copy APIs to load data ahead of time.
  6. Lazy Streaming (LST): A technique to reduce synchronization overhead by delaying computation until necessary data is available.
  7. Redundant Register Streaming (RST): Caching intermediate data in both registers and shared memory to reduce memory access times and enable deeper temporal blocking.

EBISU also incorporates a cost model and practical attainable performance analysis to guide implementation decisions, such as choosing between device tiling and SM tiling, and determining the optimal temporal blocking depth.

Datasets

Not discussed in the paper. The paper evaluates performance on a range of standard 2D and 3D stencil benchmarks, including j2d5pt, j2d9pt, j2d9pt-gol, j2d25pt, j3d7pt, j3d13pt, j3d17pt, j3d27pt, and poisson. These are standard benchmarks used in related literature.

Key Insights and Ideas

  • Low Occupancy is Key for Modern GPUs: Contrary to traditional GPU optimization wisdom, this paper demonstrates that reducing occupancy on modern GPUs can unlock significant performance gains by allowing for more aggressive use of on-chip resources like shared memory and registers.
  • Resource Scalability is Crucial: The increasing size of GPU on-chip memory necessitates new strategies for temporal blocking. EBISU's approach of scaling resource usage to maximize data reuse is a significant departure from methods that prioritize high occupancy.
  • Device Tiling for 3D Stencils: The paper finds that for 3D stencils, device tiling (processing a single large tile across the entire GPU) is more beneficial than SM tiling due to the overhead of synchronization in overlapped tiling.
  • Synergy of Optimizations: The combination of techniques like Circular Multi-Queue, Prefetching, Lazy Streaming, and Redundant Register Streaming is crucial for achieving EBISU's performance. Disabling any of these leads to performance degradation.

Key Results

  • EBISU achieves speedups up to 2.53x over state-of-the-art temporal blocking libraries (STENCILGEN, AN5D) and auto-tuning tools (ARTEMIS, DRSTENCIL).
  • A geometric mean speedup of 1.49x is achieved over the best state-of-the-art performance for each stencil benchmark.
  • EBISU demonstrates efficient resource utilization, achieving high performance with low occupancy (12.5%).
  • Despite deeper temporal blocking (on average 1.3x deeper than SOTA), EBISU uses only 87% of the registers compared to the most register-intensive SOTA kernels.
  • The paper provides a practical attainable performance model that accounts for overheads, showing EBISU achieves 88% and 80% of the modeled practical attainable performance for 2D and 3D stencils, respectively.

Limitations and Future Work

  • Focus on Nvidia GPUs: The analysis and optimizations are primarily tailored to Nvidia GPUs. Generalizing to other GPU architectures might require adjustments.
  • Potential for further optimization: The authors suggest that EBISU's optimization approach could be integrated into production libraries like Halide to benefit end-users with minimal effort.
  • Exploration of other stencil types: While the paper covers common stencil types, further investigation into more complex or irregular stencil patterns could be beneficial.
  • Auto-tuning integration: While EBISU itself is a novel method, integrating its principles into existing auto-tuning frameworks could further enhance its applicability.

Summary updated

BibTeX
@inproceedings{zhang2023revisiting,
  author = {Lingqi Zhang and Mohamed Wahib and Peng Chen and Jintao Meng and Xiao Wang and Toshio Endo and Satoshi Matsuoka},
  title = {{Revisiting Temporal Blocking Stencil Optimizations}},
  booktitle = {ICS},
  year = {2023},
  doi = {10.1145/3577193.3593716},
}
Figure