ROCM-26483 - fix cooperative_groups::reduce() would not work with 2D or 3D tiles#7588
Closed
g-h-c wants to merge 3 commits into
Closed
ROCM-26483 - fix cooperative_groups::reduce() would not work with 2D or 3D tiles#7588g-h-c wants to merge 3 commits into
g-h-c wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes cooperative_groups::reduce() for thread_block_tile when the parent thread block is 2D/3D by computing the lane/tile mask offset using the block-linear thread rank rather than threadIdx.x.
Changes:
- Update mask calculation in
amd_hip_cooperative_groups_reduce.hto useinternal::workgroup::thread_rank()for correct 2D/3D block behavior. - Add a new HIP unit test that launches a 3D block (16×4×2) and validates per-tile reductions.
- Register the new test in the cooperative groups unit-test YAML config (with the same Windows disablement pattern as related tests).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| projects/hip-tests/catch/unit/cooperativeGrps/thread_block_tile.cc | Adds a multi-dimensional block tile reduction test and kernel. |
| projects/hip-tests/catch/config/configs/unit/cooperativeGrps.yaml | Enables/configures the new unit test in the cooperativeGrps suite. |
| projects/clr/hipamd/include/hip/amd_detail/amd_hip_cooperative_groups_reduce.h | Fixes mask shifting logic to use block-linear thread rank for multi-dim blocks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ed only on threadIdx.x when it should have used internal::workgroup::thread_rank() instead
e7d6c1b to
421a29b
Compare
Contributor
Author
|
Fix already included in #5914 |
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.
Motivation
When using cooperative_groups::reduce(block, value, operator), if the thread block contains y-dimensions or z-dimensions that are different from 1, the operation would produce incorrect results or lead to a crash.
Technical Details
mask <<= (((threadIdx.x % warpSize) / group.num_threads()) * group.num_threads());should have been
mask <<= (((internal::workgroup::thread_rank() % warpSize) / group.num_threads()) * group.num_threads());(note that the previous expression cannot be simplified to mask <<= internal::workgroup::thread_rank() % warpSize` because the operator in that expression is an integer division; not a floating point division)
JIRA ID
ROCM-26483
Test Plan
Added test Unit_Thread_Block_Tile_Multi_Dimensional_Reduce
Test Result
The test fails on current develop, but passes with the fix
Submission Checklist