paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Mat2Stencil: A Modular Matrix-Based DSL for Explicit and Implicit Matrix-Free PDE Solvers on Structured Grid

Mat2Stencil:面向结构化网格上显式与隐式无矩阵 PDE 求解器的模块化基于矩阵 DSL
OOPSLA 7(OOPSLA2)2023匹配度 2/10 · 该论文属于 PL/编译器与并行代码生成方向,面向结构化网格 PDE 求解器的矩阵 DSL 和无矩阵 stencil 代码生成;用户研究核心是静态分析、LLM/Agent 与程序分析的交叉,以及浮点/贝叶斯程序分析,本文并未涉及这些主题。虽然同属程序语言与编译器领域,但与研究画像的核心问题关联很弱。引用 4 inbox
Huanqi Cao, Shizhi Tang, Qianchao Zhu, Bowen Yu, Wenguang Chen
crossref: 2026-09-10

AI 速览

一句话:提出 Mat2Stencil 矩阵 DSL 及编译器,用多阶段编程生成无矩阵 stencil 代码并自动并行化,简化结构化网格 PDE 求解器开发。

PDE 求解器广泛用于科学与工程,但在结构化网格上利用确定性稀疏模式实现高性能常需复杂底层编程。本文提出 DSL Mat2Stencil 及其编译器,以结构化稀疏矩阵抽象模块化表达 Jacobi/Gauss-Seidel 预条件子、ILU/IC 分解及多网格等求解器。编译器通过多阶段编程生成由广义 stencil 组成的无矩阵代码,可处理准仿射空间循环携带依赖,并提出针对空间依赖循环的自动并行化:编译期确定性任务划分、自动同步计算与细粒度同步的多线程实现。评估含 4 个基准,3 个 NAS Parallel Benchmarks 伪应用代码量仅为手工实现的 6.3%,无矩阵 HPGC 为 16.4%,性能最高 1.67×、平均 1.03×。

问题
结构化网格 PDE 求解器要同时获得高性能与可扩展性,往往需要复杂底层编程,尤其是利用确定性稀疏模式时。
方法
提出 Mat2Stencil DSL 与编译器,以结构化稀疏矩阵抽象统一表达多种求解器组件,并通过多阶段编程生成含广义 stencil 的无矩阵代码;针对空间依赖循环实现编译期确定性任务划分、自动同步计算与细粒度同步的多线程并行化。
评估
评估 4 个基准程序,其中 3 个为 NAS Parallel Benchmarks 伪应用、1 个为无矩阵 HPGC;代码量分别为手工实现的 6.3% 和 16.4%,性能最高 1.67×、平均 1.03×。
原文摘要(Abstract)

Partial differential equation (PDE) solvers are extensively utilized across numerous scientific and engineering fields. However, achieving high performance and scalability often necessitates intricate and low-level programming, particularly when leveraging deterministic sparsity patterns in structured grids. In this paper, we propose an innovative domain-specific language (DSL), Mat2Stencil, with its compiler, for PDE solvers on structured grids. Mat2Stencil introduces a structured sparse matrix abstraction, facilitating modular, flexible, and easy-to-use expression of solvers across a broad spectrum, encompassing components such as Jacobi or Gauss-Seidel preconditioners, incomplete LU or Cholesky decompositions, and multigrid methods built upon them. Our DSL compiler subsequently generates matrix-free code consisting of generalized stencils through multi-stage programming. The code allows spatial loop-carried dependence in the form of quasi-affine loops, in addition to the Jacobi-style stencil’s embarrassingly parallel on spatial dimensions. We further propose a novel automatic parallelization technique for the spatially dependent loops, which offers a compile-time deterministic task partitioning for threading, calculates necessary inter-thread synchronization automatically, and generates an efficient multi-threaded implementation with fine-grained synchronization. Implementing 4 benchmarking programs, 3 of them being the pseudo-applications in NAS Parallel Benchmarks with 6.3% lines of code and 1 being matrix-free High Performance Conjugate Gradients with 16.4% lines of code, we achieve up to 1.67× and on average 1.03× performance compared to manual implementations.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1836,
  title = {Mat2Stencil: A Modular Matrix-Based DSL for Explicit and Implicit Matrix-Free PDE Solvers on Structured Grid},
  author = {Huanqi Cao and Shizhi Tang and Qianchao Zhu and Bowen Yu and Wenguang Chen},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {OOPSLA2},
  year = {2023},
  doi = {10.1145/3622822}
}