To: J3 J3/19-261 From: Gary Klimowicz Subject: Flang Open Source Liaison Report Date: 2019-October-18 Flang Open Source Fortran Report ================================ Flang is an open source compiler for Fortran, sponsored by the US Department of Energy (particularly, LLNL, Sandia and LANL). The goals of the project are to - Create a new, open source Fortran 2018 compiler with Apache 2.0 licensing, - that can be used for language and parallelization experimentation, - that exists as a peer in the LLVM community of languages, like Clang, - that can rely on LLVM code generation and parallelism support for CPUs and GPUs. Flang has been accepted as a formal LLVM project as its Fortran compiler. The work that is being upstreamed to LLVM is the new "flang" compiler (formerly known as "f18"). There are now LLVM-hosted email lists for Flang. This version of Flang will ultimately replace the current Flang compiler after a period of transition where both compilers are supported. The old flang-dev and flang-announce mailing lists hosted at http://lists.flang-compiler.org/ are no longer in use. Please use the LLVM flang-dev and flang-commit email lists. There is a Slack channel, http://flang-compiler.slack.com/ for more interaction with the Flang community at large. There is a biweekly half-hour conference call providing status updates on Flang. It is held every other Wednesday at 8:30 AM Pacific time (the next is October 30, 2019). Hal Finkel of Argonne National Laboratories hosts a biweekly Flang Community Technical call Mondays 8:30 AM Pacific Time on the weeks alternating with the above call. The next call is scheduled for October 21, 2019. Recent topics have included: - DWARF (2019-10-07) - flangd - tool development using f18 with the Language Server Protocol (2019-09-23) - Module files (2019-09-09) - Array descriptors (2019-08-28) - Aliasing information and LLVM enhancements (2019-08-14) The New LLVM Flang Compiler --------------------------- The older code base used to seed the initial Flang compiler was not going to meet the long-term goals of the project. The Flang community has begun a new project to rewrite the Fortran front-end in C++ to better align with the LLVM and Clang communities and to better leverage the existing tools and techniques from these communities. This new front-end is available at https://github.com/flang-compiler/f18 until it can be moved to the LLVM monorepo repository. All development is being done on the open source repository, and you can follow the pull request activity from the developers there. No contributor license agreement is needed to contribute to LLVM Flang, which is being developed under the Apache 2.0 license with LLVM extensions (the same as LLVM and Clang). The current state of LLVM Flang is - written in modern C++ following LLVM conventions; - parses all of Fortran 2018 to abstract syntax trees (AST); - implements preprocessing directives; - implements most semantic processing, including declarations, compile-time intrinsic folding, and I/O statements and formatted I/O. - implementing a "Fortran Intermediate Representation" based on MLIR, a new multi-level IR that has been adopted by the LLVM community. (MLIR is the intermediate representation used by TensorFlow. It is extensible with dialects, like the Fortran IR and the proposed OpenMP IR, and allows mixing of dialects in the stream.) We have been taking contributions from other developers, including Arm, Ltd and others. Upcoming work includes - completing work on semantics - beginning the process of lowering Fortran IR; - completing definition of the runtime environment; - implementation of runtime. Current Flang Compiler ---------------------- The initial version of Flang is derived from the PGI Fortran compiler, with some proprietary features removed (OpenACC support, inter-procedure analysis). It was published on GitHub in May 2017 at github.com/flang-compiler, and consists of several subprojects (including the Flang driver and compiler itself, and changes to LLVM to support Fortran debug metadata to be upstreamed). The current compiler supports Fortran 2003 and some Fortran 2008 features. Recent improvements to Flang include - many bug fixes and enhancements from the PGI compiler; - support for LLVM 8.0; - improvements to libpgmath including tuned versions of LOG, ANINT and POPCNT; - support for Fortran 2018 DO CONCURRENT; - support for Fortran 2018 G0 edit descriptors; - support for the NORM2 vector intrinsic and BACK optional argument on MAXLOC and MINLOC intrinsics; - Fortran 2008 support for multiple module procedures in a single declaration and multiple allocations with SOURCE and MOLD arguments; - Fortran debug metadata for COMMON blocks, allocatable arrays and pointers, and formal parameters; - initial support for OpenMP target offload based on Clang's LLVM 7.0 work. Flang is available for Linux on x86-64, OpenPOWER and Arm processors, and is the basis of the Arm commercial Fortran compiler. AMD has indicated their interest in adopting flang as well. Members of the community are also working on ports to Mac OS X and packages for OpenBSD and FreeBSD. We will be opening up the development of the original Flang compiler to new committers in the coming months. This will move all development into open source under the Apache 2.0 with LLVM extensions license, and no longer require a contributor license agreement.