Repository navigation
feat(hipfft): add the generated Fortran bindings for hipFFT and hipFFTW in bindings/fortran/hipfft - #12367
Draft
amontoison wants to merge 12 commits into
Draft
feat(hipfft): add the generated Fortran bindings for hipFFT and hipFFTW in bindings/fortran/hipfft#12367amontoison wants to merge 12 commits into
amontoison wants to merge 12 commits into
Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #12367 +/- ##
===========================================
+ Coverage 75.95% 75.97% +0.02%
===========================================
Files 2880 2880
Lines 479025 478959 -66
Branches 71958 71942 -16
===========================================
+ Hits 363828 363852 +24
+ Misses 90338 90255 -83
+ Partials 24859 24852 -7
*This pull request uses carry forward flags. Click here to find out more. 🚀 New features to boost your workflow:
|
This was referenced Sep 24, 2026
amontoison
force-pushed
the
users/amontoison/hipfft-fortran-bindings
branch
from
September 25, 2026 04:38
4bf4b89 to
43aeb34
Compare
This was referenced Sep 25, 2026
amontoison
force-pushed
the
users/amontoison/hipfft-fortran-bindings
branch
2 times, most recently
from
September 28, 2026 03:49
9b809e5 to
0b8436e
Compare
amontoison
force-pushed
the
users/amontoison/hipfft-fortran-bindings
branch
from
September 29, 2026 03:14
0b8436e to
1b60747
Compare
amontoison
force-pushed
the
users/amontoison/hipfft-fortran-bindings
branch
from
October 4, 2026 03:45
9c09f06 to
dc432d8
Compare
amontoison
force-pushed
the
users/amontoison/hipfft-fortran-bindings
branch
from
October 5, 2026 05:13
dc432d8 to
71f5001
Compare
Add fortran/hipfft.F90 and fortran/hipfftw.F90, the hipfft and hipfftw modules generated from the C headers by the rocm-fortran generator under RFC0019 (ROCm/TheRock#8122). They are committed next to the headers, are not edited by hand, and .gitattributes marks them linguist-generated.
amontoison
force-pushed
the
users/amontoison/hipfft-fortran-bindings
branch
4 times, most recently
from
October 22, 2026 15:31
44e940a to
80d81b3
Compare
Build fortran/hipfft.F90 and fortran/hipfftw.F90 as hip::hipfft_fortran
and hip::hipfftw_fortran from fortran/, a CMake project of its own that
the root adds. BUILD_FORTRAN_BINDINGS (default ${UNIX}, OFF on the CUDA
backend), BUILD_FORTRAN_CLIENTS (default ON) and
FORTRAN_ARRAY_INTERFACES (default assumed-shape, hipfft only) control
them, and HIPFFT_BUILD_FORTRAN_* and HIPFFTW_BUILD_FORTRAN_* override
per binding. The .mod files and the archives install per compiler under
<includedir>/fortran/<compiler> and <libdir>/fortran/<compiler>, beside
hipfft-fortran and hipfftw-fortran config packages.
fortran/test/ adds 20 CTest tests labelled gpu; they use hip and skip
until ROCm/rocm-systems#11923 lands. hipFFT had no Fortran module
before, so nothing is removed.
Refs: ROCm/TheRock#8122 (RFC0019)
amontoison
force-pushed
the
users/amontoison/hipfft-fortran-bindings
branch
from
October 22, 2026 18:14
80d81b3 to
9f54e86
Compare
The hipFFT Fortran binding consumes hipFFT's public API and builds standalone against an installed hipFFT, so it moves out of the library into bindings/fortran/hipfft, the tree every monorepo and TheRock use for the Fortran bindings (RFC0015). Nothing is wired into the library build any more: the library is back to its state on develop. - bindings/fortran/hipfft reads hipFFT's version from projects/hipfft - the binding has its own .gitattributes and CHANGELOG.md - CODEOWNERS: /bindings/fortran/hipfft/, same owners - repos-config.json: register bindings/fortran/hipfft so CI detects changes
Regenerate bindings/fortran/hipfft with rocm-fortran-generator 9c8b3e4, and commit its metadata in bindings/fortran/hipfft/metadata/, where the generator reads it from a checkout, instead of the copy kept in the generator.
Install the test executables in bin/, and a CTestTestfile.cmake in bin/hipfft-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 binding is built against an installed hipFFT and is never added to the library's build, so drop what only served that: the per-library BUILD_FORTRAN_* overrides, the PARENT_SCOPE results, the ROCM_HAVE_FORTRAN shortcut, the gating on the library's client and test options, and the comments about the root. Find the Fortran compiler through the cmake/ROCmFortranCompiler.cmake shared by all the bindings, and require CMake 3.19. The binding targets the ROCm backend only, so BUILD_FORTRAN_BINDINGS no longer defaults to OFF on the CUDA backend. Without the HIPFFT_* and HIPFFTW_* overrides, both modules build together.
…modules One module per C header, as CUDA Fortran's cufft and cufftXt, so that `use cufftXt` hipifies to `use hipfftxt`: hipfft holds hipfft.h, and hipfftxt holds hipfftXt.h and hipfftMp.h. hipfftxt uses hipfft, so `use hipfftxt` alone gives the whole API. Both build into libhipfft_fortran.a (hip::hipfft_fortran), and the Xt and Mp metadata moves to metadata/hipfftxt.toml. Regenerated with ROCm/rocm-fortran-generator#17.
Every hipfftXt* and hipfftMp* function is now in hipfftxt, as cufftXtSetWorkArea is in CUDA Fortran's cufftXt module, although hipfft.h declares hipfftXtSetWorkArea. Regenerated with ROCm/rocm-fortran-generator#17.
…ortran and lib/cmake/hipfftw-fortran The package files went to lib/cmake/hipfft, the C library's directory, with a forwarder in lib/cmake/hipfft-fortran and lib/cmake/hipfftw-fortran. rocRAND and hipRAND install their own legacy <lib>-fortran-config.cmake there, so the files overlapped. Install the config, targets and version files directly where find_package(<package>) looks, as the HIP and ROCTx bindings do, and drop the forwarder.
… recursion rocm-cmake's generated hipfft-config.cmake is to include lib/cmake/hipfft-fortran/hipfft-fortran-config.cmake after its targets (ROCm/rocm-cmake#303). Skip find_dependency(hipfft) when hipfft is the package being found, not only when hip::hipfft (hip::hipfftw for hipfftw-fortran) is already imported, so that include never re-enters hipfft-config.cmake.
hipFFTW is built and exported with hipFFT, so hipfft-config.cmake defines both hip::hipfft and hip::hipfftw. hipfft-fortran-config.cmake now includes hipfftw-fortran-config.cmake when installed, so find_package(hipfft) (through the rocm-cmake hook) and find_package(hipfft-fortran) also give hip::hipfftw_fortran. The include is optional and its failure only sets hipfftw-fortran_* variables, so hipfft-fortran is still found without it.
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.
Implements RFC0015, Fortran Bindings Split (update) for hipFFT:
bindings/fortran/hipfft/is a standalone CMake project that builds the generated Fortran binding against an installed hipFFT. The library is untouched: no option, noadd_subdirectory, no change toprojects/hipfft/.What lands
cufftandcufftXtmodules, so thatuse cufftXthipifies touse hipfftxt. Generated from the hipFFT headers with feat(hipfft): bind the Xt and Mp API in a hipfftxt module beside hipfft rocm-fortran-generator#17 (not merged yet) and markedlinguist-generated:bindings/fortran/hipfft/hipfft.F90(1 683 lines): modulehipfft, thehipfft*functions ofhipfft.h, with the enum constants, thehipfftCheckhelper and array overloads.bindings/fortran/hipfft/hipfftxt.F90(651 lines): modulehipfftxt, everyhipfftXt*andhipfftMp*function, as in CUDA Fortran'scufftXt(sohipfftXtSetWorkAreatoo, althoughhipfft.hdeclares it), with the Xt enums and thehipXtDesc/hipLibXtDesctypes ofhiplibxt.h. Ituseshipfftand re-exports it, souse hipfftxtalone gives the whole API, as#include <hipfft/hipfftXt.h>does in C. Fortran is case-insensitive, souse hipfftXtworks too.bindings/fortran/hipfft/hipfftw.F90(3 021 lines): the FFTW3-compatible modulehipfftw, fromhipfftw.h, with theFFTW_*flags and thefftw_iodim/fftw_iodim64types.metadata/hipfft.toml,metadata/hipfftxt.toml,metadata/hipfftw.toml: the generator metadata they were generated with.test/: 36 CTest tests, 23.f03tests of the C interfaces and 13.f08tests of the array overloads (registered as<name>_f2008).hipfft_xt_descriptor_zskips (return code 77) on fewer than two GPUs. They also install: the executables inbin/, and aCTestTestfile.cmakewith the same tests and properties inbin/hipfft-fortran/, forctest --test-dir.hipfftandhipfftxtbuild into one archive,libhipfft_fortran.a(targethip::hipfft_fortran, packagehipfft-fortran).hipfftwdoes notuse hipfft, so it has its own target (hip::hipfftw_fortran), archive and config package (hipfftw-fortran); both build together.CMakeLists.txt, thehipfft-fortranandhipfftw-fortranconfig templates,cmake/ROCmFortranCompiler.cmake(the same in every binding: ROCm'samdflangis preferred over the first compiler onPATHunlessCMAKE_Fortran_COMPILERorFCis set),cmake/toolchains/and the binding'sCHANGELOG.md..github/CODEOWNERS:/bindings/fortran/hipfft/ @ROCm/rocm-fortran-maintainers @ROCm/fft-reviewers..github/repos-config.json: abindings/fortranentry, so CI detects changes to the binding. Each binding PR appends its entry at the end of the list, so all but the first to merge need a trivial rebase.A consumer uses
find_package(hipfft-fortran)orfind_package(hipfftw-fortran)and linkship::hipfft_fortranorhip::hipfftw_fortran. The archive and.modfiles install per compiler underlib/fortran/<compiler>/andinclude/fortran/<compiler>/;HIPFFT_FORTRAN_COMPILER_DIRnames that directory. The archive has one section per procedure, so a program linked with-Wl,--gc-sectionskeeps only the wrappers it calls.Options
BUILD_FORTRAN_BINDINGS${UNIX}BUILD_FORTRAN_CLIENTSONtest/; off underBUILD_ADDRESS_SANITIZERFORTRAN_ARRAY_INTERFACESassumed-shapenone/assumed-shape/assumed-rankarray overloadsIn TheRock
ROCm/TheRock#9446 builds
bindings/fortran/hipfftas thehipfft-fortransubproject against the hipFFT it built, with-DBUILD_FORTRAN_BINDINGS=ON -DBUILD_FORTRAN_CLIENTS=${THEROCK_BUILD_TESTING}, ships it in thefft-fortranartifact and runs the installed tests in itshipfft-fortranGPU test job.Follow-ups
hipFFT never shipped a Fortran module, so there is nothing to deprecate.
Build and test
From the repository root, with
$PREFIXthe install prefix:$HIP_FORTRAN_PREFIXholds the HIP Fortran binding (hip-fortran) built with the same compiler; without it the tests are skipped.Verification
Standalone against ROCm 10.1 on one GPU, with amdflang and with gfortran: 36 tests, 35 pass, 1 skipped. From the install tree,
ctest --test-dir $PREFIX/bin/hipfft-fortrangives the same result.JIRA ID: ROCM-31390