StencilFlow: Mapping Large Stencil Programs to Distributed Spatial Computing Systems

Johannes de Fine Licht, Andreas Kuster, Tiziano De Matteis, Tal Ben-Nun, Dominic Hofer, Torsten Hoefler · OpenReview

Abstract

Spatial computing devices have been shown to significantly accelerate stencil computations, but have so far relied on unrolling the iterative dimension of a single stencil operation to increase temporal locality. This work considers the general case of mapping directed acyclic graphs of heterogeneous stencil computations to spatial computing systems, assuming large input programs without an iterative component. StencilFlow maximizes temporal locality and ensures deadlock freedom in this setting, providing end-to-end analysis and mapping from a high-level program description to distributed hardware. We evaluate our generated architectures on a Stratix 10 FPGA testbed, yielding 1.31 TOp/s and 4.18 TOp/s on single-device and multi-device, respectively, demonstrating the highest performance recorded for stencil programs on FPGAs to date. We then leverage the framework to study a complex stencil program from a production weather simulation application. Our work enables productively targeting distributed spatial computing systems with large stencil programs, and offers insight into architecture characteristics required for their efficient execution in practice.

Introduction

Stencil computations—updating a grid point based on its neighbors—are the computational backbone of weather prediction, climate modeling, and physical simulations. While spatial architectures like FPGAs are theoretically ideal for stencils due to their high energy efficiency and customizability, a massive gap exists between theory and practice. Most existing research focuses on "toy" problems: a single stencil operation unrolled over time. Real-world applications, such as the COSMO weather model, consist of complex Directed Acyclic Graphs (DAGs) containing dozens of heterogeneous stencil operations with complex dependencies. Manually mapping these to hardware is incredibly difficult because the designer must manage thousands of on-chip buffers to ensure data reuse and prevent "deadlocks" where the hardware stalls due to synchronization issues.

The StencilFlow Framework

StencilFlow is a full-stack framework that automatically maps complex, multi-stage stencil programs onto distributed FPGA clusters. By treating an entire program as a single, deep, deadlock-free dataflow pipeline, it achieves record-breaking performance.

The StencilFlow end-to-end pipeline, from high-level description to hardware mapping.

Key components of the framework include:

  • High-Level DSL: A JSON-based language allows users to define stencils, their iteration spaces, and their dependencies without worrying about hardware specifics.
  • Automated Dataflow Analysis: This is the core "intelligence" of the system. StencilFlow analyzes the DAG to calculate internal buffers for temporal locality and delay buffers to synchronize different paths, ensuring deadlock-free execution.
  • Spatial Stencil Fusion: Unlike traditional CPU/GPU fusion, StencilFlow fuses stencils to reduce initialization latency and increase the ratio of compute logic to overhead.
  • Integration with DaCe & SMI: The system leverages the Data-Centric (DaCe) framework for low-level optimizations and the Streaming Message Interface (SMI) to handle communication between multiple FPGAs.
Mapping a high-level JSON program description to its corresponding DAG and hardware layout.

Evaluation and Results

The paper evaluates the framework using microbenchmarks and a production case study: the Horizontal Diffusion kernel from the COSMO weather model. This complex program involves 28 accesses to 10 unique input fields and a DAG of multiple heterogeneous stencil stages.

  • Record Performance: StencilFlow achieved 1.31 TOp/s on a single Intel Stratix 10 FPGA and 4.18 TOp/s on a cluster of eight FPGAs, the highest recorded for stencil programs on FPGAs to date.
  • Real-World Speedup: For the COSMO kernel, the FPGA outperformed a 12-core Intel Xeon CPU by 4.5x.
  • Competitive with GPUs: The FPGA implementation was competitive with an NVIDIA Tesla P100 GPU, though it was outperformed by the newer V100 due to the latter's superior HBM2 memory bandwidth.

Insights and Conclusion

StencilFlow’s "Deep Pipeline" philosophy views the entire program as a single massive pipeline where every grid cell flows through the entire graph of operations. A key insight is that vectorization (4-way or 8-way) is mandatory to saturate FPGA resources. While memory bandwidth remains a bottleneck for many real-world stencils, FPGAs offer high silicon efficiency. StencilFlow enables productive targeting of distributed spatial systems for large-scale scientific applications, providing a robust path for future performance gains as FPGA memory technology evolves.

Summary updated

BibTeX
@inproceedings{licht2021stencilflow,
  author = {Johannes de Fine Licht and Andreas Kuster and Tiziano De Matteis and Tal Ben-Nun and Dominic Hofer and Torsten Hoefler},
  title = {{StencilFlow: Mapping Large Stencil Programs to Distributed Spatial Computing Systems}},
  booktitle = {CGO},
  year = {2021},
  doi = {10.1109/cgo51591.2021.9370315},
}
Figure