Table of Contents
Fetching ...

Fully integrating the Flang Fortran compiler with standard MLIR

Nick Brown

TL;DR

The performance of Flang against other compilers popular in HPC for a range of benchmarks is explored before a mapping between Fortran and standard MLIR is described, demonstrating that the Flang community should seriously consider leveraging standard MLIR.

Abstract

Fortran is the lingua franca of HPC code development and as such it is crucial that we as a community have open source Fortran compilers capable of generating high performance executables. Flang is LLVM's Fortran compiler and leverages MLIR which is a reusable compiler infrastructure which, as part of LLVM, has become popular in recent years. However, whilst Flang leverages MLIR it does not fully integrate with it and instead provides bespoke translation and optimisation passes to target LLVM-IR. In this paper we first explore the performance of Flang against other compilers popular in HPC for a range of benchmarks before describing a mapping between Fortran and standard MLIR, exploring the performance of this. The result of this work is an up to three times speed up compared with Flang's existing approach across the benchmarks and experiments run, demonstrating that the Flang community should seriously consider leveraging standard MLIR.

Fully integrating the Flang Fortran compiler with standard MLIR

TL;DR

The performance of Flang against other compilers popular in HPC for a range of benchmarks is explored before a mapping between Fortran and standard MLIR is described, demonstrating that the Flang community should seriously consider leveraging standard MLIR.

Abstract

Fortran is the lingua franca of HPC code development and as such it is crucial that we as a community have open source Fortran compilers capable of generating high performance executables. Flang is LLVM's Fortran compiler and leverages MLIR which is a reusable compiler infrastructure which, as part of LLVM, has become popular in recent years. However, whilst Flang leverages MLIR it does not fully integrate with it and instead provides bespoke translation and optimisation passes to target LLVM-IR. In this paper we first explore the performance of Flang against other compilers popular in HPC for a range of benchmarks before describing a mapping between Fortran and standard MLIR, exploring the performance of this. The result of this work is an up to three times speed up compared with Flang's existing approach across the benchmarks and experiments run, demonstrating that the Flang community should seriously consider leveraging standard MLIR.
Paper Structure (15 sections, 3 figures, 5 tables)

This paper contains 15 sections, 3 figures, 5 tables.

Figures (3)

  • Figure 1: Illustration of flow used by Flang to generate LLVM-IR from Fortran source code
  • Figure 2: Illustration of our flow which lowers Flang's HLFIR and FIR dialects to the standard MLIR dialects, and then uses existing transformation and optimisation passes to ultimately generate LLVM-IR. Our transformation passes are developed in xDSL, generating IR that is consumed by MLIR.
  • Figure 3: Illustration of applying vectorisation to the affine dialect and then lowering to the LLVM dialect