To: J3 J3/19-209 From: Gary Klimowicz Subject: Flang Open Source Liaison Report Date: 2019-August-07 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 recently accepted as a formal LLVM project as it's Fortran compiler. The work that is being upstreamed to LLVM is the new "F18" compiler. There are now LLVM-hosted email lists for Flang. F18 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/ will be available through August and then we will switch tot he LLVM email lists. There is also 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, every other Wednesday at 8:30 AM Pacific time (the next is February 20, 2018). Hal Finkel of Argonne National Laboratories hosts a Flang Community Technical call on alternating weeks with the above call. Recent topics have included: - The use of MLIR as a Fortran Intermediate Representation and post-AST transformations - Plans for OpenMP implementation in Flang - A proposal for the "flang" driver 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; - many improvements in the libpgmath library; - 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. Contributions to this version of the compiler are encouraged, but require executing a contributor license agreement (CLA) with NVIDIA due to the nature of the way we combine internal and external improvements to Flang. The New F18 Compiler -------------------- The older code base used to seed the initial Flang compiler is not going to meet the long-term goals of the project. NVIDIA 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, which we call F18, is available at https://github.com/flang-compiler/f18. All development for F18 is being done on the open source repository, and you can follow the pull request activity from our developers there. No contributor license agreement is needed to contribute to F18, which is being developed under the Apache 2.0 license with LLVM extensions (the same as LLVM and Clang). The current state of F18 is - written in modern C++ following LLVM conventions; - parses all of Fortran 2018 to abstract syntax trees (AST); - recognizes most common comment-based directives (including OpenMP), though there is limited semantic processing; - 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 is expected to be adopted by the LLVM community. (MLIR is the intermediate representation used by TensorFlow. It is extensible with dialects, like the Fortran IR and a proposed OpenMP IR, and allows mixing of dialects in the stream.) We are beginning to take contributions from other developers, and have pulled in enhancements from other contrbutors, like Arm Ltd. Upcoming work includes - continued work on semantics, and beginning the process of lowering Fortran IR; - definition of runtime environment; - implementation of Fortran I/O semantics and runtime.