Translator: a kernel that reads a stage-input region takes its partial-threadgroups variant
plan_partial_groups refused a kernel's partial-threadgroups variant wherever it had a stage-input descriptor, so rt refused every dispatchThreads grid that is not whole threadgroups of a kernel with a [[stage_in]] attribute (Gap::PartialThreadgroups at the translator's site). The probe over the 11,580 indexed kernels (m3-max-70807) counted 62 such kernels on amd-780m-radv, nvidia-rtx50-linux and intel-irisxe-anv alike; a consumer's first-time setup meets one of them. The refusal goes and nothing is added to any module: the fetch already stays inside the grid. An invocation past its threadgroup's threads returns in dispatch::emit_entry, which the entry runs before stage_io::emit_entry's fetch. Where the body holds a workgroup barrier the variant walks it predicated instead, so such an invocation does fetch, but its position in the threadgroup is lin unflattened over the threads left (local_pos), so along x and y, the only axes a step reads, it is inside the grid, and its element is one a Metal thread there fetches too; it runs none of the body. A kernel that does not observe its partition now takes the grid-tiles variant, whose invocations past the grid return before the fetch as well. SEMANTICS 2290: the variant of a stage-in kernel was a refusal and is now a module, under the same key. No plain module changes. The two tests of 9089b4eea2 turn green: the translator's interpreter run over a source buffer ending at the last thread's element and a region that clamps nothing traps on any fetch past the grid, and rt runs both kernels' partial threadgroup of 25 in 1,024.
This commit is contained in:
1 parent
f4ae2c826f
commit
c6feccf773
5 files changed
+20
-12
No files matched your search
@@ -1977,8 +1977,8 @@ pub enum PartialThreadgroupsSite {
|
||||
max: u32,
|
||||
},
|
||||
/// The translator refused the variant for another of the kernel's structures: SIMD groups it
|
||||
/// emulates, a stage-in region, compute derivatives, an imageblock slice write every
|
||||
/// invocation shares, or another refusal of the variant's lowering or compile.
|
||||
/// emulates, compute derivatives, an imageblock slice write every invocation shares, or
|
||||
/// another refusal of the variant's lowering or compile.
|
||||
Translator,
|
||||
/// The threadgroup is not whole SIMD groups of the variant, whose tier runs only whole ones.
|
||||
SimdGroups {
|
||||
|
||||
@@ -427,17 +427,18 @@ pub fn check_payload(cx: &SelectCx<'_>, size: u64) -> Result<(), Error> {
|
||||
/// past them return before the body where the body holds no workgroup barrier; where it holds
|
||||
/// one, the body is walked predicated from its threadgroup's threads
|
||||
/// (`simd::divergent::barriers`, `Predication::partial_groups`), so they walk to each barrier
|
||||
/// without running anything else of it. A tile function, a kernel that reads a stage-input region,
|
||||
/// one with compute derivatives (whose quads a returned lane would leave partial) and one with a
|
||||
/// cooperative imageblock slice write (`texture::cooperative`, whose cells every invocation of the
|
||||
/// workgroup shares) are refused the kernel's input, `Unsupported{PartialThreadgroups, NotImplemented}`. Called before
|
||||
/// the push fields are placed.
|
||||
/// without running anything else of it. A kernel's `[[stage_in]]` attributes are fetched at entry
|
||||
/// after the returns, and a walked invocation's fetch reads a grid thread's element
|
||||
/// (`lower::stage_io::stage_in`). A tile function, one with compute derivatives (whose quads a
|
||||
/// returned lane would leave partial) and one with a cooperative imageblock slice write
|
||||
/// (`texture::cooperative`, whose cells every invocation of the workgroup shares) are refused the
|
||||
/// kernel's input, `Unsupported{PartialThreadgroups, NotImplemented}`. Called before the push
|
||||
/// fields are placed.
|
||||
pub fn plan_partial_groups(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
match cx.stage {
|
||||
Stage::Object => {}
|
||||
Stage::Kernel if cx.inputs.partial_threadgroups => {
|
||||
if crate::lower::access::tile::is_tile(cx)
|
||||
|| cx.inputs.stage_input.is_some()
|
||||
|| cx.families.barrier.compute_derivatives
|
||||
|| !cx.families.texture.cooperative.is_empty()
|
||||
{
|
||||
|
||||
@@ -22,6 +22,13 @@
|
||||
//! 0th thread), and so is a vertex or tessellation step in a compute layout
|
||||
//! (`StageInFetch::of`): Metal's compute pipeline creation stops at an assertion for one.
|
||||
//!
|
||||
//! **A partial threadgroup** (`LoweringInputs::partial_threadgroups`, `lower::dispatch`'s partial
|
||||
//! threadgroups) adds nothing to the fetch. An invocation past its threadgroup's threads returns in
|
||||
//! `dispatch::emit_entry`, which runs before the fetch, or, where the body is walked predicated for
|
||||
//! its barriers, fetches and runs none of the body: its position in the threadgroup is `lin`
|
||||
//! unflattened over the threads left, so along x and y, the axes a step reads, it is a thread's of
|
||||
//! the grid, and its element is one Metal's thread there fetches too.
|
||||
//!
|
||||
//! **The stride** of a layout is its descriptor's, compiled in, whatever stride the encoder binds
|
||||
//! the buffer with: Metal reads a bound stride only for a layout of
|
||||
//! `MTLBufferLayoutStrideDynamic` (an M4 read a fixed 16 under a bound 8).
|
||||
|
||||
@@ -393,8 +393,8 @@ pub struct LoweringInputs {
|
||||
/// its simdgroup operations run on the live lanes, Metal's partial simdgroup. Every lane read
|
||||
/// ballots its live lanes (`simd::partly_live`). It declares `MultiRegion` and reads the
|
||||
/// region whatever builtins it reads, and states `RuntimeFact::PartialThreadgroups`. A tile
|
||||
/// function, a stage-input region, compute derivatives, an imageblock slice write every
|
||||
/// invocation shares, emulated simdgroups (the input
|
||||
/// function, compute derivatives, an imageblock slice write every invocation shares, emulated
|
||||
/// simdgroups (the input
|
||||
/// `emulated_simdgroups` or a kernel whose lockstep order needs them), `flat_grid`,
|
||||
/// `folded_groups` and `replay_bindings` are `Unsupported{PartialThreadgroups,
|
||||
/// NotImplemented}`, and a body whose uniform barriers' vote word its workgroup memory cannot
|
||||
|
||||
+2
-2
@@ -1254,8 +1254,8 @@ push constants, and each distinct specialization is one `VkPipeline`. A kernel's
|
||||
partial-threadgroups variant (`LoweringInputs::partial_threadgroups`) runs a grid that is not
|
||||
whole threadgroups as the threadgroups its threads fill at the dispatch's threadgroup size, the
|
||||
last along an axis Metal's partial threadgroup, so every remainder takes the same `VkPipeline`; a
|
||||
kernel the variant cannot run exactly (a tile function, a stage-input region, compute
|
||||
derivatives, emulated simdgroups) is refused it, `Unsupported{PartialThreadgroups,
|
||||
kernel the variant cannot run exactly (a tile function, compute derivatives, emulated
|
||||
simdgroups) is refused it, `Unsupported{PartialThreadgroups,
|
||||
NotImplemented}`. On the identity domains the variant of a kernel that does not observe its
|
||||
threadgroup partition (`KernelFacts::partition_oblivious`) runs its grid in tiles instead
|
||||
(`RuntimeFact::GridTiles`): a direct dispatch's threads run in `pipeline::grid_tile`'s tiles, one
|
||||
|
||||
Reference in new issue
Block a user