PhD Forum
(PhD07) pystencils - Automatic Generation, Optimization and Analysis of Stencil Codes
SessionPhD Forum
Event Type
PhD Forum
HPC workflows
Performance Analysis and Optimization
Scientific Software Development
TimeMonday, June 25th1:25pm - 1:29pm
LocationAnalog 1, 2
DescriptionWe present a Python-based metaprogramming toolkit for stencil codes called pystencils.
pystencils reduces development and maintenance costs, increases readability and reusability of compute-intensive numerical kernels by introducing high level abstractions.

This is achieved with a domain-specific language (DSL) based on SymPy.
A DSL in SymPy provides not only an extensible and flexible model formulation, but also a computer algebra system, which is very useful for the manipulation of the problem description. The model can be described on multiple abstraction levels, either directly as a stencil code, or preferably as a pure mathematical formulation which is then automatically discretized and transformed into a stencil description.
This stencil description is represented as an abstract syntax tree (AST), which undergoes multiple transformations. The toolkit provides optimizing transformations, that operate on the AST, like loop splitting/merging, SIMD vectorization or common subexpression elimination.
The AST is then passed to one of the backends to generate C++, CUDA or LLVM code.
For performance evaluation, the generated kernel can be automatically benchmarked and examined in detail with the help of kerncraft - a loop kernel analysis and performance modeling toolkit. Generated kernels can be integrated into existing C/C++ frameworks like waLBerla, or run directly from Python. Direct execution in Python allows fast prototyping, since all of Python's powerful utilities and libraries are available.

All these features make pystencils a powerful tool for systematic performance engineering of numerical compute kernels that simplifies or automates important steps in development, analysis and optimization of the kernel.
Poster PDF