Translator: an object function reads its draw's group counts at an address, the rest of its region pushed

What: a new push field, PushField::GroupCountsAddress: the device address of a draw's three
threadgroup counts in Metal's MTLDispatchThreadgroupsIndirectArguments layout (three u32s at a
multiple of 4). A folded object function, its one grid form, places it with its own
DispatchRegion, in place of the 32-byte record at ReplayRegionAddress:
- access::object_region builds the region the folded walk reads: the pushed DispatchRegion, its
  first xyz replaced by the counts read at the address (three 4-aligned loads);
  EmitCx::push_field routes a folded object function's DispatchRegion there
  (held_push_field loads a field as its block holds it);
- its threadgroups per grid are the counts, and its threads per grid the counts times L,
  wrapping as Metal's builtins do, or the region's grid where the draw states one (a draw of
  threads, whose partial flag the region carries as before);
- plan_replay places the two fields for a folded object function; a folded kernel, a flat
  variant and a replay variant keep their record;
- under the identity domains GroupCountsAddress is an admitted field, and ReplayRegionAddress
  is refused for every stage (its object exception is gone).

Why: the planner's ruling on the mesh build, point 5: the counts need nothing beside them, so a
draw can point the field at counts as an indirect buffer holds them, and the threads per grid
come from the pushed L.

SEMANTICS_VERSION 2368 (a placeholder; the number is set at landing): every object function's
module moves. The engine golden table's object cells on the profiles with the mesh stages move
with it; they wait for the bless at the next named pin.

Tests: the parent's red test passes. The push field ordering test places GroupCountsAddress
after DispatchRegion. The field's encoding (cache codec) and its shape (u64) are added;
tests/api_signatures.tsv gains the variant; docs/API.md's mesh pipelines section, the dispatch
module docs, LoweringInputs::folded_groups and RuntimeFact::FoldedGroups say what the object
function reads. runtime-sources.sha256 is re-pinned.

Verified: see the job named below.
This commit is contained in:
Anees Iqbal committed 2026-12-03 17:05:42 -08:00
1 parent e537cfb7f5
commit 8a80dd27df
13 files changed
+141 -24

No files matched your search

+7 -4
View File
@@ -1204,10 +1204,13 @@ measured on the M3 Max) draws nothing: an object function's wrapper launches not
grid.
An object grid runs at any count Metal runs, past the task stage's limits too: an object function
is always compiled folded, its one grid form, its object stage reading the
threadgroups Metal runs and its grid from a 32-byte region record at its
`PushField::ReplayRegionAddress`, so a draw runs its grid in pieces within the task limits. Metal's
threads per grid wrap to 32 bits along each axis, as its builtins report them. The lowering takes
is always compiled folded, its one grid form, so a draw runs its grid in pieces within the task
limits. Its object stage reads the draw's three group counts at its `PushField::GroupCountsAddress`
(Metal's `MTLDispatchThreadgroupsIndirectArguments` layout, three `u32`s at a multiple of 4) and
its threadgroup size, and its threads per grid and partial flag where the draw states them, from
its own `PushField::DispatchRegion`: its threadgroups per grid are the counts, and its threads per
grid the counts times its threadgroup size, wrapping to 32 bits along each axis as Metal's
builtins report them, or the region's grid for a draw of threads. The lowering takes
a grid of up to 2^29 threadgroups on every device, the most Metal's GPU ran within its watchdog's
5 seconds; Metal's GPU discards a larger one and fails its command buffer with Metal's error.