GPUFORT: S2S translation tool for CUDA Fortran and Fortran+X in the spirit of hipify
This project develops a source to source translation tool that is able to convert:
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:
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.
Please take a look at the (slightly outdated) user guide.
This presentation gives an overview of GPUFORT's building blocks.
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.
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.
!$acc enter data
, !$acc exit data
, !$acc data
!$acc wait, !$acc update self/host/device
!$acc kernels
plus !$acc loop
in subsequent line, !$acc kernels loop
, !$acc parallel
plus !$acc loop
in subsequent line, !$acc parallel loop
, !$acc loop
!$acc routine seq
functions with scalar arguments!$cuf kernel do
allocate
, allocated
, deallocate
, deallocated
, =
attributes(global)
(array and scalar arguments),
and attributes(host,device)
, attributes(device)
procedures (only scalar arguments supported for the latter)(List is not complete ...)
!$acc declare
(detected but not considered in codegen yet)!$acc parallel (loop)
!$acc parallel
without !$acc loop
in next line)
gang
parallelism!$acc kernels
without !$acc loop
in next line)