Skip to content

About Flang

Gary Klimowicz edited this page Jun 7, 2019 · 7 revisions

Goals

Flang is a Fortran front-end designed for integration with LLVM, with open source licensing consistent with Clang C++ and LLVM, and suitable for deployment and interoperability with Clang/LLVM across a wide variety of systems.

The goals of Flang are:

  • Ensure Flang becomes a self-sustaining open source project
  • Attract additional developers from the (broad) community to create a critical mass of contributors
  • Deliver single-core CPU performance comparable or better than that of gfortran
  • Enable multicore CPU and GPU programming with a robust and performant implementation of OpenMP
  • Create a source base that can be readily re-hosted and re-targeted to future systems as easily as Clang and LLVM
  • Create a source base in which researchers and developers can ramp up and be productive quickly
  • Create a source base that is componentized to a degree that enables re-use of elements of Flang in tools projects

The first four of these goals have been largely addressed by the current Flang compiler.

The Flang project team has determined that the last three goals cannot be achieved in a reasonable time with the current code base. A new project has been launched, F18, to address these issues.

History of Flang

The public GitHub repository for Flang was created May 11, 2017. In the first year, over 500 commits and 900 tests have been added to the repository. Over 1400 commits have been added to the repository since its inception.

CMake Version 3.10 added support for Flang.

Spack supports building and using Flang.

A Windows port has been initiated by the broader Flang community.

ARM Ltd. introduced a commercially supported Fortran compiler for ARM/HPC November 13, 2017.

F18, the new front-end for the LLVM Fortran compiler, was announced at EuroLLVM April 17, 2018.

Fortran 2008 Features

Flang is a fairly complete Fortran 2003 compiler. Some work has been done to implement features of Fortran 2008 and Fortran 2018.

We have gotten input and feedback from various sources about the relative priority of Fortran 2008 features.

The current priority of the F2008 features is:

  • G0 edit descriptor
  • BACK optional argument on MAXLOC/MINLOC
  • BLOCK construct
  • Allocation of polymorphic variables
  • EXECUTE_COMMAND_LINE
  • Vector NORM2
  • Multiple sourced allocations in a single statement
  • Coarrays
  • Intrinsics and intrinsics used as initializers

The following Fortran 2008 features have been implemented:

  • Pointers to internal procedures
  • DO CONCURRENT
  • ERROR STOP
  • CONTIGUOUS attribute

The current Fortran 2008 implementation status can be found in the Fortran 2008 Features page.

What's New (24.May.2019)

LLVM 7.0

We've switched to LLVM 7 for flang and the flang-driver.

Fortran 2008 Features

We've implemented the following Fortran 2008 features:

  • SUBMODULE
  • DO CONCURRENT (serial implementation only)
  • Pointers to internal procedures passed as actual arguments
  • ERROR STOP

Fortran Debug Metadata

We've added Fortran debug metadata support for

  • COMMON blocks
  • Allocatable arrays and pointers
  • MODULE and SUBMODULE

Two of our patches for Fortran debug metadata generation have been upstreamed to LLVM. (We have one patch remaining.)

C++ Migration

Flang is written in C, not C++. This makes code sharing and reuse of LLVM components difficult.

Flang2 has been migrated to the C-like subset of C++, but we have not yet replaced the use of printf with IRBuilder for generating LLVM IR.

libpgmath precise/fast/relaxed intrinsics library

We have added libpgmath intrinsics library to Flang.

OpenMP 4.5 TARGET offload to GPUs and multi-core CPUs

Flang already implements most of OpenMP 4.5 for multi-core CPUs. This functionality is enabled by default with -fopenmp. It is implemented on top of the existing pre-4.5 OpenMP runtime API (kmpc).

NVIDIA is following the Clang 7.0 model to add offload support to Flang. This support can be enabled by building Flang with -DFLANG_OPENMP_GPU_NVIDIA=ON.

Bug fixes

We have fixed many Flang issues, and provided other bug fixes:

  • Fixes from the PGI Fortran compiler
  • Bugs related to structure constructors
  • Bugs related to finalizers
  • Fixes for OpenMP

See the GitHub Issues list for the current status on issues.

Clone this wiki locally