diff --git a/crates/metal2vulkan-air/src/budget/mod.rs b/crates/metal2vulkan-air/src/budget/mod.rs index e70a9f138..4a7bb0f11 100644 --- a/crates/metal2vulkan-air/src/budget/mod.rs +++ b/crates/metal2vulkan-air/src/budget/mod.rs @@ -214,6 +214,25 @@ impl Budget { } } +/// What one piece of work charged a [`Meter`] ([`Meter::measured`]): its work units, the most +/// ledger bytes it held at once above the ledger it began at, and the bytes it still held when it +/// ended. A result kept for later asks charges each of them this ([`Meter::spend`]), so what a +/// meter answers never depends on whether the result was made or found. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub struct Spent { + work: u64, + peak: u64, + held: u64, +} + +impl Spent { + /// The ledger bytes the work still held when it ended: what its result holds while it is + /// kept. + pub fn held(&self) -> u64 { + self.held + } +} + /// Per-attempt meter: deadline, cancellation, work units, and the byte ledger. #[derive(Debug)] pub struct Meter { @@ -411,6 +430,41 @@ impl Meter { pub fn ledger_peak(&self) -> u64 { self.peak_bytes } + + /// `f` run on this meter, with what it charged ([`Spent`]). A refusal is `f`'s own. + pub fn measured( + &mut self, + f: impl FnOnce(&mut Meter) -> Result, + ) -> Result<(T, Spent), E> { + let (work, bytes, peak) = (self.work, self.bytes, self.peak_bytes); + // The work's own peak, read from the ledger it begins at; the meter's is restored after. + self.peak_bytes = bytes; + let made = f(self); + let spent = Spent { + work: self.work.saturating_sub(work), + peak: self.peak_bytes.saturating_sub(bytes), + held: self.bytes.saturating_sub(bytes), + }; + self.peak_bytes = self.peak_bytes.max(peak); + made.map(|made| (made, spent)) + } + + /// Charge what `spent` states its work charged another meter, or this one before + /// ([`Meter::measured`]): its work units, then its peak to the ledger, of which the bytes it + /// held when it ended stay charged. The caps refuse it where they refused the work itself, + /// counting its work units before its bytes. + pub fn spend(&mut self, spent: Spent) -> Result<(), Error> { + let mut work = spent.work; + while work > 0 { + let units = u32::try_from(work).unwrap_or(u32::MAX); + self.tick(units)?; + work = work.saturating_sub(u64::from(units)); + } + self.charge(usize::try_from(spent.peak).unwrap_or(usize::MAX))?; + let gone = spent.peak.saturating_sub(spent.held); + self.release(usize::try_from(gone).unwrap_or(usize::MAX)); + Ok(()) + } } #[cfg(test)] diff --git a/crates/metal2vulkan-air/src/budget/tests.rs b/crates/metal2vulkan-air/src/budget/tests.rs index 1cdf1b959..cb96f6e54 100644 --- a/crates/metal2vulkan-air/src/budget/tests.rs +++ b/crates/metal2vulkan-air/src/budget/tests.rs @@ -342,3 +342,58 @@ fn budget_types_are_send_and_sync() { send_sync::(); send_sync::(); } + +/// What a piece of work charged one meter, spent on another, leaves the second where the work +/// itself would have: the same work units, the same ledger, the same peak, and the same refusals +/// at the same caps. Measured from a ledger and a peak that are not zero, so neither is read as +/// the work's own. +#[test] +fn spent_work_charges_another_meter_as_the_work_did() { + let work = |m: &mut Meter| -> Result<(), Error> { + m.tick(70_000)?; + m.charge(300)?; + m.charge(200)?; + m.release(400); + m.tick(5) + }; + let mut made = Meter::new(&Budget::default()); + made.tick(9).unwrap(); + made.charge(1_000).unwrap(); + made.release(900); + let ((), spent) = made.measured(work).unwrap(); + assert_eq!(spent.held(), 100); + assert_eq!( + (made.work(), made.ledger(), made.ledger_peak()), + (70_014, 200, 1_000) + ); + + let mut fresh = Meter::new(&Budget::default()); + work(&mut fresh).unwrap(); + let mut found = Meter::new(&Budget::default()); + found.spend(spent).unwrap(); + assert_eq!( + (found.work(), found.ledger(), found.ledger_peak()), + (fresh.work(), fresh.ledger(), fresh.ledger_peak()) + ); + assert_eq!( + (found.work(), found.ledger(), found.ledger_peak()), + (70_005, 100, 500) + ); + + // At the caps the work just fits, both fit; one under either, both are refused alike. + let at = |work_cap, byte_cap| { + let mut fresh = Meter::with_caps(&Budget::default(), work_cap, byte_cap); + let mut found = Meter::with_caps(&Budget::default(), work_cap, byte_cap); + (work(&mut fresh), found.spend(spent)) + }; + assert_eq!(at(70_005, 500), (Ok(()), Ok(()))); + let over = |limit| Err(Error::LimitExceeded(limit)); + assert_eq!( + at(70_004, 500), + (over(Limit::WorkUnits), over(Limit::WorkUnits)) + ); + assert_eq!( + at(70_005, 499), + (over(Limit::LedgerBytes), over(Limit::LedgerBytes)) + ); +} diff --git a/crates/metal2vulkan-air/tests/api_surface.txt b/crates/metal2vulkan-air/tests/api_surface.txt index 59b0c5426..f39dffe82 100644 --- a/crates/metal2vulkan-air/tests/api_surface.txt +++ b/crates/metal2vulkan-air/tests/api_surface.txt @@ -109,6 +109,7 @@ budget Meter struct(O) budget PRIVATE_ARENA_BYTES const budget SPIRV_WORDS const budget STANDARD_DEADLINE const +budget Spent struct(O) budget TYPE_COUNT const budget WORK_UNITS const budget map_bytes fn @@ -148,10 +149,12 @@ canon::function_table FIRST_FUNCTION_WORD const canon::function_table PRESENT_WORD const canon::function_table SIZE_WORD const canon::opencl entry fn +canon::rate_map_data BOUNDARY_MASK const canon::rate_map_data BYTES const canon::rate_map_data ENTRIES const canon::rate_map_data ENTRY_WORDS const canon::rate_map_data GRANULARITY const +canon::rate_map_data GRANULE_SHIFT const canon::rate_map_data HORIZONTAL_TO_PHYSICAL const canon::rate_map_data HORIZONTAL_TO_SCREEN const canon::rate_map_data INDEX_CAP const @@ -180,7 +183,9 @@ canon::rate_map_data physical_to_screen fn canon::rate_map_data screen_to_physical fn canon::rate_map_data shader_index fn canon::rate_map_data shader_physical_to_screen fn +canon::rate_map_data shader_physical_to_screen_integer fn canon::rate_map_data shader_screen_to_physical fn +canon::rate_map_data shader_screen_to_physical_integer fn canon::rate_map_data table fn canon::rate_map_data tile_line fn container BITCODE_MAGIC const diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index b0fe4085c..da2f9d5e3 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -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 = 2093; +pub const SEMANTICS_VERSION: u32 = 2094; /// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the /// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another diff --git a/crates/metal2vulkan/src/pipeline/compile.rs b/crates/metal2vulkan/src/pipeline/compile.rs index 9fbf84d4c..13e892dc0 100644 --- a/crates/metal2vulkan/src/pipeline/compile.rs +++ b/crates/metal2vulkan/src/pipeline/compile.rs @@ -33,7 +33,7 @@ use crate::air::container::{self, LibraryFunction}; use crate::air::{self, ConstValue, LinkedCode, LinkedModule, LinkedName, SpecRequest}; use crate::bind::argument_buffer::{self, EntryLayout}; use crate::bind::{ArgumentBufferLayout, ArgumentLayoutError}; -use crate::budget::{Meter, SPIRV_WORDS}; +use crate::budget::{Meter, Spent, SPIRV_WORDS}; use crate::cache::Hash256; use crate::cache::VariantKey; use crate::device::DeviceProfile; @@ -918,10 +918,17 @@ pub(crate) fn stage_uses_direct_arguments( /// at the same time for the same inputs: the whole module is decoded, with every entry's argument /// metadata, by the first ask that needs it. /// +/// **Charged as made.** An ask that finds what an earlier ask made is charged what making it +/// charged (`Spent`: its work units, its ledger peak and the ledger bytes it holds), though +/// nothing is made again. So the object spares time and never budget: a compile's answer under +/// its budget, a refusal at a cap included, is the same whether its entry, its decode or its +/// answer was made or found, and the same as a compile's that shares nothing +/// (`Device::compile_function`). +/// /// **Bounded.** It keeps at most 32 specialized entries and at most 64 MiB of them (each entry -/// charged what specializing it charged the ledger), at most 32 plain answers, and at most 4 -/// module decodes and 32 MiB of them (each charged what decoding it charged the ledger); past any -/// of those, the least recently used go, so an object that outlives one creation never grows +/// counted as the ledger bytes specializing it held), at most 32 plain answers, and at most 4 +/// module decodes and 32 MiB of them (each counted as the ledger bytes decoding it held); past +/// any of those, the least recently used go, so an object that outlives one creation never grows /// without bound. A refusal is not kept: the next ask makes it again. #[derive(Default)] pub struct StageEntries { @@ -933,8 +940,8 @@ pub struct StageEntries { /// while the search stays a scan of a handful. const KEPT_ENTRIES: usize = 32; -/// The most bytes of specialized entries one [`StageEntries`] keeps: 64 MiB, each entry charged -/// what specializing it charged the compile's ledger. One translation attempt may use 500 MiB, so +/// The most bytes of specialized entries one [`StageEntries`] keeps: 64 MiB, each entry counted +/// as the ledger bytes specializing it held. One translation attempt may use 500 MiB, so /// an object shared between creations holds a fraction of one attempt's room. const KEPT_ENTRY_BYTES: u64 = 64 << 20; @@ -943,14 +950,14 @@ const KEPT_ENTRY_BYTES: u64 = 64 << 20; /// compiled in turn, asks over. const KEPT_DECODES: usize = 4; -/// The most bytes of module decodes one [`StageEntries`] keeps: 32 MiB, each decode charged what -/// decoding it charged the compile's ledger. Half the entries' room, and a sixteenth of one +/// The most bytes of module decodes one [`StageEntries`] keeps: 32 MiB, each decode counted as +/// the ledger bytes decoding it held. Half the entries' room, and a sixteenth of one /// translation attempt's 500 MiB. pub(crate) const KEPT_DECODE_BYTES: u64 = 32 << 20; /// What a [`StageEntries`] holds: its specialized entries, its plain answers and its module -/// decodes, each least recently used first, the bytes the entries and the decodes were charged, -/// and the totals its counts report. +/// decodes, each least recently used first, the bytes the entries and the decodes hold, and the +/// totals its counts report. #[derive(Default)] struct Kept { entries: Vec, @@ -974,8 +981,9 @@ struct KeptDecode { /// decoding anything (a metallib's verified `HASH`, or a module's own hash, which every entry /// of it carries). air_hash: Hash256, - /// What decoding it charged the ledger, which the byte bound counts. - bytes: u64, + /// What decoding it charged, which every ask that copies it is charged; the byte bound counts + /// the bytes it holds. + spent: Spent, decoded: Arc, } @@ -987,6 +995,8 @@ struct StageAnswer { function: FunctionDescriptor, /// Whether the entry returns a value ([`stage_returns_value`]). returns_value: bool, + /// What reading it charged, which every ask that finds it is charged. + spent: Spent, } /// One specialized entry of [`StageEntries`], with what tells it apart. @@ -998,8 +1008,9 @@ struct StageEntry { depth: u32, /// Specialized as the kernel of a compute pipeline of OpenCL mode. open_cl_mode: bool, - /// What specializing it charged the ledger, which the byte bound counts. - bytes: u64, + /// What specializing it charged, which every ask that finds it is charged; the byte bound + /// counts the bytes it holds. + spent: Spent, specialized: Arc, } @@ -1037,12 +1048,8 @@ impl StageEntries { } /// The decode of the module whose AIR hash is `air_hash`, whose bitcode is `bitcode`: a copy - /// of the one an earlier ask read, else one read now under `m` and kept. A refusal is not - /// kept: the next ask reads it again. - /// - /// The copy is not charged to `m`, as a specialized entry an earlier ask made is not: what - /// bounds it is this object's own byte bound, and the compile that copies it would have - /// decoded the same module itself. + /// of the one an earlier ask read, charged to `m` what reading it charged, else one read now + /// under `m` and kept. A refusal is not kept: the next ask reads it again. fn module( &self, air_hash: &Hash256, @@ -1050,51 +1057,54 @@ impl StageEntries { m: &mut Meter, ) -> Result { let lock = || self.kept.lock().unwrap_or_else(|e| e.into_inner()); - if let Some(decoded) = lock().decode(air_hash) { + let found = lock().decode(air_hash); + if let Some((decoded, spent)) = found { + m.spend(spent)?; return Ok(air::Decoded::clone(&decoded)); } - // What the decode charged the ledger, which the byte bound counts: the decode is what the - // charge is still held for once this returns. - let before = m.ledger(); - let decoded = Arc::new(air::decode(bitcode, m)?); - let bytes = m.ledger().saturating_sub(before); + let (decoded, spent) = m.measured(|m| air::decode(bitcode, m))?; + let decoded = Arc::new(decoded); let mine = air::Decoded::clone(&decoded); let mut kept = lock(); // Another caller may have decoded the same module meanwhile: the bytes decide the decode, // so its decode is this one and the two share what is kept. - if let Some(theirs) = kept.decode(air_hash) { + if let Some((theirs, _)) = kept.decode(air_hash) { return Ok(air::Decoded::clone(&theirs)); } kept.decodes_read += 1; - kept.decode_bytes = kept.decode_bytes.saturating_add(bytes); + kept.decode_bytes = kept.decode_bytes.saturating_add(spent.held()); kept.decodes.push(KeptDecode { air_hash: *air_hash, - bytes, + spent, decoded, }); kept.evict(); Ok(mine) } - /// Whether the entry of stage `fd` returns a value: the answer an earlier ask read, else read - /// now under `m` by `read`, which decodes the stage's AIR and specializes nothing - /// ([`stage_returns_value`]). The stage's descriptor alone decides it. A refusal is not kept. + /// Whether the entry of stage `fd` returns a value: the answer an earlier ask read, charged to + /// `m` what reading it charged, else read now under `m` by `read`, which decodes the stage's + /// AIR and specializes nothing ([`stage_returns_value`]). The stage's descriptor alone decides + /// it. A refusal is not kept. fn returns_value( &self, fd: &FunctionDescriptor, - read: impl FnOnce(&StageEntries) -> Result, + m: &mut Meter, + read: impl FnOnce(&StageEntries, &mut Meter) -> Result, ) -> Result { // The library's table states it without decoding (`Function::info`). let air_hash = fd.function.info().air_hash; let lock = || self.kept.lock().unwrap_or_else(|e| e.into_inner()); - if let Some(returns) = lock().answer(&air_hash, fd) { + let found = lock().answer(&air_hash, fd); + if let Some((returns, spent)) = found { + m.spend(spent)?; return Ok(returns); } - let returns_value = read(self)?; + let (returns_value, spent) = m.measured(|m| read(self, m))?; let mut kept = lock(); // As a specialized entry's: another caller may have read it meanwhile, and its answer is // this one. - if let Some(theirs) = kept.answer(&air_hash, fd) { + if let Some((theirs, _)) = kept.answer(&air_hash, fd) { return Ok(theirs); } kept.made += 1; @@ -1102,6 +1112,7 @@ impl StageEntries { air_hash, function: fd.clone(), returns_value, + spent, }); kept.evict(); Ok(returns_value) @@ -1111,8 +1122,9 @@ impl StageEntries { /// taken as 1, Metal's default), specialized as a compile specializes it before lowering /// (its constants bound, its linked functions resolved, its calls inlined, SCCP run), with /// what a compile takes beside it (The AIR hash, the entry name, what its code read before, so - /// a compile of the stage reads it too, [`specialize_one`]): the one made before, else made now - /// under `m`. A refusal is not kept: the next ask makes it again. + /// a compile of the stage reads it too, [`specialize_one`]): the one made before, charged to + /// `m` what making it charged, else made now under `m`. A refusal is not kept: the next ask + /// makes it again. fn specialized( &self, fd: &FunctionDescriptor, @@ -1124,38 +1136,39 @@ impl StageEntries { // The library's table states it without decoding (`Function::info`). let air_hash = fd.function.info().air_hash; let lock = || self.kept.lock().unwrap_or_else(|e| e.into_inner()); - if let Some(specialized) = lock().take(&air_hash, fd, depth, open_cl_mode) { + let found = lock().take(&air_hash, fd, depth, open_cl_mode); + if let Some((specialized, spent)) = found { + m.spend(spent)?; return Ok(specialized); } let mut inputs = LowerInputs::new(); inputs.max_call_stack_depth = call_stack_input(depth); inputs.open_cl_mode = open_cl_mode; - // What the specialization charged the ledger, which the byte bound counts: the entry is - // what the charge is still held for once this returns. - let before = m.ledger(); - let specialized = Arc::new(with_request_shared( - &fd.function, - &fd.constants, - (&fd.linked, &fd.libraries), - InputsFrom::Given(&inputs), - Shared::Decode(self), - |r| specialize_one(r, m), - )?); - let bytes = m.ledger().saturating_sub(before); + let (specialized, spent) = m.measured(|m| { + with_request_shared( + &fd.function, + &fd.constants, + (&fd.linked, &fd.libraries), + InputsFrom::Given(&inputs), + Shared::Decode(self), + |r| specialize_one(r, m), + ) + })?; + let specialized = Arc::new(specialized); let mut kept = lock(); // Another caller may have specialized the same stage meanwhile: its entry is this one, so // the two share one. - if let Some(theirs) = kept.take(&air_hash, fd, depth, open_cl_mode) { + if let Some((theirs, _)) = kept.take(&air_hash, fd, depth, open_cl_mode) { return Ok(theirs); } kept.made += 1; - kept.bytes = kept.bytes.saturating_add(bytes); + kept.bytes = kept.bytes.saturating_add(spent.held()); kept.entries.push(StageEntry { air_hash, function: fd.clone(), depth, open_cl_mode, - bytes, + spent, specialized: Arc::clone(&specialized), }); kept.evict(); @@ -1165,15 +1178,15 @@ impl StageEntries { impl Kept { /// The entry of `fd` at `depth` whose function's AIR hash is `air_hash`, made the most - /// recently used: `None` where none is held. The hash is compared first, so a scan reads a - /// function descriptor only where the hashes agree. + /// recently used, with what making it charged: `None` where none is held. The hash is + /// compared first, so a scan reads a function descriptor only where the hashes agree. fn take( &mut self, air_hash: &Hash256, fd: &FunctionDescriptor, depth: u32, open_cl_mode: bool, - ) -> Option> { + ) -> Option<(Arc, Spent)> { let at = self.entries.iter().position(|e| { e.depth == depth && e.open_cl_mode == open_cl_mode @@ -1181,36 +1194,37 @@ impl Kept { && e.function == *fd })?; let entry = self.entries.remove(at); - let specialized = Arc::clone(&entry.specialized); + let found = (Arc::clone(&entry.specialized), entry.spent); self.entries.push(entry); self.found += 1; - Some(specialized) + Some(found) } /// The plain answer of `fd` whose function's AIR hash is `air_hash`, made the most recently - /// used: `None` where none is held. The hash is compared first, as [`Kept::take`] compares it. - fn answer(&mut self, air_hash: &Hash256, fd: &FunctionDescriptor) -> Option { + /// used, with what reading it charged: `None` where none is held. The hash is compared first, + /// as [`Kept::take`] compares it. + fn answer(&mut self, air_hash: &Hash256, fd: &FunctionDescriptor) -> Option<(bool, Spent)> { let at = self .answers .iter() .position(|a| a.air_hash == *air_hash && a.function == *fd)?; let answer = self.answers.remove(at); - let returns_value = answer.returns_value; + let found = (answer.returns_value, answer.spent); self.answers.push(answer); self.found += 1; - Some(returns_value) + Some(found) } - /// The decode of the module whose AIR hash is `air_hash`, made the most recently used: - /// `None` where none is held. The hash decides the decode completely, so nothing else is - /// compared. - fn decode(&mut self, air_hash: &Hash256) -> Option> { + /// The decode of the module whose AIR hash is `air_hash`, made the most recently used, with + /// what reading it charged: `None` where none is held. The hash decides the decode + /// completely, so nothing else is compared. + fn decode(&mut self, air_hash: &Hash256) -> Option<(Arc, Spent)> { let at = self.decodes.iter().position(|d| d.air_hash == *air_hash)?; let decode = self.decodes.remove(at); - let decoded = Arc::clone(&decode.decoded); + let found = (Arc::clone(&decode.decoded), decode.spent); self.decodes.push(decode); self.decodes_copied += 1; - Some(decoded) + Some(found) } /// Drop the least recently used entries, answers and decodes until the bounds hold, never the @@ -1221,7 +1235,7 @@ impl Kept { && (self.entries.len() > KEPT_ENTRIES || self.bytes > KEPT_ENTRY_BYTES) { let gone = self.entries.remove(0); - self.bytes = self.bytes.saturating_sub(gone.bytes); + self.bytes = self.bytes.saturating_sub(gone.spent.held()); } while self.answers.len() > KEPT_ENTRIES.max(1) { self.answers.remove(0); @@ -1230,7 +1244,7 @@ impl Kept { && (self.decodes.len() > KEPT_DECODES || self.decode_bytes > KEPT_DECODE_BYTES) { let gone = self.decodes.remove(0); - self.decode_bytes = self.decode_bytes.saturating_sub(gone.bytes); + self.decode_bytes = self.decode_bytes.saturating_sub(gone.spent.held()); } } } @@ -1260,7 +1274,7 @@ pub(crate) fn stage_returns_value( entries: &StageEntries, m: &mut Meter, ) -> Result { - entries.returns_value(fd, |shared| stage_returns_value_read(fd, shared, m)) + entries.returns_value(fd, m, |shared, m| stage_returns_value_read(fd, shared, m)) } /// [`FunctionDescriptor::needs_specialization`] under `m`: a module function's constants read @@ -1665,6 +1679,35 @@ pub(crate) fn compile_bitcode_bounded( }) } +/// Stage `fd` compiled with default lowering inputs as [`compile_stage`] compiles it, or as +/// [`compile_stage_from`] compiles it reading `entries` where given, under the stage bound +/// `weight_cap` in place of [`stage_bound::SERIALIZED_STAGE_WEIGHT`]: so a test reaches the bound +/// with a small module through either path. +#[cfg(test)] +pub(crate) fn compile_stage_bounded( + fd: &FunctionDescriptor, + p: &DeviceProfile, + entries: Option<&StageEntries>, + m: &mut Meter, + weight_cap: u64, +) -> Result { + let inputs = LowerInputs::new(); + let shared = entries.map_or(Shared::Nothing, |e| Shared::Entry(e, fd)); + guarded(|| { + with_request_shared( + &fd.function, + &fd.constants, + (&fd.linked, &fd.libraries), + InputsFrom::Given(&inputs), + shared, + |r| { + compile_bounded(r, p, m, (SPIRV_WORDS, weight_cap), |_| ()) + .map(|(artifact, _, ())| CompiledFunction::new(artifact)) + }, + ) + }) +} + /// The stage `fd` compiled for `p` as [`compile_stage`] compiles it (its linked functions and /// dynamic libraries included), returning the finished typed module its words were serialized /// from, for the CPU interpreter. @@ -2707,6 +2750,72 @@ fn plan_one( widest: crate::lower::simd::WidestPin, m: &mut Meter, ) -> Result { + let analyzed = analyze_one(r, p, m)?; + let (plan, kernel) = analyzed.select(p, widest, m)?; + Ok(analyzed.planned(plan, kernel)) +} + +/// What [`plan_one`] reads of a request before it selects: the ordered entry, what its code read +/// before specialization, the inputs it lowers under, its key, its memory plan and the partition +/// it observes. A plan made again past the stage bound (`stage_bound`) selects from it again, +/// without decoding, specializing, ordering or analyzing the entry again. +struct Analyzed { + key: FunctionCompileKey, + spec: air::Entry, + before: reflection::UnspecializedReads, + inputs: LowerInputs, + memory: crate::memory::plan::MemoryPlan, + observed: Partition, +} + +impl Analyzed { + /// The plan of the analyzed entry, keeping the widest mode's pin or weighing it as `widest` + /// says, and the kernel facts it gives. + fn select( + &self, + p: &DeviceProfile, + widest: crate::lower::simd::WidestPin, + m: &mut Meter, + ) -> Result<(Plan, KernelFacts), Error> { + let (spec, memory, observed) = (&self.spec, &self.memory, self.observed); + let plan = crate::lower::select::select(spec, memory, p, (&self.inputs, widest), m)?; + let kernel = KernelFacts { + max_total_threads: spec.ep.stage.max_total_threads(), + work_group_size: spec.ep.stage.work_group_size(), + flat_local_size: plan + .dispatch + .as_ref() + .is_some_and(|d| d.local_size == LocalSizeForm::Flat), + // The static part: the objects, and with `[[threadgroup(n)]]` regions the + // 16-byte-aligned offset where the first region starts. With typed threadgroup + // objects (no regions), the static part of Metal's own layout, which holds them too. + static_threadgroup_bytes: if memory.typed_shared.is_empty() { + crate::memory::arena::TgShape::of(&memory.tg_arena) + .static_bytes() + .unwrap_or(u64::MAX) + } else { + memory.tg_metal_static + }, + partition_oblivious: observed == Partition::Oblivious, + partition_simdgroups: observed == Partition::Simdgroups, + }; + Ok((plan, kernel)) + } + + /// The plan `plan` of the analyzed entry, with its kernel facts `kernel`. + fn planned(self, plan: Plan, kernel: KernelFacts) -> Planned { + Planned { + key: self.key, + spec: self.spec, + before: self.before, + plan, + kernel, + } + } +} + +/// [`plan_one`]'s reads before it selects ([`Analyzed`]). +fn analyze_one(r: &Request<'_>, p: &DeviceProfile, m: &mut Meter) -> Result { let Specialized { air_hash, entry, @@ -2752,33 +2861,13 @@ fn plan_one( (&linked, &r.dynamic.key()), ); let memory = crate::memory::plan::analyze_memory(&spec, p, m)?; - let plan = crate::lower::select::select(&spec, &memory, p, (&inputs, widest), m)?; - let kernel = KernelFacts { - max_total_threads: spec.ep.stage.max_total_threads(), - work_group_size: spec.ep.stage.work_group_size(), - flat_local_size: plan - .dispatch - .as_ref() - .is_some_and(|d| d.local_size == LocalSizeForm::Flat), - // The static part: the objects, and with `[[threadgroup(n)]]` regions the 16-byte-aligned - // offset where the first region starts. With typed threadgroup objects (no regions), the - // static part of Metal's own layout, which holds them too. - static_threadgroup_bytes: if memory.typed_shared.is_empty() { - crate::memory::arena::TgShape::of(&memory.tg_arena) - .static_bytes() - .unwrap_or(u64::MAX) - } else { - memory.tg_metal_static - }, - partition_oblivious: observed == Partition::Oblivious, - partition_simdgroups: observed == Partition::Simdgroups, - }; - Ok(Planned { + Ok(Analyzed { key, spec, before, - plan, - kernel, + inputs, + memory, + observed, }) } diff --git a/crates/metal2vulkan/src/pipeline/compile/api.rs b/crates/metal2vulkan/src/pipeline/compile/api.rs index 1297c46fa..c87d9797f 100644 --- a/crates/metal2vulkan/src/pipeline/compile/api.rs +++ b/crates/metal2vulkan/src/pipeline/compile/api.rs @@ -211,8 +211,10 @@ impl Device { /// one a linked-use question or a key of the same creation made /// ([`RenderPipelineDescriptor::fragment_writes_depth_unattached`], /// [`Device::render_variant_key`]), else one made there now, so a creation decodes and - /// specializes each stage once. It compiles what `compile_function` compiles; the - /// specialization a creation already did is not charged to `b` again. + /// specializes each stage once. It compiles and charges what `compile_function` compiles and + /// charges: an entry the creation already made is charged to `b` what making it charged, + /// though it is not made again, so a refusal at one of the budget's caps is + /// `compile_function`'s too. pub fn compile_function_from_entries( &self, f: &FunctionDescriptor, @@ -245,9 +247,10 @@ impl Device { /// [`ComputePipelineDescriptor::reflection`] still lists a buffer for every set attribute. /// /// It decodes and specializes the kernel's AIR under `b`, reading the stage's specialized - /// entry from `entries` (the one a key or check of the same creation made, else one made - /// there now), so a sweep of states over one kernel decodes once. Inputs without a - /// stage-input descriptor are their own answer, decoding nothing. + /// entry from `entries` (the one a key or check of the same creation made, charged to `b` + /// what making it charged, else one made there now), so a sweep of states over one kernel + /// decodes once. Inputs without a stage-input descriptor are their own answer, decoding + /// nothing. /// /// Refused by the decode's and the specialization's own errors. pub fn kernel_inputs_read( diff --git a/crates/metal2vulkan/src/pipeline/compile/stage_bound.rs b/crates/metal2vulkan/src/pipeline/compile/stage_bound.rs index 57061530b..e59cad312 100644 --- a/crates/metal2vulkan/src/pipeline/compile/stage_bound.rs +++ b/crates/metal2vulkan/src/pipeline/compile/stage_bound.rs @@ -15,8 +15,10 @@ //! //! - a kernel that took the `Emulated` simdgroup tier only in place of the `Direct` tier's pin to //! the device's widest mode (`lower::simd::widest_pin`) is planned again keeping the pin -//! (`lower::simd::WidestPin::Kept`), its emulated module dropped and what its emission charged -//! released; +//! (`lower::simd::WidestPin::Kept`), its emulated module dropped and what its plan and emission +//! hold of the ledger released. Only the selection is made again: the entry is decoded, +//! specialized, ordered and analyzed once, so the kernel is charged what any compile of it is +//! charged, whichever path reached it (`super::Analyzed`); //! - every other module past it, a kernel planned again that still is among them, is refused //! (`Unsupported`, `Feature::StageSize`, `Needs::DriverDefect`): Metal compiles it, so the //! refusal is the device's gap, recorded in `docs/FAST-PATHS.md`'s known gaps. @@ -29,7 +31,7 @@ //! is three quarters of 2^20: a stage at the bound stays under the driver's 2^20 objects at up to //! 4/3 objects per instruction, a third above the largest ratio measured. -use super::{plan_one, Planned, Request}; +use super::{analyze_one, Planned, Request}; use crate::budget::Meter; use crate::device::profile::DriverWorkaround; use crate::device::DeviceProfile; @@ -53,23 +55,24 @@ pub(super) fn emit( ) -> Result<(Planned, Emitted), Error> { let defect = DriverWorkaround::SerializedStageWrapsLargeModules; let bounded = p.workarounds().contains(&defect); + let analyzed = analyze_one(r, p, m)?; let mut widest = WidestPin::Weighed; loop { - let planned = plan_one(r, p, widest, m)?; - planned.plan.estimate.check(word_cap)?; let before = m.ledger(); - let mut emitted = crate::lower::emit::emit_module(&planned.spec, &planned.plan, m)?; + let (plan, kernel) = analyzed.select(p, widest, m)?; + plan.estimate.check(word_cap)?; + let mut emitted = crate::lower::emit::emit_module(&analyzed.spec, &plan, m)?; // Every driver compiles each repeated region of the entry again; above the measured size, // repeated regions are written once, as a loop. crate::spirv::roll::roll_entry(&mut emitted.module, m)?; if !bounded || crate::spirv::roll::entry_weight(&emitted.module, m)? <= weight_cap { - return Ok((planned, emitted)); + return Ok((analyzed.planned(plan, kernel), emitted)); } - if widest == WidestPin::Kept || !planned.plan.families.simd.widest_pin { + if widest == WidestPin::Kept || !plan.families.simd.widest_pin { return Err(Unsupported::driver_defect(Feature::StageSize, defect).into()); } - // The emulated module goes, and with it what its emission holds of the ledger. - drop(emitted); + // The emulated plan and module go, and with them what they hold of the ledger. + drop((plan, emitted)); let held = m.ledger().saturating_sub(before); m.release(usize::try_from(held).unwrap_or(usize::MAX)); widest = WidestPin::Kept; diff --git a/crates/metal2vulkan/src/tests/engine_simd_lockstep.rs b/crates/metal2vulkan/src/tests/engine_simd_lockstep.rs index b5ecf9f25..56fd47643 100644 --- a/crates/metal2vulkan/src/tests/engine_simd_lockstep.rs +++ b/crates/metal2vulkan/src/tests/engine_simd_lockstep.rs @@ -2386,6 +2386,103 @@ fn a_kernel_past_the_stage_bound_keeps_the_widest_pin_or_is_refused() { } } +/// One input, one answer, whichever path compiles it: on the Iris Xe, the pressured kernel of +/// `a_kernel_past_the_stage_bound_keeps_the_widest_pin_or_is_refused`, past a bound its emulated +/// module passes (planned again keeping the pin) and past one its pinned module passes too +/// (refused, `Feature::StageSize`), is charged the same work units compiled alone +/// (`Device::compile_function`) and compiled from a creation's entries +/// (`Device::compile_function_from_entries`), whether the entry there was made or found. So at +/// exactly that many work units both paths give the bound's answer, and at one fewer both are +/// refused at the work cap. The plan made again selects from the entry's one analysis: a meter +/// that is also charged one more plan of the entry, as the plan made again once charged, is +/// refused at the cap where the compile alone answers. +#[test] +fn a_kernel_past_the_stage_bound_gets_one_answer_through_either_path() { + use crate::device::Device; + use crate::error::{Feature, Limit, Unsupported}; + use crate::library::Library; + use crate::lower::simd::{WIDEST_PIN_FLOOR, WIDEST_PIN_WORDS}; + use crate::pipeline::compile::{ + compile_bitcode_bounded, compile_stage_bounded, plan_bitcode, StageEntries, + }; + use crate::pipeline::testing::meter; + use crate::pipeline::FunctionDescriptor; + use crate::spirv::roll::entry_weight; + let fan = Padding::Fan((WIDEST_PIN_FLOOR / 2 + 16).max(WIDEST_PIN_WORDS as usize + 8)); + let Some(bc) = assemble("device_half", &device_half_padded(fan, None)) else { + return; + }; + let iris_desc = crate::pipeline::testing::description("intel-irisxe-rplp-anv").unwrap(); + let iris = Device::new(iris_desc, DevicePolicy::default()).unwrap(); + let iris = iris.profile(); + let library = Library::from_air(&bc).expect("library"); + let fd = FunctionDescriptor::new(library.function("device_half").expect("the kernel")); + let weight = |cap| { + let compiled = + compile_bitcode_bounded(&bc, EntryRef::Name("device_half"), iris, &mut meter(), cap); + let (_, _, module) = compiled.expect("compiled"); + entry_weight(&module, &mut meter()).expect("weight") + }; + let emulated = weight(u64::MAX); + let pinned = weight(emulated - 1); + assert!(pinned < emulated, "pinned {pinned}, emulated {emulated}"); + // Its answer, as a planned-again `Direct` module's word count or the refusal's feature. + let answer = |compiled: Result| match compiled { + Ok(c) => Ok(c.artifact().module.words.len()), + Err(Error::Unsupported(Unsupported { feature, .. })) => Err(Ok(feature)), + Err(Error::LimitExceeded(limit)) => Err(Err(limit)), + Err(e) => panic!("{e:?}"), + }; + let capped = |work| Meter::with_caps(&Budget::default(), work, crate::budget::LEDGER_BYTES); + for (cap, planned_again) in [(emulated - 1, true), (pinned - 1, false)] { + // The work units each path is charged: alone, from entries that make the entry, and from + // the same entries again, which find it. + let entries = StageEntries::new(); + let work = |entries: Option<&StageEntries>| { + let mut m = meter(); + let got = answer(compile_stage_bounded(&fd, iris, entries, &mut m, cap)); + (got, m.work()) + }; + let (alone, made, found) = (work(None), work(Some(&entries)), work(Some(&entries))); + assert_eq!(entries.counts(), (1, 1), "made once, then found"); + let (want, w) = alone.clone(); + match &want { + Ok(_) => assert!(planned_again, "{want:?}"), + Err(refused) => assert_eq!(*refused, Ok(Feature::StageSize)), + } + assert_eq!( + (made, found), + ((want.clone(), w), (want.clone(), w)), + "bound {cap}" + ); + // At exactly that many work units, the bound's answer through both paths; at one fewer, + // the work cap's through both. + for (budget, expected) in [(w, want.clone()), (w - 1, Err(Err(Limit::WorkUnits)))] { + for via in [None, Some(&entries)] { + let mut m = capped(budget); + let got = answer(compile_stage_bounded(&fd, iris, via, &mut m, cap)); + let shared = via.is_some(); + assert_eq!( + got, expected, + "bound {cap}, {budget} work units, shared {shared}" + ); + } + } + // The negative control: one more plan of the entry charged first, as the plan made again + // once charged it, is past the cap the compile alone answers within. + let mut m = capped(w); + let consts = FunctionConstantValues::defaults(); + let entry = EntryRef::Name("device_half"); + plan_bitcode(&bc, entry, &consts, iris, &LowerInputs::new(), &mut m).expect("planned"); + let got = answer(compile_stage_bounded(&fd, iris, None, &mut m, cap)); + assert_eq!( + got, + Err(Err(Limit::WorkUnits)), + "bound {cap}, charged twice" + ); + } +} + /// Texture calls take no device barrier: their pointer is the texture's handle. #[test] fn texture_calls_take_no_device_barrier() { diff --git a/crates/metal2vulkan/src/tests/library_entries_decode_once.rs b/crates/metal2vulkan/src/tests/library_entries_decode_once.rs index 35e080ead..5cb53ffc6 100644 --- a/crates/metal2vulkan/src/tests/library_entries_decode_once.rs +++ b/crates/metal2vulkan/src/tests/library_entries_decode_once.rs @@ -26,6 +26,10 @@ //! taken for another ([`two_libraries_decode_their_modules_apart`]). //! - **The same module, word for word.** Every entry compiled from a shared decode is the module //! its own unshared compile makes, word for word, and its artifact is byte for byte the same. +//! - **The same charge, unit for unit.** Every entry compiled from a shared decode is charged the +//! work units its own unshared compile is charged, the decode it copied included: the object +//! spares the decode's time and never its budget, so a refusal at the work cap is the same +//! through either. //! - **The hash is the library's, not a second one.** A compile records its function's AIR hash //! from the library's table rather than hashing the bitcode again, which is exact because a //! module's hash is the hash of the bytes every entry of it shares, and a metallib function's @@ -197,14 +201,15 @@ fn the_entries_of_one_library_decode_its_module_once() { ); } - // The decode is work the shared compiles do not do: every entry past the first costs fewer - // work units than the same entry compiled with an object of its own. - for (i, fd) in stages.iter().enumerate().skip(1) { - let (shared, apart) = (shared_work[i], apart_work[i]); - assert!( - shared < apart, - "entry {} must cost fewer work units reading a shared decode than reading its own: \ - {shared} against {apart}", + // A copied decode is charged what reading it charged: every entry costs the work units of + // its own unshared compile, through a shared decode or one of its own. + for (i, fd) in stages.iter().enumerate() { + let (shared, apart, own) = (shared_work[i], apart_work[i], alone[i].2); + assert_eq!( + (shared, apart), + (own, own), + "entry {} must cost the work units of its own compile, {own}, reading a shared \ + decode ({shared}) and reading its own ({apart})", fd.function.info().name ); } diff --git a/crates/metal2vulkan/src/tests/stage_input_siblings.rs b/crates/metal2vulkan/src/tests/stage_input_siblings.rs index 6e077df1c..7cb76bea5 100644 --- a/crates/metal2vulkan/src/tests/stage_input_siblings.rs +++ b/crates/metal2vulkan/src/tests/stage_input_siblings.rs @@ -20,7 +20,8 @@ //! specialization, which its stage-input descriptor does not decide: a [`StageEntries`] shared //! between the siblings decodes and specializes the kernel **once** and spares every later one, //! and compiles the same module from it, where one object a sibling decodes once a sibling -//! ([`a_sweeps_siblings_share_one_decode`]). +//! ([`a_sweeps_siblings_share_one_decode`]). What it spares is time and not budget: each +//! sibling is charged the work units of its own unshared compile, the entry it found included. //! //! A render creation gives one such object to its checks, its keys and its compiles; a compute //! creation gives none ([`Device::compile_function`] rather than @@ -324,22 +325,16 @@ fn a_sweeps_siblings_share_one_decode() { "{n} siblings with an object each must decode the kernel {n} times" ); - // What the decodes the sharing spares are worth, in the one quantity no load touches. The - // first sibling pays the decode in both forms; the later ones pay it only apart. - let later_shared: u64 = shared_work[1..].iter().sum(); - let later_apart: u64 = apart_work[1..].iter().sum(); - assert!( - later_shared < later_apart, - "the siblings after the first must cost less work from a shared entry than from one \ - each: {later_shared} work units against {later_apart}" - ); - let plain_total: u64 = plain.iter().map(|(_, _, work)| work).sum(); - eprintln!( - "work units over {n} siblings: {plain_total} compiled as the creation path compiles them, \ - {} from a shared entry (first {}, later {later_shared} against {later_apart})", - shared_work.iter().sum::(), - shared_work[0], - ); + // A found entry is charged what making it charged: every sibling costs the work units of its + // own unshared compile, from the shared entry or from one of its own. + for (at, (format, _, plain)) in plain.iter().enumerate() { + assert_eq!( + (shared_work[at], apart_work[at]), + (*plain, *plain), + "a sibling must cost the work units of its own compile, {plain}, from a shared entry \ + and from one of its own ({format:?})" + ); + } // The entries are told apart by the kernel and its depth alone, never by the stage input, so // the sweep's siblings are one entry and not thirty-two: the object holds one. let held = format!("{shared:?}"); diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 1508e204c..b7d4c3f72 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -7924,13 +7924,16 @@ method metal2vulkan-air::budget::Meter::charge pub fn charge(&mut self, bytes: u method metal2vulkan-air::budget::Meter::grow pub fn grow(&mut self, v: &mut Vec, additional: usize) -> Result<(), Error> method metal2vulkan-air::budget::Meter::ledger pub fn ledger(&self) -> u64 method metal2vulkan-air::budget::Meter::ledger_peak pub fn ledger_peak(&self) -> u64 +method metal2vulkan-air::budget::Meter::measured pub fn measured(&mut self, f: impl FnOnce(&mut Meter) -> Result) -> Result<(T, Spent), E> method metal2vulkan-air::budget::Meter::new pub fn new(budget: &Budget) -> Meter method metal2vulkan-air::budget::Meter::release pub fn release(&mut self, bytes: usize) method metal2vulkan-air::budget::Meter::reserve pub fn reserve(&mut self, v: &mut Vec, additional: usize) -> Result<(), Error> method metal2vulkan-air::budget::Meter::reserve_exact pub fn reserve_exact(&mut self, v: &mut Vec, additional: usize) -> Result<(), Error> +method metal2vulkan-air::budget::Meter::spend pub fn spend(&mut self, spent: Spent) -> Result<(), Error> method metal2vulkan-air::budget::Meter::tick pub fn tick(&mut self, units: u32) -> Result<(), Error> method metal2vulkan-air::budget::Meter::with_caps pub fn with_caps(budget: &Budget, work_cap: u64, byte_cap: u64) -> Meter method metal2vulkan-air::budget::Meter::work pub fn work(&self) -> u64 +method metal2vulkan-air::budget::Spent::held pub fn held(&self) -> u64 method metal2vulkan-air::canon::CommandWrites::is_empty pub const fn is_empty(self) -> bool method metal2vulkan-air::canon::CommandWrites::may pub const fn may(self, bits: u32) -> bool method metal2vulkan-air::canon::CommandWrites::may_draw_primitive_type pub const fn may_draw_primitive_type(self, raw: u32) -> bool @@ -10112,6 +10115,7 @@ struct metal2vulkan-air::budget::Budget #[derive(Clone, Debug, Default)] #[non_e struct metal2vulkan-air::budget::CancelToken #[derive(Clone, Debug, Default)] pub struct CancelToken(Arc) struct metal2vulkan-air::budget::Growth #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct Growth struct metal2vulkan-air::budget::Meter #[derive(Debug)] pub struct Meter +struct metal2vulkan-air::budget::Spent #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct Spent struct metal2vulkan-air::canon::CallStack #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct CallStack struct metal2vulkan-air::canon::CommandWrites #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub struct CommandWrites struct metal2vulkan-air::canon::ConstantRead #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct ConstantRead diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index f8264cefd..0df6f5ac8 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -658,7 +658,7 @@ Each refusal's sites, with the function that builds it. - `feature::RayTracing`: `crates/metal2vulkan/src/bind/acceleration.rs (instance_record, 2 sites)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (instance_count)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (intersect, 5 sites)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (primitive_data_read)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (select_param)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (slot_of)`; `crates/metal2vulkan/src/lower/select.rs (route_air)` - `feature::Tensors`: `crates/metal2vulkan-air/src/canon/matmul2d/synth.rs (refuse)`; `crates/metal2vulkan/src/lower/select.rs (route_air)` - `feature::RasterizationRateMap`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (check_limits)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (fan_plan, 3 sites)` -- `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/flat.rs (flat_dispatch_module)`; `crates/metal2vulkan/src/bind/replay/merged.rs (draw_merge_module)`; `crates/metal2vulkan/src/lower/access/encode.rs (needs, 2 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 (plan_one, 2 sites)` +- `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/flat.rs (flat_dispatch_module)`; `crates/metal2vulkan/src/bind/replay/merged.rs (draw_merge_module)`; `crates/metal2vulkan/src/lower/access/encode.rs (needs, 2 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 (with_deviations)` - `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)`