GitHub - ROCm/gpufort: GPUFORT: S2S translation tool for CUDA Fortran and Fortran+X in the spirit of hipify (original) (raw)

This project develops a source to source translation tool that is able to convert:

  1. Fortran+OpenACC and CUDA Fortran -> Fortran + OpenMP 4.5+
  2. Fortran+OpenACC and CUDA Fortran -> Fortran + [GCC/AOMP OpenACC/MP runtime calls] + HIP C++

The result of the first translation process, can be compiled with AOMP, which has a Fortran frontend. The result of the second translation process can be compiled with hipfort or a combination of hipcc and gfortran. Note that a OpenACC runtime is only necessary for translating OpenACC code.

An overview of the different translation paths that we work on is shown below:

Image

NOTE: GPUFORT is a research project. We made it publicly available because we believe that it might be helpful for some. We want to stress that the code translation and code generation outputs produced by GPUFORT will in most cases require manual reviewing and fixing.

Installation and usage

Please take a look at the (slightly outdated) user guide.

Implementation details

This presentationgives an overview of GPUFORT's building blocks.

Limitations

GPUFORT is not intended to be a compiler. It's main purpose is to be a translator that allows an experienced user to fix and tune the outcomes of the translation process. However, we believe GPUFORT can develop into an early-outlining compiler if enough effort is put into the project. Given that all code and especially the grammar is written in python3, GPUFORT can be developed at a quick pace.

GPUFORT does only perform a small number of syntax checks as we assume that developers apply GPUFORT to code that can be run correctly on CUDA devices. (We plan to add the option to prescribe a user-specified syntax checker tool.)

While both would be possible as the translator works with a tree structure, we simply have not started to implement much in this direction yet.

GPUFORT was developed to translate a number of HPC apps to code formats that are well supported by AMD's ROCm ecosystem. The development of GPUFORT is steered by the requirements of these applications.

Fortran-C Interoperablity Limitations

To interface generated HIP C++ kernels with the original Fortran code, GPUFORT relies on the iso_c_binding interoperability mechanisms that were added to the Fortran language with the Fortran 2003 standard. Please be aware that the interoperability of C structs and Fortran derived types is quite limited till this date:

(Source: https://gcc.gnu.org/onlinedocs/gfortran/Derived-Types-and-struct.html)

We are currently investigating what workarounds could be automatically applied. Until then, you have to modify your code manually to circumvent the above limitations.

Currently supported features:

(List is not complete ...)

Planned features (or: "more limitations")