fix(amdsmi): Count clock-gated XCDs in xcd_counter API - #9686
Open
bkanango wants to merge 2 commits into
Open
Conversation
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
gabrpham
approved these changes
Aug 5, 2026
gabrpham
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me. Approved.
bkanango
force-pushed
the
users/bkanango/PR-ROCM-28766
branch
from
August 10, 2026 17:08
bc9ad4b to
e3859dc
Compare
amdsmi_get_gpu_xcd_counter() returned 0 on idle GPUs (GFX clock gated at 0 MHz) instead of the actual XCD count. The counter now includes all valid XCD entries regardless of their current clock state, fixing instability on asics where the value would toggle between idle and active on the same hardware. Changed rsmi_dev_metrics_xcd_counter_get() to count entries until the UINT16_MAX sentinel rather than skipping zero-clock entries, making the API return a power-state-independent count as callers expect. Signed-off-by: Bindhiya Kanangot Balakrishnan <Bindhiya.KanangotBalakrishnan@amd.com>
Add test case to verify amdsmi_get_gpu_xcd_counter() returns a stable count across multiple calls, regardless of GPU idle/clock-gated state. This prevents regression where zero-clock entries were incorrectly skipped, causing the count to vary with power state. The test verifies: - XCD count remains consistent across consecutive API calls - Count is non-zero on hardware with XCDs - Current GFX clock state (including 0 MHz) doesn't affect the count Signed-off-by: Bindhiya Kanangot Balakrishnan <Bindhiya.KanangotBalakrishnan@amd.com>
bkanango
force-pushed
the
users/bkanango/PR-ROCM-28766
branch
from
August 10, 2026 17:09
e3859dc to
ed0a978
Compare
marifamd
approved these changes
Aug 10, 2026
marifamd
approved these changes
Aug 10, 2026
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
amdsmi_get_gpu_xcd_counter() returned 0 on idle GPUs (GFX clock gated at 0 MHz) instead of the actual XCD count.
Technical Details
Changed rsmi_dev_metrics_xcd_counter_get() to count entries until the UINT16_MAX sentinel rather than skipping zero-clock entries, making the API return a power-state-independent count as callers expect.
Issue Tracking
JIRA ID : ROCM-28766
Test Plan
amd-smi metric -c
amd-smi metric -u
Confirm the gated state — GFX clock 0 MHz, GFX activi
python3 -c "import amdsmi; amdsmi.amdsmi_init();
print(amdsmi.amdsmi_get_gpu_xcd_counter(amdsmi.amdsmi_get_processor_handles()[0]))"
Test Result
Submission Checklist