Skip to content

Add hipSPARSE tests (csrgemm, sptrsv, sptrsm, csr2csc, csr2coo) - #480

Merged
amontoison merged 1 commit into
ROCm:developfrom
Ozone-Whiskey:hipsparse-checklist-tests
Aug 6, 2026
Merged

Add hipSPARSE tests (csrgemm, sptrsv, sptrsm, csr2csc, csr2coo)#480
amontoison merged 1 commit into
ROCm:developfrom
Ozone-Whiskey:hipsparse-checklist-tests

Conversation

@Ozone-Whiskey

Copy link
Copy Markdown
Collaborator

Summary

Seeds hipSPARSE test coverage (previously zero hipSPARSE tests existed) for the roc/hipSPARSE top-routine list, recycling the merged rocSPARSE tests. s/d/c/z where applicable, in both the Fortran 2003 and Fortran 2008 binding tiers.

Routines covered (17 total, f2003 + f2008 each = 34 new test programs):

Family Routines
Sparse GEMM Scsrgemm Dcsrgemm Ccsrgemm Zcsrgemm
Triangular solve (vector) Ssptrsv Dsptrsv Csptrsv Zsptrsv (generic SpSV)
Triangular solve (matrix) Ssptrsm Dsptrsm Csptrsm Zsptrsm (generic SpSM)
CSR → CSC (transpose) Scsr2csc Dcsr2csc Ccsr2csc Zcsr2csc
CSR → COO Xcsr2coo (index-only)

Each routine is one commit (f2003 + f2008 pair + CMake registration).

File extensions (.f08)

Per review feedback on #466/#468, files in test/f2008/ use the .f08 extension so CMake selects the Fortran 2008 standard. The shared hipfort_add_test helper is updated to prefer .f08 and fall back to .f03, so existing .f03 f2008 tests keep building.

Verification approach

Every test is self-verifying against a fixed small CSR matrix:

  • csrgemm: B = A, compute C = A*A, check structure + values (complex uses a dense matmul reference).
  • sptrsv / sptrsm: pick a known solution, form the RHS from a dense product, solve, confirm the solution is recovered.
  • csr2csc: convert and check against the known transpose (values permuted, not conjugated).
  • csr2coo: check the expanded COO row indices.

SpMV / SpMM intentionally excluded (binding bug)

SpMV/SpMM are not included. hipfort's generated hipfort_hipsparse_enums.F90 assigns wrong values to the hipsparseSpMVAlg_t / hipsparseSpMMAlg_t algorithm enums: the C headers define these as a single enum with duplicate values (the SPMV_* / SPMM_* families restart at 0, reusing the legacy MV_* / MM_* values), which a Fortran enum, bind(c) cannot represent — so the generator numbered them sequentially. For example the C HIPSPARSE_SPMV_ALG_DEFAULT = 0 but hipfort emits 4; passing it selects a COO algorithm on a CSR matrix and returns HIPSPARSE_STATUS_INVALID_VALUE. The correct fix belongs in the generator (emit these as integer parameters with the real values, as it already does for HIPSPARSE_SPMV_CSR_ALG3). rocSPARSE already covers SpMV/SpMM, so no coverage is lost here.

Notes

  • All descriptor/array arguments in the generic API are type(c_ptr)-only (no array overloads), so the f2008 tests pass device pointers via c_loc(...), matching the rocSPARSE generic tests.
  • All 34 new tests pass on gfx90a (MI210), ROCm 7.1.0, gfortran 13.3, both tiers. f2003 tests also compile with the Fortran 2008 pointer-interface macro OFF.

Test plan

  • Both tiers build and PASS for all 17 routines on gfx90a
  • f2003 tests compile with the Fortran 2008 pointer-interface macro OFF
  • f2008 files use the .f08 extension

@Ozone-Whiskey
Ozone-Whiskey marked this pull request as ready for review August 6, 2026 06:26
@Ozone-Whiskey
Ozone-Whiskey marked this pull request as draft August 6, 2026 06:26
@Ozone-Whiskey
Ozone-Whiskey force-pushed the hipsparse-checklist-tests branch from b99cdf0 to f951734 Compare August 6, 2026 07:12
@Ozone-Whiskey
Ozone-Whiskey marked this pull request as ready for review August 6, 2026 07:15
@Ozone-Whiskey

Copy link
Copy Markdown
Collaborator Author

Resolved merge conflicts

@amontoison amontoison left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
Did you forget to push the tests for csr2coo?

@amontoison
amontoison merged commit 47f33d9 into ROCm:develop Aug 6, 2026
1 of 2 checks passed
@Ozone-Whiskey

Copy link
Copy Markdown
Collaborator Author

PR is up for csr2coo. There was a conflict with new bindings generated in develop and it before.

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.

2 participants