Repository navigation
feat(fortran): add the ROCTx Fortran binding to bindings/fortran - #14024
Open
amontoison wants to merge 18 commits into
Open
amontoison wants to merge 18 commits into
amontoison wants to merge 18 commits into
Conversation
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
amontoison
force-pushed
the
users/amontoison/roctx-fortran-bindings
branch
from
October 22, 2026 15:32
7e944ce to
1bfea42
Compare
dysu-amd
reviewed
Oct 22, 2026
amontoison
commented
Oct 22, 2026
amontoison
force-pushed
the
users/amontoison/roctx-fortran-bindings
branch
from
October 22, 2026 18:15
cfb420b to
ce7d714
Compare
This was referenced Oct 22, 2026
amontoison
force-pushed
the
users/amontoison/roctx-fortran-bindings
branch
from
October 22, 2026 21:24
ce7d714 to
08de789
Compare
Add projects/fortran/hip.F90, the hip module generated from the HIP C headers by rocm-fortran-generator under RFC0015 (ROCm/TheRock#8122). projects/fortran is a standalone project for the Fortran bindings of the rocm-systems libraries. The module is not edited by hand: .gitattributes marks it linguist-generated, and metadata/ holds what the C headers cannot express (scalar arguments, optional arguments, by-value arguments, function pointers), read by the generator when it runs on this checkout.
Co-authored-by: Alexis Montoison <35051714+amontoison@users.noreply.github.com>
Build projects/fortran/hip.F90 as hip::hip_fortran, a standalone CMake
project built against an installed HIP (find_package(hip)).
BUILD_FORTRAN_BINDINGS (default ${UNIX}), BUILD_FORTRAN_CLIENTS (default
ON) and FORTRAN_ARRAY_INTERFACES (default assumed-shape) control it, and
HIP_BUILD_FORTRAN_* override them. The .mod and the archive install per
compiler under <includedir>/fortran/<compiler> and
<libdir>/fortran/<compiler>, beside a hip-fortran config package.
shared/cmake/ROCmFortran.cmake adds the amdflang-first compiler probe
for rocm-systems projects.
test/ adds 41 CTest tests labelled gpu (39 without a HIP compiler). The
Fortran tests of the rocm-libraries bindings use hip and skip until this
lands.
Refs: ROCm/TheRock#8122 (RFC0015)
RFC0015 puts the HIP and ROCTx bindings in one rocm-systems project, projects/fortran/, built against the installed runtime, so that rocprofiler-sdk's build and CI carry no Fortran. - move roctx.F90, its config package and its test from projects/rocprofiler-sdk/fortran/, and drop the rocprofiler-sdk hook, its duplicate toolchain files and its CHANGELOG entry; - regenerate roctx.F90 with rocm-fortran-generator: X / X_ generics and typed character(kind=c_char) forms of the string routines; - split projects/fortran/CMakeLists.txt into the shared options, guard and compiler naming, plus hip.cmake and roctx.cmake; ROCTX_ overrides sit beside the HIP_ ones, and both libraries install under HIP_FORTRAN_INSTALL_COMPONENT; - the test passes c_loc(tid) to roctxGetThreadId, as the C API takes a pointer, and exercises the typed forms.
amontoison
force-pushed
the
users/amontoison/roctx-fortran-bindings
branch
from
November 3, 2026 04:45
08de789 to
54ce31a
Compare
The binding consumes HIP's public API and builds standalone against an installed HIP, so it gets its own top-level tree instead of sitting next to the implementation projects: projects/fortran moves to bindings/fortran, the layout every monorepo and TheRock use for the Fortran bindings. - read HIP's VERSION from projects/hip, now two levels up - CODEOWNERS: /bindings/fortran/, same owners - repos-config.json: register bindings/fortran so CI detects changes to it, as for emulation/rocjitsu
…s/fortran The bindings consume the public HIP and ROCTx APIs and build standalone against the installed libraries, so they get their own top-level tree instead of sitting next to the implementation projects: projects/fortran moves to bindings/fortran, the layout every monorepo and TheRock use for the Fortran bindings. - read HIP's and rocprofiler-sdk's VERSION from projects/, now two levels up - CODEOWNERS: /bindings/fortran/, same owners - repos-config.json: register bindings/fortran so CI detects changes to it, as for emulation/rocjitsu - apply gersemi
Install the test executables in bin/, and one CTestTestfile.cmake per binding in bin/hip-fortran/ and bin/roctx-fortran/, with the same tests and properties as the build tree, so that ctest --test-dir runs them from an install, as TheRock's test jobs do for the libraries. The code object of module_kernel and library_module installs beside the HIP CTestTestfile.cmake, which they find by a relative path.
Install the test executables in bin/, and a CTestTestfile.cmake in bin/hip-fortran/, with the same tests and properties as the build tree, so that ctest --test-dir runs them from an install, as TheRock's test jobs do for the libraries. The code object of module_kernel and library_module installs beside it, and they find it by a relative path.
The ROCTx branch already moved both bindings to bindings/fortran and installed their tests, so the merged tree keeps its split of the HIP build into hip.cmake next to roctx.cmake.
…ator 9c8b3e4 The generator reads a library's metadata from bindings/fortran/metadata/ once that directory exists, so roctx.toml must sit next to hip.toml.
…object TheRock's hipcc comes from the HIP install and does not know where the device libraries are; it passes their path through HIP_FORTRAN_GENCO_FLAGS.
…oison/roctx-fortran-bindings
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fortran bindings for ROCTx, generated from the ROCTx headers and placed where RFC0015 (as updated in ROCm/TheRock#9433) puts them: in
bindings/fortran/, next to the HIP binding, rather than inprojects/rocprofiler-sdk/.This keeps Fortran out of rocprofiler-sdk's build and CI.
This PR takes over #12700 and keeps @Abuudiii's four commits, with their authorship.
Merge after #11923 (HIP binding), which adds
bindings/fortran/. This branch contains #11923's branch (merged in), so until #11923 lands the diff also shows the HIP binding.Technical Details
roctx.F90is regenerated with ROCm/rocm-fortran-generator:X/X_generics, and every string routine also accepts acharacter(kind=c_char)string.bindings/fortran/metadata/roctx.tomlis the generator's ROCTx metadata, next tohip.toml.bindings/fortran/CMakeLists.txt(projectrocm-systems-fortran) keeps the shared options, guard and compiler naming, and includeship.cmakeandroctx.cmake.ROCTX_BUILD_FORTRAN_BINDINGS/ROCTX_BUILD_FORTRAN_CLIENTSoverride the global switches for ROCTx alone, as theHIP_ones do for HIP.roc::roctx_fortranfrom aroctx-fortranpackage, in the samedevcomponent as the HIP binding. The archive has one section per procedure, and the test links with-Wl,--gc-sections.c_loc(tid)toroctxGetThreadId, whose C argument is a pointer, and also calls the typed string forms.develop.Issue Tracking
JIRA ID: ROCM-31390
Test Plan
Standalone build of
bindings/fortranagainst ROCm 10.2 with gfortran 13.3 and amdflang, each under the threeFORTRAN_ARRAY_INTERFACESvalues, on one gfx1101 GPU.Test Result
roctx.F90andmetadata/roctx.tomlmatch the output of ROCm/rocm-fortran-generator9c8b3e4on this checkout. 42 tests registered (41 HIP +roctx_fortran_roctx; 35 withFORTRAN_ARRAY_INTERFACES=none): all pass in the six configurations against ROCm 10.2,mem_advise,peer_copyandcooperative_launchreporting skipped on this device. Against ROCm 10.1, the HIP testsrdma_flushandlibrary_moduledo not link (newer HIP entry points) and the rest pass, includingctest --test-dir $PREFIX/bin/roctx-fortranfrom an install (/opt/rocm/libonLD_LIBRARY_PATH).Submission Checklist
cc @Abuudiii: this carries your ROCTx work into
bindings/fortran/. Could you take a look, and close #12700 if you agree?The bindings live in
bindings/fortran/, rocm-systems' tree for API consumers, outside the implementation projects (RFC0015): they use only the public API and build standalone against the installed libraries.