Skip to content

refactor(hipsparse): dedicated config header for build-time feature flags - #10263

Open
amontoison wants to merge 6 commits into
ROCm:developfrom
amontoison:hipsparse_config_header
Open

refactor(hipsparse): dedicated config header for build-time feature flags#10263
amontoison wants to merge 6 commits into
ROCm:developfrom
amontoison:hipsparse_config_header

Conversation

@amontoison

@amontoison amontoison commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Motivation

This already worked, but only halfway.
The feature-flag macros (HIPSPARSE_WITH_SPMV_BSR, HIPSPARSE_WITH_CSC_TRSV, HIPSPARSE_WITH_CSC_TRSM) were resolved by CMake into the installed hipsparse-version.h through #cmakedefine, so a consumer that pulled in a hipSPARSE header did get the correct values.

The catch is that it only held together by accident of include order. A #ifdef HIPSPARSE_WITH_* saw the right value only if hipsparse-version.h had already been included at that point.
If it hadn't, or if a stale hipsparse-version.h from another install sat earlier on the include path, a guarded piece of public API could quietly disappear with no compile error.
Versioning and build configuration were also mixed in the same header, and nothing ever verified that the whole thing stayed harmonized.
Every macro a header guards on is actually declared, and that a header using a flag actually pulls in the header that defines it.

What changed

  • Moved the build-time flags out of hipsparse-version.h into a new generated hipsparse-config.h.
    hipsparse-version.h now holds only the version macros.
    Each flag notes the release it was introduced in.
  • Every spot that reads a flag now includes hipsparse-config.h directly (public headers, amd_detail/utility.h, and the clients) instead of relying on hipsparse-version.h being dragged in first.
  • Added cmake/CheckFeatureFlags.cmake, run at configure time. It performs the two consistency checks that were missing before:
    a. every HIPSPARSE_WITH_* macro used in a public header must be declared in hipsparse-config.h.in (otherwise the flag never reaches the installed header);
    b. every public header that uses such a macro must itself #include "hipsparse-config.h" (so the value doesn't depend on include order).

Notes

  • Nothing new to install: hipsparse-config.h ships through the existing include-tree install, just like hipsparse-version.h and hipsparse-export.h.
  • rocSPARSE gets the same change in a companion PR.

…fig header

Feature-flag macros (HIPSPARSE_WITH_SPMV_BSR, HIPSPARSE_WITH_CSC_TRSV,
HIPSPARSE_WITH_CSC_TRSM) were baked into hipsparse-version.h and reached
consumers only through transitive inclusion, mixing versioning with build
configuration and making guard evaluation order-dependent.

- Add generated hipsparse-config.h (from hipsparse-config.h.in) holding the
  build-time feature flags, each tagged with its "since"/"remove-after" release.
- Trim hipsparse-version.h to version macros only.
- Include hipsparse-config.h directly at every flag consumer (public headers,
  amd_detail/utility.h, and clients) so guard evaluation no longer depends on
  include order.
- Add cmake/CheckFeatureFlags.cmake: a configure-time guardrail that fails the
  build if a public header is gated by a flag not registered in the config
  template.
@therock-pr-bot

therock-pr-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

❌ PR Check — Action Required

Check Status Details
📝 PR Description ❌ Fail Error: PR description must reference a JIRA ID, ISSUE ID, or a GitHub closing keyword.
Expected: include a JIRA ID / ISSUE ID line (separator : or -, or omitted; value may be a JIRA key, a number with/without #, or a link), OR a closing keyword + issue reference. Accepted examples:
JIRA ID : TESTAUTO-6039
JIRA ID - #330
JIRA ID #330
JIRA ID (on separate line)
ROCM-25757
ISSUE ID : TESTUTO-3334
ISSUE ID #3334
ISSUE ID - TESTAUTO-3433
ISSUE ID (on separate line)
AIRUNTIME-2352
ISSUE ID : https://github.com/<org_name>/<repo_name>/issues/1234
Closes #10
Fixes octo-org/octo-repo#100
Resolves: #123
#123
https://github.com/<org_name>/<repo_name>/issues/123
Current: no valid JIRA/ISSUE/closing-keyword reference found
Forbidden Files ✅ Pass
🧪 Unit Test ✅ Pass
🔎 pre-commit ✅ Pass
🚫 Draft PR 🔜 To Be Enabled
🚩 Feature Flag 🔜 To Be Enabled
📊 Code Coverage 🔜 To Be Enabled

⚠️ 1 policy check(s) failed. Please address the issues above before this PR can be Reviewed.

🚫 Please fix the failed policies

  • ❌ PR Description

The Not ready to Review label was added to this PR. Once all policies pass, the label is removed automatically.

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

🙋 Wish to Override Policy?

@therock-pr-bot

therock-pr-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Description

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

@amontoison
amontoison force-pushed the hipsparse_config_header branch from 397915b to f821e8a Compare August 1, 2026 00:14
@amontoison amontoison changed the title refactor(hipSPARSE): dedicated config header for build-time feature flags refactor(hipsparse): dedicated config header for build-time feature flags Aug 1, 2026
Comment thread projects/hipsparse/library/include/hipsparse-config.h.in Outdated
Comment thread projects/hipsparse/library/include/hipsparse-version.h.in Outdated
amontoison and others added 2 commits July 31, 2026 18:24
…orten guardrail comment

- Tag HIPSPARSE_WITH_SPMV_BSR as introduced in 4.6 (BSR SpMV support shipped in
  hipSPARSE 4.6.0; confirmed by changelog and by the commit that first added the
  macro, which carried project(hipsparse VERSION 4.6.0)).
- Order the feature flags newest-first (4.7 CSC flags above the 4.6 BSR flag).
- Replace the long CheckFeatureFlags.cmake header comment with a concise one.
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

❌ Your project check has failed because the head coverage (76.92%) 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   #10263   +/-   ##
========================================
  Coverage    69.62%   69.62%           
========================================
  Files         2741     2741           
  Lines       451544   451544           
  Branches     66531    66531           
========================================
  Hits        314370   314370           
  Misses      116966   116966           
  Partials     20208    20208           
Flag Coverage Δ *Carryforward flag
TensileLite 34.19% <ø> (ø) Carriedforward from 09d1b15
TensileLite-CPP 38.12% <ø> (ø) Carriedforward from 09d1b15
TensileLite-Unit 64.91% <ø> (ø) Carriedforward from 09d1b15
hipBLAS 90.62% <ø> (ø) Carriedforward from 09d1b15
hipBLASLt 34.89% <ø> (ø) Carriedforward from 09d1b15
hipCUB 83.47% <ø> (ø) Carriedforward from 09d1b15
hipDNN 86.39% <ø> (ø) Carriedforward from 09d1b15
hipFFT 47.34% <ø> (ø) Carriedforward from 09d1b15
hipRAND 76.12% <ø> (ø) Carriedforward from 09d1b15
hipSOLVER 69.18% <ø> (ø) Carriedforward from 09d1b15
hipSPARSE 86.27% <ø> (ø)
rocBLAS 47.95% <ø> (ø) Carriedforward from 09d1b15
rocFFT 47.61% <ø> (ø) Carriedforward from 09d1b15
rocRAND 57.02% <ø> (ø) Carriedforward from 09d1b15
rocSOLVER 76.92% <ø> (ø) Carriedforward from 09d1b15
rocSPARSE 72.59% <ø> (ø) Carriedforward from 09d1b15
rocThrust 91.60% <ø> (ø) Carriedforward from 09d1b15

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...rojects/hipsparse/library/src/amd_detail/utility.h 54.43% <ø> (ø)
🚀 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.

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