arXiv:2610.18382cs.PFOct 2026

Manuscript Offprint

arXiv:2610.18382

PrismStencil: Transforming Stencil Computations into Matrix Multiplications

Xianmeng Jiang, Yuan Liang, Zixuan Wang, Kun Li, Yunquan Zhang

Xianmeng Jiang

jiangxianmeng23z@ict.ac.cn

Institute of Computing Technology

Haidian Qu, Beijing Shi, China

Yuan Liang ✉^{✉}

Institute of Computing Technology

Haidian Qu, Beijing Shi, China

yuanliang@ict.ac.cn

Zixuan Wang

Institute of Computing Technology

Haidian Qu, Beijing Shi, China

wangzixuan22@mails.ucas.ac.cn

Kun Li

Tsinghua University

Haidian Qu, Beijing Shi, China

likungw@gmail.com

Abstract

Stencil computations are a fundamental class of workloads in scientific and engineering applications. Although Tensor Cores offer new opportunities for stencil acceleration, existing tensorization methods suffer from substantial redundant computation and insufficient data reuse. We propose PrismStencil, a stencil tensorization algorithm that introduces a novel mapping scheme between matrices and stencil grid points. PrismStencil employs multidimensional vector mapping to accommodate the multidimensional data dependencies of stencil computations and a unified gather–scatter tensorization scheme to exploit the relative sizes of the matrix dimensions in Tensor Core operations, thereby reducing the redundant computation introduced by tensorization. Moreover, it introduces a cross-product data-reuse mechanism that exploits the overlap among neighboring stencil updates to further enhance data reuse. Across representative stencil kernels on an NVIDIA A100 GPU, PrismStencil achieves average speedups of 2.13x and 2.17x over state-of-the-art Tensor Core stencil methods with FP64 and TF32 precision, respectively.

CCS Concepts

• Computing methodologies → Parallel algorithms.

1 Introduction

Stencil computation is one of the thirteen Berkeley motifs and represents a common class of nested-loop computations in scientific and engineering applications, dynamic programming, and image processing [1, 6, 12, 25, 33]. A stencil computation operates on data arranged on a regular spatial grid with one or more dimensions and proceeds through a sequence of time steps. At each time step, every grid point is updated using the values of a fixed set of nearby grid points from the previous time step.

A substantial body of work has been devoted to optimizing stencil computations, primarily through tiling [3, 7, 8, 24, 41] and vectorization [15, 18, 19, 44]. Tiling changes the traversal order of grid points to improve temporal and spatial locality while exposing coarse-grained parallelism across tiles. Vectorization processes multiple grid-point updates simultaneously using SIMD instructions, exposing fine-grained parallelism and increasing arithmetic throughput.

Yunquan Zhang

Institute of Computing Technology

Haidian Qu, Beijing Shi, China

zyq@ict.ac.cn

Tensor Cores offer substantially higher arithmetic throughput than standard SIMD units through their matrix multiply-and-accumulate (MMA) instructions. Although originally designed for machine-learning workloads, they have increasingly been applied to scientific computing, including stencil computations. In particular, recent studies [5, 10, 21, 43] have explored tensorizing stencil computations by organizing the weighted neighbor accumulations for multiple grid-point updates into matrix multiplications.

However, existing methods still fall short of fully exploiting this potential. Prior work [11] has shown that the matrix representations adopted by these Tensor Core stencil methods inevitably contain many zero elements, resulting in substantial redundant computation that offsets the computational advantage of Tensor Cores. Furthermore, the matrix multiplications generated by stencil tensorization are typically small and therefore offer little opportunity for data reuse across MMA instructions through conventional matrix-multiplication blocking. Consequently, the available memory bandwidth is insufficient to keep Tensor Cores fully utilized.

To address these limitations, we propose PrismStencil, a stencil tensorization algorithm that introduces a novel mapping scheme between matrices and stencil grid points. Unlike existing methods that impose a fixed correspondence between matrix-multiplication dimensions and spatial grid structures, PrismStencil maps each matrix-multiplication dimension across multiple spatial dimensions to better accommodate the multidimensional data dependencies of stencil computations, thereby constructing denser matrix representations. PrismStencil also extends the tensorized computation mode to better exploit the relative sizes of the dimensions of an MMA instruction when organizing the stencil grid points involved in each matrix multiplication, further reducing the redundant computation introduced by tensorization.

Beyond the data reuse inherent in matrix multiplication itself, PrismStencil exploits the inherent overlap among neighboring stencil updates to expose additional reuse across matrix rows. It further reorders data carefully across the matrix dimensions while preserving mathematical equivalence, extending such reuse to the granularity defined by MMA instruction shapes. Together, these optimizations reduce repeated data movement and alleviate the memory-bandwidth bottleneck of tensorized stencil computation.

The main contributions of this work are as follows:

  • We propose a multidimensional vector mapping and a unified gather–scatter tensorization scheme that better accommodate the multidimensional structure of stencil computations and the dimensions of MMA instructions, substantially reducing the redundant computation introduced by tensorization.

  • We develop a cross-product data-reuse mechanism that exploits the inherent overlap among neighboring stencil updates and enables data reuse at the granularity of MMA instruction shapes, thereby reducing repeated data movement.

  • We implement PrismStencil for a diverse set of stencil kernels. Compared with state-of-the-art Tensor Core stencil methods, PrismStencil achieves average speedups of 2.13×2.13\times and 2.17×2.17\times for FP64 and TF32 computations, respectively.

References (13)