Identity domains: a sequentially consistent fence is refused naming the fence

The translator orders a seq_cst fence (atomic_thread_fence of memory_order_seq_cst beyond the
thread, or a seq_cst barrier whose memory scope is the device) through an increment of the
command buffer's ExecutionStatus word. The identity domains reach no such word. Their refusal was
the generic one at the plan's end, which named the push field the fence asked for: "an encoder
value the function reads as ExecutionStatusAddress". require_seq_cst now refuses the fence itself
under the identity domains, as Unsupported{IdentityDomains}, not implemented, naming its Metal
form, "a sequentially consistent fence" (barrier::SEQ_CST_FORM). It stays refused; the default
domains compile it as before.

Docs: the runtime README's known gap of the forms the identity domains do not lower gains the
fence and its test. Validation's executor_contract::seq_cst_fence and
ToolingRequirement::SeqCstFence docs name the new text. docs/REFUSALS.md is regenerated (the
IdentityDomains row gains the barrier.rs site).

Tests: engine_identity's new
a_seq_cst_fence_is_refused_naming_its_form_under_the_identity_domains (a4_device_fence on
lavapipe and moltenvk-m3: under the default domains it compiles and states ExecutionStatus; under
the identity domains it is refused IdentityDomains, NotImplemented, symbol "a sequentially
consistent fence"). Validation's
a_seq_cst_fence_is_refused_through_the_runtime_as_its_requirement_says now looks for the fence's
name in the runtime's error.

SEMANTICS_VERSION 2230 (placeholder; main renumbers): a refusal's text changes.

Consumer check: no public item is added or removed.

Verified: m3-max-61154 (msi) at this commit's tree: fmt, clippy (plain, --cfg m2v_gpu and
--cfg m2v_cpu_icd) and Rustdoc green; nextest of metal2vulkan, -conformance, -validation and
-runtime, 5880 of 5881 passed, the new identity test among them; the one failure is
the_old_render_descriptor_key_keeps_its_value, which moves with SEMANTICS_VERSION and waits for the
next named pin. Only the refusal's text changes, so no play.
This commit is contained in:
Anees Iqbal committed 2026-11-20 18:57:42 -08:00
1 parent 8bafe7240d
commit acc706ca47
8 files changed
+60 -9

No files matched your search

+6 -1
View File
@@ -2510,7 +2510,12 @@ or does not check is rebuilt from the generations' names, with young counted ful
buffer, a cube read as an array, level views, a two-plane, extended-range, RGBX or `ulong`
form, or a storage texture with a format), one read through another numeric type than its
own or as the raw texels of an extended-range member, and a handle that reads its table
entry beyond its element: no test yet.
entry beyond its element: no test yet;
- a sequentially consistent fence (`atomic_thread_fence` of `memory_order_seq_cst` beyond the
thread, or a `seq_cst` barrier whose memory scope is the device), which the translator
orders through a word the identity domains do not reach ("a sequentially consistent
fence"): the translator test
`a_seq_cst_fence_is_refused_naming_its_form_under_the_identity_domains` asserts the text.
The plays' counts of the pipeline states they skipped read 0, a refusal under the identity
domains among them, on five recorded streams: three played to their end (1,047, 1,100 and
@@ -653,7 +653,9 @@ fn a_seq_cst_fence_is_refused_through_the_runtime_as_its_requirement_says() {
let error = run_on_runtime(&fence, &bitcode, &[]).unwrap_err();
assert!(matches!(error, ExecutorError::NotSupported(_)), "{error}");
assert!(
error.to_string().contains("ExecutionStatusAddress"),
error
.to_string()
.contains("a sequentially consistent fence"),
"{error}"
);
}
@@ -4,7 +4,7 @@
//! the device, with every other such fence of the command buffer through an acquire-release
//! increment of one word of its execution status buffer (`lower::sync::barrier`). The runtime's
//! identity domains reach no such word: its pipeline is refused as `Unsupported{IdentityDomains}`,
//! naming the `ExecutionStatusAddress` encoder value, so the engine's candidate does not run the
//! naming the fence ("a sequentially consistent fence"), so the engine's candidate does not run the
//! case ([`ToolingRequirement::SeqCstFence`]). The Metal oracle runs it.
//!
//! The scan reads the entry's function and the functions it reaches by direct calls, which its
@@ -169,7 +169,7 @@ pub enum ToolingRequirement {
/// memory scope is the device. The translator orders such a fence with the command buffer's
/// other ones through an atomic on its execution status word, which the runtime's identity
/// domains do not reach: the runtime refuses the pipeline (`Unsupported{IdentityDomains}`,
/// naming the `ExecutionStatusAddress` encoder value), so the limit is the runtime's
/// naming the fence, "a sequentially consistent fence"), so the limit is the runtime's
/// ([`Limit::Runtime`]) and the engine's candidate does not run the case. The device tests
/// `candidate::tests::engine_compute::a_seq_cst_fence_is_refused_through_the_runtime_as_its_requirement_says`
/// and `..::a_fence_of_another_order_is_made_through_the_runtime` hold it both ways. The Metal
+1 -1
View File
@@ -61,7 +61,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 = 2229;
pub const SEMANTICS_VERSION: u32 = 2230;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
+13 -2
View File
@@ -57,7 +57,7 @@ use crate::air::intrinsics::{
use crate::air::ir::{Callee, Inst, InstId, InstKind, Value, ValueId};
use crate::device::requirements::VkFeature;
use crate::device::subgroup::{OpBits, SimdClass, Tier};
use crate::error::{Capability, Error, Feature, LowerFamily, Unsupported};
use crate::error::{Capability, DiagName, Error, Feature, LowerFamily, Unsupported};
use crate::lower::emit::EmitCx;
use crate::lower::select::{FamilyPlans, Plan, SelectCx};
use crate::lower::strategy::{FamilyStrategy, Strategy};
@@ -482,11 +482,22 @@ pub const SEQ_CST_WORDS: u32 = 48;
/// (`dispatch::KernelDecl::rows_may_split`), its constants, and the selection around the barrier.
pub const ROWS_GUARD_WORDS: u32 = 40;
/// The form a sequentially consistent fence is refused as under the identity domains
/// ([`require_seq_cst`]).
pub(crate) const SEQ_CST_FORM: &str = "a sequentially consistent fence";
/// What a sequentially consistent fence needs ([`seq_cst_order`]): the command buffer's
/// `ExecutionStatus` word (`absent::state_status`), and the stage's atomics; a device without them
/// refuses the fence as `SeqCstFence`, naming what it needs.
/// refuses the fence as `SeqCstFence`, naming what it needs. The identity domains reach no such
/// word: under them the fence is refused as `IdentityDomains`, not implemented, naming
/// [`SEQ_CST_FORM`].
pub fn require_seq_cst(cx: &mut SelectCx<'_>) -> Result<(), Error> {
use crate::lower::access::absent::{state_status, status_short, StatusBinding, StatusShort};
if crate::lower::access::identity(cx.profile) {
return Err(Unsupported::not_implemented(Feature::IdentityDomains)
.naming(DiagName::new(SEQ_CST_FORM))
.into());
}
if let Some(StatusShort::Stores(f)) = status_short(cx) {
return Err(Unsupported::needs(Feature::SeqCstFence, Capability::Feature(f)).into());
}
@@ -3075,3 +3075,36 @@ fn a_constant_blob_past_the_modules_bound_is_refused_naming_its_size() {
);
}
}
/// A kernel whose device-scope `seq_cst` fence orders its two stores (`a4_device_fence`) compiles
/// under the default domains, its fence ordered through the command buffer's `ExecutionStatus`
/// word, and is refused under the identity domains, which reach no such word, naming the fence
/// ([`SEQ_CST_FORM`](crate::lower::sync::barrier::SEQ_CST_FORM)).
#[test]
fn a_seq_cst_fence_is_refused_naming_its_form_under_the_identity_domains() {
let Some(bc) = assemble("a4_device_fence") else {
return;
};
for stem in PROFILES {
let default = profile(stem, DevicePolicy::default()).unwrap_or_else(|e| panic!("{e}"));
let a = compile(&bc, "a4_device_fence", &default)
.unwrap_or_else(|e| panic!("{stem}: default domains: {e}"));
assert!(a.facts.contains(&RuntimeFact::ExecutionStatus), "{stem}");
let p = profile(stem, identity()).unwrap_or_else(|e| panic!("{e}"));
match compile(&bc, "a4_device_fence", &p) {
Err(Error::Unsupported(u)) => {
assert_eq!(
(u.feature, u.needs),
(Feature::IdentityDomains, Needs::NotImplemented),
"{stem}"
);
assert_eq!(
u.symbol.map(|f| f.to_string()).as_deref(),
Some(crate::lower::sync::barrier::SEQ_CST_FORM),
"{stem}"
);
}
other => panic!("{stem}: {:?}", other.map(|_| ())),
}
}
}
+2 -2
View File
@@ -139,7 +139,7 @@ Columns:
| `GpuEncodedIndirectCommands` | | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism); every device (not implemented) | `ours` | 20: `crates/metal2vulkan/src/bind/replay.rs (preprocess)`, `crates/metal2vulkan/src/bind/replay.rs (replay_preprocess_module)` (+12) | `rare`: indirect command buffers encoded by a kernel |
| `VulkanVersion` | The device's Vulkan version is below the 1.2 floor | devices without ApiVersion::V1_2 | `device` | 2: `crates/metal2vulkan/src/ash_interop/query.rs (query)`, `crates/metal2vulkan/src/device/derive.rs (from_queries)` | `none`: a device below Vulkan 1.2 |
| `PushWindow` | The device's `maxPushConstantsSize` is below the 256 bytes of the push window every stage is lowered for | devices without VkLimit::MaxPushConstantsSize | `device` | 1: `crates/metal2vulkan/src/device/derive.rs (from_queries)` | `none`: a device whose maxPushConstantsSize is below 256 bytes |
| `IdentityDomains` | The identity pointer and handle domains (`PointerDomain::Identity`, `HandleDomain::Identity`) | devices without a capability the site computes (`all`); every device (not implemented) | `ours` | 6: `crates/metal2vulkan/src/device/derive.rs (identity_domains)`, `crates/metal2vulkan/src/lower/sampler/anisotropic.rs (select)` (+4) | `none`: the identity domains, which the runtime alone takes and which lower only kernels over buffer slots, textures in slots or argument buffers, and runtime samplers, so far |
| `IdentityDomains` | The identity pointer and handle domains (`PointerDomain::Identity`, `HandleDomain::Identity`) | devices without a capability the site computes (`all`); every device (not implemented) | `ours` | 7: `crates/metal2vulkan/src/device/derive.rs (identity_domains)`, `crates/metal2vulkan/src/lower/sampler/anisotropic.rs (select)` (+5) | `none`: the identity domains, which the runtime alone takes and which lower only kernels over buffer slots, textures in slots or argument buffers, and runtime samplers, so far |
| `Constant` | A constants-block record LLVM defines that the typed model has no form for (a block address, a `select` and the other constant expressions of... | - | `-` | via a helper: 3: `crates/metal2vulkan-air/src/bitcode/constants.rs (record, 2 sites)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: LLVM constant forms AIR does not emit |
| `Attribute` | An LLVM attribute kind that changes the calling ABI and that AIR does not use (`inalloca`, `preallocated`, `byref`, `nest`, the `swift*` kinds) | - | `-` | via a helper: 2: `crates/metal2vulkan-air/src/bitcode/attrs.rs (known)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: LLVM ABI attributes AIR does not use |
| `BitcodeRecord` | A bitcode record LLVM defines in `block` that the typed model does not cover and that has no more specific variant (legacy spellings predating... | - | `-` | via a helper: 8: `crates/metal2vulkan-air/src/bitcode/attrs.rs (decode_lists)`, `crates/metal2vulkan-air/src/bitcode/function.rs (symtab)` (+5) | `none`: bitcode records AIR does not emit |
@@ -478,7 +478,7 @@ Each refusal's sites, with the function that builds it.
- `feature::GpuEncodedIndirectCommands`: `crates/metal2vulkan/src/bind/replay.rs (preprocess)`; `crates/metal2vulkan/src/bind/replay.rs (replay_preprocess_module)`; `crates/metal2vulkan/src/bind/replay/draws.rs (draw_replay_module)`; `crates/metal2vulkan/src/bind/replay/draws.rs (draw_replay_preprocess)`; `crates/metal2vulkan/src/bind/replay/merged.rs (draw_merge_module)`; `crates/metal2vulkan/src/lower/access/encode.rs (needs, 3 sites)`; `crates/metal2vulkan/src/lower/access/encode.rs (select_command)`; `crates/metal2vulkan/src/lower/access/mod.rs (plan_replay, 3 sites)`; `crates/metal2vulkan/src/lower/mesh/mod.rs (plan_partial_groups)`; `crates/metal2vulkan/src/lower/select.rs (finish, 2 sites)`; `crates/metal2vulkan/src/lower/simd/divergent.rs (barriers)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (merged)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`; `crates/metal2vulkan/src/pipeline/compile.rs (analyze_one, 2 sites)`
- `feature::VulkanVersion`: `crates/metal2vulkan/src/ash_interop/query.rs (query)`; `crates/metal2vulkan/src/device/derive.rs (from_queries)`
- `feature::PushWindow`: `crates/metal2vulkan/src/device/derive.rs (from_queries)`
- `feature::IdentityDomains`: `crates/metal2vulkan/src/device/derive.rs (identity_domains)`; `crates/metal2vulkan/src/lower/sampler/anisotropic.rs (select)`; `crates/metal2vulkan/src/lower/sampler/mod.rs (finish)`; `crates/metal2vulkan/src/lower/select.rs (identity_admits)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format)`; `crates/metal2vulkan/src/pipeline/link.rs (identity_set)`
- `feature::IdentityDomains`: `crates/metal2vulkan/src/device/derive.rs (identity_domains)`; `crates/metal2vulkan/src/lower/sampler/anisotropic.rs (select)`; `crates/metal2vulkan/src/lower/sampler/mod.rs (finish)`; `crates/metal2vulkan/src/lower/select.rs (identity_admits)`; `crates/metal2vulkan/src/lower/sync/barrier.rs (require_seq_cst)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format)`; `crates/metal2vulkan/src/pipeline/link.rs (identity_set)`
- `feature::Constant`: `crates/metal2vulkan-air/src/bitcode/constants.rs (record, 2 sites)`; `crates/metal2vulkan/src/error/mod.rs (from)`
- `feature::Attribute`: `crates/metal2vulkan-air/src/bitcode/attrs.rs (known)`; `crates/metal2vulkan/src/error/mod.rs (from)`
- `feature::BitcodeRecord`: `crates/metal2vulkan-air/src/bitcode/attrs.rs (decode_lists)`; `crates/metal2vulkan-air/src/bitcode/function.rs (symtab)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs (decode, 2 sites)`; `crates/metal2vulkan-air/src/bitcode/module.rs (check_bodies)`; `crates/metal2vulkan-air/src/bitcode/module.rs (read)`; `crates/metal2vulkan-air/src/bitcode/module.rs (symtab)`; `crates/metal2vulkan/src/error/mod.rs (from)`