Translator and runtime: a refusal of the partial-threadgroups variant names its cause

The translator refuses a kernel's partial-threadgroups variant for five structures, and
the refusal named none, so a walk could not tell them apart (a guest library's kernels
5ba5f694ad0576ff #81 and #83 refuse it with no cause) and the runtime reported each as
Gap::PartialThreadgroups at site Translator.

- error: PartialThreadgroupsCause (ComputeDerivatives, OtherForm, SharedSliceWrite,
  TileFunction, VoteWord), Cause::PartialThreadgroups and Unsupported::partial_threadgroups.
  Each site names its cause: compile.rs's analyze_one (the variant beside another form),
  mesh::plan_partial_groups (a tile function, compute derivatives, an imageblock slice write
  every invocation shares) and simd::divergent's barriers (the vote word, still needing the
  maxComputeSharedMemorySize limit). Feature::PartialThreadgroups' doc lists today's causes
  (the stage-input region and the emulated SIMD-group tier are no longer refused).
- runtime: VariantRefusal reads the cause (the vote word's, a structure's, or none) instead of
  the needs; PartialThreadgroupsSite gains Structure { cause }, the translator's type
  re-exported; Translator stays for a refusal that names no structure. The cache directory
  keeps each refusal under a marker of its own (cache::REFUSALS: the old two plus one a
  structure), so a refusal read back names the same cause.
- Tests: the red test, and a runtime unit test that every cause maps to its refusal and its
  marker and back. README: the gap's sites. REFUSALS.md and basis.rs regenerated;
  api_surface row; api_signatures.tsv blessed.
- SEMANTICS_VERSION 2362 and RUNTIME_VERSION 2567: the refusal and the dispatch's gap say
  more (renumbered at landing: SEMANTICS 2360 and 2361 went to the seq_cst fence and the
  argument buffer border texels, RUNTIME 2566 to the seq_cst fence).

Verified (jobs m3-max-84834, -84836, -84838, -84839, -85025):
- red, the red commit's crates over this commit's target: 3 tests run, 0 passed, 3 failed,
  each refusal PartialThreadgroups with no cause; green: 4 tests run, 4 passed (the three and
  a_variant_refusal_keeps_the_translator_s_cause).
- product suites: 3495 tests run, 3494 passed, 1 failed, 24 skipped; the failure is
  golden_hashes_match_the_table, whose table is re-blessed on development. Validation: 1348
  passed, 2 skipped. Conformance: 1053 passed, 0 skipped. Doctests pass.
- clippy --workspace --all-targets --all-features -D warnings: plain, --cfg m2v_gpu and
  --cfg m2v_cpu_icd, each EXIT=0. Rustdoc with -D warnings and scripts/api-docs: EXIT=0.
Not verified here: which cause the walk's kernels #81 and #83 name (a probe on the walk's
library, reported apart).
This commit is contained in:
Anees Iqbal committed 2026-12-03 11:37:12 -08:00
1 parent 706eb4b12f
commit aa15ad6b5b
16 files changed
+221 -70

No files matched your search

+6 -2
View File
@@ -4726,8 +4726,12 @@ cache is answered compile-required on both.
refused (`Gap::PartialThreadgroups`) at a threadgroup that is not whole subgroups of a kernel
that runs only whole subgroups where the translator refuses its partial-threadgroups variant on
emulated SIMD groups (site `SimdGroups`), and for a kernel that observes its threadgroup
partition and whose partial-threadgroups variant the translator refuses. It refuses the
variant of a kernel whose barriers in a
partition and whose partial-threadgroups variant the translator refuses, the site naming why:
the vote word below (`VoteWord`), a structure of the kernel's the variant does not take
(`Structure`, its `PartialThreadgroupsCause`: compute derivatives, an imageblock slice write
every invocation shares, a tile function), or another refusal of the variant's (`Translator`).
The cache directory keeps the site with the refusal. It refuses the variant of a kernel whose
barriers in a
loop need a vote word that does not fit beside its threadgroup memory in
`maxComputeSharedMemorySize`, which `Device::max_threadgroup_memory_length` leaves room for: a
kernel that takes more threadgroup memory than that answer, as one built for a Mac's 32,768
+46 -16
View File
@@ -59,7 +59,8 @@
//! function's AIR, entry, constants and linked functions, its lowering inputs, the device
//! profile's fingerprint and the translator's semantics version. The bytes are the translator's
//! self-checking encoding (`CompiledFunction::to_bytes`), and bytes that do not decode for the key
//! are a miss. A partial-threadgroups variant the translator refused is kept too, as a marker, and
//! are a miss. A partial-threadgroups variant the translator refused is kept too, as a marker of
//! why (the vote word, the structure the refusal names, or another refusal), and
//! so is the translator's answer that a kernel observes its threadgroup partition, under its
//! variant's key, until that variant's lowering replaces it.
//!
@@ -137,6 +138,7 @@ use crate::pipeline::VariantRefusal;
use crate::times::host_time;
use ash::vk;
use metal2vulkan::cache::{Hash256, ARTIFACT_FORMAT_VERSION, SEMANTICS_VERSION};
use metal2vulkan::error::PartialThreadgroupsCause;
use std::collections::VecDeque;
use std::fs::{self, File};
use std::io::{self, ErrorKind, Read, Write};
@@ -181,20 +183,46 @@ pub(crate) const BLOBS_KEPT: usize = 4;
/// waits, so the heaviest kernels, the costliest to lower again, are kept too.
pub(crate) const PENDING_BYTES: u64 = 8 << 20;
/// What a translation file holds where the translator refused the lowering, but for the vote word
/// ([`REFUSED_VOTE`]): bytes no lowering encodes to, and that a file cut short is not.
/// ([`REFUSED_VOTE`]) or a structure of the kernel's ([`REFUSALS`]): bytes no lowering encodes
/// to, and that a file cut short is not.
const REFUSED: &[u8] = b"m2v-refused";
/// Each refusal of a partial-threadgroups variant the cache directory keeps
/// ([`VariantRefusal`]), with the marker its translation file holds: the vote word's
/// ([`REFUSED_VOTE`]), one for each structure of the kernel's the translator names, and any
/// other refusal's ([`REFUSED`]). The markers are bytes no lowering encodes to, no two alike nor
/// [`OBSERVES`], and none a file cut short.
pub(crate) const REFUSALS: [(VariantRefusal, &[u8]); 6] = [
(VariantRefusal::VoteWord, REFUSED_VOTE),
(
VariantRefusal::Structure(PartialThreadgroupsCause::ComputeDerivatives),
b"m2v-refused-derivatives",
),
(
VariantRefusal::Structure(PartialThreadgroupsCause::OtherForm),
b"m2v-refused-form",
),
(
VariantRefusal::Structure(PartialThreadgroupsCause::SharedSliceWrite),
b"m2v-refused-slice",
),
(
VariantRefusal::Structure(PartialThreadgroupsCause::TileFunction),
b"m2v-refused-tile",
),
(VariantRefusal::Translator, REFUSED),
];
/// What a partial-threadgroups variant's translation file holds where the translator refused it
/// for its predicated walk's vote word ([`VariantRefusal::VoteWord`]): bytes no lowering encodes
/// to, nor [`REFUSED`] or [`OBSERVES`], and that a file cut short is not.
pub(crate) const REFUSED_VOTE: &[u8] = b"m2v-refused-vote";
/// What a partial-threadgroups variant's translation file holds where the translator answered
/// that the kernel observes its threadgroup partition, until the variant is lowered over it:
/// bytes no lowering encodes to, nor [`REFUSED`] or [`REFUSED_VOTE`], and that a file cut short is
/// bytes no lowering encodes to, nor another marker, and that a file cut short is
/// not. The file is named by the variant's `FunctionCompileKey`, which covers everything that changes the answer:
/// the kernel's AIR, entry, constants and linked functions, its lowering inputs, the device
/// profile's fingerprint and the translator's semantics version, which a change to the answer
/// bumps. It is 12 bytes, written and counted as a lowering is, within the store's cap.
const OBSERVES: &[u8] = b"m2v-observes";
pub(crate) const OBSERVES: &[u8] = b"m2v-observes";
/// The translations' directory, under a generation.
const TRANSLATIONS: &str = "translations";
/// The render contents' records' directory, under a generation.
@@ -1143,11 +1171,13 @@ fn keep(core: &Core, file: String, bytes: Vec<u8>) {
/// Hands the translator's refusal of the lowering of key digest `key`, and `why`, to the reaper,
/// as [`keep_translation`] does a lowering.
pub(crate) fn keep_refusal(core: &Core, key: &[u8], why: VariantRefusal) {
let marker = match why {
VariantRefusal::VoteWord => REFUSED_VOTE,
VariantRefusal::Translator => REFUSED,
};
keep_translation(core, key, marker.to_vec());
keep_translation(core, key, refusal_marker(why).to_vec());
}
/// The marker [`REFUSALS`] keeps for `why`; [`REFUSED`] for a structure it holds none of.
pub(crate) fn refusal_marker(why: VariantRefusal) -> &'static [u8] {
let kept = REFUSALS.iter().find(|&&(refusal, _)| refusal == why);
kept.map_or(REFUSED, |&(_, marker)| marker)
}
/// Hands the translator's answer that a kernel observes its threadgroup partition to the reaper,
@@ -1502,8 +1532,10 @@ impl Caches {
decode: impl FnOnce(&[u8]) -> Option<T>,
) -> Option<T> {
let file = Caches::translation_file(key);
let refusal = |bytes: &[u8]| REFUSALS.iter().any(|&(_, marker)| marker == bytes);
let kept = self.store.as_ref()?.get(&file, |bytes| match bytes {
REFUSED | REFUSED_VOTE | OBSERVES => Some(None),
OBSERVES => Some(None),
marker if refusal(marker) => Some(None),
lowering => decode(lowering).map(Some),
});
kept.flatten()
@@ -1537,12 +1569,10 @@ impl Caches {
pub(crate) fn refused(&self, key: &[u8]) -> Option<VariantRefusal> {
let store = self.store.as_ref()?;
let file = Caches::translation_file(key);
if store.holds(&file, REFUSED_VOTE) {
return Some(VariantRefusal::VoteWord);
}
store
.holds(&file, REFUSED)
.then_some(VariantRefusal::Translator)
REFUSALS
.iter()
.find(|&&(_, marker)| store.holds(&file, marker))
.map(|&(why, _)| why)
}
/// Whether the translator answered on a device before that the kernel whose
@@ -1656,6 +1656,7 @@ pub(crate) fn decide<'a>(
static_length: compiled.static_length(),
max,
},
VariantRefusal::Structure(cause) => PartialThreadgroupsSite::Structure { cause },
VariantRefusal::Translator => PartialThreadgroupsSite::Translator,
})
};
+13 -3
View File
@@ -100,6 +100,11 @@ pub enum Error {
/// `docs/REFUSALS.md` lists.
pub use metal2vulkan::error::RefusalBasis;
/// The structure of a kernel's that the translator's partial-threadgroups variant does not take
/// ([`PartialThreadgroupsSite::Structure`]): the translator's type. Metal has no counterpart:
/// Metal runs every partial threadgroup.
pub use metal2vulkan::error::PartialThreadgroupsCause;
/// A call Metal refuses, with what it was asked.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -2318,9 +2323,14 @@ pub enum PartialThreadgroupsSite {
/// held against.
max: u32,
},
/// The translator refused the variant for another of the kernel's structures: compute
/// derivatives, an imageblock slice write every invocation shares, or another refusal of the
/// variant's lowering or compile.
/// The translator refused the variant for a structure of the kernel's that it names: compute
/// derivatives, an imageblock slice write every invocation shares, or a tile function.
Structure {
/// The structure.
cause: PartialThreadgroupsCause,
},
/// The translator refused the variant with a refusal that names no structure of the
/// kernel's: 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,
/// and the translator refused the variant on emulated SIMD groups that runs such a
+3 -3
View File
@@ -89,9 +89,9 @@ pub use device::{Device, DeviceOptions, RawDevice};
pub use encoder::{ComputeCommandEncoder, Dispatch, DispatchType, Resource, ResourceUsage};
pub use error::{
DrawInputCause, DrawKind, Error, Gap, IndirectCommandsKind, KernelInputKind, Limit,
PartialThreadgroupsSite, Refusal, RefusalBasis, RenderPassKind, RenderPipelineKind,
SamplePositionsKind, StageGap, StageInKind, StorageElementCase, TextureBacking,
TextureBytesCause, TextureViewKind,
PartialThreadgroupsCause, PartialThreadgroupsSite, Refusal, RefusalBasis, RenderPassKind,
RenderPipelineKind, SamplePositionsKind, StageGap, StageInKind, StorageElementCase,
TextureBacking, TextureBytesCause, TextureViewKind,
};
pub use event::{Event, SharedEvent};
pub use export::{Export, ExportHandle};
+18 -20
View File
@@ -75,8 +75,10 @@ use crate::stage::{Create, Heavy};
use crate::times::host_time;
use ash::vk;
use metal2vulkan::cache::Hash256;
use metal2vulkan::device::{VkLimit, KERNEL_BUFFER_BINDINGS};
use metal2vulkan::error::{Capability, Error as TranslationError, Feature, Needs, Unsupported};
use metal2vulkan::device::KERNEL_BUFFER_BINDINGS;
use metal2vulkan::error::{
Cause, Error as TranslationError, Feature, PartialThreadgroupsCause, Unsupported,
};
use metal2vulkan::library::{CompiledFunction, FunctionCompileKey};
use metal2vulkan::metal::{BindingAccess, BindingType, TextureType, TextureUsage};
use metal2vulkan::pipeline::{
@@ -442,7 +444,7 @@ pub(crate) enum Lowered {
/// The module, and the translator's notes of it.
Made(Box<Kernel>, Vec<PrecisionNote>),
/// The translator refused the variant (`Unsupported`), now or on a device on the cache
/// directory before (which keeps that it refused, and whether for the vote word): the need's
/// directory before (which keeps that it refused, and why: `VariantRefusal`): the need's
/// own refusal, the variant's gap.
Refused(VariantRefusal),
/// The translator's lowering or compile of the variant failed otherwise, a translator bug or
@@ -459,30 +461,26 @@ pub(crate) enum Lowered {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum VariantRefusal {
/// Its predicated walk's vote word does not fit beside the kernel's threadgroup memory:
/// `Unsupported{PartialThreadgroups}` needing the `Limit` of `maxComputeSharedMemorySize`.
/// `Unsupported{PartialThreadgroups}` of cause `VoteWord`, needing the `Limit` of
/// `maxComputeSharedMemorySize`.
VoteWord,
/// A structure of the kernel's the variant does not take: `Unsupported{PartialThreadgroups}`
/// of another cause.
Structure(PartialThreadgroupsCause),
/// Any other refusal of its lowering or compile.
Translator,
}
impl VariantRefusal {
/// Why the translator's refusal `refused` refused the variant.
/// Why the translator's refusal `refused` refused the variant: the partial-threadgroups
/// cause it names, if any.
pub(crate) fn of(refused: &Unsupported) -> VariantRefusal {
let shared_memory = |capability: &Capability| {
matches!(
capability,
Capability::Limit {
limit: VkLimit::MaxComputeSharedMemorySize,
..
}
)
};
let vote = refused.feature == Feature::PartialThreadgroups
&& matches!(&refused.needs, Needs::AnyOf(alternatives)
if alternatives.iter().flatten().any(shared_memory));
match vote {
true => VariantRefusal::VoteWord,
false => VariantRefusal::Translator,
match refused.cause {
Some(Cause::PartialThreadgroups(PartialThreadgroupsCause::VoteWord)) => {
VariantRefusal::VoteWord
}
Some(Cause::PartialThreadgroups(cause)) => VariantRefusal::Structure(cause),
_ => VariantRefusal::Translator,
}
}
}
@@ -60,3 +60,46 @@ fn a_lowering_error_is_not_reported_as_the_variant_s_gap() {
reported(&Lowered::Refused(VariantRefusal::Translator))
);
}
/// The translator's refusal of the partial-threadgroups variant keeps its cause
/// (`VariantRefusal::of`): the vote word, each structure of the kernel's the translator names
/// (`PartialThreadgroupsCause`), and any other refusal, which names none. The cache directory
/// keeps each under a marker of its own (`cache::REFUSALS`), no two alike and none the observer's
/// answer, so a refusal read back from it names the same cause.
#[test]
fn a_variant_refusal_keeps_the_translator_s_cause() {
use crate::cache::{refusal_marker, OBSERVES, REFUSALS};
use metal2vulkan::error::{Cause, Feature, PartialThreadgroupsCause, Unsupported};
use std::collections::BTreeSet;
let of = |cause: Option<Cause>| {
let mut refused = Unsupported::not_implemented(Feature::PartialThreadgroups);
refused.cause = cause;
VariantRefusal::of(&refused)
};
let vote = Cause::PartialThreadgroups(PartialThreadgroupsCause::VoteWord);
assert_eq!(of(Some(vote)), VariantRefusal::VoteWord);
assert_eq!(of(None), VariantRefusal::Translator);
let structures = [
PartialThreadgroupsCause::ComputeDerivatives,
PartialThreadgroupsCause::OtherForm,
PartialThreadgroupsCause::SharedSliceWrite,
PartialThreadgroupsCause::TileFunction,
];
let mut kept = vec![VariantRefusal::VoteWord, VariantRefusal::Translator];
for cause in structures {
let why = of(Some(Cause::PartialThreadgroups(cause)));
assert_eq!(why, VariantRefusal::Structure(cause));
kept.push(why);
}
for why in kept {
let marker = refusal_marker(why);
let back: Vec<VariantRefusal> = (REFUSALS.iter())
.filter(|&&(_, m)| m == marker)
.map(|&(w, _)| w)
.collect();
assert_eq!(back, [why], "{why:?}");
}
let markers: BTreeSet<&[u8]> = REFUSALS.iter().map(|&(_, marker)| marker).collect();
assert_eq!(markers.len(), REFUSALS.len());
assert!(!markers.contains(OBSERVES));
}
+2 -2
View File
@@ -60,7 +60,7 @@ mod tests;
/// unchanged version, and its bless records the version. Independent of the crate's version and of
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
/// history.
pub const SEMANTICS_VERSION: u32 = 2361;
pub const SEMANTICS_VERSION: u32 = 2362;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
@@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 608;
/// changes no behaviour, and then updates that hash alone with the commit saying why, or changes
/// behaviour and also bumps this version. The commit that bumps it says what changed; this comment
/// keeps no history.
pub const RUNTIME_VERSION: u32 = 2566;
pub const RUNTIME_VERSION: u32 = 2567;
/// Writes a digest as lowercase hex.
pub(crate) fn write_hex(f: &mut fmt::Formatter<'_>, name: &str, hash: &Hash256) -> fmt::Result {
+43 -6
View File
@@ -453,6 +453,15 @@ impl Unsupported {
..Unsupported::not_implemented(Feature::IdentityDomains)
}
}
/// The partial-threadgroups variant's refusal of the structure `cause` names
/// (`Feature::PartialThreadgroups`, not implemented).
pub(crate) fn partial_threadgroups(cause: PartialThreadgroupsCause) -> Unsupported {
Unsupported {
cause: Some(Cause::PartialThreadgroups(cause)),
..Unsupported::not_implemented(Feature::PartialThreadgroups)
}
}
}
impl fmt::Display for Unsupported {
@@ -596,13 +605,11 @@ pub enum Feature {
axis: Option<Axis>,
},
/// A kernel's partial-threadgroups variant (`LoweringInputs::partial_threadgroups`) that the
/// lowering cannot make: a tile function, a kernel that reads a stage-input region, one with
/// compute derivatives or a cooperative imageblock slice write; a kernel whose simdgroups run
/// on the emulated tier (its profile's subgroups, its lockstep order or its large body's
/// pinned width give it that tier), whose exchanges are not walked past the grid; a body whose
/// lowering cannot make, its cause named (`PartialThreadgroupsCause`): a tile function, one
/// with compute derivatives or an imageblock slice write every invocation shares, a body whose
/// uniform barriers need a vote word that the stage's workgroup memory cannot hold beside its
/// static arena; or the input beside `flat_grid`, `folded_groups`, `replay_bindings` or
/// `emulated_simdgroups`. The kernel's dispatches keep the plain module's exact split.
/// static arena, or the input beside `flat_grid`, `folded_groups` or `replay_bindings`. The
/// kernel's dispatches keep the plain module's exact split.
PartialThreadgroups,
/// An irreducible region containing a convergent instruction.
IrreducibleConvergent,
@@ -1057,6 +1064,8 @@ pub enum Cause {
/// The identity domains' refusal of a form they do not lower (`Feature::IdentityDomains`,
/// [`Needs::NotImplemented`]).
Identity(IdentityCause),
/// A kernel's partial-threadgroups variant's refusal (`Feature::PartialThreadgroups`).
PartialThreadgroups(PartialThreadgroupsCause),
}
impl fmt::Display for Cause {
@@ -1066,6 +1075,7 @@ impl fmt::Display for Cause {
Cause::Tessellation(cause) => write!(f, "{cause:?}"),
Cause::Imageblocks(cause) => write!(f, "{cause:?}"),
Cause::Identity(cause) => write!(f, "{cause:?}"),
Cause::PartialThreadgroups(cause) => write!(f, "{cause:?}"),
}
}
}
@@ -1350,6 +1360,33 @@ pub enum ImageblockCause {
TwoImageblocks,
}
/// The structure a kernel's partial-threadgroups variant (`LoweringInputs::partial_threadgroups`)
/// does not take (`Feature::PartialThreadgroups`): what the kernel holds, or the form the variant
/// was asked beside. Each is [`Needs::NotImplemented`] but `VoteWord`, which names the limit the
/// word passes. Refusals that meet the same structure name the same cause, wherever the
/// translator meets it.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum PartialThreadgroupsCause {
/// Compute derivatives: the quads of a threadgroup whose invocations past the grid return
/// would be left partial.
ComputeDerivatives,
/// The variant asked beside `LoweringInputs::flat_grid`, `folded_groups` or `replay_bindings`:
/// each runs a dispatch other than the direct `dispatchThreads` whose invocations past the
/// grid the variant walks.
OtherForm,
/// An imageblock slice write every invocation of the threadgroup shares, each writing a
/// strided share of the slice's cells after a threadgroup barrier: invocations past the grid
/// would write no share.
SharedSliceWrite,
/// A tile function (`LoweringInputs::tile_attachments`): its threadgroups are its tile's.
TileFunction,
/// Workgroup-uniform barriers that the walk takes to with a vote word, which the stage's
/// workgroup memory cannot hold beside the kernel's static threadgroup memory: the refusal
/// needs `maxComputeSharedMemorySize` at the bytes of both.
VoteWord,
}
/// A pipeline input that the caller did not supply.
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+16 -8
View File
@@ -88,7 +88,9 @@ use crate::air::Entry;
use crate::bind::mesh_arguments::{METAL_MESH_GRID_AXIS, METAL_MESH_GRID_TOTAL};
use crate::device::requirements::{VkExtension, VkFeature, VkLimit};
use crate::device::DeviceProfile;
use crate::error::{Capability, Error, Feature, LowerFamily, Unsupported};
use crate::error::{
Capability, Error, Feature, LowerFamily, PartialThreadgroupsCause, Unsupported,
};
use crate::lower::dispatch::KernelBuiltin;
use crate::lower::emit::EmitCx;
use crate::lower::select::{Plan, SelectCx};
@@ -432,17 +434,23 @@ pub fn check_payload(cx: &SelectCx<'_>, size: u64) -> Result<(), Error> {
/// (`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.
/// kernel's input, `Unsupported{PartialThreadgroups, NotImplemented}` naming the structure
/// (`PartialThreadgroupsCause`). 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.families.barrier.compute_derivatives
|| !cx.families.texture.cooperative.is_empty()
{
return Err(Unsupported::not_implemented(Feature::PartialThreadgroups).into());
let cause = if crate::lower::access::tile::is_tile(cx) {
Some(PartialThreadgroupsCause::TileFunction)
} else if cx.families.barrier.compute_derivatives {
Some(PartialThreadgroupsCause::ComputeDerivatives)
} else if !cx.families.texture.cooperative.is_empty() {
Some(PartialThreadgroupsCause::SharedSliceWrite)
} else {
None
};
if let Some(cause) = cause {
return Err(Unsupported::partial_threadgroups(cause).into());
}
}
_ => return Ok(()),
@@ -61,7 +61,7 @@ use std::collections::BTreeMap;
use crate::air::ir::{BlockId, Idx, InstKind, Value, ValueId};
use crate::budget::Meter;
use crate::device::subgroup::Tier;
use crate::error::{Error, Feature, Location, Needs, Unsupported};
use crate::error::{Cause, Error, Feature, Location, Needs, PartialThreadgroupsCause, Unsupported};
use crate::graph::LoopForest;
use crate::lower::select::SelectCx;
use crate::lower::strategy::{FamilyStrategy, Strategy};
@@ -261,8 +261,8 @@ pub const VOTE_BYTES: u32 = 4;
/// barriers are uniform and whose word does not fit runs no partial threadgroup instead
/// (`MeshPlan::partial_groups` cleared, so the binder refuses such a draw), and a kernel's
/// partial-threadgroups variant (`LoweringInputs::partial_threadgroups`) is refused,
/// `Unsupported{PartialThreadgroups}` needing the `Limit` of `maxComputeSharedMemorySize` its
/// arena and word pass.
/// `Unsupported{PartialThreadgroups}` of cause `VoteWord` needing the `Limit` of
/// `maxComputeSharedMemorySize` its arena and word pass.
pub fn barriers(
cx: &mut SelectCx<'_>,
strategy: &[Option<Strategy>],
@@ -335,9 +335,12 @@ pub fn barriers(
..
})) if !divergent => {
if cx.stage == Stage::Kernel {
return Err(
Unsupported::needs_any_of(Feature::PartialThreadgroups, limit).into(),
);
let cause = PartialThreadgroupsCause::VoteWord;
return Err(Unsupported {
cause: Some(Cause::PartialThreadgroups(cause)),
..Unsupported::needs_any_of(Feature::PartialThreadgroups, limit)
}
.into());
}
cx.families.mesh.partial_groups = false;
return Ok(());
+2 -1
View File
@@ -2894,7 +2894,8 @@ fn analyze_one(r: &Request<'_>, p: &DeviceProfile, m: &mut Meter) -> Result<Anal
if inputs.partial_threadgroups
&& (inputs.flat_grid || inputs.folded_groups || inputs.replay_bindings)
{
return Err(Unsupported::not_implemented(Feature::PartialThreadgroups).into());
let other_form = crate::error::PartialThreadgroupsCause::OtherForm;
return Err(Unsupported::partial_threadgroups(other_form).into());
}
// A flat variant runs its grid in threadgroups of its own: only a kernel that does not observe
// its partition computes the same there; one of the call's threadgroups, also a kernel that
@@ -388,7 +388,8 @@ pub struct LoweringInputs {
/// `flat_grid`, `folded_groups` and `replay_bindings` are `Unsupported{PartialThreadgroups,
/// NotImplemented}`, and a body whose uniform barriers' vote word its workgroup memory cannot
/// hold is `Unsupported{PartialThreadgroups}` needing the `Limit` of
/// `maxComputeSharedMemorySize` the word passes. Any other function compiles as without it,
/// `maxComputeSharedMemorySize` the word passes, each naming its cause
/// (`PartialThreadgroupsCause`). Any other function compiles as without it,
/// but for its reconvergence: its tangled instructions take the profile's mode even where
/// the plain module's are reached together, since its invocations past the grid return before
/// the body and SPIR-V reconverges only over all invocations, those that returned included
@@ -636,6 +636,7 @@ enum metal2vulkan-runtime::MultisampleDepthResolveFilter #[derive(Clone, Copy, D
enum metal2vulkan-runtime::MultisampleStencilResolveFilter #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum MultisampleStencilResolveFilter
enum metal2vulkan-runtime::NumberedSampler #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum NumberedSampler
enum metal2vulkan-runtime::OverCause #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum OverCause
enum metal2vulkan-runtime::PartialThreadgroupsCause #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum PartialThreadgroupsCause
enum metal2vulkan-runtime::PartialThreadgroupsSite #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum PartialThreadgroupsSite
enum metal2vulkan-runtime::PrecisionNote #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum PrecisionNote
enum metal2vulkan-runtime::RangeKind #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum RangeKind
@@ -725,6 +726,7 @@ enum metal2vulkan::error::LowerFamily #[derive(Clone, Copy, Debug, PartialEq, Eq
enum metal2vulkan::error::MeshPipelineProblem #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum MeshPipelineProblem
enum metal2vulkan::error::MetalAnswer #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum MetalAnswer
enum metal2vulkan::error::Needs #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum Needs
enum metal2vulkan::error::PartialThreadgroupsCause #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum PartialThreadgroupsCause
enum metal2vulkan::error::PrivateRenderField #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum PrivateRenderField
enum metal2vulkan::error::RefusalBasis #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum RefusalBasis
enum metal2vulkan::error::Retry #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Retry
@@ -8591,7 +8593,13 @@ variant metal2vulkan-runtime::OverCause::RenderReach RenderReach
variant metal2vulkan-runtime::OverCause::Spilled Spilled
variant metal2vulkan-runtime::OverCause::Surface Surface
variant metal2vulkan-runtime::OverCause::ViewStorage ViewStorage
variant metal2vulkan-runtime::PartialThreadgroupsCause::ComputeDerivatives ComputeDerivatives
variant metal2vulkan-runtime::PartialThreadgroupsCause::OtherForm OtherForm
variant metal2vulkan-runtime::PartialThreadgroupsCause::SharedSliceWrite SharedSliceWrite
variant metal2vulkan-runtime::PartialThreadgroupsCause::TileFunction TileFunction
variant metal2vulkan-runtime::PartialThreadgroupsCause::VoteWord VoteWord
variant metal2vulkan-runtime::PartialThreadgroupsSite::SimdGroups SimdGroups { width: u32 }
variant metal2vulkan-runtime::PartialThreadgroupsSite::Structure Structure { cause: PartialThreadgroupsCause }
variant metal2vulkan-runtime::PartialThreadgroupsSite::Translator Translator
variant metal2vulkan-runtime::PartialThreadgroupsSite::VoteWord VoteWord { static_length: u32, max: u32 }
variant metal2vulkan-runtime::PrecisionNote::AnisotropicFilter AnisotropicFilter
@@ -9504,6 +9512,7 @@ variant metal2vulkan::error::Capability::Property Property(VkProperty)
variant metal2vulkan::error::Cause::Access Access(AccessCause)
variant metal2vulkan::error::Cause::Identity Identity(IdentityCause)
variant metal2vulkan::error::Cause::Imageblocks Imageblocks(ImageblockCause)
variant metal2vulkan::error::Cause::PartialThreadgroups PartialThreadgroups(PartialThreadgroupsCause)
variant metal2vulkan::error::Cause::Tessellation Tessellation(TessellationCause)
variant metal2vulkan::error::ComputePipelineProblem::MaxThreadsDiffer MaxThreadsDiffer { specified: u32, max: u32 }
variant metal2vulkan::error::ComputePipelineProblem::MaxThreadsOverLimit MaxThreadsOverLimit { max: u32, limit: u32 }
@@ -9787,6 +9796,11 @@ variant metal2vulkan::error::MetalAnswer::NilWithError NilWithError
variant metal2vulkan::error::Needs::AnyOf AnyOf(Vec<Vec<Capability>>)
variant metal2vulkan::error::Needs::NotImplemented NotImplemented
variant metal2vulkan::error::Needs::NotRepresentable NotRepresentable
variant metal2vulkan::error::PartialThreadgroupsCause::ComputeDerivatives ComputeDerivatives
variant metal2vulkan::error::PartialThreadgroupsCause::OtherForm OtherForm
variant metal2vulkan::error::PartialThreadgroupsCause::SharedSliceWrite SharedSliceWrite
variant metal2vulkan::error::PartialThreadgroupsCause::TileFunction TileFunction
variant metal2vulkan::error::PartialThreadgroupsCause::VoteWord VoteWord
variant metal2vulkan::error::PrivateRenderField::AlphaTest AlphaTest
variant metal2vulkan::error::PrivateRenderField::ExplicitVisibilityGroup ExplicitVisibilityGroup
variant metal2vulkan::error::PrivateRenderField::FragmentDepthCompareClamp FragmentDepthCompareClamp
Can't render this file because it is too large.
+1
View File
@@ -197,6 +197,7 @@ surface! {
enum AccessCause N;
enum TessellationCause N;
enum ImageblockCause N;
enum PartialThreadgroupsCause N;
enum IdentityCause N;
enum PrivateRenderField N;
enum RuntimeInput N;
+2 -2
View File
@@ -68,7 +68,7 @@ Columns:
| `Linking` | Linkage signatures / stitching / dynamic libraries | every device (not implemented) | `ours` | 3: `crates/metal2vulkan-air/src/canon/link.rs (not_implemented)`, `crates/metal2vulkan-air/src/canon/mod.rs (post_check)` (+1) | `rare`: dynamic libraries and linked functions |
| `SimdWidth` | Simdgroup width 32 is not achievable for this usage, stage, and device | devices without a capability the site computes (`subgroup::width_needs(cx.stage, model.stage(cx.stage))`); devices without a capability the site computes (`width_needs(stage, st)`) | `device` | 2: `crates/metal2vulkan/src/device/subgroup.rs (subgroup_tier)`, `crates/metal2vulkan/src/lower/simd/mod.rs (finish)` | `app`: simdgroup functions on a device whose subgroups cannot run 32 wide for the use |
| `LocalSize` | A local size beyond a device limit on this axis (`None` | - | `-` | 0 | `app`: a threadgroup size past a smaller device's limit |
| `PartialThreadgroups` | A kernel's partial-threadgroups variant (`LoweringInputs::partial_threadgroups`) that the lowering cannot make | devices without a capability the site computes (`limit`); every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/lower/mesh/mod.rs (plan_partial_groups)`, `crates/metal2vulkan/src/lower/simd/divergent.rs (barriers)` (+1) | `app`: a dispatchThreads grid that is not whole threadgroups, of a kernel whose partial-threadgroups variant cannot be made |
| `PartialThreadgroups` | A kernel's partial-threadgroups variant (`LoweringInputs::partial_threadgroups`) that the lowering cannot make, its cause named... | devices without a capability the site computes (`limit`); every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/error/mod.rs (partial_threadgroups)`, `crates/metal2vulkan/src/lower/simd/divergent.rs (barriers)` | `app`: a dispatchThreads grid that is not whole threadgroups, of a kernel whose partial-threadgroups variant cannot be made |
| `IrreducibleConvergent` | An irreducible region containing a convergent instruction | every device (no Vulkan mechanism) | `device` | 1: `crates/metal2vulkan/src/structurize/irreducible.rs (refuse_tangled)` | `rare`: irreducible loops around barriers or simd operations |
| `ComputeDerivativesWithSimd` | Compute derivatives in a flattened simd tier | every device (no Vulkan mechanism) | `device` | 1: `crates/metal2vulkan/src/lower/dispatch.rs (plan_kernel)` | `rare`: derivatives in a kernel |
| `ComputeDerivatives` | Derivatives outside fragment without compute-derivative support | devices without VkFeature::ComputeDerivativeGroupLinear; every device (no Vulkan mechanism); every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/lower/sync/barrier.rs (select_derivative, 3 sites)` | `rare`: derivatives in a kernel |
@@ -403,7 +403,7 @@ Each refusal's sites, with the function that builds it.
- `feature::InlineAsm`: `crates/metal2vulkan-air/src/canon/mod.rs (post_check)`
- `feature::Linking`: `crates/metal2vulkan-air/src/canon/link.rs (not_implemented)`; `crates/metal2vulkan-air/src/canon/mod.rs (post_check)`; `crates/metal2vulkan-air/src/canon/mod.rs (specialize_dynamic)`
- `feature::SimdWidth`: `crates/metal2vulkan/src/device/subgroup.rs (subgroup_tier)`; `crates/metal2vulkan/src/lower/simd/mod.rs (finish)`
- `feature::PartialThreadgroups`: `crates/metal2vulkan/src/lower/mesh/mod.rs (plan_partial_groups)`; `crates/metal2vulkan/src/lower/simd/divergent.rs (barriers)`; `crates/metal2vulkan/src/pipeline/compile.rs (analyze_one)`
- `feature::PartialThreadgroups`: `crates/metal2vulkan/src/error/mod.rs (partial_threadgroups)`; `crates/metal2vulkan/src/lower/simd/divergent.rs (barriers)`
- `feature::IrreducibleConvergent`: `crates/metal2vulkan/src/structurize/irreducible.rs (refuse_tangled)`
- `feature::ComputeDerivativesWithSimd`: `crates/metal2vulkan/src/lower/dispatch.rs (plan_kernel)`
- `feature::ComputeDerivatives`: `crates/metal2vulkan/src/lower/sync/barrier.rs (select_derivative, 3 sites)`