Repository navigation
borealis: scale packed compute static-work budget with GPU core count - #1179
RyanTheTide merged 3 commits into
Conversation
HK_PACK_MAX_STATIC_WORK (2^35 thread-instructions) was calibrated for
~16-20 core GPUs (~18 ms at M4 ALU rate), which artificially splits
multi-CB compute graphs and rejects post-fusion runs on wider GPUs.
- Add hk_pack_max_static_work_for_cores() / hk_pack_max_static_work()
scaling linearly from 1x at <=20 cores to 4x at >=80 cores via
agx_get_num_cores() (1.6x at 32, 2x at 40, 4x at 80).
- Add max_static_work to struct hk_pack_limits and *_limit() variants
of hk_pack_account_dispatch_work{,_eff}() and hk_pack_fusion_fits_run(),
keeping existing defaults unchanged when max_static_work == 0.
- Wire the core-scaled limit through hk_cmd_dispatch.c and hk_queue.c
and cover core scaling, bounded-loop accounting, fusion re-accounting,
and run planning in test-hk-pack.
Signed-off-by: oreater <145754695+oreater@users.noreply.github.com>
|
This branch no longer merges into current |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at eec2d72eca08f
Blockers: none
Checked: Read the whole diff (hk_pack.c/.h, hk_queue.c, hk_cmd_dispatch.c, the tests). The budget comes from agx_get_num_cores(), the sum of the core masks the kernel reports, so it is a hardware property and not a chip table. That satisfies the no-gates rule. The arithmetic is exact at the end points: (2^35 / 4) * clamp(cores, 20, 80) / 5 gives exactly 2^35 for 20 cores or fewer, so every Mac at or below 20 cores (M1/M2/M3/M4 base and Pro parts, A18 Pro, all current lab Macs) keeps the current budget bit for bit. It cannot overflow (max 2^37). Record time and pack time use the same value: dispatch_grid_shader() calls hk_pack_max_static_work(dev) when it sets pack_loops/pack_static_work, and hk_pack_runs() passes the same value in limits.max_static_work to hk_pack_plan() and to the fusion check. The old entry points keep 2^35 for callers and tests that pass no limit, and in a merged tree no non-test code calls the unscaled variants. The new tests check exact values and the 24G+24G split-versus-pack case, so they cannot pass without the change.
To finish:
- Merge
aurora-wipinto the branch. Inhk_pack.chk_pack_within_bounds(), keep wip's(!cs->pack_loops || m->obs_ns <= HK_PACK_MAX_OBS_NS)line from #1186 next tomax_work. Intest-hk-pack.c, put your budget tests inside the block wherew,nw,nlandrunsare declared, before wip's new obs-retire block. A scratch merge done that way passes the local gate (see Evidence). - Rows owed at the merged head: the change only does anything on GPUs with more than 20 cores, and the J716c is the only such Mac we have, so the M5 Max row at the merged head is the feature row. Add one 20-core-or-fewer regression Mac to show nothing changed there. Max and Ultra parts of the M1/M2 generations would get 1.6x to 3.8x larger packets. On those GPUs a compute command blocks other clients' compute for its whole length, so a packet that takes as long in wall-clock time also stalls the compositor that long. That matches what the scaling intends, but it is untested. Please say so under "Not yet".
Non-blocking: the comment says the 2^35 budget was "calibrated for ~16-20 core GPUs (~18 ms at M4 ALU rate)", but 2^35 thread-instructions on a 10-core M4 is about 17 ms, and on a 20-core part about half that. Worth rewording so nobody later reads 18 ms as the bound on a 20-core part.
Landing order: this conflicts with #1180 in tests/test-hk-pack.c only (both append tests in the same place). Either order works; the second one keeps both blocks.
Evidence
- Local x86 drm-shim gate (stands in for CI; docker
aurora/hk6356-mesa-x86-tests:local, clang release with asserts,meson test --suite asahi --suite poly):- base aurora-wip
fa8970cda14f: 336 OK / 0 FAIL - scratch merge of
eec2d72eca08fintofa8970cda14f, resolved as above: 336 OK / 0 FAIL;hk_packlog showsPASS work budget stays 1x for <=20 cores,PASS work budget scales cleanly on 32/40/80+ cores,PASS 24G + 24G splits under 20-core 1x budget,PASS 24G + 24G packs under 40-core 2x budget.
- base aurora-wip
|
The 24 h window on the merge request from 11-27 04:20Z has passed, so per our PR fast-track policy I forward-merged Conflicts, kept both sides:
Host check at Before merge it goes into the next combined lab regression row (M1 Pro G13S + M4 G16G). If you'd rather resolve it differently, push on top and I'll re-run. |
|
@DjDeveloperr, code-owner heads-up: this PR has an aurora-silicon-review App approval at |
|
Second forward merge, |
|
Merge-train landing at
Revert: |
What: Scale the per-packet compute submit-packing static-work budget (
HK_PACK_MAX_STATIC_WORK,2^35thread-instructions calibrated for ~16–20 core GPUs) linearly withagx_get_num_cores()from1xat<= 20cores up to4xat>= 80cores (1.6xat 32,2xat 40,4xat 80), so wider GPUs maintain the same wall-clock packet budget without prematurely splitting compute graphs or rejecting post-fusion runs.Tested: J716c Apple M5 Max at
eec2d72eca0: 334/334 Clang debug CI tests (--suite asahi --suite poly) PASS, 48-CB high-work compute graph cuts CDM firmware commands48 -> 24(runs=0 -> 24) and wall-clock time -17.3% (1.290 -> 1.066 ms,1.21x) with exact counter readback, 159/160 Vulkan CTS PASS (0 fail, 0 diffs), 0 kernel errors.Risk: two-way door · Macs with
> 20GPU cores — A plain revert restores the fixed2^35static-work cap; Macs with<= 20GPU cores get the exact1x(2^35) budget unchanged.HK_PACK_MAX_DISPATCHES,HK_PACK_MAX_THREADS, per-packet attachment caps, and synchronization rules are untouched.Not yet: Hardware-tested on 40-core J716c Apple M5 Max; wider 60–80 core (Ultra) parts get up to
4xproportional scaling without per-chip tables.Details and verification evidence
Summary
src/asahi/vulkan/hk_pack.h,hk_pack.c:hk_pack_max_static_work_for_cores()andhk_pack_max_static_work()scaling(HK_PACK_MAX_STATIC_WORK / 4u) * CLAMP(cores, 20u, 80u) / 5uviaagx_get_num_cores().max_static_worktostruct hk_pack_limits(defaulting toHK_PACK_MAX_STATIC_WORKwhen0) and use it inhk_pack_within_bounds()andhk_pack_plan().*_limit()variants ofhk_pack_account_dispatch_work_eff(),hk_pack_account_dispatch_work(), andhk_pack_fusion_fits_run().src/asahi/vulkan/hk_cmd_dispatch.c,hk_queue.c:hk_pack_max_static_work(dev)into dispatch work accounting,hk_pack_limits.max_static_work, and submit-time fusion re-accounting.src/asahi/vulkan/tests/test-hk-pack.c:splitson 20-core1x,packson 40-core2x).Build & Artifacts
J716c Apple M5 Max (G17C B1, 40 GPU cores), Fedora Remix 44, kernel7.3.0-40.j716c19.fc44.aurora.aarch64origin/aurora-wip41fe336dffa):libvulkan_asahi.soSHA-2560ea0ee4efd3bb78ef2eab7770e5d2bf9dacd59a4cd4f8809729941acff43e476eec2d72eca0):libvulkan_asahi.soSHA-256801962892fc776590c6004202b8e93af31ccebacb2ee7a6df6ca2c7b3de9c005Verification
--suite asahi --suite poly, Gallium + Vulkan +drm-shim, assertions enabled):334/334 PASS, 0 FAIL.MESA_SHADER_CACHE_DISABLE=1, 48-CB compute graph × 40 iters, exact output counter1920on every run):HK_PACK_CDM_TRACE=1)0 runs(48 cmds)24 runs(24 cmds)1.2897 ms1.0664 ms1.21x)deqp-vk, base vs head,MESA_SHADER_CACHE_DISABLE=1):160-case slice acrossdEQP-VK.compute.pipeline.basic.*+dEQP-VK.api.command_buffers.*:159/160 PASS, 0 FAIL, 1 NotSupported(0status diffs vs base).SELinux=Enforcing,0DRM/asahi/GPU kernel errors.