Repository navigation
test(rdc): run rdcd and rdci in CI against a fake amd-smi #14041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d83f167
test(rdc): run rdcd and rdci in CI against a fake amd-smi
adam360x fa1719e
test(rdc): add handle generations and fault knobs to the fake amd-smi
adam360x 6c3f327
test(rdc): give the fake's four-partition mode its own profile
adam360x 6adc211
Merge the fake amd-smi's handle generations and fault knobs
adam360x daf94a9
test(rdc): make the fake amd-smi match amd-smi on three calls
joshnguy-amd a4f99f8
ci(rdc): run rdc_test_gpu on the lstt-ci-runner GPU runners
joshnguy-amd 48d5b3c
Revert "ci(rdc): run rdc_test_gpu on the lstt-ci-runner GPU runners"
joshnguy-amd 42f8ac1
Merge branch 'develop' into users/adam360x/rdc-fake-gpu-tests
adam360x cbe733a
test(rdc): apply ruff format to the fake-GPU suite
adam360x abbfbda
Merge branch 'develop' into users/adam360x/rdc-fake-gpu-tests
joshnguy-amd ec1479c
test(rdc): check that the fake amd-smi accepts the CPU init flag
adam360x aadd315
Merge branch 'develop' into users/adam360x/rdc-fake-gpu-tests
joshnguy-amd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| """Expected RDC readings for the fake amd-smi in tests/fake_amdsmi. | ||
|
|
||
| The fake answers every amdsmi_* call with per-GPU readings from fake_values.inc. This | ||
| module reads the same table and converts each reading to the unit RDC documents for the | ||
| field (see `rdci dmon -l`), so tests compare RDC's output with an expectation that does | ||
| not depend on RDC's own conversion code. | ||
| """ | ||
|
|
||
| import os | ||
| import re | ||
|
|
||
| _ROW = re.compile(r"^FAKE_VALUE\((\w+),\s*(-?\d+),\s*(-?\d+),\s*(\d+)\)$") | ||
| _HERE = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
||
|
|
||
| def _table_path(): | ||
| for path in ( | ||
| os.path.join(_HERE, "fake_values.inc"), # installed next to this file | ||
| os.path.join(_HERE, "..", "fake_amdsmi", "fake_values.inc"), # source tree | ||
| ): | ||
| if os.path.isfile(path): | ||
| return path | ||
| raise FileNotFoundError("fake_values.inc not found next to this file or in ../fake_amdsmi") | ||
|
|
||
|
|
||
| def _load(): | ||
| table, rows = {}, 0 | ||
| with open(_table_path()) as f: | ||
| for line in f: | ||
| rows += line.startswith("FAKE_VALUE(") | ||
| m = _ROW.match(line.strip()) | ||
| if m: | ||
| table[m.group(1)] = tuple(int(m.group(i)) for i in (2, 3, 4)) | ||
| if not table or len(table) != rows: | ||
| raise ValueError(f"parsed {len(table)} of {rows} FAKE_VALUE rows in fake_values.inc") | ||
| return table | ||
|
|
||
|
|
||
| TABLE = _load() | ||
|
|
||
| GIB = 1 << 30 | ||
|
|
||
|
|
||
| def reading(name, gpu): | ||
| """Raw reading `name` of GPU `gpu`, in amd-smi's unit.""" | ||
| base, step, modulo = TABLE[name] | ||
| value = base + step * gpu | ||
| return value % modulo if modulo else value | ||
|
|
||
|
|
||
| # RDC field id -> (fake reading, factor to the unit RDC documents for the field). | ||
| FIELDS = { | ||
| 100: ("GFX_CLK_MHZ", 1_000_000), # RDC_FI_GPU_CLOCK, Hz | ||
| 101: ("MEM_CLK_MHZ", 1_000_000), # RDC_FI_MEM_CLOCK, Hz | ||
| 200: ("TEMP_MEM_C", 1000), # RDC_FI_MEMORY_TEMP, millidegrees Celsius | ||
| 201: ("TEMP_EDGE_C", 1000), # RDC_FI_GPU_TEMP, millidegrees Celsius | ||
| 300: ("SOCKET_POWER_W", 1_000_000), # RDC_FI_POWER_USAGE, microwatts | ||
| 500: ("GFX_ACTIVITY_PCT", 1), # RDC_FI_GPU_UTIL, percent | ||
| 501: ("VRAM_USED_GIB", GIB), # RDC_FI_GPU_MEMORY_USAGE, bytes | ||
| 502: ("VRAM_TOTAL_GIB", GIB), # RDC_FI_GPU_MEMORY_TOTAL, bytes | ||
| } | ||
|
|
||
|
|
||
| def expected(field_id, gpu): | ||
| """Value RDC must report for `field_id` on fake GPU `gpu`.""" | ||
| name, factor = FIELDS[field_id] | ||
| return reading(name, gpu) * factor | ||
|
|
||
|
|
||
| def device_name(gpu): | ||
| return f"Fake AMD Instinct GPU {gpu}" |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.