Skip to content

Update the classification of the arguments, and cover the query routines - #571

Merged
amontoison merged 4 commits into
developfrom
bump_types
Oct 2, 2026
Merged

amontoison merged 4 commits into
developfrom
bump_types

Conversation

@amontoison

@amontoison amontoison commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #564 and #569.

Bindings

Reclassifies the output arguments of ~110 query routines across hipSOLVER, hipSPARSE, rocBLAS, rocSOLVER and rocSPARSE. Arguments the C API writes through a pointer were declared type(c_ptr),value, which forced callers to wrap them in c_loc(...) and gave up every bit of type checking. They are now declared as the Fortran scalars they actually are:

  • integer(c_int) :: version, integer(c_size_t) :: bufferSize, real(c_double) :: zero
  • integer(kind(SOME_ENUM)) :: mode for the enum-valued getters

Callers pass the variable directly. A few modules gained use hipfort_enums for the HIP_R_32F datatype kind.

Tests

Only two call sites in the whole test tree were affected by the signature change (rocsparse_spildlt0_buffer_size, f2003 + f2008) — because almost none of these query routines had any test at all. That is the gap the second commit fills: 20 tests x 2 dialects covering the version, pointer-mode, handle-state and descriptor getters of rocBLAS, rocSOLVER, rocSPARSE, hipBLAS, hipSOLVER, hipSPARSE, hipFFT, hipRAND and rocRAND.

Each test poisons every output variable with a sentinel before the call, so a binding that fails to write through the reference fails the test instead of silently passing. Where a round-trip is possible the exact value set is required back; the descriptor getters are checked against the values the descriptor was built with, using distinct m/n and a one-based index base so neither is trivially a default.

Two assertions are deliberately weaker, with the reason stated inline in the source:

  • rocblas_set_math_mode(xf32) reports success but is only honoured on gfx94x, so the mode is checked to be a valid member of the enum rather than round-tripped.
  • The hipsolverRfSet* entry points return NOT_SUPPORTED on ROCm, so hipsolver_rf_params queries the documented defaults instead.

0422854 reclassified rocsparse_spildlt0_buffer_size's p_buffer_size_in_bytes
from type(c_ptr),value to a bare integer(c_size_t), so the two callers now pass
bufSize directly instead of c_loc(bufSize); the target attribute goes with it.

These were the only call sites in the test tree affected by that commit.
0422854 reclassified the output scalars of ~110 query routines from type(c_ptr),value to real Fortran scalars, and almost none of them had any test: only two call sites in the whole tree were even affected by the change. Add 20 tests (f2003 + f2008) exercising the version, pointer-mode, handle-state and descriptor getters across rocblas, rocsolver, rocsparse, hipblas, hipsolver, hipsparse, hipfft, hiprand and rocrand.

Each test passes the reclassified outputs directly rather than through c_loc, and poisons every output variable with a sentinel before the call, so a binding that fails to write through the reference is caught instead of silently passing. Where a round-trip is possible the exact value set is required back; the descriptor getters are checked against the values the descriptor was built with, using distinct m/n and a one-based index base so neither is trivially a default.

Two assertions are deliberately weaker, with the reason stated inline: rocblas_set_math_mode(xf32) reports success but is only honoured on gfx94x, so the mode is checked to be a valid member of the enum rather than round-tripped; and the hipsolverRfSet* entry points return NOT_SUPPORTED on ROCm, so hipsolver_rf_params queries the documented defaults instead.

Verified on gfx1101 with ROCm 10.2.
@amontoison
amontoison merged commit 2b41b4a into develop Oct 2, 2026
2 of 3 checks passed
@amontoison
amontoison deleted the bump_types branch October 2, 2026 00:56
amontoison added a commit that referenced this pull request Oct 6, 2026
The symbol tests were last regenerated before #553, #564, #571, #572 and
5de6093, so they no longer matched the bindings: eight of them failed to
compile with -DHIPFORT_EXTENDED_TESTS=ON, passing type(c_ptr) to arguments
those changes typed (hipblasGetProperty_, hipsolver *gels niters, the
hipSPARSE/rocSPARSE descriptor getters, rocfft_cache_serialize, the hipFFTW
guru dims, ...).

Regenerated with gen_symbol_tests.jl from rocm-fortran main, against the
bindings on develop. Besides the signature fixes, the tests now reference
the routines added by the ROCm 10.1 regeneration (rocsolver cholqr and
larft_64, rocblas gemm_grouped_batched, ...). Most of the remaining churn
is the scratch variables being renumbered around the new types.

Built with gfortran against ROCm 10.1 with -DHIPFORT_EXTENDED_TESTS=ON:
all 13 symbol tests compile, link and pass, and the full ctest run shows
only the three known WSL failures (hip_mem_advise f2003/f2008,
hip_module_kernel).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant