Exploiting Scratchpad Memory for Deep Temporal Blocking: A case study for 2D Jacobian 5-point iterative stencil kernel (j2d5pt)

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

TL;DR

This paper proposes a simpler approach to optimize stencil computations on GPUs by fully leveraging the ever-increasing capacity of scratchpad memory. By tiling the computational domain to fit entirely within the scratchpad, the authors achieve performance comparable to complex, auto-generated methods, while using a much more straightforward implementation.

What Problem Does This Paper Address?

Modern GPUs boast significantly larger scratchpad memory (also known as shared memory in CUDA) than in previous generations. However, existing optimization techniques for scientific computations like stencil kernels, which rely on "temporal blocking" (processing multiple time steps at once), haven't fully exploited this increased capacity. These traditional methods often assume smaller scratchpad sizes, leading to complex tiling strategies and reliance on code auto-generation to achieve peak performance. This leaves a gap: how can we effectively utilize the abundant scratchpad memory for stencil computations without resorting to overly complicated implementations?

Methods

The core of this work is a novel tiling strategy for the 2D Jacobian 5-point iterative stencil kernel. Instead of tiling the spatial domain into small chunks that fit within a thread block's scratchpad, the authors propose tiling the domain into much larger tiles. The key idea is to make each tile large enough to occupy all available scratchpad memory on the GPU.

Once a tile is loaded into the scratchpad, the computation for multiple time steps (the "temporal blocking") is performed entirely within this fast on-chip memory. Only after all these time steps are computed for a given tile is the result written back to slower global memory. This process is repeated serially for each large tile. To handle dependencies between these large tiles, a grid-level barrier is used, aligning with the bulk synchronous parallel (BSP) model. This approach is termed "Deep Temporal Blocking" (DTB).

Datasets

Not discussed in the paper. The evaluation uses a specific stencil kernel (2D Jacobian 5-point iterative stencil) and a custom domain size for testing.

Key Insights and Ideas

  • Scratchpad Memory is Underutilized: The paper highlights that despite significant increases in GPU scratchpad memory capacity, existing optimization techniques for stencil computations are not aggressively exploiting it.
  • Simplicity Through Large Tiles: By making tiles large enough to fill the scratchpad, the authors simplify the temporal blocking process. Instead of complex inter-tile communication or intricate scheduling, the computation for multiple time steps happens "locally" within the scratchpad for each large tile.
  • Performance Without Complexity: The DTB approach achieves performance comparable to state-of-the-art methods that rely on complex code auto-generation, demonstrating that simplicity and performance are not mutually exclusive.
  • Manual Implementation Feasible: A significant advantage is that DTB allows for manual implementation of the stencil kernel, unlike more complex temporal blocking schemes that necessitate code generation tools.

Key Results

The paper evaluates their Deep Temporal Blocking (DTB) method on the 2D Jacobian 5-point iterative stencil kernel. They compare their approach against two state-of-the-art temporal blocking implementations: StencilGen and AN5D.

  • Comparable Performance: DTB achieves performance comparable to StencilGen and AN5D. For instance, on a domain size of 8592x8328, DTB shows competitive results. A "pruned" version of DTB, evaluated on a smaller 8192x8192 domain (to match the other SOTAs), also demonstrates comparable performance.
  • Simpler Implementation: The authors emphasize that their implementation is significantly simpler and does not require auto-generation of code, which is a major advantage for developers.

Limitations and Future Work

  • Domain Size Dependence: The effectiveness of DTB is tied to the ability to tile the domain such that each tile can fully utilize the available scratchpad memory. The paper suggests that DTB could perform even better on architectures with larger scratchpad memory, implying that current GPU scratchpad sizes might still be a limiting factor for extremely large domains.
  • Future Work: The authors explicitly state that exploring DTB on larger scratchpad memory architectures is a promising direction for future research. They also hint at the potential for further optimization by considering the inter-thread block data exchange pattern, which was not the primary focus of this work.

Summary updated

BibTeX
@inproceedings{zhang2023exploiting,
  author = {Lingqi Zhang and Mohamed Wahib and Peng Chen and Jintao Meng and Xiao Wang and Toshio Endo and Satoshi Matsuoka},
  title = {{Exploiting Scratchpad Memory for Deep Temporal Blocking: A case study for 2D Jacobian 5-point iterative stencil kernel (j2d5pt)}},
  booktitle = {GPGPU@PPoPP},
  year = {2023},
  doi = {10.1145/3589236.3589242},
}
Figure