Skip to content

feat(hw-oracle): run on Windows through the AMD driver's HIP runtime and comgr - #9209

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
SirDarky:feat/hw-oracle-windows
Oct 23, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
SirDarky:feat/hw-oracle-windows

Conversation

@SirDarky

Copy link
Copy Markdown
Contributor

What

tools/hw-oracle runs only on Linux with ROCm. Many measurements in issues and PRs come from AMD GPUs on Windows anyway (#8299, #8282, #5492, #1281 and #5782 among them), each through a private runner that assembles with the driver's amd_comgr and launches with its HIP runtime. This PR makes that path part of the tool, so a Windows measurement runs the same template.s, validation, padding, dispatch splitting and JSON report as a Linux one.

  • New oracle_hip.py, the Windows counterpart of oracle.c. It reads the target from the HIP device, assembles and links through amd_comgr_*.dll, and dispatches through amdhip64_*.dll, so no clang, ld.lld or C compiler is needed. Wave64 bodies are assembled with -mwavefrontsize64, as clang is called on Linux. hw_oracle.py loads it in-process, so the driver DLLs are loaded once per run, not once per dispatch. Run in a separate process for each dispatch, the run below took 9 min 48 s instead of 1 min 4 s. It also works on its own, with the oracle command line (--target, and CODE THREADS IN OUT OUT_DWORDS with COARSE) plus --assemble SOURCE OUTPUT TARGET [--wave64].
  • The action numbers of the comgr in AMD's Windows driver (2.9) are not those of the ROCm header: assembly is 0x8 and linking to an executable is 0x7, where the header has 0xA and 0x9. Each step tries both values and keeps the one that returns exactly one output of the expected kind. If no value works, it reports every attempt with its log.
  • hw_oracle.py picks the runtime with HW_ORACLE_RUNTIME, which defaults to hip on Windows and hsa elsewhere. The Linux path is unchanged.
  • ROCR_VISIBLE_DEVICES selects the HIP device through HIP_VISIBLE_DEVICES, unless that variable is set. HW_ORACLE_HIP and HW_ORACLE_COMGR name other DLLs.
  • HW_ORACLE.md: a Windows requirements section.

Tested

Windows 11, AMD Radeon RX 5700 XT (gfx1010), AMD driver 26.8.1 (comgr 2.9, amdhip64_6.dll), Python 3.12.

  • test_hw_oracle.py: 44 tests, all passing, 3 skipped. The skipped ones are the existing Linux and clang fixtures. On main the same machine gives 36 tests, all passing, 3 skipped. The existing tests pin HW_ORACLE_RUNTIME=hsa, because on Windows they would otherwise select the new default. The new tests cover:
    • runtime selection;
    • the calls run makes into the HIP runtime, in wave32 and wave64, fine and coarse;
    • the output-size check on the HIP path;
    • the CLI's argument checks;
    • the comgr action fallback and its error message;
    • the device-selection mapping;
    • a real wave32 and wave64 assembly through the driver's comgr, skipped where that DLL is missing.
  • The example in HW_ORACLE.md gives 00004000 / 00007e01. A wave64 body using s_and_saveexec_b64 and v_mbcnt_hi_u32_b32 runs. --coarse and --json work.
  • A larger run: @thuanquang's oob_select_stride0.py from AGC: zero-stride vertex fetches with OOB_SELECT 0, 1 and 3 do not follow RDNA 2's range checks #8299, through hw_oracle.run. It does 480 dispatches of 64 lanes, with buffer descriptors built from extra, and took 1 min 4 s. All 84480 dwords are identical to the results of the private runner posted in AGC: zero-stride vertex fetches with OOB_SELECT 0, 1 and 3 do not follow RDNA 2's range checks #8299, which matched gfx1031.
  • Not run on Linux. The HSA path is unchanged apart from building the dispatch payload in memory before writing in.bin, and the existing tests cover it.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (tooling; the oracle itself ran on an AMD Radeon RX 5700 XT, AMD driver 26.8.1, Windows 11)
  • AI-assisted: yes

🤖 Generated with Claude Code

…and comgr

tools/hw-oracle needed Linux with ROCm, so Windows measurements went
through private runners. oracle_hip.py assembles and links template.s
kernels with the driver's amd_comgr and dispatches them with its HIP
runtime, with the same rows, padding, dispatch splitting and report as
oracle.c. hw_oracle.py selects it with HW_ORACLE_RUNTIME, by default on
Windows, and loads it in-process so the DLLs are loaded once per run.

The driver's comgr 2.9 numbers its assemble and link actions 0x8 and
0x7, not 0xA and 0x9, so each step tries both and keeps the one that
returns exactly one output of the expected kind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the docs label Oct 21, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 22, 2026
@oneandonlydean
oneandonlydean merged commit a5d8d1d into boykopovar:main Oct 23, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants