identity: every dispatch reads Metal's grid from its pushed region
Under the identity domains a kernel that reads a grid builtin no longer declares the MultiRegion
specialization constant. It tells a region from an indirect dispatch by the region's grid
(RegionSelect::Grid in lower::dispatch):
- Every dispatch the host knows (dispatchThreads, dispatchThreadgroups, and each piece of a split
of either) pushes DispatchRegion with Metal's threads_per_grid in region[1].xyz and its piece's
first threadgroup in region[0].xyz. So the pieces of a split read Metal's whole grid, and every
compute pipeline takes the base offset.
- An indirect dispatch pushes a zero grid. Its kernel then takes the single-region form, its grid
NumWorkgroups times L, which needs its workgroup size to be Metal's threadgroup size.
- One pipeline runs every dispatch of a threadgroup size, with no constant to specialize.
A flat variant (LoweringInputs::flat_grid), bound as any other kernel, reads its grid from the same
pushed field rather than from a record at ReplayRegionAddress (plan_replay, EmitCx::push_field).
The consumer runs non-observing kernels in a fixed shape with it, and invocations past the grid
return before the body. A replay or folded variant keeps its record and stays refused under the
identity domains.
The runtime lane takes this ABI as agreed: the zero grid marks an indirect dispatch, which runs
the per-size pipeline.
SEMANTICS_VERSION 2148: modules under the identity domains change.
Tests (src/tests/engine_identity.rs), on lavapipe and moltenvk-m3:
- every_dispatch_reads_metals_grid_from_its_pushed_region. A generated kernel reads
thread_position_in_grid, threads_per_grid and threadgroups_per_grid. It declares no MultiRegion
constant and passes L3. On the CPU interpreter, with L = (4, 2, 1) over an 8x6 grid, it stores
the same answer at every position in three forms: one whole dispatch, a split into two pieces at
region base (0, 1, 0), and an indirect dispatch with a zero grid.
- a_flat_variant_reads_its_grid_from_its_pushed_region. Its flat variant reads a 7x5 grid from
the pushed region in three workgroups of 16. The 13 invocations past the grid store nothing.
- The buffer-kernel test runs once, with its region pushed.
Verified:
- m3-max-41225 (msi, check commit 7fe9bc780c: this tree's metal2vulkan files, which equal those
here on 1bb5fe5bf8): clippy -p metal2vulkan --all-targets --all-features, rustdoc -D warnings,
and nextest -p metal2vulkan --all-features, exit 0 (every test passed; the count's log was
lost to the scratch path two of the lane's jobs shared, since fixed).
- m3-max-41226 (msi, 7fe9bc780c): clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
This commit is contained in:
1 parent
227b118bd9
commit
50c5bd0fe1
9 files changed
+297
-53
No files matched your search
+5
-2
@@ -114,8 +114,11 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`:
|
||||
pushed as `PushField::SlotGuestBase`, with no root table, no descriptor and no containment, as
|
||||
Metal contains no device-address access. Fields past the 128-byte push window go to a
|
||||
parameter block in memory, read at the device address `PushField::ArgumentTableAddress`, which
|
||||
the window always holds. So far they lower a kernel that reaches memory only through its buffer
|
||||
slots; any other function is refused as `Unsupported{IdentityDomains}`.
|
||||
the window always holds. A kernel that reads a grid builtin reads `PushField::DispatchRegion` on
|
||||
every dispatch, with no `MultiRegion` constant: a dispatch the host knows states Metal's grid
|
||||
and its piece's first threadgroup there, and an indirect dispatch a zero grid, whose kernel
|
||||
takes `NumWorkgroups` times its workgroup size. So far they lower a kernel that reaches memory
|
||||
only through its buffer slots; any other function is refused as `Unsupported{IdentityDomains}`.
|
||||
- **The model's linear sample of planes read in place** (`YCbCrInPlacePolicy::Model`, the
|
||||
default; changes emitted code). On an integrated GPU or a CPU device a function that only
|
||||
samples, gathers or sizes a `YCBCR8_420_2P` or `YCBCR10_420_2P` texture reads its planes' codes
|
||||
|
||||
Reference in new issue
Block a user