To: J3 J3/23-224r1 From: Mark LeAir Subject: Flang Liaison Report Date: 2023-October-16 Flang Open Source Fortran Report ================================ Flang is an open-source compiler for Fortran. It is an official subproject of the LLVM Project (llvm.org). NVIDIA's portion of the work was partially sponsored by the US Department of Energy Exascale Computing Project (particularly, LLNL, Sandia and LANL). The current goals of the project are to - Create an open source Fortran compiler with LLVM 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. There is a Slack workspace for Flang and a number of conference calls related to Flang development. - Flang biweekly sync call ("umbrella call") - Flang biweekly technical call - "Classic Flang" biweekly call - OpenMP in Flang Technical Call Details can be found on the Getting Involved page http://flang.llvm.org/docs/GettingInvolved.html. The New LLVM Flang Compiler --------------------------- The LLVM Fortran compiler is available at https://github.com/llvm/llvm-project (the LLVM monorepo) in the flang/ directory. LLVM Flang is being developed under the Apache 2.0 license with LLVM exceptions (the same as LLVM, Clang, OpenMP, etc.). Flang Work that has been completed in part of Q2 and Q3 (until 10-October) 2023: New features: * Added end-to-end support for IEEE_ARITHMETIC intrinsic module procedures IEEE_CLASS, IEEE_COPY_SIGN, IEEE_GET_ROUNDING_MODE, IEEE_IS_FINITE, IEEE_IS_NAN, IEEE_IS_NEGATIVE, IEEE_IS_NORMAL, IEEE_SET_ROUNDING_MODE, IEEE_SIGNBIT, IEEE_SUPPORT_ROUNDING, IEEE_UNORDERED, IEEE_VALUE for all applicable real kinds * CUDA Fortran parsing and semantic checking was merged * The macro #line is now supported * Support for Fortran 2023 SELECTED_LOGICAL_KIND was added in parsing and semantics * Enforce F2023 C7125. * Folding of NORM2, OUT_OF_RANGE, and MERGE with derived types was added * Folding of numerical intrinsics with quad precision arguments is now implemented. * Several extensions are now supported with warnings: ALLOCATABLE INTENT(IN) dummies now accept NULL actual argument. POINTER (resp. ALLOCATABLE) INTENT(IN) unlimited polymorphic dummies accept non unlimited polymorphic POINTER (resp. ALLOCATABLE) actual arguments. Pointer-valued function results are accepted in ASSOCIATED. Empty SEQUENCE type is accepted. Unrestricted intrinsics can be used as specifics in generics. DATA statements can now precede declaration under IMPLICIT NONE. * Automatic deallocation of local allocatable and allocatable components * All uninitialized saved variables are now zero initialized as an extension * Flang runtime can now be partially compiled for the device. Improvements to existing features for part of Q2 and Q3 (until 10-October) 2023 * More semantic errors are caught and reported at compile time: Automatic object in common blocks, READ of a namelist with undefinable member, use of X_PTR/C_FUNPTR as structure constructors, use of CONTIGUOUS on a pointer in BIND(C) interface, impure specifics called in DO CONCURRENT, noninteroperable dummy procedures in interoperable procedures, bad TARGET= arguments to ASSOCIATED(), ASYNCHRONOUS for subroutine, vector subscripts with duplicated elements when object must be definable, bad constant POS or LEN arguments of IBITS, COMMON block and implicit interface external subprogram with same name. More actual argument warnings. Warn about overflow after folding HYPOT. More compile-time error checking for null implied DO loops in array constructors. Strengthened procedure compatibility checking. Stricter checking of DIM= arguments to LBOUND/UBOUND/SIZE. * Additional errors detected at runtime: Detect NEWUNIT= without FILE= or STATUS='SCRATCH'. Detect references to invalid assigned formats. * Added portability warning for F2023 changes that are not backward compatible. Warn about automatic reallocation of deferred length allocatable in IOMSG/ERRMSG, INQUIRE or as INTENT(OUT) arguments of intrinsic procedures. * Updating documentation about build instructions, supported extensions, and Fortran 2023 * Improved error messages for DATA statements * Improved MATMUL and MATMUL-TRANSPOSE runtime. * Improved compile time performance in certain areas. * Bringing the new lowering using a higher-level representation IR (HLFIR) to a state where it can become default. The work covered the gaps in Forall, Where, user defined assignments, and vector subscripted entities as well as minor gaps. Alias analysis with HLFIR was improved. HLFIR is not yet default, because some IR tests needs to be ported, but it is expected to become default in the next quarter. * Added Comdat support in MLIR LLVM dialect and Flang to properly support properly linking symbols on Windows. * Fixed issue with nested subroutines on Windows/AArch64. * Made fdefault-integer-8 flag change the kinds of logical type as well. * Fixed performance issues with HLFIR enablement. * Patch in review for generating more TBAA alias information generation for subroutine arguments, globals etc. * OpenMP - Progress with various target and target data constructs, requires directive, map clauses. - A simple OpenMP offloading works now. * OpenACC - OpenACC is under active development in lowering to allow the lowering of the various OpenACC constructs to an MLIR based representation. Summary The current state of the LLVM Flang compiler: - written in modern C++ following LLVM conventions - over 200,000 lines of code, tests and scripts - parses all of Fortran 2018 to abstract syntax trees (AST) - parses OpenMP 4.5 and some OpenMP 5.0 - parses OpenACC 3.0 - defines a "Fortran Intermediate Representation" (FIR) based on LLVM's MLIR - can analyze most OpenMP and OpenACC constructs - can compile and correctly run Fortran 77 programs (passes FCVS test suite), nearly all Fortran 95 programs, and many programs that use Fortran 2003+ modern features. - supports end-to-end compilation of all OpenMP 1.1 except for reduction, privatization, and one atomic construct. - for later versions of OpenMP, Flang has support for simd, task, taskgroup etc. Current ("Classic") Flang Compiler ---------------------------------- The previous version of Flang, now known as Classic Flang, is derived from the PGI Fortran compiler, with some proprietary features removed (e.g., OpenACC support, inter-procedure analysis). It is the basis for commercial Fortran compilers from Arm, AMD, and Huawei. Classic Flang is available for Linux on x86-64, OpenPOWER, and Arm processors. OpenPower support is not currently being maintained but it is still available. Classic Flang developers report that the porting to LLVM-17 is almost complete. They are also working on interoperability with Microsoft Visual C/C++ so the compiler can be used on Windows. Detailed status can be found in the biweekly call Google doc at: docs.google.com/document/d/1-OuiKx4d7O6eLEJDBDKSRnSiUO2rgRR-c2Ga4AkrzOI