The Fortran programming language is an essential component of many exascale applications and broad scientific missions within the US Department of Energy (DOE). Until recently, Fortran has not had the benefit of using the widely leveraged LLVM Compiler Infrastructure and the vibrant community that supports it. By leveraging a multiyear investment made by the National Nuclear Security Administration’s (NNSA’s) Advanced Simulation and Computing (ASC) program to establish Fortran as a component of the LLVM infrastructure, the Flang project aims to build on this foundation and further the capabilities and feature set of Fortran as a first-class language in the LLVM community. This will provide developers with a viable and robust path forward for producing performant Fortran-based applications on DOE’s pre-exascale and exascale system architectures.
Today there are several commercially-supported Fortran compilers, typically available from one vendor and often for a limited set of platforms. None of these are open source. While the GNU gfortran compiler is open source and available on a wide variety of platforms, the source base is not modern LLVM-style C++ and the GPL license is not compatible with LLVM — a powerful set of compiler and toolset technologies. This places limits on scientific collaborations, and thus has an impact on broader community participation and adoption.
Removing these limits provided the motivation for the Exascale Computing Project (ECP) Flang project, which created a source base with the maturity, features, and performance of proprietary solutions along with the cross-platform capability of GNU compilers, and which is licensed and coded in a style that will be embraced by the LLVM community. Additional challenges come from supporting all Fortran language features, language extensions (e.g., OpenMP, OpenACC), and scalability required for effective use of exascale-class systems.
The Flang project provides an open-source Fortran standard compiler front-end for the LLVM Compiler Infrastructure (see http://llvm.org). Leveraging LLVM, Flang will provide a cross-platform Fortran solution available to ECP and the broader international LLVM community. The goals of the project include extending support to GPU accelerators, thus targeting GPU-accelerated Exascale systems, and supporting LLVM-based software and tools of interest to a large, deployed base of Fortran applications.
LLVM’s growing popularity and wide adoption make it an integral part of the modern software ecosystem. Flang provides a foundation for Fortran that will complement and interoperate with the Clang C/C++ compiler and other tools within the LLVM infrastructure. The project provides a modern, open-source Fortran implementation that is stable, has an active footprint within the LLVM community, and will meet the specific needs of ECP as well as the broader scientific computing community.
Beyond parsing and semantics, the project has focused on creating a Fortran-centric intermediate representation (Fortran IR, or FIR) that leverages recent activities within Google. (See “MLIR: accelerating AI with open-source infrastructure” to understand how MLIR addresses the complexity of modern, accelerated hardware technology).
With the adoption of Flang into the LLVM community, the project successfully introduced, developed and delivered a solid, alternative Fortran compiler for DOE’s platforms. Flang also established and has been growing a strong community around it.
It is critical that the Flang project continues to act as a good shepherd within the LLVM community. This engagement is in the best interest of ECP as well as the long-term success of Fortran and enables leveraging the significant momentum and strengths of the LLVM and Fortran codebases, both of which are in wide use and are generally accepted.
Flang was formally accepted as an official component of LLVM in 2019 and merged portions of its initial code base into the main LLVM repository in April 2020. Work continues today with a growing set of contributors to the code base. This, plus the need for a modern, platform agnostic Fortran compiler that does not limit potential collaborations ensures a long lifespan.
The Flang project focuses on taking a key role in contributing to the recently accepted open-source LLVM-based Fortran front-end (“Flang”) established by a multiyear investment made by the NNSA’s ASC program. By contributing to the overall community effort, the infrastructure will provide support for the critical features needed by Fortran applications to obtain performance on pre-exascale and exascale architectures, such as accelerator offload, improved optimizations, and tooling. This effort will help establish a modernized Fortran environment that will provide a robust and productive infrastructure for mission-critical applications within the DOE and across other US agencies and industry for which Fortran applications are essential for national security, scientific discovery, and engineering design.