The Fortran 2008 standard has introduced a new form of parallelism named “Coarray” that is integrated directly into the Fortran language and based on the SPMD model.
The Fortran 2018 standard extends coarrays to include the notion of “team” and “collective” procedures.
The advantage of integrating the use of coarrays is that only minor changes to existing Fortran code are required to take account of this parallelism.
GCC currently supports all coarray-related features from Fortran 2008 and 2018. The use of coarrays can be done by using one of the three modes, which can be selected with
-fcoarray option at compile time.
none: Disables features on coarrays and displays an error message when one of the coarray constructs is encountered.
single: An optimized version of coarrays but using only 1 image.
lib: A communication lib based coarray version where OpenCoarrays provides 3 backends (MPI, GasNet, ARMCI).
OpenCoarrays is an open-source library that produces an ABI used by GCC Fortran frontend to build programs with Coarray and that abstracts away the underlying communication library. [GitHub - sourceryinstitute/OpenCoarrays: A parallel application binary interface for Fortran 2018 compilers.]
Today in LLVMFlang can only parse and perform semantic analysis on code containing coarray features. Execution is not possible since instructions or intrinsics related to coarrays because they are not yet implemented in LLVM.
I’m currently working on integrating the OpenCoarrays library into LLVM.
In the same way as GCC (explained above), I’d like to integrate the
-fcoarray= option, which would take
lib as arguments.
To compile a program in
lib mode, in GCC we also need to link to
-libcaf_mpi if we’re using the OpenCoarray’ MPI backend, or
-libcaf_mpi if we’re using the GasNet backend. Theses libraries need to be located in the
LD_LIBRARY_PATH or in a path given by -L option.
However, GCC has a
libgfortran which it can link to use coarrays. Flang doesn’t have these libraries. So It would be possible to add an option to select the backend has also been added like
-fcoarray-backend= to tell LLVMFlang which of
libcaf_gasnet and other we should link and these libraries need to be in the
- What is your feeling about this option?
Nowadays OpenCoarrays can only be built with GCC. When trying to build this library with LLVMFlang, we encounter problems due to the lack of implementation of coarray related features.
Or problems are related to the way OpenCoarrays has been developed, which implements certain functions depending on the version of GCC used.
So today I have proof-of-concept where a vast majority of the features from Fortran 2008 and some from Fortran 2018 are implemented using function calls from the OpenCoarrays library in the
However, I’m working on a version of
libcaf built with GCC and several symbols I use are prefixed with
_gfortran_caf due to having been built with GCC.
Is it appropriate to use symbols prefixed with
_gfortran_cafin LLVM, even if this is currently the only way to use Coarray functions from this library ?
Should we support
flang-newby OpenCoarrays before integrating its use in LLVM ? But this can only be done if
flang-newhas implemented the basic functionality of coarrays ?
Can I first release a version that uses
At the end of my work, it will then be possible to build OpenCoarrays library with LLVMFlang and with symbols that can be prefixed with
_flang_caf for example.
Thank you in advance for your feedback.