Repository navigation
feat(hip): events, stream waits and device memory info - #630
Conversation
Mirrors the CUDA module: Event (timing or ordering-only) with record, synchronize, done and elapsedMs; Stream.done and Stream.wait(event); and Context.memInfo from hipMemGetInfo. hipErrorNotReady from a query means unfinished work, not failure; other results still fail. A probe kernel that sleeps before one write gives the GPU tests queued work to observe: right after queueing, the event and stream report unfinished; a second stream that waits on the event reads the written value, and the timed span is positive. Without the wait the reader returns the zero fill, so the ordering check fails when the wait is missing. memInfo is checked on the device for a stable total of at least 1 GiB. The check that a 64 MiB allocation lowers free memory skips, and says so, when another process leaves less than 128 MiB free.
|
Thanks, @jkuepker. #611 landed first (56150e6), and as you expected it touches the same four files. We merged yours on top locally, keeping both sides: |
|
gfx1151 receipt at this head (Strix Halo: Ryzen AI Max+ 395, Radeon 8060S), fresh Zig cache per step:
|
|
Receipt for this PR on
#631 also runs on top of it, taking this PR's |
|
Thank you, @jkuepker. This landed in 1.0.8. No rebase was needed from you after all: we did it on our side, as we should have. Sorry for asking.
The negative controls in particular made this easy to trust without a card. |
The change landed rebased onto the 1.0.8 candidate as 5a89c22e3 with its author kept; this keeps the PR's head in the history with no change to the tree.
This adds HIP events, stream waits and device memory info to #463's runtime, matching the CUDA module:
Event, either timing or ordering-only, withrecord,synchronize,doneandelapsedMs.Stream.doneandStream.wait(event).Context.memInfo, fromhipMemGetInfo.A query that returns
hipErrorNotReadymeans the work is unfinished, not that it failed. Any other result still fails.Nothing in the open HIP PRs (#607, #609, #611, #612, #613, #617) adds events, stream waits or
hipMemGetInfo. #611's memory usage counts the bytes this process holds, whilememInfois the driver's free/total for the device, so the two answer different questions. #611 and #617 append next to this inabi.zig,context.zig,runtime_tests.hipandruntime_tests.zig. All of those are keep-both merges, and I'm happy to rebase onto whichever lands first.How it's tested
not_readymaps to unfinished, that other query failures still fail, and thatmemInforefuses impossible driver counts.Receipt
Setup: two AMD Radeon AI PRO R9700 cards (gfx1201, 32 GB each), ROCm 7.2.1 in
rocm/dev-ubuntu-24.04:7.2.1-complete, Zig 0.17.0, this branch at52449e0b(on main9041e20a), each card tested on its own (HIP_VISIBLE_DEVICES).zig build hip-host-testhip-gpu-test -Dhip-arch=gfx1201hip-affine-test -Dhip-arch=gfx1201hip-gpu-test -Dhip-arch=gfx1151(wrong arch, must fail)UnsupportedArchitecturehip-affine-test -Dhip-arch=gfx1151(wrong arch, must fail)UnsupportedArchitecturehip-gpu-testwith thereader.wait(end)line removed (must fail)0, expected12648430No test skipped; the memory check ran with both cards free.
Mac, on this branch:
zig build test -Dcpu=apple_m1: exit 0, no test errors.zig build --help: the HIP steps and options still register.python3 tools/zig/lean_check.py: 542 problems on main9041e20aand 542 on this branch.Earlier runs of this events code, stacked on the multi-architecture branch before #463 landed:
907911cand2b20f268.907911c.Both included the negative control: with the wait removed, the ordering test fails.
The events code hasn't changed since. Two edits in the tests since then: the event test now builds its own single-image list, the way main's tests do, and two comments (
runtime_tests.hip,runtime_tests.zig) no longer quote timings.