Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

GPUFORT: S2S translation tool for CUDA Fortran and Fortran+X in the spirit of hipify

License

NotificationsYou must be signed in to change notification settings

ROCm/gpufort

Repository files navigation

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 compiledwith AOMP, which has a Fortran frontend.The result of the second translation process can be compiledwith hipfort or a combination of hipcc and gfortran.Note that a OpenACC runtime is only necessary for translatingOpenACC 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 becausewe believe that it might be helpful for some.We want to stress that the code translation and code generation outputs producedby 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 a compiler (yet)

GPUFORT is not intended to be a compiler.It's main purpose is to be a translator that allowsan experienced user to fix and tune the outcomesof the translation process.However, we believe GPUFORT can develop into anearly-outlining compiler if enough effortis put into the project.Given that all code and especially the grammar iswritten in python3, GPUFORT can be developed at a quickpace.

  • GPUFORT assumes syntactically and functionally correct input

GPUFORT does only perform a small number of syntax checks as we assumethat 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.)

  • GPUFORT does a bad job in analyzing what code parts can be offloaded and which ones not
  • GPUFORT does a bad job in reorganizing loops and assignments in order to maximizethe available parallelism

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 does not implement the full OpenACC standard (yet)

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

Fortran-C Interoperablity Limitations

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

  • "Derived types with the C binding attribute shall not have the sequence attribute, type parameters, the extends attribute, nor type-bound procedures."
  • "Every component must be of interoperable type and kind and may not have thepointer orallocatable attribute. The names of the components are irrelevant for interoperability."

(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:

  • ACC:
    • ACC2OMP & ACC2HIP
    • Translation of data directives:!$acc enter data,!$acc exit data,!$acc data
    • Synchronization directives:!$acc wait, !$acc update self/host/device
    • Kernel and loop constructs!$acc kernels plus!$acc loop in subsequent line,!$acc kernels loop,!$acc parallel plus!$acc loopin subsequent line,!$acc parallel loop,!$acc loop
    • Support for!$acc routine seq functions with scalar arguments
  • CUF:
    • CUF2HIP
      • Majority of CUDA libary functionality via HIPFORT
      • Kernel and loop constructs:!$cuf kernel do
      • Overloaded intrinsics:allocate,allocated,deallocate,deallocated,=
      • Support for CUDA Fortranattributes(global) (array and scalar arguments),andattributes(host,device),attributes(device) procedures (only scalar arguments supported for the latter)

(List is not complete ...)

Planned features (or: "more limitations")

  • Current work focuses on:
    • ACC:
      • Initial support for!$acc declare (detected but not considered in codegen yet)
      • Improve support for!$acc parallel (loop)
      • Add support for!$acc parallel without!$acc loop in next line)
        • Results ingang parallelism
      • Add support for!$acc kernels without!$acc loop in next line)
        • Auto detection of offloadable code parts
      • Rewrite of GPUFORT Fortran runtime in (HIP) C++
    • ACC/CUF:
      • Support of derived types with allocatable, pointer members
  • Planned:
    • Add option for prescribing syntax checker (e.g. use other compiler for syntax checks.)

[8]ページ先頭

©2009-2025 Movatter.jp