Repository navigation
hk: pack runs of plain compute command buffers into one command - #488
Conversation
|
Thanks for porting the packing work. The packtest and Geekbench numbers on the M4 mini are a big win, and the bounds on each packet are carefully reasoned. One request about how packing is selected. In this project we choose behaviour by a hardware or kernel property, not by the list of machines it has been measured on. In
G17C and G17G use the same stream encoding and expose the same feature, so they would only be left out because they haven't been measured. Could the M5 default be "on wherever the kernel reports visible completion"? Keep a chip check only where there is a real hardware difference, with a comment saying what it is. The G16G reason (one command at a time on HAL200) is a good example. Once the default is set that way, |
Submit packing copies the compute streams of several command buffers into one command. To decide which streams it may copy and how much work one command may then hold, it needs facts the stream does not record yet: - whether a dispatch runs a program with global atomics (a new compiler output, set where global atomics are emitted); - how many launches are direct application dispatches, their threads, and threads times static native instructions; - whether the stream calls another stream through a link with return (ray tracing's single kick), whose bytes must stay where they were recorded; - whether the command buffer sets, resets or waits on an event, which the host or another queue can observe before its submission completes. Stream merges carry the new fields, and hk_cs_merge_cdm_until() merges a stream up to a given point, before its terminate, into a stream of another command buffer. No behaviour changes. Signed-off-by: Diljit Singh <hey@djdev.me>
Every firmware compute command costs a fixed setup and completion on top of its dispatches: on the M5 Pro (G17S) a chain of 242 one-dispatch command buffers took 3.0 ms as separate commands and 0.31 ms as one, and the M4 (G16G) firmware runs the device's compute commands one at a time, with 0.1 to 0.3 ms of firmware and host turnaround each. Applications that record a dispatch or a few per command buffer and submit many at once (ML graphs, image filters, Geekbench's compute workloads) pay that per command buffer. At submit, copy each run of consecutive command buffers that hold one plain compute stream back to back into one submission-owned stream, and submit the run as one command. Each member boundary publishes the member's writes to the members after it: - M5 streams end with the strong, memory-scoped flush that visible completion asks for; the copy keeps it. - G16G streams end with the last launch's ordering barrier or a strong flush, and the end of the command publishes the writes. At a boundary the record becomes the strong flush (0x60001560), the record a compute or transfer dependency inside one stream gets on G16G. HAL200 has no memory-scoped or wide form, and hk treats no G16G memory as reachable through a second address (hk_cdm_alias_scope() is false there), as for those in-stream dependencies. The last member's tail stays as recorded, followed by the packet's own end of command. The packet carries no compute flags, which the G16 kernel requires. Work in the packet waits for what any member waited for, and later work waits for the whole packet: packing only adds ordering the firmware imposes on separate commands anyway. Streams with links, calls, immediate writes, queries, timestamps, events, indirect or internal launches, or global atomics stay separate commands. A packet covers at most 256 launches, 2^28 threads and 2^35 threads times static instructions, so one watchdog allowance (5 s per command on G16) still covers it, and no more compute attachments than the kernel takes for one command, so none is dropped that a separate command would carry; a longer run starts a new packet. The packet's stream lives in a driver-owned buffer. On M5 the existing command-memory pins keep it until the submission retires; elsewhere the same mechanism now pins that buffer alone, since the BO cache would otherwise hand it out again while the GPU still reads it. Default on for G17S and G16G. HK_PACK_CDM_SUBMIT=0 turns it off (the older ASAHI_M5_PACK_CDM_SUBMIT is still read), =1 turns it on for the other M5 parts; HK_PACK_CDM_TRACE=1 prints what each submit packed. Signed-off-by: Diljit Singh <hey@djdev.me>
Each packed M5 command buffer ends with the strong, memory-scoped flush that publishes its writes at the end of its own command. Inside a packet the next member reads through the same GPU addresses, and the host and other queues observe nothing of the packet before its completion, so between members the plain strong flush is enough unless memory can also be reached through a second address (hk_cdm_alias_scope()). The packet's last flush keeps the memory scope. G16G has no memory-scoped flush and is unchanged. Signed-off-by: Diljit Singh <hey@djdev.me>
Streams with global atomics stayed separate commands because, on M5, two kernel queues running packed atomic chains on the same memory lost contributions (root cause unknown). That concern needs another kernel queue running beside the packet. On G16 every queue feeds one firmware compute queue, which runs one command at a time (queued commands take exactly their GPU time each, measured on the J773g Mac mini), so nothing runs beside a packet there: G16G packs such streams by default (HK_PACK_ATOMICS=0 keeps them separate). On M5 they are packed only with ASAHI_M5_PACK_ATOMICS=1 (or HK_PACK_ATOMICS=1) and while the device has a single kernel queue, which runs its commands in order; a second kernel queue created while a packet runs is not covered, and unpacked atomic work has the same exposure. Signed-off-by: Diljit Singh <hey@djdev.me>
With HK_PACK_CDM_TRACE=1, a submission that packs nothing now says so too, and every line counts the command buffers that qualified as packet members, so a run can tell a workload that never qualifies from one whose qualifying command buffers are not adjacent. Signed-off-by: Diljit Singh <hey@djdev.me>
0eec131 to
2c46924
Compare
|
Rebased onto aurora-wip af7ec5f (#551 merged). Old head 0eec131 (on 57df4db), new head 2c46924.
Local checks (Actions doesn't run on this repo), host aarch64, clang 23.1.1,
M4 hardware A/B (packtest packing off/on, Geekbench 6 Vulkan with |
Independent review (separate agent, not the author's lane)Reviewed head I found no wrong-result bug in the dependency translation, the member-boundary flushes or the packed BO's lifetime. There are two design problems and a test gap worth fixing before this ships on by default on G16G and G17S. Findings (most severe first)1. The packet bounds don't limit how long a packet runs, so a packet can exceed the per-command watchdog that each member would pass. The work bound is threads × static instruction count. The code comment says this doesn't bound loops, but the commit message relies on it: "so one watchdog allowance (5 s per command on G16) still covers it". Scenario: an ML-style submit of 256 one-dispatch CBs, each with 2^20 threads, 64 static instructions and a 2048-iteration K loop.
Fix: have the compiler report whether a program contains loops, the same way this PR adds 2. Hoisting a later member's render (VDM) wait onto earlier members serializes compute that used to overlap rendering.
Scenario: one submit of
Fix: close the open run before a member whose VDM requirement adds kinds the packet doesn't already wait for. That requirement is its 3. No test covers the packing paths.
Suggestion: move the packet's dependency folding (the loop at 2766-2781 plus the
Also check packtest in next to the other Lower severity / nits
Checked and found correct
No commits pushed; not approving or merging. 🤖 Generated with Claude Code |
Review of #488 found two ways a packet could behave worse than the command buffers it replaces: - The static work bound (threads x static instructions) does not bound a program with loops. 256 looping one-dispatch command buffers fit one packet and could run far past the per-command timeout that each of them alone stays under (on G16 the kernel's 5 s deadline renews only when a command's stamp moves, so it limits a command's total run time). The compiler now reports whether a program has a loop (has_loops, like uses_global_atomics), streams record it (pack_loops), and a packet holds at most one looping stream: it runs about as long as that stream alone plus statically bounded work. - A packet waits for whatever any member waits for. For the compute subqueue that adds no ordering, but a later member's wait on a render held the earlier members back, so [render][C1][C2 reads the render] serialized C1 behind the render. A member now starts a new packet when it, or the tail of a member before it, would add a render wait or a synchronization kind (whose carried requirements the packet would take on); the last member's tail is a requirement of later command buffers only and no longer holds the packet itself back. The member check, the planner and the dependency fold move to hk_pack.c, so they can be tested without a device. Also: - The inline-merge size condition is checked at run time; a packet that would not fit falls back to separate commands instead of letting the merge link into the source command buffer's stream. - The command-memory pin is allocated before anything changes queue or synchronization state, and a failed allocation fails the submission with VK_ERROR_OUT_OF_HOST_MEMORY instead of losing the device. Signed-off-by: Diljit Singh <hey@djdev.me>
hk_pack_test runs the member check, the planner and the dependency fold against the real hk_sync recorder and resolver (suite asahi, no device): every rejection of hk_pack_run_member() (events, timestamps including a pending start stamp, immediate writes, indirect and internal launches, linked streams and calls, queries, atomics, cuts); the bounds, the one-looping-member cap and the render-wait and kind splits of the planner; and through hk_sync_resolve_submit() that a member's tail cut or tail prior makes later command buffers wait for the packet, that a member's render wait reaches the packet's barrier, that a render after a packet waits for it, and that the last member's tail holds back later command buffers only. aurora-packtest is the hardware test the packing was qualified with: dependent chains, barriers, transfers and work that stays out of packets, compared word for word with a CPU model. Its plain dispatches run a program without loops, its heavy ones a looping program; run it with HK_PACK_CDM_SUBMIT=0 and =1. Signed-off-by: Diljit Singh <hey@djdev.me>
|
Thanks for the review. Fixed on top of 2c46924, new head 6816224 (two commits, no history rewritten): 1. Packet run time and loops ( 2. Render waits pulled forward (same commit). A member now starts a new packet when it would add a render wait or a synchronization kind: its 3. Tests (
packtest is checked in as Lower severity:
Local checks at 6816224 (host aarch64, clang 23.1.1, release, |
|
Thanks for the rebase and for the fixes after the independent review. Allowing one looping member per packet, the render-wait split and The default at |
Independent re-review (separate agent, not the author's lane)Re-reviewed head How I checked it:
Status of the first review's findings
Findings (most severe first)1. Real bug, blocking: the render-wait split treats compute-only barriers as render waits. A command buffer recorded as Why it happens:
Measured: I ran the real Impact:
Fix: mask
2. Test gap, medium: the dependency tests cover packet shapes the planner cannot form, and nothing checks that packing actually happens.
3. Residual risk, low-medium, non-blocking: the static work bound assumes the ALU rate.
Nits
Checked and correctKernel deadline claim. It holds.
Loop flag. Set for every loop form, with no stale cache entries.
No dropped waits: randomized harness.
OOM path. Queue and synchronization state stay consistent.
Runtime size guard (
Pending start stamp. Now rejected explicitly ( VerdictNot ready to merge. Blocking: finding 1. As it stands, packing is effectively off for the No commits pushed; not approving or merging. 🤖 Generated with Claude Code |
hk_sync_src_dep() records a barrier's source kinds against both
subqueues, so a COMPUTE -> COMPUTE barrier after a dispatch also names
COMPUTE work on the render subqueue. The resolver turns that into a wait
only once the render subqueue ran COMPUTE-kind work (resolve_prior()), but
the planner took it for an added render wait and split: command buffers
recorded as {dispatch, barrier}, the pattern packing was measured on
(242 such command buffers, 3.0 -> 0.31 ms), formed no packets.
The planner now masks a member's render waits and tail with the kinds the
render subqueue ran before it: the queue's earlier submissions
(hk_sync_queue::ever) and the render streams of the command buffers before
it in the submission. The kind rule applies only once render work ran:
before that no carried requirement can resolve to a render wait.
The planner also keeps the tail per kind, as hk_pack_fold_member() folds
it: a packet waits for a member's tail only for the kinds the packet has,
so a GFX -> GFX barrier after a dispatch no longer splits. Neither change
alters which waits are kept, only how much is packed.
Also: no compute-kick note after a submission that failed untouched, and
the comments say the static work bound limits a packet at ALU rate.
Signed-off-by: Diljit Singh <hey@djdev.me>
- The planner packs a {dispatch, COMPUTE -> COMPUTE barrier} chain into
one packet on G16G and on G17S (M5), also after a render or on a queue
that rendered; COMPUTE work on the render subqueue makes that barrier a
render wait again. A render tail splits a packet only for kinds the
packet has.
- The dependency checks build their packets through the planner, and run
with both the legacy and the exact-prior resolver (the G16 kernel takes
exact priors), including a later submission that waits through the
queue's persisted tail.
- The two folds the planner's rules make redundant are pinned on packets
built directly.
- 2000 random submissions per resolver mode are resolved packed and
unpacked: no wait may be dropped, and no packet may wait for more render
work than its first member (from the second review of #488).
aurora-packtest reads back the driver's packing trace and reports the
command buffers packed per case. With HK_PACK_CDM_SUBMIT=1 a case that
must pack fails when nothing was packed, and with =0 any packing fails.
Signed-off-by: Diljit Singh <hey@djdev.me>
|
Thanks for the re-review and the harness. Fixed in two new commits on top of 6816224, new head 532fbf4 (history before it unchanged): 1. Compute-only barriers split packets (blocker) ( The M5 lane's re-review added one more change, now included. The planner keeps the render tail per kind, as Neither change affects which waits are kept, only how much is packed. The random harness (below) runs on this head. 2. Tests (
3. Static work bound vs memory-bound code. I took the "explain" option rather than a cap. Nits: Local checks at 532fbf4 (host aarch64, clang 23.1.1, release,
The M4 hardware A/B runs on this head in the next J773g slot: aurora-packtest packing off/on with packed counts per case, and Geekbench 6 Vulkan with |
Independent re-review (separate agent, not the author's lane)I re-reviewed the two new commits at head Verdict: ready to merge.
How I checked it:
1. Is the planner's test the same as the resolver's?Yes, with one exception (finding 1).
2. Does the per-kind tail match the fold?Exactly.
Two pieces of the planner never change the result. Their mutants (M2e, M2i) are equivalent:
Both matter only while 3. Do the tests catch the old and the under-cautious versions?Each mutant was rebuilt, run and reverted. "fail" counts failing checks; "random" counts failures in the random harness.
Findings (most severe first)1. LOW, perf only. The planner and the resolver disagree after
2. LOW, test gap. The test re-implements
3. LOW, test gap. The random harness never plans against queue history, and its renders are all GFX-kind.
4. LOW, aurora-packtest. The must-pack verdict for
5. NIT, aurora-packtest. When a case dies, the trace capture loses the driver's stderr.
6. NIT, comment. This was in the M5 lane's notes and is still open.
Optional follow-up (not blocking)Once a queue has rendered,
Out of scopeThese commits don't touch RyanTheTide's question about the M5 default (now The disposable worktree has been removed. Nothing was pushed, approved or merged. 🤖 Generated with Claude Code |
Packing was on by chip: G17S and G16G, other M5 parts opting in. hk_pack_boundary() now decides it from how a member's end publishes its writes to the members after it: - M5 streams, where the kernel takes their own completion flush (DRM_ASAHI_FEATURE_COMPUTE_VISIBLE_COMPLETION): every stream then ends with the strong memory-scoped flush a boundary keeps. G17G and G17C pack as G17S does. - HAL200 streams whose strong flush has no memory-scoped form (G16): the kernel publishes a command's writes when it completes, and a boundary becomes the strong flush an in-stream compute dependency gets. G17P stays out: its strong flush also has a memory-scoped form, which memory reached through a second address needs and which no such boundary asks for (hk_cdm_memory_scope_form(), now shared with hk_cdm_flush_has_memory_scope()). G15 and AGX2 streams have no boundary. Packing is on wherever a boundary is defined; HK_PACK_CDM_SUBMIT stays for A/B rows. The member check and the copy take the boundary from the same function. Global atomics stay packed only on G16G: the G16 kernel's whole-device ordering is not reported by any uAPI feature yet. The planner's render kinds now come from the fields the resolver reads, through hk_sync_queue_kinds() (hk_sync_queue::ever, or last_absolute on exact-prior queues) and hk_sync_cmd_kinds() (cmd->sync.last). Reading stream kinds disagreed after hk_sync_forget_stream() left a latest render of a kind on a render of another kind. hk_pack_describe_submit() is the one describe loop for hk_pack_runs() and the tests. The planner and the fold now apply a member's tail to each destination class of the packet's stream (hk_sync_full_kinds()), as the resolver applies carried requirements: a fragment-class tail of a member of every kind was neither checked nor folded. Signed-off-by: Diljit Singh <hey@djdev.me>
- hk_pack_boundary(): G17G, G17S and G17C pack with visible completion and not without; G16G and G16S take the HAL200 boundary; G17P, G15S and G14G have none. A G17S stream is a member only with the feature. - The tests plan through hk_pack_describe_submit(), the loop hk_pack_runs() runs. - A render forgotten after a transfer render leaves a graphics render wait that the planner now sees, as the resolver does (legacy and exact). - A fragment-class tail of a member of every kind splits the plan and is folded. - The random harness also draws members of every kind (HK_SYNC_ALL), and a history harness (from the third review of #488) runs 1-2 earlier submissions with graphics, transfer and compute renders before planning a submission against the queue's state, in legacy and exact mode, comparing it packed and unpacked. aurora-packtest passes the driver's stderr through as it is written, through a pipe and a thread that counts packed command buffers, so a case that dies keeps its driver messages. It forces HK_PACK_CDM_TRACE=1, fails a must-pack check when no trace is available, and checks chain-all (an ALL -> ALL barrier in each command buffer) as must-pack only before the queue ran a render. Signed-off-by: Diljit Singh <hey@djdev.me>
|
New head ee3de2b: two commits on top of 532fbf4 ( @RyanTheTide: the default now follows a property, not a chip list.
Third review:
Nits:
From the M5 lane's re-review: the planner's tail check ( Local checks at ee3de2b (host aarch64, clang 23.1.1, release,
The PR body now records hardware status: G17S by the M5 lane's s8c row, and G16G at the first head. The M4 on/off row on this head comes next. |
Independent review of
|
| Mutant | Result |
|---|---|
| S1: old chip list (G17S with the feature, G16G) | 3 fail: G17G/G17C with the feature, G16S |
| S2: M5 ignores the feature | 4 fail |
| S3: HAL200 branch takes G17P / S4: G15 too | 1 fail each |
S5: hk_pack_run_member() skips the NONE check |
1 fail |
| F1: planner tail on raw kinds | 3 fail, random 2, history 56 |
| F2: fold on raw kinds | 1 fail (test_full_classes) |
| F3: both on raw kinds (old) | 3 fail, history 5 |
| R1: render kinds from stream kinds (old) | 2 fail (test_forget legacy and exact) |
R3: render kinds start at 0 / R4: no per-command-buffer accumulation / R5: hk_sync_cmd_kinds() returns 0 |
8 fail, history 1656 / 4 fail, random 540, history 274 / same as R4 |
R6: exact hk_sync_queue_kinds() returns 0 |
1 fail, history 665 |
| All old behaviour together | 8 fail |
R2: exact hk_sync_queue_kinds() returns ever |
survives (finding 5) |
The previous review's surviving M4a/M4b (render kinds starting at 0, no accumulation) are now caught (R3, R4).
Findings (most severe first)
1. LOW, older than these commits, needs a hardware check: G16 boundaries assume no G16G memory has a second GPU address.
- Code:
hk_queue.c:2660-2663, and the selector's HAL200 branch athk_pack.c:42-44. - Premise: hk treats no G16G memory as reachable through a second address, because
hk_cdm_alias_scope()is false there. - But a G16G device can have such memory:
KHR_external_memory_fd,EXT_external_memory_dma_bufandbufferDeviceAddressCaptureReplayare exposed (hk_physical_device.c:152, 256, 500);hk_device_may_alias_memory()counts each of them (hk_device.c:928-954).
- In-stream dependencies already carry this exposure. Packing adds a new case: it replaces the end of a command, which writes caches back, with a flags-5 flush.
- The wide word, which has the memory write-back bit, is grounded on G16G (
agx3_cmdstream.h:623-631, 637-648). So "no memory-scoped form" is not quite true for G16G either. - Scenario, if G16G caches are tagged by virtual address like G17P/M5 (unverified either way): two imports of one dma-buf, or a capture/replay buffer over the same memory.
- CB1 writes through one address, CB2 reads through the other.
- As separate commands, CB2 reads the new data. Packed, it can read stale data.
- Fix, either of:
- an M4 A/B on exactly that case;
- until then, on
STRONG_FLUSHdevices withdev->may_alias_memory, either skip packing or end non-last members with the grounded G16G wide word.
- Geekbench-style compute processes enable none of these features, so the fallback would cost little.
2. LOW (rationale): the G16G atomics exception names a property linux#2419 removes.
- The text says "The G16 kernel runs one command of the whole device at a time, so nothing ever runs beside a packet". It appears in:
hk_queue.c:2443-2447, the comment this commit added to;- the PR body ("Global atomics: packed on G16G, whose kernel runs one command of the device at a time");
- and, in the same terms,
hk_pack.c:189-190.
- The PR body pairs this PR with linux#2419, which changes that: "Compute commands queue behind the same VM's in-flight compute on the one firmware compute queue" (
g16/engine.rscan_queue_behind(), 926-949). Two kernel queues of one VkDevice share that VM. - Packing atomics there is still sound if the one firmware compute queue runs its commands in order. #2419 already relies on that: "same-queue compute dependencies follow the published frontier", with CTS at 0 Fail, and packtest atom-chain/atom-multi pass packed.
- But that is the property a future uAPI feature would have to report, not "one command at a time".
- Fix: restate both comments and the PR body as "G16 runs every compute command of a VM in order on one firmware compute queue, and never beside another VM's". Ideally the M4 row confirms atom-multi on two VkQueues with #2419.
3. LOW (accuracy, affects the requested rows): G17G and G17C are not on by default with any current kernel.
- Only J714 reports
DRM_ASAHI_FEATURE_COMPUTE_VISIBLE_COMPLETION(see (a)). So "G17G and G17C pack as G17S does" (commit message, reply) and "packing is on by default" for G17C/G17G (PR body) describe a kernel that does not exist yet. - The default is unchanged on every M5 board today. That is fine under a by-property rule.
- The PR body asks G17C/G17G owners to run
HK_PACK_CDM_SUBMIT=1 aurora-packtest 3and expectpacked_cbs > 0.- On those machines
hk_pack_runs_enabled()returns false before reading the variable, so nothing packs. - Every must-pack case then prints
FAIL ... (must pack), which reads as a packing bug.
- On those machines
- Fix:
- PR body: say "wherever the kernel reports it (today J714 only)".
- aurora-packtest: report
UNAVAILABLEinstead of FAIL when a case of two or more command buffers produced noHK_PACKtrace line at all. The driver prints one (runs=0 ...) whenever packing is enabled.
4. LOW (latent): the HAL200 branch selects "HAL200 minus G17P", which also gives G17A (and G16P/G16S/G16C) the STRONG_FLUSH boundary.
- Code:
hk_pack.c:42-44, table atagx_chip.h:394-411. - G17A sits between G17P and M5, which both have tagged caches and the memory-scope form. It gets
STRONG_FLUSHonly becausehk_cdm_memory_scope_form()(hk_device.h:450-457) does not list it. - Unreachable today:
agx_chip_driver_supported()admits only G16G of these (agx_chip.c:397-447). - But admitting G17A would turn packing on without anyone deciding it.
- Fix: limit the branch to the G16 parts the comment names, and add a G17A row to
test_boundary().
5. LOW (test gap, performance only): nothing distinguishes the exact-mode hk_sync_queue_kinds() from ever.
- Mutant R2 (
hk_pack.c:148usingsync->ever[HK_SYNC_VDM]) passes every test. - The two differ only when a render was forgotten in an earlier submission on an exact queue.
test_forget()forgets within the planned submission. - Effect of the bug: a packet that waits for more render work than its first member. No wait is dropped.
- This test passes at head and catches R2:
static void
test_forget_history(void)
{
struct hk_cmd_buffer *r = new_cmd();
r->sync.kind_override = HK_SYNC_XFER;
add(r, false);
r->sync.kind_override = 0;
struct hk_cs *gone = add(r, false);
hk_sync_forget_stream(r, gone);
list_del(&gone->node);
struct hk_queue *q = new_queue(true);
T("exact: earlier forget: history resolves", resolve(q, &r, 1));
struct hk_cmd_buffer *c[2] = {plain(1), after_render()};
struct hk_pack_run runs[4];
unsigned count;
plan_queue(q, c, 2, false, runs, &count);
T("exact: a render forgotten in an earlier submission splits", count == 0);
T("exact: earlier forget: resolves", resolve(q, c, 2));
T("exact: earlier forget: the resolver agrees",
wait_of(first_cs(c[0]), HK_SYNC_VDM, 0, true) == 0 &&
wait_of(first_cs(c[1]), HK_SYNC_VDM, 0, true) != 0);
}6. NIT (wording): the G15 reason at hk_pack.c:27-29 and the test name "G15S: wide visibility, no boundary" (test-hk-pack.c:483).
- As shown in (a), the wide word is what the boundary would emit on G15.
- The real reason is that G15 packing (kernel, watchdog and attachment limits) has not been qualified.
- Since this is the "chip check with a stated hardware reason" the request asked for, say that instead.
7. NIT: aurora_packtest.c:970 return bad + on; fails every case when no trace is available with HK_PACK_CDM_SUBMIT=1, not only must-pack cases as the commit message says.
- Fix:
bad + (on && must), and keep WARN for the rest.
8. NIT: on G16G, an unparsable HK_PACK_ATOMICS now means off (was on) (hk_queue.c:2459).
- This matches the M5 path and is more conservative. Mention it in the commit message, or keep the old default.
🤖 Generated with Claude Code
M4 hardware row on ee3de2b: packing off vs onSetup. J773g Mac mini (M4, G16G B0) running kernel 7.3.0-ARCH-m4drv8 with GPU firmware Apple GFX 25G83. The aurora.ko is p5d (sha 2f97353a), the linux#2419 module the first-head numbers used. The Mesa driver is built from this head ( aurora-packtest at this head
Result: 22/22 PASS with packing off and 22/22 PASS with packing on.
Must-pack cases: chain242, chain300, loops, chain-all, multi, multi-tail, disjoint. Geekbench 6.7.1 GPU VulkanMedian ms per iteration (iterations 1–19); every workload ran its 20 iterations in both arms.
Review finding 1 on hardware: the same memory at two GPU addressesThe new aurora-packtest cases
What the failures show:
|
|
Follow-up to the M4 row above (same session, head unchanged at ee3de2b). Feature Matching / Particle Physics: confirmed, the one-looping-stream cap. Geekbench 6 ran with
No other condition (kinds, render waits, dispatch/thread/static-work bounds, size) fired. So the review's loop cap costs exactly the ~3 ms these two gained at the first head. Getting it back needs a run-time bound on looping members (for example a per-pipeline measured GPU time), not a different rule. I'm leaving that to a follow-up, and #488 keeps the cap. Two GPU addresses: a fix candidate passes on hardware. The fix makes G16G use its wide barrier word, which writes cached data back to memory, wherever
It goes up as its own PR after #488, together with the |
Geekbench's Vulkan compute workloads (and ML graphs and image filters generally) record one dispatch per command buffer and submit hundreds at once. Each command buffer became one firmware command, and each command costs a fixed firmware and host turnaround: ~0.3 ms on the M4 (G16G) before the matching kernel change (aurora-silicon/linux#2419), ~11 µs of GPU time plus host time on the M5. Metal records one command buffer with many encoders: ~1 kick per iteration.
This PR packs each run of consecutive command buffers that hold one plain compute stream into one submission-owned stream, submitted as one command. It is the M5 driver-overhead lane's design, ported to aurora-wip.
Where it is on
Packing is chosen by how a member's end publishes its writes to the next member (
hk_pack_boundary()), not by which GPUs were measured:DRM_ASAHI_FEATURE_COMPUTE_VISIBLE_COMPLETION. Every stream then ends with the strong memory-scoped flush the kernel takes as the command's completion, and a boundary keeps it. The kernel advertises the feature only with the M5 command format and its completion inputs, so every GPU that reports it has the same completion semantics.0x60001560on G16G), the record an in-buffer compute/transfer barrier already gets.What a packet keeps
HK_PACK_CDM_SUBMIT=0/1(the oldASAHI_M5_PACK_CDM_SUBMITstill works),HK_PACK_ATOMICS=0/1, andHK_PACK_CDM_TRACE=1for a per-submit stderr line.Tests
hk_pack_test(suite asahi, 135 checks) runs the realhk_syncrecorder and resolver withhk_pack.c:aurora-packtest(hardware) compares 21 cases word for word with a CPU model. It reports packed command buffers per case and fails a must-pack case that packs nothing withHK_PACK_CDM_SUBMIT=1, or any packing with=0.Hardware verification
G17S (M5 Pro): hardware verification pending (M5 lane s8c). It will be the first GPU reporting the feature to run this head; results are posted here when they land.
G16G (M4, J773g Mac mini), with the kernel PR, at this PR's first head:
chain24225.4 → 0.84 ms,atom-chain20.6 → 0.98 ms,indep-cbs13.6 → 0.61 ms);The on/off row on the reviewed head (aurora-packtest must-pack and pack-off checks, Geekbench
HK_PACK_CDM_SUBMIT=0/1) runs in the next mini slot and will be posted here.What M5 packs with this PR alone. At the visible-completion boundary a member must end with the memory-scoped strong flush, as
hk_EndCommandBuffer()makes a trailing dispatch's weak tail. An application barrier at the end of a command buffer leaves a strong flush without memory scope (no aliasing feature enabled), and that does not qualify.multi-tailanddisjoint.chain242,chain300,loops,chain-allandmulti.G17C and G17G: not packing yet. They pack once their kernel reports
DRM_ASAHI_FEATURE_COMPUTE_VISIBLE_COMPLETION.HK_PACK_CDM_SUBMIT=1FAIL.HK_PACK_CDM_SUBMIT=1 aurora-packtest 3should show every case PASS withpacked_cbs > 0on the must-pack cases, andHK_PACK_CDM_SUBMIT=0 aurora-packtest 3should showpacked_cbs=0.meson test --suite asahi: 139/139 (host aarch64, clang, release).🤖 Generated with Claude Code