Repository navigation
feat(rocrand): add the generated Fortran binding in bindings/fortran/rocrand - #12505
Draft
amontoison wants to merge 10 commits into
Draft
amontoison wants to merge 10 commits into
amontoison wants to merge 10 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. |
Pre-commit check failed⛔ pre-commit failed Please run locally:
This repo uses |
amontoison
force-pushed
the
users/amontoison/rocrand-fortran-bindings
branch
2 times, most recently
from
September 24, 2026 02:10
7d4b156 to
558118c
Compare
amontoison
force-pushed
the
users/amontoison/rocrand-fortran-bindings
branch
3 times, most recently
from
September 24, 2026 03:32
542aa70 to
bcace51
Compare
|
🎉 All checks passed! This PR is ready for review. |
This was referenced Sep 24, 2026
amontoison
force-pushed
the
users/amontoison/rocrand-fortran-bindings
branch
4 times, most recently
from
September 25, 2026 04:22
0e9fbe0 to
4f5a4e8
Compare
This was referenced Sep 25, 2026
amontoison
force-pushed
the
users/amontoison/rocrand-fortran-bindings
branch
from
September 25, 2026 19:08
4f5a4e8 to
e82e12d
Compare
amontoison
force-pushed
the
users/amontoison/rocrand-fortran-bindings
branch
2 times, most recently
from
September 28, 2026 03:48
69100d5 to
cb6a8e9
Compare
amontoison
force-pushed
the
users/amontoison/rocrand-fortran-bindings
branch
2 times, most recently
from
September 30, 2026 17:21
55550f3 to
ecba5ce
Compare
amontoison
force-pushed
the
users/amontoison/rocrand-fortran-bindings
branch
from
October 4, 2026 03:45
8731cb3 to
40d15fa
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (57.35%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #12505 +/- ##
===========================================
- Coverage 78.17% 78.15% -0.02%
===========================================
Files 2977 2977
Lines 508873 508796 -77
Branches 79012 79006 -6
===========================================
- Hits 397805 397639 -166
- Misses 83888 83926 +38
- Partials 27180 27231 +51
*This pull request uses carry forward flags. Click here to find out more. 🚀 New features to boost your workflow:
|
amontoison
force-pushed
the
users/amontoison/rocrand-fortran-bindings
branch
from
October 5, 2026 05:13
40d15fa to
c0ab44b
Compare
Add fortran/rocrand.F90, the rocrand 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
force-pushed
the
users/amontoison/rocrand-fortran-bindings
branch
3 times, most recently
from
October 22, 2026 15:31
62fdbb2 to
3593575
Compare
Build fortran/rocrand.F90 as roc::rocrand_fortran from fortran/, a CMake
project of its own that the root adds. BUILD_FORTRAN_BINDINGS (default
${UNIX}), BUILD_FORTRAN_CLIENTS (default ON) and
FORTRAN_ARRAY_INTERFACES (default assumed-shape) control it, and
ROCRAND_BUILD_FORTRAN_* override per library. The .mod and the archive
install per compiler under <includedir>/fortran/<compiler> and
<libdir>/fortran/<compiler>, beside a rocrand-fortran config package.
Remove the rocrand_m wrapper, its HIP modules and BUILD_FORTRAN_WRAPPER,
deprecated since rocRAND 4.0.0, so use rocrand_m becomes use rocrand.
The FRUIT suite moves to fortran/test/, which adds 25 CTest tests; all
but the version query are labelled gpu, use hip, and skip until
ROCm/rocm-systems#11923 lands.
Refs: ROCm/TheRock#8122 (RFC0019)
amontoison
force-pushed
the
users/amontoison/rocrand-fortran-bindings
branch
from
October 22, 2026 18:14
3593575 to
c67db52
Compare
The Fortran binding moves out of the library into bindings/fortran/rocrand (next commit), so the library goes back to develop: its Fortran wrappers, FRUIT tests and build options stay as they are until their deprecation. The content is develop's, byte for byte; the whitespace and cmake-lint hooks are skipped for this commit only, since projects/rocrand is not excluded from them and develop's files do not pass them.
The rocRAND Fortran binding consumes rocRAND's public API and builds standalone against an installed rocRAND, so it moves out of the library into bindings/fortran/rocrand, 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/rocrand reads rocRAND's version from projects/rocrand - the binding has its own .gitattributes and CHANGELOG.md - CODEOWNERS: /bindings/fortran/rocrand/, same owners - repos-config.json: register bindings/fortran/rocrand so CI detects changes
Regenerate bindings/fortran/rocrand with rocm-fortran-generator 9c8b3e4, and commit its metadata in bindings/fortran/rocrand/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/rocrand-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 rocRAND 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 version test no longer requires an exact match, which only held in-tree.
…-fortran The package files went to lib/cmake/rocrand, the C library's directory, with a forwarder in lib/cmake/rocrand-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.
…ut recursion rocm-cmake's generated rocrand-config.cmake is to include lib/cmake/rocrand-fortran/rocrand-fortran-config.cmake after its targets (ROCm/rocm-cmake#303). Skip find_dependency(rocrand) when rocrand is the package being found, not only when roc::rocrand is already imported, so that include never re-enters rocrand-config.cmake. Drop the early return() for that same case, which would make the include a no-op once the legacy rocrand-fortran-config.cmake is no longer passed via INCLUDE.
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 rocRAND:
bindings/fortran/rocrand/is a standalone CMake project that builds the generated Fortran binding against an installed rocRAND. The library is untouched: no option, noadd_subdirectory, no change toprojects/rocrand/.What lands
bindings/fortran/rocrand/rocrand.F90(1 013 lines, generated with ROCm/rocm-fortran-generator 9c8b3e4 from the rocRAND headers, markedlinguist-generated): one modulerocrandwith abind(C)interface for each host entry point ofrocrand.h, the enum constants, theuint4androcrand_discrete_distribution_sttypes, therocrandCheckhelper and array overloads.metadata/rocrand.toml: the generator metadata it was generated with.test/: 49 CTest tests: 24.f03programs of the C interfaces, 24.f08variants of the array overloads (registered as<name>_f2008) and the FRUIT suite. They also install: the executables inbin/, and aCTestTestfile.cmakewith the same tests and properties inbin/rocrand-fortran/, forctest --test-dir.projects/rocrand/test/fortran/(which stays until the follow-up) and ported to the generated module: one program per generator and distribution, a version query, and the FRUIT suite as one test. The vendored FRUIT files intest/fruit/are byte-identical to the originals and excluded from the formatting hooks in.pre-commit-config.yaml.CMakeLists.txt, therocrand-fortranconfig template,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/rocrand/ @ROCm/rocm-fortran-maintainers @ROCm/prims-rands-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(rocrand-fortran)and linksroc::rocrand_fortran. The archive and.modfiles install per compiler underlib/fortran/<compiler>/andinclude/fortran/<compiler>/;ROCRAND_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/rocrandas therocrand-fortransubproject against the rocRAND it built, with-DBUILD_FORTRAN_BINDINGS=ON -DBUILD_FORTRAN_CLIENTS=${THEROCK_BUILD_TESTING}, ships it in therand-fortranartifact and runs the installed tests in itsrocrand-fortranGPU test job.Follow-ups
This binding replaces the hand-written
rocrand_mwrapper (library/src/fortran/, behindBUILD_FORTRAN_WRAPPER, deprecated since rocRAND 4.0.0), which stays for now. Removing it 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
$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 with amdflang on one GPU: 49 tests, 49 pass.
JIRA ID: ROCM-31390