Repository navigation
fix(clr): honor no-preference LDS carveout; fix hipDeviceGetCacheConfig - #13807
Conversation
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🚫 Please fix the failed policies before requesting reviews. The following policy checks failed:
The |
There was a problem hiding this comment.
🟡 Changes recommended
Shared cache state lacks synchronization, and the round-trip test accepts the previous always-no-preference behavior.
2 open issues
What changed in this PR
This PR corrects HIP cache-preference handling in CLR, distinguishing no preference from explicit zero-percent LDS carveout and reporting device cache configuration.
Changes:
- Correct carveout mapping and dispatch encoding.
- Store, report, and reset device cache preferences.
- Update mapping tests and add round-trip coverage.
| File | Description |
|---|---|
| projects/hip-tests/catch/unit/executionControl/hipFuncSetCacheConfig.cc | Correct expected carveout mappings. |
| projects/hip-tests/catch/unit/device/hipDeviceSetGetCacheConfig.cc | Add round-trip checks and restore defaults. |
| projects/hip-tests/catch/config/configs/unit/device.yaml | Register the round-trip test. |
| projects/clr/rocclr/device/rocm/rocvirtual.cpp | Encode and log dispatch carveout preferences. |
| projects/clr/rocclr/device/device.hpp | Preserve no-preference values and define encoding. |
| projects/clr/hipamd/src/hip_internal.hpp | Store device cache configuration. |
| projects/clr/hipamd/src/hip_device.cpp | Reset cache and carveout preferences. |
| projects/clr/hipamd/src/hip_device_runtime.cpp | Implement device cache configuration reporting. |
Review effort: Balanced
084fa5a to
3f3ac63
Compare
mangupta
left a comment
There was a problem hiding this comment.
🤖 AI-assisted pre-review (for @mangupta)
[SUGGESTION] Document the changed behavior of hipDeviceGetCacheConfig and the cache-config-to-carveout mapping
This PR changes what users can observe through the public API. (1) hipDeviceGetCacheConfig used to return hipFuncCachePreferNone every time. It now returns the last value passed to hipDeviceSetCacheConfig on devices that support a configurable carveout. (2) After hipFuncSetCacheConfig, the preferredShmemCarveout value seen by callers is now -1 for hipFuncCachePreferNone (was 0) and 0 for hipFuncCachePreferL1 (was 1). (3) hipDeviceReset now clears the device carveout hint. (4) A 'no preference' setting no longer forces a 0%-LDS dispatch encoding. The diff contains no CHANGELOG entry and no doxygen update for any of these.
Suggested fix: Add a projects/clr/CHANGELOG.md entry that covers: the LDS no-preference fix, hipDeviceGetCacheConfig reporting the configured value (with PreferNone on devices that have no configurable carveout), the new preferredShmemCarveout values (-1 and 0), and hipDeviceReset restoring the default. If the hipDeviceGetCacheConfig and hipDeviceSetCacheConfig doxygen in hip_runtime_api.h says the setting is ignored or that PreferNone is always returned on AMD, update it.
3f3ac63 to
7f2a5bd
Compare
addressed in 7f2a5bd
|
|
🤖 AI-assisted pre-review (for @mangupta) Re-reviewed the updated head ( |
2ca3824 to
bec0b14
Compare
|
🤖 AI-assisted pre-review (for @mangupta) Re-reviewed the updated head ( |
bec0b14 to
d433a31
Compare
|
🤖 AI-assisted pre-review (for @mangupta) Re-reviewed the updated head ( |
…onfig Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
d433a31 to
0c1524c
Compare
TheRock Submodule Bump ActivityNewest first
|

Motivation
The extended AQL dispatch packet's
group_mem_carveouthint uses0for no preference and[1, 127]for 0%..100% group memory (LDS). CLR never sends0, so every dispatch without a preference asks for 0% LDS. Related problems:hipFuncCachePreferNoneis stored as an explicit 0%, so it overrideshipDeviceSetCacheConfig.hipFuncCachePreferL1maps to 1% (encoding2) instead of 0% (1).hipDeviceGetCacheConfigalways returnshipFuncCachePreferNone.hipDeviceResetdoes not clear the device-level carveout.Technical Details
{None: -1, Shared: 100, L1: 0, Equal: 50};-1means no preference.std::atomic<int8_t>(default-1).hipDeviceGetCacheConfigmaps it back, andhipDeviceResetclears it.amd::encodeGroupMemCarveout:-1 -> 0, otherwise(percent + 1) * 126 / 100, which matches the previous encoding for all of 0..100.-1). The AIRUNTIME-2610 - implement hipKernelSetCacheConfig() #12628hipKernelSetCacheConfigoverride and the per-ISA127override are unchanged.group_mem_carveout(AMD_LOG_LEVEL=5 AMD_LOG_MASK=8).hipDeviceSetCacheConfig/hipDeviceGetCacheConfigdoxygen updated.VerifyCarveoutMappingexpectations updated, newUnit_hipDeviceGetCacheConfig_Positive_RoundTrip, and an RAII guard restores the device cache config in the device tests.Issue Tracking
JIRA ID: AIRUNTIME-2976
Test Plan
group_mem_carveoutcaptured from the dispatch log on a simulation model of a carveout-capable target, develop vs this PR (before the rebase).encodeGroupMemCarveoutcompared with develop for every percentage 0..100.Test Result
All tests pass; explicit percentages encode as on develop.
hipFuncSetCacheConfig(PreferL1)PreferShared, functionPreferNonePreferNone, attribute-1PreferEqual, thenhipDeviceResethipDeviceGetCacheConfigafterPreferSharedSubmission Checklist