Optimising Stencil Code on FPGAs by Trading Data Movement for Compute using Compiler Rewrite Rules
Open Access
- 2 March 2026
- journal article
- research article
- Published by Springer Nature in International Journal of Parallel Programming
- Vol. 54 (1-2) , 1
Abstract
FPGAs are promising accelerators for scientific computing tasks because of their potential for delivering high performance-per-Watt. However, programming for optimal performance remains a complex task. Our goal is to bring FPGAs within the reach of domain scientists by developing compilers targeting scientific Fortran code. In this paper, we present a novel approach to aggressively reduce memory utilisation of stencil-based finite-difference Fortran code through a compiler-based automatic program transformation that trades memory accesses for computation. The key contribution of this work is a set of type-driven rewrite rules that identify and eliminate the intermediate arrays in stencil computations and replace them with re-computation, thus reducing the number of memory accesses. The main novelty lies in the transformations to move stencil operations out of maps and folds and to fuse stencils. We demonstrate the effectiveness of our approach using a set of five 3-D and 2-D stencil benchmarks evaluated on an Intel Arria 10 FPGA board. Our transformation result on average in a $$2.5\times$$ reduction in DRAM usage, a $$3.4\times$$ increase in DSP usage, and a $$25\times$$ improvement in throughput. We show on a real-world exemplar, the Large Eddy Simulator for Urban Flows, that our algorithm successfully removes all intermediate arrays (18 in total), reducing the memory footprint by a factor of $$4.5\times$$ . The memory-reduced FPGA code, automatically transpiled from the original Fortran source, is $$9.7\times$$ faster than the original Fortran code, and performance competitive with a hand optimised FPGA version while supporting a four times larger domain size.
Keywords
Funding Information
- Engineering and Physical Sciences Research Council (00855959)
This publication has 35 references indexed in Scilit:
- Making legacy Fortran code type safe through automated program transformationThe Journal of Supercomputing, 2021
- Domain-specific acceleration and auto-parallelization of legacy scientific code in FORTRAN 77 using source-to-source compilationComputers & Fluids, 2018
- Type-Driven Automated Program Transformations and Cost Modelling for Optimising Streaming Programs on FPGAsInternational Journal of Parallel Programming, 2018
- Large-Eddy-Simulation Study of the Effects of Building-Height Variability on Turbulent Flows over an Actual Urban AreaBoundary-Layer Meteorology, 2018
- An analysis of the feasibility and benefits of GPU/multicore acceleration of the Weather Research and Forecasting modelConcurrency and Computation: Practice and Experience, 2015
- Modeling Stencil Computations on Modern HPC Architectures2015
- Ocean Modelling for Beginners2009
- SAC—A Functional Array Language for Efficient Multi-threaded ExecutionInternational Journal of Parallel Programming, 2006
- Improving FPGA Performance and Area Using an Adaptive Logic Module2004
- Extended term rewriting systems1991