arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2204.13304cs.DC
收藏

Mat2Stencil:一种用于结构化网格上显式和隐式无矩阵PDE求解器的基于矩阵的模块化DSL

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

Huanqi Cao, Shizhi Tang, Qianchao Zhu, Bowen Yu, Wenguang Chen

AI总结:

提出用于结构化网格PDE求解器的DSL Mat2Stencil及其编译器,通过结构化稀疏矩阵抽象生成无矩阵代码,并采用新型自动并行化技术处理空间依赖循环,在大幅减少代码量的同时实现了优于手动实现的性能。

摘要:

偏微分方程(PDE)求解器在众多科学和工程领域得到了广泛应用。然而,实现高性能和可扩展性往往需要复杂且底层的编程,特别是在利用结构化网格中的确定性稀疏模式时。在本文中,我们提出了一种创新的领域特定语言(DSL)Mat2Stencil及其编译器,用于结构化网格上的PDE求解器。Mat2Stencil引入了结构化稀疏矩阵抽象,促进了广泛范围内求解器的模块化、灵活和易用的表达,包括Jacobi或Gauss-Seidel预处理程序、不完全LU或Cholesky分解以及基于它们构建的多重网格方法等组件。我们的DSL编译器随后通过多阶段编程生成由广义模板组成的无矩阵代码。除了Jacobi式模板在空间维度上的尴尬并行外,该代码还允许以拟仿射循环的形式存在空间循环携带依赖。我们进一步提出了一种针对空间依赖循环的新型自动并行化技术,该技术为线程化提供编译时确定性任务划分,自动计算必要的线程间同步,并生成具有细粒度同步的高效多线程实现。通过实现4个基准测试程序,其中3个是NAS Parallel Benchmarks中的伪应用程序(代码行数占比6.3%),1个是无矩阵High Performance Conjugate Gradients(代码行数占比16.4%),与手动实现相比,我们实现了最高1.67倍、平均1.03倍的性能。

英文摘要:

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\times$ and on average $1.03\times$ performance compared to manual implementations.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑