Repository navigation
fix(rocsparse): size the csr2csc temporary buffer for the types it actually sorts - #11651
Merged
kliegeois merged 3 commits intoSep 3, 2026
Merged
Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #11651 +/- ##
========================================
Coverage 64.11% 64.11%
========================================
Files 2826 2826
Lines 469784 469792 +8
Branches 69375 69377 +2
========================================
+ Hits 301190 301197 +7
Misses 147486 147486
- Partials 21108 21109 +1
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
kliegeois
approved these changes
Sep 3, 2026
jsandham
approved these changes
Sep 3, 2026
dso-amd
reviewed
Sep 3, 2026
dso-amd
approved these changes
Sep 3, 2026
dso-amd
left a comment
Contributor
There was a problem hiding this comment.
LGTM (see suggestions on the changelog entry)
Co-authored-by: Daniel So <dso@amd.com>
YvanMokwinski
approved these changes
Sep 3, 2026
Contributor
TheRock Submodule Bump ActivityNewest first
|
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.
csr2csc_buffer_size_corealways asked rocPRIM how much scratch a<J, J>sortneeds, but the numeric path sorts
<J, I>(column indices as keys, permutationoffsets as values). rocPRIM tunes its onesweep config per key/value size, so the
answer differs between the two, and the conversion ended up writing past the end
of the buffer it had asked the caller to allocate.
This only bites when the row pointer and column index types differ, so it is
reachable through
rocsparse_sparse_to_sparse(CSR source, CSC target) but notthrough
rocsparse_Xcsr2csc, where both types arerocsparse_int. It also needsmore than 1M non-zeros, below that rocPRIM uses a merge sort whose scratch does
not depend on the value type. On gfx942/gfx950 the shortfall is about 64 KB at
1M non-zeros and grows from there; gfx908, gfx90a and gfx1100 happen to pick the
same config for both sorts and were never affected.
The fix is to query the size with the types the sort actually uses.
The new unit test converts a matrix with 1,075,200 non-zeros for all four
index-type combinations, with a poisoned guard band right behind the buffer, and
fails if anything wrote into it. It passes on gfx1100, and shrinking the
allocation by 64 KB as a negative control makes the guard fire. Worth knowing:
on gfx1100 the old and new code produce identical buffer sizes, so this test can
only catch the real defect on MI300-class hardware and the other affected
targets. That caveat is in the file's header comment.
JIRA ID: ROCM-30643