arXiv:2611.00968cs.DCOct 2026

Manuscript Offprint

arXiv:2611.00968

Autotuning GPU Thread Block Sizes for Large-Scale Stencil Applications Using the OPS DSL

Kevin Antonio Nava Garcia, Istvan Zoltan Reguly

Kevin Antonio Nava Garcia*, Istvan Zoltan Reguly*

  • Faculty of Information Technology and Bionics, Pázmány Péter Catholic University, Budapest, Hungary

Email: {nava.garcia.kevinantonio, reguly.istvan}@itk.ppke.hu

Abstract—Large-scale structured-mesh stencil applications can run for hours or days on modern HPC GPU platforms, making launch-configuration choices important. OPS enables high-level stencil codes to target multiple GPU architectures, but its GPU backends rely on a default or user-selected global block/work-group shape, even though different kernels, problem geometries, and architectures may favor different configurations.

This paper presents a transparent per-kernel block/workgroup-shape autotuning extension for OPS. The extension explores valid block/workgroup shapes during execution, records the fastest configuration for each kernel, and enables precomputed replay of the selected configurations in subsequent runs.

We evaluate the approach on structured-mesh proxy and academic research applications, covering 459 unique kernels across 3 NVIDIA and 2 AMD GPUs. The evaluation reports speedup distributions, representative wall-time summaries, timing variability, and input problem shape effects. Replaying the best per-kernel launch shapes improves 923 of 995 measured application/input/GPU cases over the default OPS shape. Depending on the GPU, the median speedup ranges from 1.02× to 1.18×, with individual configurations of LAPL2D, TTI3D, and OpenSBLI-based TGV solvers exceeding 1.5×. The results also show that performance sensitivity is not limited to launch shape. At fixed cell count, changing the input problem shape changes precomputed-replay runtime by 0.8–34.6% in representative cases, while kernel-level timing variability depends on the interaction between runtime contribution, input problem shape, and GPU/backend behavior. Overall, automatic per-kernel block/workgroup-shape selection improves OPS performance across GPUs, provided shape sensitivity and timing stability are interpreted together.

Index Terms—GPU autotuning, block/workgroup shape, OPS DSL, stencil applications, performance portability, structured mesh

I. Introduction

Structured-mesh stencil algorithms are widely used in scientific and engineering simulations, including computational fluid dynamics (CFD), heat transfer, shallow-water models, wave propagation, and image processing. These applications typically apply stencil-based computations over structured domains for many time steps. In this context, a kernel is the computation applied at each mesh point, for example one stencil update over all grid points. Since such kernels are executed many times in long-running simulations, even modest improvements to individual kernel executions can translate into substantial reductions in total application runtime.

The regular structure of these applications makes them well suited to domain-specific programming frameworks. OPS (Oxford Parallel Library for Structured Mesh Solvers) is one such framework: it is designed specifically for applications operating on multi-block structured grids and using explicit solvers [2]. Rather than requiring developers to write backend-specific GPU or CPU code, OPS lets them describe stencil kernels at a high level. The OPS translator and runtime then generate backend-specific implementations for CPUs, GPUs, and distributed-memory systems. This separation improves programmer productivity and performance portability: developers focus on the numerical method, while OPS manages backend code generation, data movement, halo exchanges, and kernel launches.

However, performance portability does not imply performance optimality. Even when the same OPS application can run across different GPU architectures, the performance of the generated code still depends on low-level execution parameters. Prior work has shown that GPU heterogeneity makes a single tuning choice unlikely to be optimal across devices and kernels, and identifies workgroup configuration as one possible direction for performance improvement [9]. In the OPS context, this directly motivates block/workgroup-shape tuning: different kernels and GPU backends may favor different launch configurations. OPS currently uses a default global block/workgroup shape applied uniformly across kernels, which can limit performance. This creates an opportunity for automatic, per-kernel block/workgroup-shape selection inside the OPS runtime.