fix(amdsmi): correct empty and mislabeled APU metric output - #11009
Open
marifamd wants to merge 2 commits into
Open
fix(amdsmi): correct empty and mislabeled APU metric output#11009marifamd wants to merge 2 commits into
marifamd wants to merge 2 commits into
Conversation
- Gate the APU section suppression on the default dump only, so a section named on the command line reports N/A instead of printing nothing and exiting 0 - Apply the same rule to the end-of-pass filter that dropped scalar N/A sections, which removed energy, ecc_blocks, overdrive and xgmi_err after they had been populated - Report N/A for the APU fan section when apu_metrics.fan_pwm is absent - Add hardware-free unit tests covering the explicitly named sections and the unchanged default dump Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
- Widen the uint16 unavailable marker to UINT32_MAX in amdsmi_get_clock_info, so GFX, MEM, SOC, VCLK and DCLK no longer report a literal 65535 MHz reading; DF already returned the 32-bit marker - Document that amdsmi_clk_info_t.clk is UINT32_MAX when unavailable - Report the APU IPU read and write counters in MB/s, matching the adjacent DRAM counters, and annotate all four in the header - Cover the bandwidth units in the APU metric unit tests Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
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
On APU parts (gfx1151 / Strix),
amd-smi metric --energyprinted only the GPU header and exited 0, with noenergykey in--jsonor--csvoutput. Seven other section flags behaved the same way, so a user could not tell "unsupported" from "tool bug".An audit of the remaining
metricarguments on the same part found two more reporting defects:amdsmi_get_clock_info()returning an unavailable clock as a literal65535MHz, and the APU IPU bandwidth counters printing without a unit.Technical Details
CLI metric sections (
amdsmi_cli/subcommands/metric.py):apu_suppressedis true only when no section was named, so an explicitly named section reportsN/A."N/A", which removedenergy,ecc_blocks,overdriveandxgmi_errafter they had been populated. It now applies the same default-dump-only rule, and a section emptied by the APU key-stripping reportsN/Ainstead of disappearing.--energy,--ecc-blocks,--overdrive,--xgmi-err,--pcie,--voltage-curve,--voltageand--fan.Clock reporting (
src/amd_smi/amd_smi.cc,include/amd_smi/amdsmi.h):amdsmi_get_clock_infocopied theuint16_tgpu_metrics clock straight into theuint32_tinfo->clk, so the 16-bit unavailable marker widened to a literal65535MHz reading for GFX, MEM, SOC, VCLK and DCLK. TheDFcase in the same switch already returnedUINT32_MAX.UINT32_MAXwhen the clock is unavailable, which the Python interface maps toN/A.amdsmi_clk_info_t.clkdocuments the convention.metric.pytakes clocks from gpu_metrics and usesamdsmi_get_clock_infoonly formin_clk/max_clk/clk_deep_sleep, andset_value.pyuses onlymin_clk/max_clk.APU bandwidth units (
amdsmi_cli/subcommands/metric.py,include/amd_smi/amdsmi.h):average_ipu_readsandaverage_ipu_writesprinted bare numbers while the adjacent DRAM counters carriedMB/s. All four bandwidth counters now reportMB/s, and each is annotated[MB/s]in the header.Tests (
tests/python/unit/gpu/test_cli_metric_apu_sections.py):MetricCommands.metric_gpuwith the C library, logger and helpers stubbed, covering explicitly named sections, the unchanged default dump, and the bandwidth units.Issue Tracking
JIRA ID: ROCM-9454
Test Plan
tests/python/unit/gpu/test_cli_metric_apu_sections.py, run before and after the fix.tests/python/unit) compared against a baseline run with the new file excluded.amd-smi metricargument before and after, in human-readable, JSON and CSV.amdsmi_get_clock_infobefore and after, with a locally built library loaded through theAMDSMI_LIB_OVERRIDEhook.pre-commit(clang-format, ruff format, SPDX headers).Test Result
New tests: 7 passed, 11 subtests passed. Confirmed failing before the fix (
AssertionError: 'energy' not found in {}and12 != '12 MB/s').Full unit suite matches the baseline exactly (no new failures or errors) and adds 7 passes.
Explicitly named sections on Strix:
--energyENERGY: N/A--ecc-blocks,--overdrive,--xgmi-errN/A--pcie,--voltage-curve,--fan,--voltageN/Afields--energy --json{"gpu": 0}{"gpu": 0, "energy": "N/A"}--energy --csvgpu/0gpu,energy/0,N/AThe default
amd-smi metricdump is structurally identical to before (84 fields, same 9 JSON sections); the only textual differences between runs are live power and activity telemetry.amdsmi_get_clock_infoon Strix: GFX, MEM and SOCclkchanged from65535toN/A;DFunchanged; everymin_clkandmax_clkunchanged.APU_AVERAGE_IPU_READS: 0now reads0 MB/s; the DRAM counters are unchanged.Submission Checklist