Skip to content

feat(hipsolver): add the generated Fortran binding in bindings/fortran/hipsolver - #12581

Draft
amontoison wants to merge 10 commits into
ROCm:developfrom
amontoison:users/amontoison/hipsolver-fortran-bindings
Draft

amontoison wants to merge 10 commits into
ROCm:developfrom
amontoison:users/amontoison/hipsolver-fortran-bindings

Conversation

@amontoison

@amontoison amontoison commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Implements RFC0015, Fortran Bindings Split (update) for hipSOLVER: bindings/fortran/hipsolver/ is a standalone CMake project that builds the generated Fortran binding against an installed hipSOLVER. The library is untouched: no option, no add_subdirectory, no change to projects/hipsolver/.

Draft until ROCm/rocm-systems#11923 (HIP Fortran binding, which the tests use) merges.

What lands

  • bindings/fortran/hipsolver/hipsolver.F90 (77 511 lines, generated with ROCm/rocm-fortran-generator 9c8b3e4 from the hipSOLVER headers, marked linguist-generated): one module hipsolver with the bind(C) interfaces, the enum constants, the hipsolverCheck helper and array overloads for the routines the generator supports.
  • metadata/hipsolver.toml: the generator metadata it was generated with.
  • test/: 106 CTest tests, 51 .f03 tests of the C interfaces and 55 .f08 tests of the array overloads (registered as <name>_f2008). They also install: the executables in bin/, and a CTestTestfile.cmake with the same tests and properties in bin/hipsolver-fortran/, for ctest --test-dir.
  • The binding defines roc::hipsolver_fortran, the name hipSOLVER's own Fortran target is exported under when the library is built with EXPORT_FORTRAN_BINDINGS=ON (its default). Configure finds hipSOLVER first and stops with a clear error in that case: build hipSOLVER with -DEXPORT_FORTRAN_BINDINGS=OFF. ROCm 10.1 does not export it.
  • CMakeLists.txt, the hipsolver-fortran config template, cmake/ROCmFortranCompiler.cmake (the same in every binding: ROCm's amdflang is preferred over the first compiler on PATH unless CMAKE_Fortran_COMPILER or FC is set), cmake/toolchains/ and the binding's CHANGELOG.md.
  • .github/CODEOWNERS: /bindings/fortran/hipsolver/ @ROCm/rocm-fortran-maintainers @ROCm/solvers-reviewers.
  • .github/repos-config.json: a bindings/fortran entry, 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(hipsolver-fortran) and links roc::hipsolver_fortran. The archive and .mod files install per compiler under lib/fortran/<compiler>/ and include/fortran/<compiler>/; HIPSOLVER_FORTRAN_COMPILER_DIR names that directory. The archive has one section per procedure, so a program linked with -Wl,--gc-sections keeps only the wrappers it calls.

Options

Option Default Effect
BUILD_FORTRAN_BINDINGS ${UNIX} builds the binding; skipped without a Fortran compiler
BUILD_FORTRAN_CLIENTS ON builds and installs the tests in test/; off under BUILD_ADDRESS_SANITIZER
FORTRAN_ARRAY_INTERFACES assumed-shape none / assumed-shape / assumed-rank array overloads

In TheRock

ROCm/TheRock#9446 builds bindings/fortran/hipsolver as the hipsolver-fortran subproject against the hipSOLVER it built, with -DBUILD_FORTRAN_BINDINGS=ON -DBUILD_FORTRAN_CLIENTS=${THEROCK_BUILD_TESTING}, ships it in the solver-fortran artifact and runs the installed tests in its hipsolver-fortran GPU test job.

Follow-ups

This binding replaces the hand-written library/src/hipsolver_module.f90 (deprecated since hipSOLVER 2.3.0) and the EXPORT_FORTRAN_BINDINGS option, which stay for now. Removing them and moving the library's Fortran clients and tests to this binding come in separate pull requests.

Build and test

From the repository root, with $PREFIX the install prefix:

lib=hipsolver
cmake -S bindings/fortran/$lib -B build/$lib-fortran \
  -DCMAKE_PREFIX_PATH="/opt/rocm;$HIP_FORTRAN_PREFIX" -DCMAKE_INSTALL_PREFIX="$PREFIX"
cmake --build build/$lib-fortran
ctest --test-dir build/$lib-fortran
cmake --install build/$lib-fortran
ctest --test-dir "$PREFIX/bin/$lib-fortran"

$HIP_FORTRAN_PREFIX holds the HIP Fortran binding (hip-fortran) built with the same compiler; without it the tests are skipped.

Verification

Standalone against ROCm 10.1 with amdflang on one GPU: 106 tests, 106 pass. Against a stand-in hipSOLVER package that exports roc::hipsolver_fortran, configure stops with the error above.

JIRA ID: ROCM-31390

@therock-pr-bot

therock-pr-bot Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass PR does not contain code files — Unit Test auto-passed
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #12581   +/-   ##
========================================
  Coverage    75.95%   75.95%           
========================================
  Files         2880     2880           
  Lines       479025   479025           
  Branches     71958    71958           
========================================
  Hits        363828   363828           
  Misses       90338    90338           
  Partials     24859    24859           
Flag Coverage Δ *Carryforward flag
TensileLite-CPP 48.93% <ø> (ø) Carriedforward from c3e9e1a
TensileLite-Unit 83.68% <ø> (ø) Carriedforward from c3e9e1a
hipBLAS 90.62% <ø> (ø) Carriedforward from c3e9e1a
hipBLASLt 64.43% <ø> (ø) Carriedforward from c3e9e1a
hipCUB 82.68% <ø> (ø) Carriedforward from c3e9e1a
hipDNN 86.78% <ø> (ø) Carriedforward from c3e9e1a
hipFFT 42.00% <ø> (ø) Carriedforward from c3e9e1a
hipRAND 76.12% <ø> (ø) Carriedforward from c3e9e1a
hipSOLVER 69.67% <ø> (ø)
hipSPARSE 86.99% <ø> (ø) Carriedforward from c3e9e1a
rocBLAS 68.73% <ø> (ø) Carriedforward from c3e9e1a
rocFFT 48.10% <ø> (ø) Carriedforward from c3e9e1a
rocRAND 57.30% <ø> (ø) Carriedforward from c3e9e1a
rocSOLVER 76.74% <ø> (ø) Carriedforward from c3e9e1a
rocSPARSE 76.92% <ø> (ø) Carriedforward from c3e9e1a
rocThrust 93.15% <ø> (ø) Carriedforward from c3e9e1a

*This pull request uses carry forward flags. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@amontoison
amontoison force-pushed the users/amontoison/hipsolver-fortran-bindings branch 2 times, most recently from 4b027b5 to ab0c960 Compare October 4, 2026 03:45
@amontoison amontoison changed the title feat(hipsolver): replace the hand-written Fortran binding with a generated one (RFC0014) feat(hipsolver): replace the hand-written Fortran binding with a generated one Oct 4, 2026
@amontoison
amontoison force-pushed the users/amontoison/hipsolver-fortran-bindings branch from ab0c960 to 627aef9 Compare October 5, 2026 05:13
Add fortran/hipsolver.F90, the hipsolver module generated
from the C headers by the rocm-fortran generator under RFC0019
(ROCm/TheRock#8122). It is committed next to the headers, is not
edited by hand, and .gitattributes marks it linguist-generated.
@amontoison
amontoison force-pushed the users/amontoison/hipsolver-fortran-bindings branch 3 times, most recently from 8a46dc7 to fca1b72 Compare October 22, 2026 15:31
…rated one

Build fortran/hipsolver.F90 as roc::hipsolver_fortran from fortran/, a
CMake project of its own that the root adds. BUILD_FORTRAN_BINDINGS
(default ${UNIX}, OFF on the CUDA backend) and BUILD_FORTRAN_CLIENTS
(default ON) control it, and HIPSOLVER_BUILD_FORTRAN_* override both per
library; FORTRAN_ARRAY_INTERFACES selects nothing here. The .mod and the
archive install per compiler under <includedir>/fortran/<compiler> and
<libdir>/fortran/<compiler>, beside a hipsolver-fortran config package.

Remove library/src/hipsolver_module.f90, deprecated since hipSOLVER
2.3.0, and EXPORT_FORTRAN_BINDINGS. Its hipsolver_enums module is folded
into hipsolver, so use hipsolver_enums becomes use hipsolver, and
outputs are passed by reference. fortran/test/ adds 51 CTest tests
labelled gpu; they use hip and skip until ROCm/rocm-systems#11923 lands.

Refs: ROCm/TheRock#8122 (RFC0019)
…bindings are missing

A standalone clients build with BUILD_FORTRAN_BINDINGS=ON (the default on
Linux) stopped with a FATAL_ERROR when hipsolver-fortran was not installed
for the Fortran compiler in use. Build the clients without the Fortran
tests and say so in a STATUS line, as every other project does when the
bindings are unavailable.
@amontoison
amontoison force-pushed the users/amontoison/hipsolver-fortran-bindings branch from fca1b72 to 11d4bca Compare October 22, 2026 18:13
…solver

The hipSOLVER Fortran binding consumes hipSOLVER's public API and builds
standalone against an installed hipSOLVER, so it moves out of the library
into bindings/fortran/hipsolver, 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. Its hand-written
Fortran module stays for now: its deprecation and removal, with the
Fortran clients that use it, follow in separate pull requests.

- bindings/fortran/hipsolver reads hipSOLVER's version from projects/hipsolver
- the binding has its own .gitattributes and CHANGELOG.md
- CODEOWNERS: /bindings/fortran/hipsolver/, same owners
- repos-config.json: register bindings/fortran/hipsolver so CI detects changes
@github-actions github-actions Bot added github actions project: none Does not target any component labels Nov 3, 2026
@amontoison amontoison changed the title feat(hipsolver): replace the hand-written Fortran binding with a generated one feat(hipsolver): add the generated Fortran binding in bindings/fortran/hipsolver Nov 3, 2026
Regenerate bindings/fortran/hipsolver with rocm-fortran-generator 9c8b3e4, and
commit its metadata in bindings/fortran/hipsolver/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/hipsolver-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.
An installed hipSOLVER built with EXPORT_FORTRAN_BINDINGS=ON exports its own
roc::hipsolver_fortran, so the alias defined first made find_package(hipsolver)
fail with "Some (but not all) targets in this export set were already
defined". Find hipSOLVER first and stop with a clear message when it still
exports that target. The tests reuse the parent's find_package result.
The binding is built against an installed hipSOLVER 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.
…lver-fortran

The package files went to lib/cmake/hipsolver, the C library's directory, with a forwarder in lib/cmake/hipsolver-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.
…ithout recursion

rocm-cmake's generated hipsolver-config.cmake is to include
lib/cmake/hipsolver-fortran/hipsolver-fortran-config.cmake after its
targets (ROCm/rocm-cmake#303). Skip find_dependency(hipsolver) when
hipsolver is the package being found, not only when roc::hipsolver is
already imported, so that include never re-enters
hipsolver-config.cmake.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant