fix (rocprim): Update lookback scan and ordered_block_id optimizations to include gfx1250 and gfx1250-strict #11620
<!-- therock-pr-bot-policy-check -->
✅ All Checks Passed — Ready for Review
| Check | Status | Details |
|---|:---:|---|
| 📝 PR Description | ✅ Pass | — |
| ⛔ Forbidden Files | ✅ Pass | — |
| 🧪 Unit Test | ⚠️ Warning | Error: Source/code files changed without an accompanying unit test.<br>Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).<br>Current: code file(s) changed: projects/rocprim/rocprim/include/rocprim/config.hpp, projects/rocprim/rocprim/include/rocprim/device/config_types.hpp, projects/rocprim/rocprim/include/rocprim/device/detail/lookback_scan_state.hpp, projects/rocprim/rocprim/include/rocprim/device/detail/ordered_block_id.hpp, projects/rocprim/rocprim/include/rocprim/intrinsics/atomic.hpp (+2 more); no test file found |
| 🔎 pre-commit | ✅ Pass | — |
| 🚫 Draft PR | 🔜 To Be Enabled | — |
| 🚩 Feature Flag | 🔜 To Be Enabled | — |
| 📊 Code Coverage | 🔜 To Be Enabled | — |
| 🤖 therock-pr-bot | ✅ Pass | — |
🎉 All checks passed! This PR is ready for review.
📖 Need help? See the Policy FAQ for details on every check and how to fix failures.
<!-- therock-pr-bot-fix-policies -->
🎉 All checks passed! This PR is ready for review.
@stanleytsang-amd there seems to be some compile errors related to the changes:
https://github.com/ROCm/rocm-libraries/actions/runs/33659735785/job/100357235705?pr=11620#step:15:6302.
To fix this you need to add the target in rocprim/rocprim/include/rocprim/device/config_types.hpp
Should "|| defined(__gfx1250__)" be inside the second pair of parentheses? Like
#if defined(__HIP_DEVICE_COMPILE__) && (defined(__gfx942__) || defined(__gfx950__) || defined(__gfx9_4_generic__) || defined(__gfx1250__))
What will happen to #if ROCPRIM_TARGET_RDNA4, now that it is removed from the condition?
What will happen to #if ROCPRIM_TARGET_RDNA4?
Yes, you're right. Sorry, I should move this PR to draft state, it's still in a WIP.
RDNA4 never "needed" this in the first place, it was me incorrectly labelling gfx1250 (which needs this) as RDNA4. Interestingly enough, when compiling for gfx1200 and gfx1201 (RDNA4), it seems to be happy with either asm volatile("s_wait_storecnt 0x0" : : : "memory"); or __builtin_amdgcn_s_waitcnt(/vmcnt/ 0 | (/exp_cnt/ 0x7 << 4) | (/lgkmcnt/ 0xf << 8));.
RDNA4 will go the default __builtin_amdgcn_s_waitcnt(/vmcnt/ 0 | (/exp_cnt/ 0x7 << 4) | (/lgkmcnt/ 0xf << 8)); call like all other architectures.
defined(__gfx1250-strict__) => defined(__gfx1250_strict__)? see https://github.com/ROCm/rocm-systems/pull/11551/changes
defined(__gfx1250-strict__) => defined(__gfx1250_strict__)
Looks like the new target is spelled as __gfx1250_strict__
Done
Should this be #if defined(ROCPRIM_TARGET_CDNA4)? Then the lines below become
#define ROCPRIM_IS_CDNA4() 1
#else
#define ROCPRIM_IS_CDNA4() 0
#endif
should this be gfx1250_strict?
Sorry, I have one more question - see above.
Looks like they spell the offload target as gfx1250-strict.
Reviewed at high-level for gfx1250-strict, LGTM
Sorry I didn't see your comment earlier - yes you are right, I will fix this now. Thank you
LGTM. Thanks.
amd-hsong
stanleytsang-amd
Motivation
PR has been modified since creation to include gfx1250-strict support.
The same technical conditions which necessitated having the slow threadfence workaround in
lookback_scanandordered_block_idwith atomics for maximum performance on MI300-series GPUs also exist on MI400-series GPUs.In the process of carrying forward the workaround for MI455x/gfx1250, I realized that we did not properly support it in rocPRIM. gfx1250 was grouped together with RDNA4 (perhaps because gfx1200/gfx1201 are RNDA4) - this is wrong, gfx1250 is CDNA5. I have added CDNA5 support to rocPRIM.
Technical Details
Update the aforementioned optimizations to also be in effect for gfx1250.
Test Plan
Ran device_partition which uses lookback_scan on gfx1250 to verify it is in effect. Built and ran full test suite on gfx1200 to ensure I did not break compatibility with RDNA4. Built tests on gfx1201, gfx1250 to check it is .
Test Result
The above checks passed.
Submission Checklist
JIRA ID: ROCM-28420