Flang support in LLVM (FLANG)

Introduction

Linaro and Linaro Members' are working on flang targeting AArch64 on Linux and Windows. Linux has had a head start in flang, so in general Linux support has been slightly ahead of Windows support. Therefore, part of our work is to bring Windows on Arm (WoA) support to the same level of parity as Linux. However, we also strive to improve flang in general, for any platform. Enabling Flang in LLVM is a big project with plenty of work for to go around.

 

Scope

  • Include flang in AArch64 releases for both Linux and Windows

  • Provide CI for flang for both Linux and Windows, running check-all and the llvm-test-suite

  • Test relevant open-source workloads with flang; add them to CI if license/resources permit

  • Fix bugs, add missing features as needed by the workloads that we choose to prioritize

  • Check flang’s integration with CMake and provide CI if necessary

  • Publish developer notes on how to generate a WoA binary

  • Help the flang community as much as possible (e.g. with upstreaming from fir-dev/classic-flang)

Project lead(s): @Carlos Seo

Project Contacts

Source Code

LLVM Buildbots CI

LLVM Releases

Upstream Wiki

Upstream Collaboration (Slack, Technical and Community calls etc)

Community Production-Ready Criteria and Linaro Goals

The LLVM community currently agrees that flang-new will be renamed to flang only when:

  • Make HLFIR the default Fortran IR (done)

  • Remove -flang-experimental-exec flag (done)

  • Build and run SPEC CPU 2017 (done)

  • Full procedure pointers support (mostly done)

  • Most of the gfortran testsuite not crashing — special interest in fixing all the segmentation faults (done)

This happened in October 2024 and will be available in LLVM 20.

AArch64 enablement

We currently have full feature parity with x86_64 as of LLVM 19.

Support for trampoline intrinsics currently depend on compiler-rt and this dependency is planned to be removed when Flang has support for procedure pointers for internal procedures.

Linaro “production ready” criteria

In addition to the community criteria for renaming flang-new to flang, Linaro also considers that Flang will be production ready when:

  • Can build and run both SPEC CPU 2006 and 2017 (done)

  • Has debug information support (done)

  • Has Fortran 2008 support, except for coarrays

  • OpenMP support is stabilised (almost done)

  • Feature parity with x86 (done)

  • Performance is no slower than 25% compared to gfortran in SPEC CPU 2017 ‘rate’.

Linaro development completion criteria

 

Based on the current state of the compiler, Linaro should declare this project completed when the following conditions are met:

 

  1. Next-generation SPEC CPU is supported

As the next generation of SPEC CPU is close to release, Flang should be able to build it and correctly run all of its benchmarks in both ‘rate’ and ‘speed’ modes.

 

  1. OpenMP 2.5+ essential features are supported

OpenMP is becoming increasingly important with AI, so we need to support at least:

 

  • OpenMP 2.5

    • Workshare

    • Reprivatisation

    • Reduction (arrays)

    • Threadprivate (variables) (done)

    • Copyin (variables) (done)

    • Numthreads (done)

    • Copyprivate (done)

    • Directives can contain comments

    • _OPENMP macro

    • omp_lib module contains interface

    • OpenMP runtime routines

 

  • OpenMP 3.x — community goal for LLVM 20

    • Task (mostly done, missing support for delayed execution of tasks)

    • Taskwait

    • taskyield

 

  • OpenMP 4.x

    • Declare SIMD

    • Declare Reduction

    • Depend

    • Atomics

    • Target

    • Taskgroup

    • Teams

    • Taskloop

 

  • OpenMP 5.x — community goal for 2026

    • Order clause

    • Declare Target

    • Scan

    • Tile

    • Unroll

 

One caveat is that most of the fixes/supported features are on the host side only now. For GPU offloading, we currently have only a 15% pass rate in the tests. If Flang+OpenMP support in offloading is important, then we’ll have to revisit this list.

Active Tasks and Coordination

  • We are currently targeting: SPEC2017, SPEC2006, OpenBLAS, SciPy, NumPy

  • OpenBLAS

    • We have committed some fixes to flang to enable it to build OpenBLAS on WoA

  • SPEC2017 is tracked upstream in this board: https://github.com/orgs/llvm/projects/8

  • NumPy

  • SPEC2006

    • All benchmarks are passing except 465.tonto, which fails at compile time because of 2 issues

    • Qualcomm is working on one of them, the upstream community is working on the other

  • SNAP is known to work with flang, Linaro has been reviewing a patch to add it to the test-suite https://reviews.llvm.org/D130734

Achievements and Status

 

Current Plan

key summary created status due fixversions
Loading...
Refresh

Backlog

key summary created status
Loading...
Refresh

Accomplished

key summary created status resolutiondate
Loading...
Refresh

Linaro Ltd.