Skip to content

More typed forms, and the fixes a per-library audit found - #584

Merged
amontoison merged 1 commit into
developfrom
more_typed_forms
Oct 9, 2026
Merged

amontoison merged 1 commit into
developfrom
more_typed_forms

Conversation

@amontoison

Copy link
Copy Markdown
Collaborator

Follow-up to #581 and #583, from a library-by-library audit of the bindings against the ROCm 10.1 headers. Regenerated with rocm-fortran 3b65cdb.

More typed forms

These scalar pointers still needed c_loc(). They now also get a _typed form:

  • rocBLAS / hipBLAS:
    • the dot/dotu/dotc/nrm2/asum/iamax/iamin result;
    • the rotg and rotmg scalars;
    • c/s of hipBLAS rot.
  • rocSPARSE / hipSPARSE:
    • the doti/dotci results;
    • the nnz counts of the *_nnz/*_nnzb/nnz_compress/csr2bsrNnz/csr2gebsrNnz routines;
    • the pivot positions of csritsv_zero_pivot and csric0/csrilu0_singular_pivot;
    • ell_width of csr2ell_width.
  • hipBLAS: info of getrs/geqrf/gels, which the header documents as host memory.
  • HIP:
    • hipChooseDevice, whose metadata key named the short alias instead of the hipChooseDeviceR0600 symbol, so the entry never applied;
    • the failIdx and nbGroups outputs.

The array overloads take the BLAS results and the hipBLAS info typed. New _rank_N_devptr variants keep the type(c_ptr) these arguments always had there, so existing c_loc() calls still compile.

Fixes

  • rocSOLVER larf/larfg: alpha and tau are device scalars, since the library forces the device pointer mode. They lose the _typed form introduced by Bind every scalar pointer as type(c_ptr), add its typed form as _typed #581, which would have handed the kernel a host address.
  • hipsolverRfBatchZeroPivot and rocblas_set_solution_fitness_query lose theirs too. The first one's position is an array of batchSize ints. The second one's fitness is a pointer the library keeps.
  • csrcolor (rocSPARSE and hipSPARSE): coloring and reordering are arrays again in the array overloads. The color count and fraction_to_color are host scalars.
  • rocSPARSE: the nullable error arguments (spgeam, spmv_set_input, v2_spmv, ...) are optional.
  • hipMalloc(..., source=) and its hipMallocManaged/hipHostMalloc siblings: the copy used to overwrite the allocation's status. They now copy only after a successful allocation, so an out-of-memory is reported.
  • USE_CUDA_NAMES: the compat hipsolver?gesvd_bufferSize/??gels_bufferSize were bound to cusolverDn routines with different arguments. These were amdflang's 8 -Wexternal-interface-mismatch warnings, and the build now has none. They are ROCm-only now.
  • hipChooseDevice is a generic over hipChooseDeviceR0600's own specifics, instead of a second interface on the same binding label (F2018 19.2).

Also in this PR

Validation

ROCm 10.1, gfortran and amdflang.

Check Result
Modules compile, with no macro, USE_ASSUMED_SHAPE, USE_ASSUMED_RANK and USE_ASSUMED_SHAPE + USE_CUDA_NAMES all four configurations, no amdflang warning (8 on develop with USE_CUDA_NAMES)
Current tests build 1248/1248
hipfort 0.9.0 test programs build 728/807, the same set as on develop
ctest with -DHIPFORT_EXTENDED_TESTS=ON 1258/1261: the three known WSL failures (hip_mem_advise ×2, hip_module_kernel)
Shared-link tests every symbol resolves against ROCm 10.1, and against CUDA 13.3 without libcuda
gfx1101 GPU, 0.9.0 test programs that build same results as against the 0.9.0 library

Not in this PR

  • NVIDIA backend (enum values not translated for CUDA, and a few CUDA mappings whose signature differs): this will be a separate PR, verified by compilation only.
  • New functionality (hipfftXt, hipFFTW array overloads, more .native routines): after the release.

@amontoison
amontoison requested a review from a team as a code owner October 7, 2026 14:12
Regenerated with rocm-fortran 3b65cdb.

Typed forms for scalar pointers that still needed c_loc(): the BLAS
dot/nrm2/asum/iamax/iamin results and rotg/rotmg scalars (rocBLAS and
hipBLAS) and hipBLAS rot's c/s; the sparse doti/dotci results, nnz
counts, pivot positions and csr2ell_width's ell_width; hipBLAS
getrs/geqrf/gels info (host); hipChooseDevice. The array overloads take
the BLAS results and hipBLAS info typed and gain _rank_N_devptr twins
that keep the type(c_ptr), so existing c_loc() calls still compile.

Fixes:
- rocSOLVER larf/larfg alpha/tau are device scalars and lose their
  _typed form, which would have handed the kernel a host address;
- hipsolverRfBatchZeroPivot position (an array) and
  rocblas_set_solution_fitness_query fitness (a retained pointer) lose
  theirs too;
- csrcolor's coloring/reordering are arrays again in the array
  overloads;
- rocSPARSE's nullable `error` arguments are optional;
- hipMalloc(..., source=) and its siblings report an allocation failure
  instead of the copy's status;
- the compat hipsolver*gels/gesvd_bufferSize are no longer bound to
  cusolverDn symbols with different arguments under USE_CUDA_NAMES;
- hipChooseDevice is a generic over hipChooseDeviceR0600's specifics
  instead of a second interface on the same binding label.

Three tests take a result through the new typed forms: rocBLAS ddot,
hipBLAS snrm2 and rocSPARSE ddoti (host pointer mode).

Also regenerates the supported-API tables (only the generated diff: the
variants column gains typed and devptr), and updates the changelog with
the Scalar arguments section and tests of #583, the typed forms above and
the fixes.
@amontoison
amontoison merged commit f414a88 into develop Oct 9, 2026
3 checks passed
@amontoison
amontoison deleted the more_typed_forms branch October 9, 2026 03:14
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