rt: a kernel past the stage bound is made from its helper's compile alone, never compiled in the process
A driver's compiler takes memory that grows faster than the stage, in the process that creates the pipeline. The translator refused every stage past COMPILED_STAGE_WEIGHT (99,109, the heaviest measured to compile within host-sized memory, ANV on the Iris Xe of RPL-P), where Metal makes it. Now the translator states the weight and the runtime compiles such a kernel only in a helper process the consumer starts, caps and times. Translator: the stage bound refuses nothing. stage_bound::emit still plans a kernel again keeping its widest-mode pin where only that emulation passed the bound, and returns the module with its entry weight, now ModuleStats::entry_weight (codec and serde carry it). COMPILED_STAGE_WEIGHT is public in pipeline. Feature::StageSize and Needs::StageBound are gone. SEMANTICS_VERSION 2257, ARTIFACT_FORMAT_VERSION 588. Runtime (new stage.rs): - Floor: pipelineCreationCacheControl, required and enabled (Vulkan 1.3 requires it), for VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT. - A kernel's VkPipeline of a module past the bound is made from a VkPipelineCache of its own entry in the cache directory's stages/ alone, with the fail-on-compile-required flag, the cache destroyed when the create returns; the device's shared cache and blob never hold it (Metrics::pipelines_from_stage_fills). - With no entry the make is refused with Error::StageUnfilled(StageRequest), at the state's creation, at prepare_dispatch (which now returns Result and reports only this refusal) and at the dispatch. A StageRequest is Clone, Send, Sync, Eq and Hash by its stage key, the entry's name, so a consumer joins the makes and dispatches of one pipeline into one fill. - Device::fill_stage writes the request to the helper's pipe, reads its reply and keeps the cache data as the entry (Metrics::stage_fills); serve_stage is the helper's main: it opens the device of the request's deviceUUID and driverUUID with the parent's options, checks the enables, compiles through an empty cache and writes its data. A wire frame is the magic m2vstage, the wire version, the length and a checksum. - Device::record_stage_breach keeps what the consumer ended its helper for (memory, time) as the entry; fill_stage keeps a failed compile; a create answered compile-required keeps that. Each refuses the pipeline (Gap::StageSize, StageGap::Breach) with no helper asked again, until the driver's header changes the key. - stages/ holds at most 256 MiB and 32 entries, breaches among them, least recently used out first (a hit touches the file). An entry that does not check, of another key or another driver's header is a miss and is removed. Nothing of an entry stays in memory past the call that reads or writes it. - A device with no cache directory, or whose driver writes no pipeline cache header (lavapipe), and a render stage past the bound are refused typed (Gap::StageSize with its StageGap). The validation runtime executor reports a refused prepare_dispatch; the replay prepass ignores it as the dispatch reports it again. Docs: the runtime README's "Kernels past the stage bound" and its known gaps, the stages/ directory, prepare_dispatch's one error, the floor row; docs/API.md's entry_weight; docs/REFUSALS.md regenerated; the api signature and surface tables. Tests: tests/stage.rs: the directory past capacity on both bounds, oldest use out first, a hit outliving older entries, a breach under the same bounds; cut, foreign-key, other-header and unknown-breach entries a miss and removed; the wire's version and cut frames; the request's joinable bounds; and on a device (m2v_gpu, m2v_cpu_icd), with the bound lowered for the test, the refusal with no directory, lavapipe's NoPipelineCache, and elsewhere refused unfilled, filled by serve_stage over two pipes, made from the entry alone with the shared cache's data unchanged, then refused by a recorded breach.
This commit is contained in:
1 parent
e6e70666ed
commit
c3f9f55e63
38 files changed
+1591
-199
No files matched your search
@@ -23,6 +23,8 @@ path = "src/lib.rs"
|
||||
ash = { workspace = true, features = ["std", "loaded"] }
|
||||
# The translator: Metal AIR to SPIR-V, through its public API only.
|
||||
metal2vulkan = { version = "=0.2.0", path = "../metal2vulkan", features = ["ash"] }
|
||||
# The stage keys of kernels past the stage bound, and the digest of a device's enables.
|
||||
sha2.workspace = true
|
||||
|
||||
# The host clock of command buffer times, and the ids of the runtime's threads, on unix.
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
|
||||
@@ -2423,7 +2423,9 @@ while the driver's exit handler waited on a lock, with every runtime thread alre
|
||||
own variant's make, a first-use wait. The call makes nothing where the dispatch would refuse
|
||||
its threadgroup size, its variant or its threadgroup memory, or would record nothing (a grid
|
||||
with no threads, a kernel that writes no memory), and reports no error: the dispatch reports
|
||||
its own. What the dispatch checks of the encoder's bindings is not checked. A make that failed
|
||||
its own. The one error it reports is a make refused for the stage bound (`Error::StageUnfilled`,
|
||||
or `Gap::StageSize`; Kernels past the stage bound, below), which the dispatch reports too until
|
||||
the consumer's helper fills the entry. What the dispatch checks of the encoder's bindings is not checked. A make that failed
|
||||
is made again by the next call or dispatch that needs it. What a dispatch records is the same
|
||||
whether or not its pipeline was made ahead. `Metrics::made_ahead_variants` counts what the
|
||||
calls made, with their time in `made_ahead_variant_nanos`.
|
||||
@@ -2520,6 +2522,9 @@ the lowerings from one device to the next:
|
||||
longer holds is a miss too, counted (`Metrics::render_records_stale`): the state decodes,
|
||||
specializes and lowers as with no record, and keeps the record again. Records are written and
|
||||
counted as lowerings are, within the cap below.
|
||||
- `stages/`: the cache data of each `VkPipeline` of a kernel past the stage bound, one file per
|
||||
pipeline, which the consumer's helper compiled (Kernels past the stage bound, below). At most
|
||||
256 MiB and 32 files, apart from the blobs and the lowerings' cap.
|
||||
|
||||
**The pipeline cache.** The reaper makes an empty cache first when it starts, which a creation that
|
||||
comes before it waits for (microseconds). Then, off every guest thread, it reads the blob, makes a
|
||||
@@ -2591,6 +2596,52 @@ write, a full disk included, is a miss too, and never fails a call; in a directo
|
||||
read and not write, its hits stay where they are and it writes nothing. A `state` that is missing
|
||||
or does not check is rebuilt from the generations' names, with young counted full.
|
||||
|
||||
### Kernels past the stage bound
|
||||
|
||||
A driver's compiler takes memory that grows faster than the stage, in the process that creates the
|
||||
pipeline. The translator states each module's entry weight (`ModuleStats::entry_weight`: the
|
||||
entry's instructions, each call counted as its callee's body); `COMPILED_STAGE_WEIGHT`, 99,109, is
|
||||
the heaviest measured to compile within host-sized memory on the slowest compiler measured (ANV,
|
||||
Mesa 26.2.6, on the Iris Xe of RPL-P: 132 s and a 3.65 GiB peak resident set; one of 532,213 passed
|
||||
16 GiB). No Vulkan query states how large a stage a device's compiler takes, so the bound is one
|
||||
for every device. A kernel past it is never compiled in the process that runs the program: each
|
||||
of its `VkPipeline`s is compiled in a helper process the consumer starts, caps and times, and is
|
||||
created here from that compile's cache data alone.
|
||||
|
||||
- The make of such a `VkPipeline` (at the state's creation, a `prepare_dispatch` call or a
|
||||
dispatch) reads the pipeline's entry under `stages/` in the cache directory. With data, it
|
||||
makes a `VkPipelineCache` of that entry alone, creates the pipeline through it with
|
||||
`VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT`, and destroys the cache: the
|
||||
device's own pipeline cache and its blob never hold it. `Metrics::pipelines_from_stage_fills`
|
||||
counts these creates, which `pipelines_created` counts too.
|
||||
- With no entry, the make is refused with `Error::StageUnfilled`, carrying a `StageRequest`. Two
|
||||
requests of one pipeline compare equal and hash alike (by the pipeline's stage key, the name of
|
||||
its entry), so a consumer joins the makes, the `prepare_dispatch` calls and the dispatches that
|
||||
meet one pipeline into one helper run. The consumer starts its helper process, whose main calls
|
||||
`serve_stage` with an instance made as its own process's and the `DeviceOptions` the device was
|
||||
opened with, and hands the helper's two pipes to `Device::fill_stage` on a thread of its own.
|
||||
That call writes the request, reads the helper's cache data and keeps it as the entry
|
||||
(`Metrics::stage_fills`); the make then succeeds when asked again. A request holds the module's
|
||||
words, the pipeline's entry point, specialization and pinned subgroup size, and the device's
|
||||
`deviceUUID`, `driverUUID`, pipeline cache header and enables, so the helper opens the same
|
||||
device with the same features; a helper whose device differs is answered `StageFill::NoDevice`
|
||||
or `StageFill::Enables`, and one of another build of the runtime `StageFill::Version`.
|
||||
- rt starts, caps, times and kills no process. A consumer that ends its helper for its memory cap
|
||||
or its time limit keeps that with `Device::record_stage_breach` (`StageBreach::Memory`,
|
||||
`StageBreach::Time`); a compile the driver failed is kept as `StageBreach::Compile` by
|
||||
`fill_stage`. A breach is an entry of the same directory, and refuses the pipeline's makes
|
||||
(`Gap::StageSize`, `StageGap::Breach`) with no helper asked again. So does cache data the driver
|
||||
answers compile-required for (`StageBreach::CompileRequired`): it is not filled a second time.
|
||||
The stage key holds the driver's pipeline cache header, so a new driver version asks again.
|
||||
- The entries are files of the cache directory only: nothing of an entry stays in memory past
|
||||
the call that reads or writes it. Each holds its key again under a magic, its length and its
|
||||
checksum; one that does not check, names another key or holds data that does not begin with the
|
||||
device's header is a miss and is removed. A hit marks its file used. `stages/` holds at most
|
||||
256 MiB and 32 entries; each write removes the entries past that, the least recently used first.
|
||||
- A device with no cache directory, and one whose driver writes no pipeline cache header
|
||||
(lavapipe in Mesa 26.2.4), keeps no entry: the make is refused (`Gap::StageSize`,
|
||||
`StageGap::NoCacheDirectory` or `StageGap::NoPipelineCache`).
|
||||
|
||||
### Known gaps of pipeline states
|
||||
|
||||
- A narrow integer's high bits (an 8- or 16-bit value held in a 32-bit word) are cleared by
|
||||
@@ -2783,12 +2834,12 @@ or does not check is rebuilt from the generations' names, with young counted ful
|
||||
- NVIDIA 615.71.09 on GA10x gives sign-extended bits for a mask over a signed clamp, to exactly N
|
||||
bits' range, of a sum or difference of two values sign-extended from N bits; not reproduced on
|
||||
620.70.06.
|
||||
- A kernel whose translated entry weighs more than 99,109 instructions (each call counted as its
|
||||
callee's body) is made on no device: that is the heaviest stage measured to compile within
|
||||
host-sized memory on the slowest compiler measured (ANV, Mesa 26.2.6, on the Iris Xe of RPL-P).
|
||||
One that emulated its SIMD groups only in place of the 32-lane pin is translated again pinned,
|
||||
and every other is refused (`Error::Translation`: `Feature::StageSize`, `Needs::StageBound`)
|
||||
where Metal makes it.
|
||||
- A kernel past the stage bound is made only from its helper's compile (Kernels past the stage
|
||||
bound, above). On a device with no cache directory, or whose driver writes no pipeline cache
|
||||
header (lavapipe in Mesa 26.2.4), on a driver that answers compile-required for its helper's
|
||||
cache data, and where the helper passed the consumer's cap or time, it is refused
|
||||
(`Gap::StageSize`) where Metal makes it. A dispatch of it waits for the consumer's helper, where
|
||||
Metal compiles in the program's process.
|
||||
- A loop asks the driver nothing about unrolling unless its AIR does (`#pragma unroll`,
|
||||
`#pragma nounroll`) or the translator wrote the loop itself (`DontUnroll`), so the driver's
|
||||
choice decides, and it can differ from Metal's compiler's. RADV (Mesa 26.2.6) unrolls a
|
||||
@@ -2966,6 +3017,9 @@ or does not check is rebuilt from the generations' names, with young counted ful
|
||||
|
||||
### Known gaps of render pipeline states
|
||||
|
||||
- A render pipeline whose vertex or fragment stage weighs more than the stage bound (Kernels past
|
||||
the stage bound) is refused (`Gap::StageSize`, `StageGap::RenderStage`) where Metal makes it: no
|
||||
helper compiles a render stage.
|
||||
- Refused at creation by `Gap::RenderPipeline`, naming its `RenderPipelineKind`: depth and
|
||||
stencil attachment formats that differ, as of separate depth and stencil textures
|
||||
(`DepthStencilFormats`: Vulkan's pipeline takes one format for both,
|
||||
@@ -3954,6 +4008,7 @@ Presenting runs on the runtime's own device; nothing is exported or imported.
|
||||
| `hostQueryReset` | `VkPhysicalDeviceVulkan12Features` | a command buffer's timestamp queries reset on the host as it retires |
|
||||
| `synchronization2` | `VkPhysicalDeviceVulkan13Features` | barriers, layout changes and submission |
|
||||
| `dynamicRendering` | `VkPhysicalDeviceVulkan13Features` | render passes |
|
||||
| `pipelineCreationCacheControl` | `VkPhysicalDeviceVulkan13Features` | a kernel past the stage bound created from its helper's cache data alone, never compiled in the process (Kernels past the stage bound); Vulkan 1.3 requires it |
|
||||
|
||||
### Portability features
|
||||
|
||||
|
||||
@@ -611,7 +611,7 @@ fn write_at(file: &File, buf: &[u8]) -> io::Result<()> {
|
||||
|
||||
/// The bytes of the file at `path`, where they are `len` long (any length with none); `None`
|
||||
/// where they are not.
|
||||
fn read_whole(path: &Path, len: Option<u64>) -> io::Result<Option<Vec<u8>>> {
|
||||
pub(crate) fn read_whole(path: &Path, len: Option<u64>) -> io::Result<Option<Vec<u8>>> {
|
||||
let mut opened = File::open(path)?;
|
||||
let held = opened.metadata()?.len();
|
||||
if len.is_some_and(|len| len != held) {
|
||||
@@ -671,7 +671,7 @@ pub(crate) fn prune_blobs(dir: &Path, own: &str) {
|
||||
|
||||
/// Writes `parts`, one after another, to `path` through a temporary file beside it, named for this
|
||||
/// process and this write, then renamed over it.
|
||||
fn write_whole(path: &Path, parts: &[&[u8]]) -> io::Result<()> {
|
||||
pub(crate) fn write_whole(path: &Path, parts: &[&[u8]]) -> io::Result<()> {
|
||||
static WRITES: AtomicU64 = AtomicU64::new(0);
|
||||
let mut temp = path.as_os_str().to_owned();
|
||||
temp.push(format!(
|
||||
@@ -798,6 +798,9 @@ pub(crate) struct Caches {
|
||||
dir: Option<PathBuf>,
|
||||
/// The device's blob in it, named once the reaper has read the device's header.
|
||||
blob: OnceLock<PathBuf>,
|
||||
/// The pipeline cache header the device's driver writes ([`usable_header`]), set before the
|
||||
/// reaper makes the cache; unset where the driver writes none.
|
||||
header: OnceLock<[u8; 32]>,
|
||||
pipelines: Mutex<Pipelines>,
|
||||
/// Signalled once the reaper made the cache.
|
||||
made: Condvar,
|
||||
@@ -1102,6 +1105,7 @@ impl Caches {
|
||||
store: dir.map(|dir| Store::open(dir.to_owned(), cap, counters.clone())),
|
||||
dir: dir.map(Path::to_owned),
|
||||
blob: OnceLock::new(),
|
||||
header: OnceLock::new(),
|
||||
pipelines: Mutex::new(Pipelines {
|
||||
made: false,
|
||||
seeding: false,
|
||||
@@ -1247,6 +1251,23 @@ impl Caches {
|
||||
)
|
||||
}
|
||||
|
||||
/// The cache directory, where the device has one.
|
||||
pub(crate) fn dir(&self) -> Option<&Path> {
|
||||
self.dir.as_deref()
|
||||
}
|
||||
|
||||
/// The pipeline cache header the device's driver writes ([`usable_header`]), once the reaper
|
||||
/// made the device's cache, which the calling thread waits for (microseconds, at the device's
|
||||
/// start); none where the driver writes none.
|
||||
pub(crate) fn header(&self) -> Option<[u8; 32]> {
|
||||
let mut pipelines = lock(&self.pipelines);
|
||||
while !pipelines.made {
|
||||
pipelines = (self.made.wait(pipelines)).unwrap_or_else(PoisonError::into_inner);
|
||||
}
|
||||
drop(pipelines);
|
||||
self.header.get().copied()
|
||||
}
|
||||
|
||||
fn translation_file(key: &[u8]) -> String {
|
||||
format!("{TRANSLATIONS}/{}", hex(key))
|
||||
}
|
||||
@@ -1345,6 +1366,9 @@ impl Caches {
|
||||
// SAFETY: the cache is the device's.
|
||||
let size = empty.map_or(0, |cache| unsafe { data_size(device, cache) });
|
||||
counters.set(Gauge::PipelineCacheBytes, size);
|
||||
if let Some(header) = header {
|
||||
let _ = self.header.set(header);
|
||||
}
|
||||
let mut pipelines = lock(&self.pipelines);
|
||||
pipelines.current = empty.map(|cache| Arc::new(PipelineCache(cache)));
|
||||
pipelines.written = size;
|
||||
|
||||
@@ -256,10 +256,14 @@ pub(crate) enum Metric {
|
||||
Resolves,
|
||||
/// [`Metrics::preprocess_regions_remade`].
|
||||
PreprocessRegionsRemade,
|
||||
/// [`Metrics::stage_fills`].
|
||||
StageFills,
|
||||
/// [`Metrics::pipelines_from_stage_fills`].
|
||||
PipelinesFromStageFills,
|
||||
}
|
||||
|
||||
/// The number of [`Metric`]s.
|
||||
const METRICS: usize = Metric::PreprocessRegionsRemade as usize + 1;
|
||||
const METRICS: usize = Metric::PipelinesFromStageFills as usize + 1;
|
||||
|
||||
/// Every [`Metric`], in its order: each at its own index.
|
||||
const METRIC_ORDER: [Metric; METRICS] = [
|
||||
@@ -299,6 +303,8 @@ const METRIC_ORDER: [Metric; METRICS] = [
|
||||
Metric::SparseBinds,
|
||||
Metric::Resolves,
|
||||
Metric::PreprocessRegionsRemade,
|
||||
Metric::StageFills,
|
||||
Metric::PipelinesFromStageFills,
|
||||
];
|
||||
|
||||
// Each metric of the order is at its own index.
|
||||
@@ -660,6 +666,8 @@ struct Atomics {
|
||||
sparse_binds: AtomicU64,
|
||||
resolves: AtomicU64,
|
||||
preprocess_regions_remade: AtomicU64,
|
||||
stage_fills: AtomicU64,
|
||||
pipelines_from_stage_fills: AtomicU64,
|
||||
/// Each [`Part`]'s calls, at its index: their count, bytes, total and longest nanoseconds,
|
||||
/// and those over each of [`OVER_NANOS`].
|
||||
parts: [[AtomicU64; 7]; PARTS],
|
||||
@@ -806,6 +814,8 @@ impl Counters {
|
||||
Metric::SparseBinds => &a.sparse_binds,
|
||||
Metric::Resolves => &a.resolves,
|
||||
Metric::PreprocessRegionsRemade => &a.preprocess_regions_remade,
|
||||
Metric::StageFills => &a.stage_fills,
|
||||
Metric::PipelinesFromStageFills => &a.pipelines_from_stage_fills,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1628,6 +1638,8 @@ impl Counters {
|
||||
sparse_binds: a.sparse_binds.load(Relaxed),
|
||||
resolves: a.resolves.load(Relaxed),
|
||||
preprocess_regions_remade: a.preprocess_regions_remade.load(Relaxed),
|
||||
stage_fills: a.stage_fills.load(Relaxed),
|
||||
pipelines_from_stage_fills: a.pipelines_from_stage_fills.load(Relaxed),
|
||||
takes: part(Part::Take),
|
||||
take_lock_waits: part(Part::TakeLock),
|
||||
take_makes: part(Part::TakeMake),
|
||||
@@ -2425,6 +2437,15 @@ pub struct Metrics {
|
||||
/// within a second after the device freed an idle one past its bound of idle regions (128
|
||||
/// MiB): regions given back and made again, each at its own `vkAllocateMemory`.
|
||||
pub preprocess_regions_remade: u64,
|
||||
/// No Metal counterpart: cache data of kernels past the stage bound that
|
||||
/// [`Device::fill_stage`](crate::Device::fill_stage) took from the consumer's helper and kept
|
||||
/// in the cache directory, one entry each.
|
||||
pub stage_fills: u64,
|
||||
/// No Metal counterpart: `VkPipeline`s of kernels past the stage bound made from their
|
||||
/// entries' cache data alone, with `VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT`,
|
||||
/// so the driver compiled nothing for them in this process. Each is counted in
|
||||
/// [`pipelines_created`](Self::pipelines_created) too.
|
||||
pub pipelines_from_stage_fills: u64,
|
||||
/// Takes from the pool on the consumer's threads, each whole: a block of
|
||||
/// [`Device::take_block`](crate::Device::take_block) and a texture block, carved from a free
|
||||
/// range or from an allocation the take made ([`take_makes`](Self::take_makes)); their bytes
|
||||
|
||||
@@ -1458,6 +1458,23 @@ pub(crate) struct EncoderLimits {
|
||||
}
|
||||
|
||||
impl Core {
|
||||
/// A digest of what the device enabled: its extensions, the consumer's features and the
|
||||
/// translator's profile of the device (its features, properties and limits). Two devices of
|
||||
/// one physical device opened with the same [`DeviceOptions`] have one; the stage keys and a
|
||||
/// helper's device check it (`crate::stage`).
|
||||
pub(crate) fn enables(&self) -> [u8; 32] {
|
||||
use sha2::{Digest, Sha256};
|
||||
let mut h = Sha256::new();
|
||||
for name in &self.extensions {
|
||||
h.update(name.as_bytes_with_nul());
|
||||
}
|
||||
for feature in &self.consumer_features {
|
||||
h.update(format!("{feature:?};"));
|
||||
}
|
||||
h.update(self.translator.profile().fingerprint());
|
||||
h.finalize().into()
|
||||
}
|
||||
|
||||
/// The most bytes a dispatch's slots of the private arena take: the device's
|
||||
/// ([`EncoderLimits::arena_budget`]), or in a device test the one the test set.
|
||||
pub(crate) fn arena_budget(&self) -> u64 {
|
||||
|
||||
@@ -73,6 +73,13 @@ pub enum Error {
|
||||
},
|
||||
/// A Metal feature the runtime does not build yet: a typed known gap.
|
||||
Unsupported(Gap),
|
||||
/// [`Device::new_compute_pipeline_state`](crate::Device::new_compute_pipeline_state), a
|
||||
/// dispatch, or [`ComputePipelineState::prepare_dispatch`](crate::ComputePipelineState::prepare_dispatch):
|
||||
/// a `VkPipeline` of a kernel past the stage bound whose cache data the cache directory does
|
||||
/// not hold, which this process never compiles. The consumer's helper compiles it
|
||||
/// ([`Device::fill_stage`](crate::Device::fill_stage)), and the call is made again. Metal has no
|
||||
/// counterpart: Metal compiles every pipeline in its own compiler service.
|
||||
StageUnfilled(crate::StageRequest),
|
||||
/// A call that needs one of the runtime's threads, after
|
||||
/// [`Device::quiesce`](crate::Device::quiesce) stopped them. Metal has no counterpart.
|
||||
Quiesced,
|
||||
@@ -1322,6 +1329,42 @@ pub enum Gap {
|
||||
/// What the pass sets beside the plane, or into it.
|
||||
kind: LinearPlanePassKind,
|
||||
},
|
||||
/// A pipeline of a function whose module weighs more than the compiled stage bound
|
||||
/// (`metal2vulkan::pipeline::COMPILED_STAGE_WEIGHT`, the heaviest measured to compile within
|
||||
/// host-sized memory), which this process never compiles, that the device does not make:
|
||||
/// what `cause` names. A kernel's `VkPipeline` is made from its helper's cache data alone
|
||||
/// ([`Device::fill_stage`](crate::Device::fill_stage)). Metal's counterpart is the pipeline
|
||||
/// state's make, which Metal's compiler service compiles.
|
||||
///
|
||||
/// Basis: device (ANV, Mesa 26.2.6, took 3.65 GiB to compile a stage of entry weight 99,109
|
||||
/// and passed 16 GiB on one of 532,213; a driver whose helper's compile met its cap or time,
|
||||
/// or that keeps no pipeline cache data, gives no data to make the pipeline from).
|
||||
StageSize {
|
||||
/// The heaviest stage's entry weight (`ModuleStats::entry_weight`).
|
||||
weight: u64,
|
||||
/// Why it is not made.
|
||||
cause: StageGap,
|
||||
},
|
||||
}
|
||||
|
||||
/// Why a pipeline past the stage bound is not made ([`Gap::StageSize`]).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum StageGap {
|
||||
/// The kernel's entry holds a breach: what ended its helper's compile, or the driver's
|
||||
/// compile-required answer to the helper's cache data
|
||||
/// ([`Device::record_stage_breach`](crate::Device::record_stage_breach)). Kept until the
|
||||
/// driver's version changes.
|
||||
Breach(crate::StageBreach),
|
||||
/// The device has no cache directory
|
||||
/// ([`DeviceOptions::pipeline_cache_dir`](crate::DeviceOptions::pipeline_cache_dir)) to keep a
|
||||
/// helper's cache data in.
|
||||
NoCacheDirectory,
|
||||
/// The device's driver writes no pipeline cache header, so its cache data holds no compile
|
||||
/// another process can hand it: lavapipe's (an empty cache's data is 20 bytes in Mesa 26.2.4).
|
||||
NoPipelineCache,
|
||||
/// A render pipeline's vertex or fragment stage: no helper compiles render stages.
|
||||
RenderStage,
|
||||
}
|
||||
|
||||
/// What a render pass sets beside a surface plane that renders as a linear colour attachment
|
||||
@@ -1978,6 +2021,12 @@ impl fmt::Display for Error {
|
||||
functions.join(", ")
|
||||
),
|
||||
Error::Unsupported(gap) => write!(f, "{gap}"),
|
||||
Error::StageUnfilled(request) => write!(
|
||||
f,
|
||||
"a kernel of entry weight {} is past the stage bound, and the cache directory \
|
||||
holds no helper's compile of it",
|
||||
request.weight()
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2487,6 +2536,17 @@ impl fmt::Display for Gap {
|
||||
}
|
||||
})
|
||||
}
|
||||
Gap::StageSize { weight, cause } => {
|
||||
write!(f, "a stage of entry weight {weight} past the stage bound is not made: ")?;
|
||||
match cause {
|
||||
StageGap::Breach(breach) => write!(f, "its helper's compile met {breach:?}"),
|
||||
StageGap::NoCacheDirectory => f.write_str("the device has no cache directory"),
|
||||
StageGap::NoPipelineCache => {
|
||||
f.write_str("the device's driver keeps no pipeline cache data")
|
||||
}
|
||||
StageGap::RenderStage => f.write_str("no helper compiles a render stage"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2600,7 +2660,8 @@ impl std::error::Error for Error {
|
||||
| Error::Limit(_)
|
||||
| Error::NoSuchBlock(_)
|
||||
| Error::Quiesced
|
||||
| Error::Unsupported(_) => None,
|
||||
| Error::Unsupported(_)
|
||||
| Error::StageUnfilled(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -549,6 +549,10 @@ pub(crate) const REQUIRED: &[Feature] = &[
|
||||
feature!(vulkan12.host_query_reset),
|
||||
feature!(vulkan13.synchronization2 => Synchronization2),
|
||||
feature!(vulkan13.dynamic_rendering),
|
||||
// A kernel past the stage bound is created only from its helper's cache data, with
|
||||
// `VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT`, so the process never compiles
|
||||
// it (`crate::stage`). Vulkan 1.3 requires it.
|
||||
feature!(vulkan13.pipeline_creation_cache_control),
|
||||
];
|
||||
|
||||
/// The features of the portability subset the runtime requires of a device that lists
|
||||
|
||||
@@ -55,6 +55,7 @@ mod render_encoder;
|
||||
mod ring;
|
||||
mod sampler;
|
||||
mod shadow;
|
||||
mod stage;
|
||||
mod staging;
|
||||
mod submit;
|
||||
mod submit_calls;
|
||||
@@ -77,7 +78,7 @@ pub use device::{Device, DeviceOptions, RawDevice};
|
||||
pub use encoder::{ComputeCommandEncoder, Dispatch, DispatchType, Resource, ResourceUsage};
|
||||
pub use error::{
|
||||
DrawKind, Error, Gap, IndirectCommandsKind, KernelInputKind, Limit, LinearPlanePassKind,
|
||||
Refusal, RenderPassKind, RenderPipelineKind, TextureViewKind,
|
||||
Refusal, RenderPassKind, RenderPipelineKind, StageGap, TextureViewKind,
|
||||
};
|
||||
pub use event::{Event, SharedEvent};
|
||||
pub use export::{Export, ExportHandle};
|
||||
@@ -142,6 +143,7 @@ pub use render_encoder::{
|
||||
IndexBuffer, RenderCommandEncoder, ScissorRect, Viewport, VisibilityResultMode,
|
||||
};
|
||||
pub use sampler::SamplerState;
|
||||
pub use stage::{serve_stage, StageBreach, StageFill, StageRequest};
|
||||
pub use surface::{
|
||||
PlaneLayout, PlaneSpec, Surface, SurfaceCopy, SurfaceExport, SurfaceForm, SurfaceSpec,
|
||||
};
|
||||
|
||||
@@ -60,6 +60,7 @@ use crate::kernel_map::KernelKey;
|
||||
use crate::reaper::{Free, Job};
|
||||
use crate::ring::CHUNK;
|
||||
use crate::sampler::{canonical, constexpr_notes, hold_constexpr, release_constexpr};
|
||||
use crate::stage::{Create, Heavy};
|
||||
use crate::times::host_time;
|
||||
use ash::vk;
|
||||
use metal2vulkan::cache::Hash256;
|
||||
@@ -395,6 +396,9 @@ pub(crate) struct Kernel {
|
||||
/// The module's entry point.
|
||||
entry: CString,
|
||||
pub(crate) interface: Interface,
|
||||
/// The module, where it is past the stage bound: each `VkPipeline` is made from its helper's
|
||||
/// cache data alone (`crate::stage`).
|
||||
heavy: Option<Heavy>,
|
||||
/// The `VkPipeline`s made so far, by their specialization.
|
||||
variants: Variants,
|
||||
}
|
||||
@@ -1044,7 +1048,8 @@ impl Compiled {
|
||||
// below its 1024; the device's own limit is no declared bound. The `VkPipeline`s a whole
|
||||
// grid and a ragged one run are made, where the module takes no threadgroup memory length
|
||||
// from the encoder. A make that fails here is made again by the dispatch that needs it,
|
||||
// which reports its own error.
|
||||
// which reports its own error; a make refused for the stage bound refuses the state's,
|
||||
// which the consumer's helper then fills.
|
||||
let interface = &compiled.whole.interface;
|
||||
let declared = descriptor.max_total_threads_per_threadgroup.is_some()
|
||||
|| interface.metal_max_total_threads < METAL_MAX_THREADS;
|
||||
@@ -1056,7 +1061,11 @@ impl Compiled {
|
||||
if let Some((kernel, module, local, lengths)) = found {
|
||||
if kernel.interface.threadgroups.is_empty() {
|
||||
let variant = compiled.dispatch_key(module, local, lengths);
|
||||
kernel.make_ahead(&compiled.core, variant, VariantStart::State);
|
||||
let made = kernel.make_ahead(&compiled.core, variant, VariantStart::State);
|
||||
match made {
|
||||
Err(error) if past_stage_bound(&error) => return Err(error),
|
||||
Ok(_) | Err(_) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1243,6 +1252,15 @@ pub(crate) fn made_through_cache(
|
||||
Ok(pipeline)
|
||||
}
|
||||
|
||||
/// Whether `error` is a refusal of a kernel past the stage bound: a make that only the consumer's
|
||||
/// helper, or nothing, lets succeed.
|
||||
fn past_stage_bound(error: &Error) -> bool {
|
||||
matches!(
|
||||
error,
|
||||
Error::StageUnfilled(_) | Error::Unsupported(Gap::StageSize { .. })
|
||||
)
|
||||
}
|
||||
|
||||
/// The runtime's view of the translator's kernel, or what the kernel reads that the compute
|
||||
/// encoder does not supply ([`Gap::KernelInput`] of that kind), the first this finds.
|
||||
fn interface(
|
||||
@@ -1635,28 +1653,36 @@ impl ComputePipelineState {
|
||||
/// returns at once where that is made, or another thread is making it: a dispatch that needs
|
||||
/// it then waits for that thread alone. It makes nothing where the dispatch would refuse its
|
||||
/// threadgroup size, its variant or its threadgroup memory, or records nothing (a grid with no
|
||||
/// threads, a kernel that writes no memory), and it reports nothing: every error is the
|
||||
/// dispatch's own. What the dispatch checks of the encoder's bindings is not checked here. A
|
||||
/// make that failed is made again by the next call or dispatch that needs it.
|
||||
/// threads, a kernel that writes no memory), and it reports no other error than a kernel's past
|
||||
/// the stage bound: every other is the dispatch's own. What the dispatch checks of the
|
||||
/// encoder's bindings is not checked here. A make that failed is made again by the next call
|
||||
/// or dispatch that needs it.
|
||||
///
|
||||
/// Counted as [`Metrics::made_ahead_variants`](crate::Metrics::made_ahead_variants).
|
||||
///
|
||||
/// Err: the refusal the dispatch would meet of a kernel past the stage bound:
|
||||
/// [`Error::StageUnfilled`], whose request the consumer's helper fills before the dispatch is
|
||||
/// encoded ([`Device::fill_stage`](crate::Device::fill_stage)), or [`Gap::StageSize`].
|
||||
pub fn prepare_dispatch(
|
||||
&self,
|
||||
dispatch: Dispatch,
|
||||
threads_per_threadgroup: [u32; 3],
|
||||
threadgroup_memory_lengths: &[(u32, u32)],
|
||||
) {
|
||||
) -> Result<(), Error> {
|
||||
let compiled = &self.inner.compiled;
|
||||
let (size, set) = (threads_per_threadgroup, threadgroup_memory_lengths);
|
||||
let Some((kernel, module, local, lengths)) = compiled.dispatched(dispatch, size, set)
|
||||
else {
|
||||
return;
|
||||
return Ok(());
|
||||
};
|
||||
let core = &compiled.core;
|
||||
let variant = compiled.dispatch_key(module, local, lengths);
|
||||
if let Some(nanos) = kernel.make_ahead(core, variant, VariantStart::Ahead) {
|
||||
core.counters.made_ahead(nanos);
|
||||
match kernel.make_ahead(core, variant, VariantStart::Ahead) {
|
||||
Ok(Some(nanos)) => core.counters.made_ahead(nanos),
|
||||
Err(error) if past_stage_bound(&error) => return Err(error),
|
||||
Ok(None) | Err(_) => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// No Metal counterpart: a hook for a consumer's pre-pass, beside
|
||||
@@ -1919,6 +1945,7 @@ impl Kernel {
|
||||
) -> Result<Kernel, Unmade> {
|
||||
let interface = interface(&pipeline, required_size).map_err(Unmade::Unsupplied)?;
|
||||
let stage = pipeline.stage;
|
||||
let heavy = Heavy::of(&stage);
|
||||
// The translator's entry points hold no NUL; one that did would name no entry point.
|
||||
let entry = CString::new(stage.entry_point)
|
||||
.map_err(|_| Unmade::Unsupplied(KernelInputKind::EntryPoint))?;
|
||||
@@ -1928,6 +1955,7 @@ impl Kernel {
|
||||
module,
|
||||
entry,
|
||||
interface,
|
||||
heavy,
|
||||
variants: Variants::default(),
|
||||
})
|
||||
}
|
||||
@@ -2006,25 +2034,25 @@ impl Kernel {
|
||||
|
||||
/// A make of `variant` ahead of its dispatches, started by `start`: none where it is made or a
|
||||
/// thread is making it; else made on the calling thread, and its nanoseconds where it was
|
||||
/// made.
|
||||
/// made, or the make's error.
|
||||
pub(crate) fn make_ahead(
|
||||
&self,
|
||||
core: &Core,
|
||||
variant: DispatchVariant,
|
||||
start: VariantStart,
|
||||
) -> Option<u64> {
|
||||
) -> Result<Option<u64>, Error> {
|
||||
let variants = &self.variants;
|
||||
let key = variant.key();
|
||||
if variants.in_cells(key).is_ok() {
|
||||
return None;
|
||||
return Ok(None);
|
||||
}
|
||||
let more = lock(&variants.more);
|
||||
if variants.made(&more, key).is_some() || more.pending(key).is_some() {
|
||||
return None;
|
||||
return Ok(None);
|
||||
}
|
||||
let began = host_time();
|
||||
let made = self.make_pending(core, more, variant, start, None).ok();
|
||||
made.map(|_| host_time().saturating_sub(began))
|
||||
self.make_pending(core, more, variant, start, None)?;
|
||||
Ok(Some(host_time().saturating_sub(began)))
|
||||
}
|
||||
|
||||
/// Makes `variant`, which `more`, the lock held, shows neither made nor pending, started by
|
||||
@@ -2108,6 +2136,21 @@ impl Kernel {
|
||||
let info = vk::ComputePipelineCreateInfo::default()
|
||||
.stage(stage)
|
||||
.layout(core.layout);
|
||||
if let Some(heavy) = &self.heavy {
|
||||
let ids: Vec<u32> = constants.iter().map(|&(id, _)| id).collect();
|
||||
let create = Create {
|
||||
entry: &self.entry,
|
||||
flags: self.interface.stage_flags,
|
||||
subgroup: self.interface.required_subgroup_size,
|
||||
ids: &ids,
|
||||
data: &values,
|
||||
};
|
||||
let info = info.flags(vk::PipelineCreateFlags::FAIL_ON_PIPELINE_COMPILE_REQUIRED);
|
||||
return crate::stage::made(core, heavy, &create, |cache| {
|
||||
// SAFETY: as below; the cache is made of the pipeline's entry alone.
|
||||
unsafe { core.device.create_compute_pipelines(cache, &[info], None) }
|
||||
});
|
||||
}
|
||||
made_through_cache(core, "vkCreateComputePipelines", |cache| {
|
||||
// SAFETY: the module, the layout and the cache are the device's, and the
|
||||
// specialization gives each of the kernel's constants a 4-byte value.
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
use crate::cache::{self, Lowerings};
|
||||
use crate::counters::{FirstUse, Gauge, Metric};
|
||||
use crate::device::{lock, Core};
|
||||
use crate::error::{Error, Gap, Refusal, RenderPipelineKind};
|
||||
use crate::error::{Error, Gap, Refusal, RenderPipelineKind, StageGap};
|
||||
use crate::hazard::Access;
|
||||
use crate::kernel_map::KernelKey;
|
||||
use crate::pass::Pass;
|
||||
@@ -1011,6 +1011,17 @@ impl RenderCompiled {
|
||||
if let Some(kind) = unbuilt(&pipeline, translator.profile().enabled()) {
|
||||
return Err(Error::Unsupported(Gap::RenderPipeline { kind }));
|
||||
}
|
||||
// A stage past the stage bound is compiled in no process of the runtime's, and no helper
|
||||
// compiles a render stage.
|
||||
let heaviest = (pipeline.stages.iter())
|
||||
.map(|stage| stage.stats.entry_weight)
|
||||
.max();
|
||||
if let Some(weight) = heaviest.filter(|&weight| weight > crate::stage::bound()) {
|
||||
return Err(Error::Unsupported(Gap::StageSize {
|
||||
weight,
|
||||
cause: StageGap::RenderStage,
|
||||
}));
|
||||
}
|
||||
let nonzero_first_instance = translator
|
||||
.profile()
|
||||
.limits()
|
||||
|
||||
@@ -0,0 +1,789 @@
|
||||
//! Kernels past the stage bound: compiled in the consumer's helper process, created here from the
|
||||
//! helper's cache data alone, never compiled in this process.
|
||||
//!
|
||||
//! A kernel whose module weighs more than `metal2vulkan::pipeline::COMPILED_STAGE_WEIGHT`
|
||||
//! (`ModuleStats::entry_weight`) is one whose compile may take the host's memory, so the process
|
||||
//! that runs the program never compiles it. Each of its `VkPipeline`s is made from a
|
||||
//! `VkPipelineCache` made of that pipeline's own entry in the cache directory alone, with
|
||||
//! `VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT` ([`made`]), and the cache destroyed
|
||||
//! once the create returns: the device's own pipeline cache and its blob never hold it. Where the
|
||||
//! directory holds no entry for the pipeline, the make (or the dispatch, or
|
||||
//! [`ComputePipelineState::prepare_dispatch`](crate::ComputePipelineState::prepare_dispatch)) is
|
||||
//! refused with [`Error::StageUnfilled`], carrying a [`StageRequest`]: the consumer runs its helper
|
||||
//! process, hands its pipes to [`Device::fill_stage`], which keeps the helper's cache data as the
|
||||
//! entry, and makes again. The helper's main is [`serve_stage`]. The runtime starts, caps, times
|
||||
//! and kills no process: the consumer owns the helper, and [`Device::record_stage_breach`] keeps
|
||||
//! what it ended one for.
|
||||
//!
|
||||
//! **The entry.** One file per pipeline under `stages/` in the cache directory, named by the hex of
|
||||
//! the pipeline's stage key: a digest of the wire version, the device's pipeline cache header, the
|
||||
//! device's enables, the module's words, its entry point, stage flags, pinned subgroup size and
|
||||
//! specialization. It holds, framed as the blob is (magic, length, checksum), the key again and
|
||||
//! either the pipeline's cache data, as the helper's `vkGetPipelineCacheData` gave it, or a breach:
|
||||
//! what the helper's compile met ([`StageBreach`]). A file that does not check, names another key,
|
||||
//! or holds data that does not begin with the device's header is a miss and is removed. A hit
|
||||
//! touches the file's modification time; each write removes the entries past [`STAGE_BOUNDS`],
|
||||
//! oldest use first. Nothing of an entry stays in memory past the call that reads or writes it.
|
||||
//!
|
||||
//! **A breach is final for its driver.** An entry that holds a breach refuses the pipeline
|
||||
//! ([`Gap::StageSize`]) with no helper asked again, and so does one whose cache data the driver
|
||||
//! answered compile-required for: that answer is kept as a breach. The key holds the driver's
|
||||
//! header, so a new driver version asks again.
|
||||
//!
|
||||
//! **The wire.** [`Device::fill_stage`] writes one request frame to the helper and reads one reply
|
||||
//! frame back: each the magic `m2vstage`, the wire version, the payload's length and its checksum,
|
||||
//! then the payload. A reply of another wire version is [`StageFill::Version`].
|
||||
|
||||
use crate::cache::{checksum, frame, hex, read_whole, unframe, write_whole};
|
||||
use crate::counters::{Gauge, Metric};
|
||||
use crate::device::{Core, Device, DeviceOptions};
|
||||
use crate::error::{Error, Gap, StageGap};
|
||||
use crate::instance::Instance;
|
||||
use crate::times::host_time;
|
||||
use ash::vk;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::fmt;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{self, ErrorKind, Read, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use std::time::SystemTime;
|
||||
|
||||
/// The bytes and the entries the `stages/` directory holds at most: 256 MiB and 32 entries,
|
||||
/// sixteen heavy kernels at two pipelines each at about 7.6 MB, the largest entry measured (an RTX
|
||||
/// 2080's, NVIDIA 620.70.06).
|
||||
pub(crate) const STAGE_BOUNDS: StageBounds = StageBounds {
|
||||
bytes: 256 << 20,
|
||||
entries: 32,
|
||||
};
|
||||
|
||||
/// The bounds of the `stages/` directory.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct StageBounds {
|
||||
pub(crate) bytes: u64,
|
||||
pub(crate) entries: usize,
|
||||
}
|
||||
|
||||
/// The directory of the entries, under the cache directory.
|
||||
const STAGES: &str = "stages";
|
||||
/// The first bytes of a frame on the wire.
|
||||
const WIRE: &[u8; 8] = b"m2vstage";
|
||||
/// The wire's version: a frame of another is not read.
|
||||
const WIRE_VERSION: u32 = 1;
|
||||
/// The longest payload a frame is read with.
|
||||
const MAX_PAYLOAD: u64 = 1 << 30;
|
||||
/// An entry's kinds, after its key.
|
||||
const DATA: u8 = 0;
|
||||
const BREACH: u8 = 1;
|
||||
/// A reply's statuses.
|
||||
const DONE: u32 = 0;
|
||||
const COMPILE: u32 = 1;
|
||||
const NO_DEVICE: u32 = 2;
|
||||
const ENABLES: u32 = 3;
|
||||
|
||||
/// No Metal counterpart: what ended a helper's compile of a kernel past the stage bound, kept as
|
||||
/// the pipeline's entry ([`Device::record_stage_breach`], [`Device::fill_stage`]) so its makes are
|
||||
/// refused ([`Gap::StageSize`]) with no helper asked again, until the driver's version changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum StageBreach {
|
||||
/// The helper passed the memory cap the consumer gave it.
|
||||
Memory,
|
||||
/// The helper passed the time the consumer gave it.
|
||||
Time,
|
||||
/// The driver failed the helper's compile (`vkCreateComputePipelines` answered an error).
|
||||
Compile,
|
||||
/// The driver answered compile-required for the helper's cache data
|
||||
/// (`VK_PIPELINE_COMPILE_REQUIRED`): it would compile again in this process.
|
||||
CompileRequired,
|
||||
}
|
||||
|
||||
impl StageBreach {
|
||||
const ALL: [StageBreach; 4] = [
|
||||
StageBreach::Memory,
|
||||
StageBreach::Time,
|
||||
StageBreach::Compile,
|
||||
StageBreach::CompileRequired,
|
||||
];
|
||||
|
||||
fn byte(self) -> u8 {
|
||||
match self {
|
||||
StageBreach::Memory => 0,
|
||||
StageBreach::Time => 1,
|
||||
StageBreach::Compile => 2,
|
||||
StageBreach::CompileRequired => 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// No Metal counterpart: why [`Device::fill_stage`] kept no cache data. Only
|
||||
/// [`StageFill::Compile`] is kept, as a breach.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum StageFill {
|
||||
/// The helper's reply did not come whole: it ended, was killed (a cap, a time limit, a
|
||||
/// cancel) or closed its pipes first. Nothing is kept; the consumer keeps a cap's or a time
|
||||
/// limit's end with [`Device::record_stage_breach`].
|
||||
Ended,
|
||||
/// The helper speaks another wire version: a helper of another build of the runtime.
|
||||
Version,
|
||||
/// The helper found no device of the request's `deviceUUID` and `driverUUID`, could not open
|
||||
/// it, or gave cache data of another driver's header.
|
||||
NoDevice,
|
||||
/// The helper's device enabled other extensions or features than this one: it was opened
|
||||
/// with other [`DeviceOptions`].
|
||||
Enables,
|
||||
/// The driver failed the helper's compile with this result; kept as
|
||||
/// [`StageBreach::Compile`].
|
||||
Compile(vk::Result),
|
||||
/// The cache directory took no entry: it is read-only, or the write failed.
|
||||
Unkept,
|
||||
}
|
||||
|
||||
impl fmt::Display for StageFill {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
StageFill::Ended => f.write_str("the helper ended before its reply"),
|
||||
StageFill::Version => f.write_str("the helper speaks another wire version"),
|
||||
StageFill::NoDevice => f.write_str("the helper opened no device of the request's"),
|
||||
StageFill::Enables => f.write_str("the helper's device enabled other features"),
|
||||
StageFill::Compile(result) => write!(f, "the helper's compile failed: {result}"),
|
||||
StageFill::Unkept => f.write_str("the cache directory took no entry"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A kernel's module past the stage bound, kept with its kernel for the requests of its
|
||||
/// `VkPipeline`s.
|
||||
pub(crate) struct Heavy {
|
||||
/// The module's entry weight.
|
||||
weight: u64,
|
||||
words: Arc<[u32]>,
|
||||
/// The digest of the words, which every stage key holds.
|
||||
digest: [u8; 32],
|
||||
}
|
||||
|
||||
/// The entry weight past which a stage is compiled only in the consumer's helper: the translator's
|
||||
/// `COMPILED_STAGE_WEIGHT`, or, in a device test, one the test sets ([`TEST_BOUND`]), so a small
|
||||
/// kernel passes it.
|
||||
pub(crate) fn bound() -> u64 {
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
if let Some(bound) =
|
||||
std::num::NonZeroU64::new(TEST_BOUND.load(std::sync::atomic::Ordering::Relaxed))
|
||||
{
|
||||
return bound.get();
|
||||
}
|
||||
metal2vulkan::pipeline::COMPILED_STAGE_WEIGHT
|
||||
}
|
||||
|
||||
/// The stage bound a device test sets; none where zero ([`bound`]).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) static TEST_BOUND: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
||||
|
||||
impl Heavy {
|
||||
/// The module of `stage` where it weighs more than the stage bound ([`bound`]).
|
||||
pub(crate) fn of(stage: &metal2vulkan::pipeline::StageModule) -> Option<Heavy> {
|
||||
let weight = stage.stats.entry_weight;
|
||||
(weight > bound()).then(|| Heavy {
|
||||
weight,
|
||||
words: Arc::clone(&stage.spirv),
|
||||
digest: Sha256::digest(words_bytes(&stage.spirv)).into(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// What a compute `VkPipeline`'s create gives its one stage besides the module.
|
||||
pub(crate) struct Create<'a> {
|
||||
pub(crate) entry: &'a CStr,
|
||||
pub(crate) flags: vk::PipelineShaderStageCreateFlags,
|
||||
pub(crate) subgroup: Option<u32>,
|
||||
/// The specialization constants' ids, each 4 bytes of `data` in order.
|
||||
pub(crate) ids: &'a [u32],
|
||||
pub(crate) data: &'a [u8],
|
||||
}
|
||||
|
||||
/// No Metal counterpart: a `VkPipeline` of a kernel past the stage bound whose cache data the
|
||||
/// device's cache directory does not hold ([`Error::StageUnfilled`]): what the consumer's helper
|
||||
/// compiles ([`Device::fill_stage`]). Requests of one pipeline compare equal, so a consumer runs
|
||||
/// one helper for them.
|
||||
#[derive(Clone)]
|
||||
pub struct StageRequest(Arc<Request>);
|
||||
|
||||
/// What a request holds.
|
||||
struct Request {
|
||||
key: [u8; 32],
|
||||
weight: u64,
|
||||
header: [u8; 32],
|
||||
uuids: [[u8; 16]; 2],
|
||||
enables: [u8; 32],
|
||||
words: Arc<[u32]>,
|
||||
entry: CString,
|
||||
flags: u32,
|
||||
subgroup: Option<u32>,
|
||||
ids: Vec<u32>,
|
||||
data: Vec<u8>,
|
||||
}
|
||||
|
||||
impl StageRequest {
|
||||
/// The module's entry weight (`ModuleStats::entry_weight`), past the compiled stage bound.
|
||||
pub fn weight(&self) -> u64 {
|
||||
self.0.weight
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for StageRequest {
|
||||
fn eq(&self, other: &StageRequest) -> bool {
|
||||
self.0.key == other.0.key
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for StageRequest {}
|
||||
|
||||
impl std::hash::Hash for StageRequest {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.0.key.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for StageRequest {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("StageRequest")
|
||||
.field("key", &hex(&self.0.key))
|
||||
.field("weight", &self.0.weight)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// The bytes of `words`, least significant byte first.
|
||||
fn words_bytes(words: &[u32]) -> Vec<u8> {
|
||||
words.iter().flat_map(|word| word.to_le_bytes()).collect()
|
||||
}
|
||||
|
||||
/// The `deviceUUID` and `driverUUID` of `physical`.
|
||||
fn uuids(instance: &ash::Instance, physical: vk::PhysicalDevice) -> [[u8; 16]; 2] {
|
||||
let mut ids = vk::PhysicalDeviceIDProperties::default();
|
||||
let mut properties = vk::PhysicalDeviceProperties2::default().push_next(&mut ids);
|
||||
// SAFETY: the instance listed the device, at the floor's Vulkan 1.3, which defines the
|
||||
// structure.
|
||||
unsafe { instance.get_physical_device_properties2(physical, &mut properties) };
|
||||
[ids.device_uuid, ids.driver_uuid]
|
||||
}
|
||||
|
||||
/// The stage key of a pipeline of `heavy` made with `create` on a device of `header` and
|
||||
/// `enables` (the module docs).
|
||||
fn key(header: &[u8; 32], enables: &[u8; 32], heavy: &Heavy, create: &Create<'_>) -> [u8; 32] {
|
||||
let mut h = Sha256::new();
|
||||
h.update(WIRE);
|
||||
h.update(WIRE_VERSION.to_le_bytes());
|
||||
h.update(header);
|
||||
h.update(enables);
|
||||
h.update(heavy.digest);
|
||||
let entry = create.entry.to_bytes();
|
||||
h.update((entry.len() as u64).to_le_bytes());
|
||||
h.update(entry);
|
||||
h.update(create.flags.as_raw().to_le_bytes());
|
||||
h.update(create.subgroup.unwrap_or(0).to_le_bytes());
|
||||
h.update((create.ids.len() as u64).to_le_bytes());
|
||||
for id in create.ids {
|
||||
h.update(id.to_le_bytes());
|
||||
}
|
||||
h.update(create.data);
|
||||
h.finalize().into()
|
||||
}
|
||||
|
||||
/// The refusal of a pipeline of `weight` for `cause`.
|
||||
fn gap(weight: u64, cause: StageGap) -> Error {
|
||||
Error::Unsupported(Gap::StageSize { weight, cause })
|
||||
}
|
||||
|
||||
/// A compute `VkPipeline` of `heavy` that `make` creates through the cache it is given, with
|
||||
/// `VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT` in its create info: through a cache
|
||||
/// made of the pipeline's entry alone, destroyed once `make` returns (the module docs). Counted as
|
||||
/// made, and its time (`Metrics::pipeline_creation_nanos`).
|
||||
///
|
||||
/// Err: [`Error::StageUnfilled`] where the directory holds no entry for it; [`Gap::StageSize`]
|
||||
/// where it holds a breach, where the driver answers compile-required for its data (kept as a
|
||||
/// breach), on a device with no cache directory or whose driver writes no pipeline cache header;
|
||||
/// [`Error::Vulkan`] where the create fails otherwise.
|
||||
pub(crate) fn made(
|
||||
core: &Core,
|
||||
heavy: &Heavy,
|
||||
create: &Create<'_>,
|
||||
make: impl FnOnce(vk::PipelineCache) -> Result<Vec<vk::Pipeline>, (Vec<vk::Pipeline>, vk::Result)>,
|
||||
) -> Result<vk::Pipeline, Error> {
|
||||
let weight = heavy.weight;
|
||||
let dir = (core.caches.dir()).ok_or_else(|| gap(weight, StageGap::NoCacheDirectory))?;
|
||||
let dir = dir.join(STAGES);
|
||||
let header = (core.caches.header()).ok_or_else(|| gap(weight, StageGap::NoPipelineCache))?;
|
||||
let enables = core.enables();
|
||||
let key = key(&header, &enables, heavy, create);
|
||||
let data = match read_entry(&dir, &key, &header) {
|
||||
None => {
|
||||
let (instance, physical) = (core.instance.raw().1, core.physical);
|
||||
return Err(Error::StageUnfilled(StageRequest(Arc::new(Request {
|
||||
key,
|
||||
weight,
|
||||
header,
|
||||
uuids: uuids(instance, physical),
|
||||
enables,
|
||||
words: Arc::clone(&heavy.words),
|
||||
entry: create.entry.to_owned(),
|
||||
flags: create.flags.as_raw(),
|
||||
subgroup: create.subgroup,
|
||||
ids: create.ids.to_vec(),
|
||||
data: create.data.to_vec(),
|
||||
}))));
|
||||
}
|
||||
Some(Entry::Breach(breach)) => return Err(gap(weight, StageGap::Breach(breach))),
|
||||
Some(Entry::Data(data)) => data,
|
||||
};
|
||||
let info = vk::PipelineCacheCreateInfo::default().initial_data(&data);
|
||||
// SAFETY: the data is what the helper's `vkGetPipelineCacheData` gave for a device of this
|
||||
// header, whole, as its frame's length and checksum show; the driver ignores data it does not
|
||||
// take.
|
||||
let cache = unsafe { core.device.create_pipeline_cache(&info, None) }.map_err(|result| {
|
||||
Error::Vulkan {
|
||||
call: "vkCreatePipelineCache",
|
||||
result,
|
||||
}
|
||||
})?;
|
||||
let began = host_time();
|
||||
let created = make(cache);
|
||||
core.counters
|
||||
.pipeline_creation(host_time().saturating_sub(began));
|
||||
// SAFETY: the cache is the device's, and the create that used it has returned.
|
||||
unsafe { core.device.destroy_pipeline_cache(cache, None) };
|
||||
match created {
|
||||
Ok(pipelines) => {
|
||||
core.counters.count(Metric::PipelinesCreated);
|
||||
core.counters.count(Metric::PipelinesFromStageFills);
|
||||
core.counters.rise(Gauge::Pipelines);
|
||||
Ok(pipelines[0])
|
||||
}
|
||||
Err((_, vk::Result::PIPELINE_COMPILE_REQUIRED)) => {
|
||||
let breach = StageBreach::CompileRequired;
|
||||
keep_entry(&dir, &key, &Entry::Breach(breach), STAGE_BOUNDS);
|
||||
Err(gap(weight, StageGap::Breach(breach)))
|
||||
}
|
||||
Err((_, result)) => Err(Error::Vulkan {
|
||||
call: "vkCreateComputePipelines",
|
||||
result,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
impl Device {
|
||||
/// No Metal counterpart: the cache data of `request`'s pipeline from the consumer's helper,
|
||||
/// kept as its entry in the cache directory, so the make refused with
|
||||
/// [`Error::StageUnfilled`] makes the pipeline when asked again. Writes the request to
|
||||
/// `to_helper`, closes it, and reads the helper's reply ([`serve_stage`]) from `from_helper`,
|
||||
/// on the calling thread, until the reply is whole or the helper's end closes the pipe: a
|
||||
/// consumer that kills the helper (its cap, its time limit, a cancel) ends the call at once.
|
||||
///
|
||||
/// Err: [`StageFill`] for each reply that keeps no cache data; a failed compile is kept as
|
||||
/// [`StageBreach::Compile`].
|
||||
pub fn fill_stage(
|
||||
&self,
|
||||
request: &StageRequest,
|
||||
mut to_helper: impl Write,
|
||||
mut from_helper: impl Read,
|
||||
) -> Result<(), StageFill> {
|
||||
let request = &request.0;
|
||||
let sent = write_frame(&mut to_helper, &request_payload(request));
|
||||
drop(to_helper);
|
||||
sent.map_err(|_| StageFill::Ended)?;
|
||||
let payload = match read_frame(&mut from_helper) {
|
||||
Ok(payload) => payload,
|
||||
Err(Framing::Version) => return Err(StageFill::Version),
|
||||
Err(Framing::Cut) => return Err(StageFill::Ended),
|
||||
};
|
||||
let mut reply = Reader(&payload);
|
||||
let (Some(key), Some(status)) = (reply.array::<32>(), reply.u32()) else {
|
||||
return Err(StageFill::Ended);
|
||||
};
|
||||
if key != request.key {
|
||||
return Err(StageFill::Ended);
|
||||
}
|
||||
let core = self.core();
|
||||
let dir = core.caches.dir().map(|dir| dir.join(STAGES));
|
||||
let keep = |entry: &Entry| {
|
||||
(dir.as_deref()).is_some_and(|dir| keep_entry(dir, &request.key, entry, STAGE_BOUNDS))
|
||||
};
|
||||
match status {
|
||||
DONE => {
|
||||
let data = reply.bytes().ok_or(StageFill::Ended)?;
|
||||
if !data.starts_with(&request.header) {
|
||||
return Err(StageFill::NoDevice);
|
||||
}
|
||||
if !keep(&Entry::Data(data.to_vec())) {
|
||||
return Err(StageFill::Unkept);
|
||||
}
|
||||
core.counters.count(Metric::StageFills);
|
||||
Ok(())
|
||||
}
|
||||
COMPILE => {
|
||||
let raw = reply.u32().ok_or(StageFill::Ended)?;
|
||||
keep(&Entry::Breach(StageBreach::Compile));
|
||||
Err(StageFill::Compile(vk::Result::from_raw(raw as i32)))
|
||||
}
|
||||
NO_DEVICE => Err(StageFill::NoDevice),
|
||||
ENABLES => Err(StageFill::Enables),
|
||||
_ => Err(StageFill::Ended),
|
||||
}
|
||||
}
|
||||
|
||||
/// No Metal counterpart: keeps `breach` as the entry of `request`'s pipeline, so its makes are
|
||||
/// refused ([`Gap::StageSize`]) with no helper asked again, until the driver's version changes:
|
||||
/// what the consumer ended its helper for ([`StageBreach::Memory`], [`StageBreach::Time`]).
|
||||
/// A directory that takes no entry keeps nothing.
|
||||
pub fn record_stage_breach(&self, request: &StageRequest, breach: StageBreach) {
|
||||
if let Some(dir) = self.core().caches.dir() {
|
||||
let entry = Entry::Breach(breach);
|
||||
keep_entry(&dir.join(STAGES), &request.0.key, &entry, STAGE_BOUNDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// No Metal counterpart: the consumer's helper process's main, which compiles one kernel past the
|
||||
/// stage bound for [`Device::fill_stage`]. Reads one request from `from_parent`; opens the device
|
||||
/// of `instance` whose `deviceUUID` and `driverUUID` are the request's, with `options` and no cache
|
||||
/// directory, which must be the options the parent's device was opened with (the parent's
|
||||
/// [`StageFill::Enables`] otherwise); compiles the pipeline through an empty `VkPipelineCache`; and
|
||||
/// writes that cache's data to `to_parent`. The consumer makes `instance` as it makes its main
|
||||
/// process's (the same loader and drivers), and caps, times and kills the process itself.
|
||||
///
|
||||
/// Err: the pipes' errors, or a request that does not read whole; every outcome of the compile is
|
||||
/// the parent's reply.
|
||||
pub fn serve_stage(
|
||||
instance: &Instance,
|
||||
mut options: DeviceOptions,
|
||||
mut from_parent: impl Read,
|
||||
mut to_parent: impl Write,
|
||||
) -> io::Result<()> {
|
||||
let payload = match read_frame(&mut from_parent) {
|
||||
Ok(payload) => payload,
|
||||
// The reply's own version tells the parent.
|
||||
Err(Framing::Version) => return write_frame(&mut to_parent, &[]),
|
||||
Err(Framing::Cut) => return Err(ErrorKind::InvalidData.into()),
|
||||
};
|
||||
let request = read_request(&payload).ok_or(ErrorKind::InvalidData)?;
|
||||
options.pipeline_cache_dir = None;
|
||||
let mut reply = Vec::new();
|
||||
reply.extend_from_slice(&request.key);
|
||||
match serve(instance, options, &request) {
|
||||
Ok(data) => {
|
||||
reply.extend(DONE.to_le_bytes());
|
||||
put_bytes(&mut reply, &data);
|
||||
}
|
||||
Err(Served::Compile(result)) => {
|
||||
reply.extend(COMPILE.to_le_bytes());
|
||||
reply.extend((result.as_raw() as u32).to_le_bytes());
|
||||
}
|
||||
Err(Served::NoDevice) => reply.extend(NO_DEVICE.to_le_bytes()),
|
||||
Err(Served::Enables) => reply.extend(ENABLES.to_le_bytes()),
|
||||
}
|
||||
write_frame(&mut to_parent, &reply)
|
||||
}
|
||||
|
||||
/// What kept the helper's compile from giving cache data.
|
||||
enum Served {
|
||||
NoDevice,
|
||||
Enables,
|
||||
Compile(vk::Result),
|
||||
}
|
||||
|
||||
/// The helper's compile of `request` on a device of `instance` opened with `options`: the data
|
||||
/// of an empty `VkPipelineCache` the pipeline was created through.
|
||||
fn serve(
|
||||
instance: &Instance,
|
||||
options: DeviceOptions,
|
||||
request: &Request,
|
||||
) -> Result<Vec<u8>, Served> {
|
||||
let raw = instance.raw().1;
|
||||
let physical = (instance.physical_devices().map_err(|_| Served::NoDevice)?)
|
||||
.into_iter()
|
||||
.find(|physical| uuids(raw, physical.raw()) == request.uuids)
|
||||
.ok_or(Served::NoDevice)?;
|
||||
let device = Device::new(&physical, options).map_err(|_| Served::NoDevice)?;
|
||||
let core = device.core();
|
||||
if core.enables() != request.enables {
|
||||
return Err(Served::Enables);
|
||||
}
|
||||
// SAFETY: the words are the parent's translator's SPIR-V for a device of these enables.
|
||||
unsafe { compile(core, request) }.map_err(Served::Compile)
|
||||
}
|
||||
|
||||
/// Compiles `request`'s pipeline on `core`'s device through an empty `VkPipelineCache` and gives
|
||||
/// the cache's data; everything it made is destroyed.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `request`'s words are a valid SPIR-V module for the features `core`'s device enabled.
|
||||
unsafe fn compile(core: &Core, request: &Request) -> Result<Vec<u8>, vk::Result> {
|
||||
let device = &core.device;
|
||||
let info = vk::ShaderModuleCreateInfo::default().code(&request.words);
|
||||
// SAFETY: the caller's contract.
|
||||
let module = unsafe { device.create_shader_module(&info, None) }?;
|
||||
// SAFETY: no data.
|
||||
let cache =
|
||||
unsafe { device.create_pipeline_cache(&vk::PipelineCacheCreateInfo::default(), None) };
|
||||
let cache = match cache {
|
||||
Ok(cache) => cache,
|
||||
Err(result) => {
|
||||
// SAFETY: the module is the device's, and nothing uses it.
|
||||
unsafe { device.destroy_shader_module(module, None) };
|
||||
return Err(result);
|
||||
}
|
||||
};
|
||||
let entries: Vec<vk::SpecializationMapEntry> = (request.ids.iter().enumerate())
|
||||
.map(|(index, &id)| vk::SpecializationMapEntry {
|
||||
constant_id: id,
|
||||
offset: (index * 4) as u32,
|
||||
size: 4,
|
||||
})
|
||||
.collect();
|
||||
let specialization = vk::SpecializationInfo::default()
|
||||
.map_entries(&entries)
|
||||
.data(&request.data);
|
||||
let mut required = (request.subgroup).map(|size| {
|
||||
vk::PipelineShaderStageRequiredSubgroupSizeCreateInfo::default()
|
||||
.required_subgroup_size(size)
|
||||
});
|
||||
let mut stage = vk::PipelineShaderStageCreateInfo::default()
|
||||
.flags(vk::PipelineShaderStageCreateFlags::from_raw(request.flags))
|
||||
.stage(vk::ShaderStageFlags::COMPUTE)
|
||||
.module(module)
|
||||
.name(&request.entry)
|
||||
.specialization_info(&specialization);
|
||||
if let Some(required) = &mut required {
|
||||
stage = stage.push_next(required);
|
||||
}
|
||||
let info = vk::ComputePipelineCreateInfo::default()
|
||||
.stage(stage)
|
||||
.layout(core.layout);
|
||||
// SAFETY: the module, the layout and the cache are the device's, and the specialization gives
|
||||
// each constant a 4-byte value, as the parent's create does.
|
||||
let made = unsafe { device.create_compute_pipelines(cache, &[info], None) };
|
||||
let data = match made {
|
||||
Ok(pipelines) => {
|
||||
// SAFETY: the pipeline is the device's, and nothing uses it.
|
||||
unsafe { device.destroy_pipeline(pipelines[0], None) };
|
||||
// SAFETY: the cache is the device's.
|
||||
unsafe { device.get_pipeline_cache_data(cache) }
|
||||
}
|
||||
Err((_, result)) => Err(result),
|
||||
};
|
||||
// SAFETY: both are the device's, and nothing uses them.
|
||||
unsafe {
|
||||
device.destroy_pipeline_cache(cache, None);
|
||||
device.destroy_shader_module(module, None);
|
||||
}
|
||||
data
|
||||
}
|
||||
|
||||
/// What an entry holds.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) enum Entry {
|
||||
Data(Vec<u8>),
|
||||
Breach(StageBreach),
|
||||
}
|
||||
|
||||
/// The entry of key `key` in `dir`, where it checks for a device of `header`, touched as used; a
|
||||
/// file that does not check is removed (the module docs).
|
||||
pub(crate) fn read_entry(dir: &Path, key: &[u8; 32], header: &[u8; 32]) -> Option<Entry> {
|
||||
let path = dir.join(hex(key));
|
||||
let file = read_whole(&path, None).ok().flatten()?;
|
||||
let entry = unframe(&file).and_then(|body| {
|
||||
let (held, rest) = body.split_first_chunk::<32>()?;
|
||||
let (&kind, payload) = rest.split_first()?;
|
||||
match (kind, payload) {
|
||||
_ if held != key => None,
|
||||
(DATA, data) if data.starts_with(header) => Some(Entry::Data(data.to_vec())),
|
||||
(BREACH, &[byte]) => (StageBreach::ALL.into_iter())
|
||||
.find(|breach| breach.byte() == byte)
|
||||
.map(Entry::Breach),
|
||||
_ => None,
|
||||
}
|
||||
});
|
||||
match &entry {
|
||||
Some(_) => {
|
||||
let touched = File::options().write(true).open(&path);
|
||||
let _ = touched.and_then(|file| file.set_modified(SystemTime::now()));
|
||||
}
|
||||
None => {
|
||||
let _ = fs::remove_file(&path);
|
||||
}
|
||||
}
|
||||
entry
|
||||
}
|
||||
|
||||
/// Keeps `entry` as key `key`'s in `dir`, made where it is missing, then removes the entries past
|
||||
/// `bounds`, oldest use first; whether it was written.
|
||||
pub(crate) fn keep_entry(dir: &Path, key: &[u8; 32], entry: &Entry, bounds: StageBounds) -> bool {
|
||||
let mut body = key.to_vec();
|
||||
match entry {
|
||||
Entry::Data(data) => {
|
||||
body.push(DATA);
|
||||
body.extend_from_slice(data);
|
||||
}
|
||||
Entry::Breach(breach) => body.extend([BREACH, breach.byte()]),
|
||||
}
|
||||
let _ = fs::create_dir_all(dir);
|
||||
let written = write_whole(&dir.join(hex(key)), &[&frame(&body), &body]).is_ok();
|
||||
prune(dir, bounds);
|
||||
written
|
||||
}
|
||||
|
||||
/// Removes the entries of `dir` past `bounds`: keeping the most recently used while they fit.
|
||||
fn prune(dir: &Path, bounds: StageBounds) {
|
||||
let Ok(listed) = fs::read_dir(dir) else {
|
||||
return;
|
||||
};
|
||||
let mut entries: Vec<(SystemTime, u64, PathBuf)> = (listed.flatten())
|
||||
.filter_map(|entry| {
|
||||
let name = entry.file_name();
|
||||
let name = name.to_str()?;
|
||||
(name.len() == 64 && name.bytes().all(|byte| byte.is_ascii_hexdigit())).then_some(())?;
|
||||
let meta = entry.metadata().ok()?;
|
||||
Some((meta.modified().ok()?, meta.len(), entry.path()))
|
||||
})
|
||||
.collect();
|
||||
entries.sort_unstable_by_key(|(used, _, _)| std::cmp::Reverse(*used));
|
||||
let mut bytes = 0u64;
|
||||
for (at, (_, len, path)) in entries.into_iter().enumerate() {
|
||||
bytes = bytes.saturating_add(len);
|
||||
if at >= bounds.entries || bytes > bounds.bytes {
|
||||
let _ = fs::remove_file(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Why a frame was not read.
|
||||
pub(crate) enum Framing {
|
||||
/// It is of another wire version.
|
||||
Version,
|
||||
/// It ended early, or does not check.
|
||||
Cut,
|
||||
}
|
||||
|
||||
/// Writes `payload` as one frame (the module docs).
|
||||
pub(crate) fn write_frame(to: &mut impl Write, payload: &[u8]) -> io::Result<()> {
|
||||
let mut head = Vec::with_capacity(28);
|
||||
head.extend_from_slice(WIRE);
|
||||
head.extend(WIRE_VERSION.to_le_bytes());
|
||||
head.extend((payload.len() as u64).to_le_bytes());
|
||||
head.extend(checksum(payload).to_le_bytes());
|
||||
to.write_all(&head)?;
|
||||
to.write_all(payload)?;
|
||||
to.flush()
|
||||
}
|
||||
|
||||
/// The payload of one frame read from `from`.
|
||||
pub(crate) fn read_frame(from: &mut impl Read) -> Result<Vec<u8>, Framing> {
|
||||
let mut head = [0u8; 28];
|
||||
from.read_exact(&mut head).map_err(|_| Framing::Cut)?;
|
||||
let word = |at: usize| u64::from_le_bytes(head[at..at + 8].try_into().expect("8 bytes"));
|
||||
if &head[..8] != WIRE {
|
||||
return Err(Framing::Cut);
|
||||
}
|
||||
if u32::from_le_bytes(head[8..12].try_into().expect("4 bytes")) != WIRE_VERSION {
|
||||
return Err(Framing::Version);
|
||||
}
|
||||
let len = word(12);
|
||||
if len > MAX_PAYLOAD {
|
||||
return Err(Framing::Cut);
|
||||
}
|
||||
let mut payload = vec![0; len as usize];
|
||||
from.read_exact(&mut payload).map_err(|_| Framing::Cut)?;
|
||||
(checksum(&payload) == word(20))
|
||||
.then_some(payload)
|
||||
.ok_or(Framing::Cut)
|
||||
}
|
||||
|
||||
/// `bytes`, after their length.
|
||||
fn put_bytes(out: &mut Vec<u8>, bytes: &[u8]) {
|
||||
out.extend((bytes.len() as u64).to_le_bytes());
|
||||
out.extend_from_slice(bytes);
|
||||
}
|
||||
|
||||
/// A request's payload.
|
||||
fn request_payload(request: &Request) -> Vec<u8> {
|
||||
let mut out = Vec::new();
|
||||
out.extend_from_slice(&request.key);
|
||||
out.extend(request.weight.to_le_bytes());
|
||||
out.extend_from_slice(&request.header);
|
||||
out.extend_from_slice(&request.uuids[0]);
|
||||
out.extend_from_slice(&request.uuids[1]);
|
||||
out.extend_from_slice(&request.enables);
|
||||
put_bytes(&mut out, request.entry.to_bytes());
|
||||
out.extend(request.flags.to_le_bytes());
|
||||
out.extend(request.subgroup.unwrap_or(0).to_le_bytes());
|
||||
out.extend((request.ids.len() as u64).to_le_bytes());
|
||||
for id in &request.ids {
|
||||
out.extend(id.to_le_bytes());
|
||||
}
|
||||
put_bytes(&mut out, &request.data);
|
||||
put_bytes(&mut out, &words_bytes(&request.words));
|
||||
out
|
||||
}
|
||||
|
||||
/// The request of a payload [`request_payload`] wrote.
|
||||
fn read_request(payload: &[u8]) -> Option<Request> {
|
||||
let mut r = Reader(payload);
|
||||
let key = r.array::<32>()?;
|
||||
let weight = r.u64()?;
|
||||
let header = r.array::<32>()?;
|
||||
let uuids = [r.array::<16>()?, r.array::<16>()?];
|
||||
let enables = r.array::<32>()?;
|
||||
let entry = CString::new(r.bytes()?).ok()?;
|
||||
let flags = r.u32()?;
|
||||
let subgroup = Some(r.u32()?).filter(|&size| size != 0);
|
||||
let count = usize::try_from(r.u64()?).ok()?;
|
||||
let ids = (0..count).map(|_| r.u32()).collect::<Option<Vec<u32>>>()?;
|
||||
let data = r.bytes()?.to_vec();
|
||||
let words = r.bytes()?;
|
||||
let (words, []) = words.as_chunks::<4>() else {
|
||||
return None;
|
||||
};
|
||||
let words: Arc<[u32]> = words.iter().map(|word| u32::from_le_bytes(*word)).collect();
|
||||
r.0.is_empty().then_some(Request {
|
||||
key,
|
||||
weight,
|
||||
header,
|
||||
uuids,
|
||||
enables,
|
||||
words,
|
||||
entry,
|
||||
flags,
|
||||
subgroup,
|
||||
ids,
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/// Reads a payload from its front.
|
||||
struct Reader<'a>(&'a [u8]);
|
||||
|
||||
impl<'a> Reader<'a> {
|
||||
fn array<const N: usize>(&mut self) -> Option<[u8; N]> {
|
||||
let (head, rest) = self.0.split_first_chunk::<N>()?;
|
||||
self.0 = rest;
|
||||
Some(*head)
|
||||
}
|
||||
|
||||
fn u32(&mut self) -> Option<u32> {
|
||||
self.array::<4>().map(u32::from_le_bytes)
|
||||
}
|
||||
|
||||
fn u64(&mut self) -> Option<u64> {
|
||||
self.array::<8>().map(u64::from_le_bytes)
|
||||
}
|
||||
|
||||
fn bytes(&mut self) -> Option<&'a [u8]> {
|
||||
let len = usize::try_from(self.u64()?).ok()?;
|
||||
let (bytes, rest) = self.0.split_at_checked(len)?;
|
||||
self.0 = rest;
|
||||
Some(bytes)
|
||||
}
|
||||
}
|
||||
@@ -390,7 +390,9 @@ mod on_device {
|
||||
}
|
||||
}
|
||||
for &(dispatch, size, _) in &table {
|
||||
state.prepare_dispatch(dispatch, size, &[]);
|
||||
state
|
||||
.prepare_dispatch(dispatch, size, &[])
|
||||
.expect("made ahead");
|
||||
}
|
||||
let after = counters.metrics();
|
||||
let pipelines: HashSet<&str> = table.iter().map(|entry| entry.2).collect();
|
||||
|
||||
@@ -102,6 +102,7 @@ fn at_the_floor() -> Queried {
|
||||
features.vulkan12.host_query_reset = vk::TRUE;
|
||||
features.vulkan13.synchronization2 = vk::TRUE;
|
||||
features.vulkan13.dynamic_rendering = vk::TRUE;
|
||||
features.vulkan13.pipeline_creation_cache_control = vk::TRUE;
|
||||
features.robustness2.null_descriptor = vk::TRUE;
|
||||
features.line_rasterization.bresenham_lines = vk::TRUE;
|
||||
|
||||
@@ -614,6 +615,10 @@ fn each_missing_feature_is_named() {
|
||||
|f| f.vulkan13.dynamic_rendering = vk::FALSE,
|
||||
feature(V13, "dynamicRendering"),
|
||||
),
|
||||
(
|
||||
|f| f.vulkan13.pipeline_creation_cache_control = vk::FALSE,
|
||||
feature(V13, "pipelineCreationCacheControl"),
|
||||
),
|
||||
(
|
||||
|f| f.robustness2.null_descriptor = vk::FALSE,
|
||||
feature(ROBUSTNESS2, "nullDescriptor"),
|
||||
|
||||
@@ -88,6 +88,7 @@ mod shadow;
|
||||
mod signed_zeros;
|
||||
mod sites;
|
||||
mod spill;
|
||||
mod stage;
|
||||
mod staging;
|
||||
#[cfg(m2v_gpu)]
|
||||
mod stamps;
|
||||
|
||||
@@ -1009,7 +1009,8 @@ mod on_device {
|
||||
if prepared {
|
||||
let ahead = counters.metrics();
|
||||
let threads = crate::Dispatch::Threads([grid[0], grid[1], depth]);
|
||||
down.prepare_dispatch(threads, [4, 4, 1], &[]);
|
||||
down.prepare_dispatch(threads, [4, 4, 1], &[])
|
||||
.expect("made ahead");
|
||||
let made = counters.metrics().made_ahead_variants - ahead.made_ahead_variants;
|
||||
assert_eq!(
|
||||
made, 1,
|
||||
|
||||
@@ -0,0 +1,332 @@
|
||||
//! Kernels past the stage bound: the `stages/` directory holds at most its bounds, the most
|
||||
//! recently used kept; an entry cut short, of another key or another driver's header is a miss and
|
||||
//! removed; the wire reads its own version alone; and on a device, a kernel past the bound is
|
||||
//! refused until its helper fills its entry, then made from that entry alone, leaving the device's
|
||||
//! own pipeline cache as it was, and a breach refuses it with no helper asked again.
|
||||
|
||||
use crate::stage::{keep_entry, read_entry, read_frame, write_frame, Entry, Framing, StageBounds};
|
||||
use crate::StageBreach;
|
||||
use std::fs::{self, File};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
/// A directory of its own under the OS temp dir, removed when dropped.
|
||||
struct Scratch(PathBuf);
|
||||
|
||||
impl Scratch {
|
||||
fn new(test: &str) -> Scratch {
|
||||
let dir = std::env::temp_dir().join(format!("m2v-rt-{test}-{}", std::process::id()));
|
||||
let _ = fs::remove_dir_all(&dir);
|
||||
Scratch(dir)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Scratch {
|
||||
fn drop(&mut self) {
|
||||
let _ = fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
/// A pipeline cache header of a device.
|
||||
const HEADER: [u8; 32] = [7; 32];
|
||||
|
||||
/// The key numbered `at`.
|
||||
fn key(at: u8) -> [u8; 32] {
|
||||
[at; 32]
|
||||
}
|
||||
|
||||
/// Cache data of `len` bytes, beginning with [`HEADER`].
|
||||
fn data(len: usize) -> Vec<u8> {
|
||||
let mut data = HEADER.to_vec();
|
||||
data.resize(len, 0x5a);
|
||||
data
|
||||
}
|
||||
|
||||
/// The keys of the entries `dir` holds, sorted.
|
||||
fn held(dir: &Path) -> Vec<u8> {
|
||||
let mut held: Vec<u8> = (fs::read_dir(dir).expect("the directory").flatten())
|
||||
.filter_map(|entry| {
|
||||
let name = entry.file_name().into_string().ok()?;
|
||||
u8::from_str_radix(name.get(..2)?, 16).ok()
|
||||
})
|
||||
.collect();
|
||||
held.sort_unstable();
|
||||
held
|
||||
}
|
||||
|
||||
/// Marks key `at`'s entry as last used `seconds` after the epoch.
|
||||
fn used_at(dir: &Path, at: u8, seconds: u64) {
|
||||
let path = dir.join(crate::cache::hex(&key(at)));
|
||||
let file = File::options().write(true).open(path).expect("the entry");
|
||||
let time = SystemTime::UNIX_EPOCH + Duration::from_secs(seconds);
|
||||
file.set_modified(time).expect("its time");
|
||||
}
|
||||
|
||||
/// Past its count bound and past its byte bound, the directory keeps the most recently used
|
||||
/// entries that fit, the one just written among them; a hit marks an entry used, so it outlives
|
||||
/// older ones.
|
||||
#[test]
|
||||
fn the_stage_directory_keeps_its_bounds_oldest_use_out_first() {
|
||||
let scratch = Scratch::new("stage-bounds");
|
||||
let dir = &scratch.0;
|
||||
// By count: four entries of 100 bytes under a bound of three.
|
||||
let bounds = StageBounds {
|
||||
bytes: 1 << 20,
|
||||
entries: 3,
|
||||
};
|
||||
for at in 1..=3 {
|
||||
assert!(keep_entry(dir, &key(at), &Entry::Data(data(100)), bounds));
|
||||
used_at(dir, at, 1000 + u64::from(at));
|
||||
}
|
||||
// Key 1, the oldest, is used again: it is now the newest.
|
||||
assert_eq!(
|
||||
read_entry(dir, &key(1), &HEADER),
|
||||
Some(Entry::Data(data(100)))
|
||||
);
|
||||
assert!(keep_entry(dir, &key(4), &Entry::Data(data(100)), bounds));
|
||||
assert_eq!(held(dir), [1, 3, 4], "key 2, the oldest use, went");
|
||||
// By bytes: each entry is its frame, its key and its kind beside the data. A bound of two
|
||||
// and a half entries keeps two.
|
||||
let len = fs::metadata(dir.join(crate::cache::hex(&key(4))))
|
||||
.expect("an entry")
|
||||
.len();
|
||||
let bounds = StageBounds {
|
||||
bytes: len * 5 / 2,
|
||||
entries: 32,
|
||||
};
|
||||
for (at, seconds) in [(1, 2000), (3, 2001), (4, 2002)] {
|
||||
used_at(dir, at, seconds);
|
||||
}
|
||||
assert!(keep_entry(dir, &key(5), &Entry::Data(data(100)), bounds));
|
||||
assert_eq!(held(dir), [4, 5], "the two most recently used fit");
|
||||
// A breach is an entry of the same directory, under the same bounds: of two entries, it and
|
||||
// key 5, written after key 4 was last used.
|
||||
let bounds = StageBounds {
|
||||
bytes: 1 << 20,
|
||||
entries: 2,
|
||||
};
|
||||
let breach = Entry::Breach(StageBreach::Memory);
|
||||
assert!(keep_entry(dir, &key(6), &breach, bounds));
|
||||
assert_eq!(held(dir), [5, 6]);
|
||||
assert_eq!(read_entry(dir, &key(6), &HEADER), Some(breach));
|
||||
}
|
||||
|
||||
/// An entry cut short, one under another key's name, one whose data begins with another driver's
|
||||
/// header, and one of an unknown breach are each a miss, and removed.
|
||||
#[test]
|
||||
fn a_cut_or_foreign_entry_is_a_miss_and_is_removed() {
|
||||
let scratch = Scratch::new("stage-foreign");
|
||||
let dir = &scratch.0;
|
||||
let bounds = crate::stage::STAGE_BOUNDS;
|
||||
let path = |at: u8| dir.join(crate::cache::hex(&key(at)));
|
||||
// Cut short.
|
||||
assert!(keep_entry(dir, &key(1), &Entry::Data(data(64)), bounds));
|
||||
let whole = fs::read(path(1)).expect("the entry");
|
||||
fs::write(path(1), &whole[..whole.len() - 1]).expect("cut");
|
||||
assert_eq!(read_entry(dir, &key(1), &HEADER), None);
|
||||
assert!(!path(1).exists(), "the cut entry is removed");
|
||||
// Another key's entry under this key's name.
|
||||
assert!(keep_entry(dir, &key(2), &Entry::Data(data(64)), bounds));
|
||||
fs::rename(path(2), path(3)).expect("renamed");
|
||||
assert_eq!(read_entry(dir, &key(3), &HEADER), None);
|
||||
assert!(!path(3).exists(), "the foreign entry is removed");
|
||||
// Data of another driver's header.
|
||||
assert!(keep_entry(dir, &key(4), &Entry::Data(data(64)), bounds));
|
||||
assert_eq!(read_entry(dir, &key(4), &[8; 32]), None);
|
||||
assert!(!path(4).exists(), "another driver's data is removed");
|
||||
// Each breach reads back as itself, and an unknown one is a miss.
|
||||
let breaches = [
|
||||
StageBreach::Memory,
|
||||
StageBreach::Time,
|
||||
StageBreach::Compile,
|
||||
StageBreach::CompileRequired,
|
||||
];
|
||||
for (at, breach) in (10..).zip(breaches) {
|
||||
assert!(keep_entry(dir, &key(at), &Entry::Breach(breach), bounds));
|
||||
let read = read_entry(dir, &key(at), &HEADER);
|
||||
assert_eq!(read, Some(Entry::Breach(breach)));
|
||||
}
|
||||
let mut body = key(20).to_vec();
|
||||
body.extend([1, 0xff]);
|
||||
let framed = [&crate::cache::frame(&body)[..], &body].concat();
|
||||
fs::write(path(20), framed).expect("an unknown breach");
|
||||
assert_eq!(read_entry(dir, &key(20), &HEADER), None);
|
||||
assert!(!path(20).exists(), "the unknown breach is removed");
|
||||
// A key with no file is a miss.
|
||||
assert_eq!(read_entry(dir, &key(21), &HEADER), None);
|
||||
}
|
||||
|
||||
/// A frame reads back whole; one of another wire version is refused as such; one cut short or
|
||||
/// changed in one byte reads as cut.
|
||||
#[test]
|
||||
fn the_wire_reads_its_own_version_alone() {
|
||||
let payload: Vec<u8> = (0..=255).collect();
|
||||
let mut wire = Vec::new();
|
||||
write_frame(&mut wire, &payload).expect("written");
|
||||
assert_eq!(read_frame(&mut wire.as_slice()).ok(), Some(payload));
|
||||
// The version, after the 8-byte magic.
|
||||
let mut other = wire.clone();
|
||||
other[8] ^= 0x40;
|
||||
assert!(matches!(
|
||||
read_frame(&mut other.as_slice()),
|
||||
Err(Framing::Version)
|
||||
));
|
||||
let cut = &wire[..wire.len() - 1];
|
||||
assert!(matches!(read_frame(&mut &cut[..]), Err(Framing::Cut)));
|
||||
let mut changed = wire.clone();
|
||||
*changed.last_mut().expect("a byte") ^= 1;
|
||||
assert!(matches!(
|
||||
read_frame(&mut changed.as_slice()),
|
||||
Err(Framing::Cut)
|
||||
));
|
||||
}
|
||||
|
||||
/// A consumer joins the makes and dispatches that ask for one pipeline's fill by its request:
|
||||
/// cloned, sent between threads, and compared and hashed by its stage key.
|
||||
#[test]
|
||||
fn a_request_is_a_key_a_consumer_joins_fills_by() {
|
||||
fn joins<T: Clone + Send + Sync + Eq + std::hash::Hash>() {}
|
||||
joins::<crate::StageRequest>();
|
||||
}
|
||||
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
use super::Scratch;
|
||||
use crate::tests::devices_of_the_cfgs_kind;
|
||||
use crate::{
|
||||
serve_stage, ComputePipelineDescriptor, Device, DeviceOptions, Error, FunctionDescriptor,
|
||||
Gap, Library, StageBreach, StageGap, StageSource,
|
||||
};
|
||||
use metal2vulkan_devtools::{engine_dir, llvm_assemble, AssembleError};
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
|
||||
/// The tiling kernel of the engine fixture `a1_bool_from_float.ll`, whose one `VkPipeline` the
|
||||
/// state's make makes; None where `llvm-as` is missing.
|
||||
fn tiled() -> Option<ComputePipelineDescriptor> {
|
||||
let name = "a1_bool_from_float";
|
||||
let bitcode = match llvm_assemble(&engine_dir().join(format!("{name}.ll"))) {
|
||||
Ok(bitcode) => bitcode,
|
||||
Err(AssembleError::Missing(why)) => {
|
||||
eprintln!("SKIPPED: {why}");
|
||||
return None;
|
||||
}
|
||||
Err(error) => panic!("{name}: {error:?}"),
|
||||
};
|
||||
let library = Library::from_air(&bitcode).expect("the library");
|
||||
let function = library.function(name).expect("the kernel");
|
||||
Some(ComputePipelineDescriptor::new(StageSource::Function(
|
||||
FunctionDescriptor::new(function),
|
||||
)))
|
||||
}
|
||||
|
||||
/// A device on `dir`, or with no cache directory.
|
||||
fn on(name: &str, physical: &crate::PhysicalDevice, dir: Option<&Path>) -> Device {
|
||||
let options = DeviceOptions {
|
||||
pipeline_cache_dir: dir.map(Path::to_owned),
|
||||
..DeviceOptions::default()
|
||||
};
|
||||
Device::new(physical, options).unwrap_or_else(|error| panic!("{name}: {error}"))
|
||||
}
|
||||
|
||||
/// With the stage bound below every kernel's weight, the tiling kernel is past it. On a
|
||||
/// device with no cache directory, and on one whose driver writes no pipeline cache header
|
||||
/// (lavapipe), its make is refused ([`Gap::StageSize`]). Elsewhere it is refused unfilled; a
|
||||
/// helper served over two pipes on a thread of the test fills its entry, and the make made
|
||||
/// again creates the `VkPipeline` from that entry alone, with the fail-on-compile-required
|
||||
/// flag, counted, leaving the device's own pipeline cache's data as it was. A breach recorded
|
||||
/// for the request refuses a later device's make, with no helper asked.
|
||||
#[test]
|
||||
fn a_kernel_past_the_stage_bound_is_made_only_from_its_helpers_fill() {
|
||||
let Some(descriptor) = tiled() else {
|
||||
return;
|
||||
};
|
||||
crate::stage::TEST_BOUND.store(1, Relaxed);
|
||||
let instance = crate::tests::validation::instance(&[]);
|
||||
let devices = devices_of_the_cfgs_kind(&instance);
|
||||
assert!(!devices.is_empty(), "no device of this cfg's kind");
|
||||
let make = |device: &Device| {
|
||||
device.new_compute_pipeline_state(&descriptor, crate::tests::no_constexpr_samplers)
|
||||
};
|
||||
for (name, physical) in &devices {
|
||||
let refused = make(&on(name, physical, None)).err();
|
||||
assert!(
|
||||
matches!(
|
||||
refused,
|
||||
Some(Error::Unsupported(Gap::StageSize {
|
||||
cause: StageGap::NoCacheDirectory,
|
||||
..
|
||||
}))
|
||||
),
|
||||
"{name}: {refused:?}"
|
||||
);
|
||||
let scratch = Scratch::new("stage-fill");
|
||||
let device = on(name, physical, Some(&scratch.0));
|
||||
if !crate::tests::keeps_a_blob(name, &device) {
|
||||
let refused = make(&device).err();
|
||||
assert!(
|
||||
matches!(
|
||||
refused,
|
||||
Some(Error::Unsupported(Gap::StageSize {
|
||||
cause: StageGap::NoPipelineCache,
|
||||
..
|
||||
}))
|
||||
),
|
||||
"{name}: {refused:?}"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
let unfilled = || match make(&device) {
|
||||
Err(Error::StageUnfilled(request)) => request,
|
||||
other => panic!("{name}: {:?}", other.err()),
|
||||
};
|
||||
let request = unfilled();
|
||||
assert!(request.weight() > 1, "{name}: {request:?}");
|
||||
// Each make of the pipeline asks for the same fill.
|
||||
assert_eq!(unfilled(), request, "{name}");
|
||||
let core = device.core();
|
||||
// SAFETY: the device is the caches'.
|
||||
let shared = unsafe { core.caches.data(&core.device) }.map(|data| data.len());
|
||||
let (helper_in, to_helper) = std::io::pipe().expect("a pipe");
|
||||
let (from_helper, helper_out) = std::io::pipe().expect("a pipe");
|
||||
let helpers: &crate::Instance = &instance;
|
||||
let served = std::thread::scope(|scope| {
|
||||
let helper = scope.spawn(move || {
|
||||
serve_stage(helpers, DeviceOptions::default(), helper_in, helper_out)
|
||||
});
|
||||
let filled = device.fill_stage(&request, to_helper, from_helper);
|
||||
(filled, helper.join().expect("the helper's thread"))
|
||||
});
|
||||
assert_eq!(served.0, Ok(()), "{name}: the fill");
|
||||
served.1.expect("the helper's pipes");
|
||||
let counters = device.counters();
|
||||
assert_eq!(counters.metrics().stage_fills, 1, "{name}");
|
||||
let state = make(&device).unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let metrics = counters.metrics();
|
||||
assert_eq!(metrics.pipelines_from_stage_fills, 1, "{name}");
|
||||
// SAFETY: as above.
|
||||
let after = unsafe { core.caches.data(&core.device) }.map(|data| data.len());
|
||||
assert_eq!(after, shared, "{name}: the device's own pipeline cache");
|
||||
drop(state);
|
||||
drop(device);
|
||||
// A breach refuses a later device's make, with no helper asked.
|
||||
let device = on(name, physical, Some(&scratch.0));
|
||||
device.record_stage_breach(&request, StageBreach::Memory);
|
||||
let refused = make(&device).err();
|
||||
assert!(
|
||||
matches!(
|
||||
refused,
|
||||
Some(Error::Unsupported(Gap::StageSize {
|
||||
cause: StageGap::Breach(StageBreach::Memory),
|
||||
..
|
||||
}))
|
||||
),
|
||||
"{name}: {refused:?}"
|
||||
);
|
||||
println!(
|
||||
"{name}: refused unfilled, filled by its helper, made from the entry alone, then \
|
||||
refused by its breach"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -689,7 +689,9 @@ mod on_device {
|
||||
for (prepared, size, (grid, how)) in cases {
|
||||
let lengths = [(0, length(size))];
|
||||
let before = counters.metrics();
|
||||
state.prepare_dispatch(prepared, size, &lengths);
|
||||
state
|
||||
.prepare_dispatch(prepared, size, &lengths)
|
||||
.expect("made ahead");
|
||||
let ahead = counters.metrics();
|
||||
assert_eq!(
|
||||
(
|
||||
@@ -700,7 +702,9 @@ mod on_device {
|
||||
(1, 1, 0),
|
||||
"{name}: {prepared:?} by {size:?}: what the call made"
|
||||
);
|
||||
state.prepare_dispatch(prepared, size, &lengths);
|
||||
state
|
||||
.prepare_dispatch(prepared, size, &lengths)
|
||||
.expect("made ahead");
|
||||
let again = counters.metrics();
|
||||
assert_eq!(
|
||||
(again.made_ahead_variants, again.pipelines_created),
|
||||
@@ -732,7 +736,9 @@ mod on_device {
|
||||
];
|
||||
for ((grid, size, how), length, runs) in refusals {
|
||||
let before = counters.metrics();
|
||||
state.prepare_dispatch(Dispatch::Threads(grid), size, &[(0, length)]);
|
||||
state
|
||||
.prepare_dispatch(Dispatch::Threads(grid), size, &[(0, length)])
|
||||
.expect("made ahead");
|
||||
let ahead = counters.metrics();
|
||||
assert_eq!(
|
||||
(
|
||||
@@ -808,7 +814,9 @@ mod on_device {
|
||||
let (grid, size) = ([8, 4, 1], [4, 2, 1]);
|
||||
let lengths = [(0, length(size))];
|
||||
let from = next(&counters);
|
||||
state.prepare_dispatch(Dispatch::Threads(grid), size, &lengths);
|
||||
state
|
||||
.prepare_dispatch(Dispatch::Threads(grid), size, &lengths)
|
||||
.expect("made ahead");
|
||||
let make = one(name, counters.variant_makes(from), "prepare_dispatch");
|
||||
let key = (state.dispatch_variant(Dispatch::Threads(grid), size, &lengths))
|
||||
.map(|(variant, _)| variant);
|
||||
@@ -963,7 +971,9 @@ mod on_device {
|
||||
let mut met = HashSet::new();
|
||||
for (&(dispatch, size, length, pipeline), variant) in table.iter().zip(&keys) {
|
||||
let before = counters.metrics();
|
||||
first.prepare_dispatch(dispatch, size, &[(0, length)]);
|
||||
first
|
||||
.prepare_dispatch(dispatch, size, &[(0, length)])
|
||||
.expect("made ahead");
|
||||
let after = counters.metrics();
|
||||
let new = u64::from(met.insert(*variant));
|
||||
assert_eq!(
|
||||
@@ -990,7 +1000,9 @@ mod on_device {
|
||||
"{name}: {entry:?}: the content's key"
|
||||
);
|
||||
let (dispatch, size, length, _) = entry;
|
||||
again.prepare_dispatch(dispatch, size, &[(0, length)]);
|
||||
again
|
||||
.prepare_dispatch(dispatch, size, &[(0, length)])
|
||||
.expect("made ahead");
|
||||
}
|
||||
assert_eq!(
|
||||
counters.metrics().made_ahead_variants - before.made_ahead_variants,
|
||||
@@ -1004,7 +1016,9 @@ mod on_device {
|
||||
assert!(!keys.contains(&other_key), "{name}: another content's key");
|
||||
let before = counters.metrics();
|
||||
let (dispatch, at, bytes, _) = table[0];
|
||||
other.prepare_dispatch(dispatch, at, &[(0, bytes)]);
|
||||
other
|
||||
.prepare_dispatch(dispatch, at, &[(0, bytes)])
|
||||
.expect("made ahead");
|
||||
assert_eq!(
|
||||
counters.metrics().made_ahead_variants - before.made_ahead_variants,
|
||||
1,
|
||||
@@ -1051,7 +1065,9 @@ mod on_device {
|
||||
let (key, made) = (state.dispatch_variant(dispatch, size, &lengths))
|
||||
.unwrap_or_else(|| panic!("{name}: {size:?}: no key"));
|
||||
assert!(!made, "{name}: {size:?}: made before its make");
|
||||
state.prepare_dispatch(dispatch, size, &lengths);
|
||||
state
|
||||
.prepare_dispatch(dispatch, size, &lengths)
|
||||
.expect("made ahead");
|
||||
let answer = state.dispatch_variant(dispatch, size, &lengths);
|
||||
assert_eq!(
|
||||
answer,
|
||||
@@ -1107,7 +1123,9 @@ mod on_device {
|
||||
let counters = device.counters();
|
||||
let (groups, size) = ([3, 1, 1], [80, 1, 1]);
|
||||
let before = counters.metrics();
|
||||
state.prepare_dispatch(Dispatch::Threadgroups(groups), size, &[]);
|
||||
state
|
||||
.prepare_dispatch(Dispatch::Threadgroups(groups), size, &[])
|
||||
.expect("made ahead");
|
||||
let ahead = counters.metrics();
|
||||
assert_eq!(
|
||||
(
|
||||
@@ -1175,7 +1193,9 @@ mod on_device {
|
||||
How::Groups => crate::Dispatch::Threadgroups(grid),
|
||||
How::Indirect => crate::Dispatch::Indirect,
|
||||
};
|
||||
state.prepare_dispatch(dispatch, size, &[(0, length)]);
|
||||
state
|
||||
.prepare_dispatch(dispatch, size, &[(0, length)])
|
||||
.expect("made ahead");
|
||||
}
|
||||
grid_template_run(name, device, &state, (grid, size, how), length)
|
||||
.unwrap_or_else(|error| panic!("{name}: {how:?} {grid:?}: {error}"));
|
||||
|
||||
@@ -154,7 +154,7 @@ const STAGE_MODULE: &[(&str, Verdict)] = &[
|
||||
"private_bytes",
|
||||
Fact("the bytes FunctionStorageAssumed's announcement may name"),
|
||||
),
|
||||
("stats", Fact("counts of the module, for diagnostics")),
|
||||
("stats", Applied),
|
||||
];
|
||||
|
||||
const COMPUTE_PIPELINE: &[(&str, Verdict)] = &[
|
||||
|
||||
@@ -413,7 +413,9 @@ fn run(
|
||||
device.new_compute_pipeline_state(&descriptor, |samplers| numbered(samplers))
|
||||
})?;
|
||||
// Every pipeline the dispatch runs, made before anything is submitted.
|
||||
state.prepare_dispatch(dispatch, threads_per_group, &lengths);
|
||||
state
|
||||
.prepare_dispatch(dispatch, threads_per_group, &lengths)
|
||||
.map_err(|error| ExecutorError::Failed(format!("the dispatch's pipeline: {error}")))?;
|
||||
let created = device
|
||||
.counters()
|
||||
.metrics()
|
||||
|
||||
@@ -126,8 +126,7 @@ pub enum Outcome {
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum UnsupportedReason {
|
||||
/// Not implemented by this translator version, or a stage past its stage bound
|
||||
/// (`Needs::StageBound`).
|
||||
/// Not implemented by this translator version.
|
||||
NotImplemented,
|
||||
/// No Vulkan 1.2+ mechanism exists.
|
||||
NotRepresentable,
|
||||
@@ -411,8 +410,7 @@ impl From<&Error> for Outcome {
|
||||
feature,
|
||||
capability: capabilities_key(alternatives),
|
||||
},
|
||||
// A stage past the stage bound is the translator's own gap.
|
||||
Needs::NotImplemented | Needs::StageBound => Outcome::Unsupported {
|
||||
Needs::NotImplemented => Outcome::Unsupported {
|
||||
reason: UnsupportedReason::NotImplemented,
|
||||
feature,
|
||||
},
|
||||
|
||||
@@ -50,7 +50,9 @@ impl Pool {
|
||||
return;
|
||||
}
|
||||
tally[0].fetch_add(1, SeqCst);
|
||||
state.prepare_dispatch(grid, size, &lengths);
|
||||
// A kernel past the stage bound is refused at its dispatch too, which the
|
||||
// player reports as the dispatch's own error.
|
||||
let _ = state.prepare_dispatch(grid, size, &lengths);
|
||||
tally[1].fetch_add(1, SeqCst);
|
||||
};
|
||||
let named = std::thread::Builder::new().name(format!("m2v-prepass-{at}"));
|
||||
|
||||
+4
@@ -771,6 +771,7 @@ impl Codec for ModuleStats {
|
||||
constructs: _,
|
||||
loops: _,
|
||||
inert: _,
|
||||
entry_weight: _,
|
||||
} = self;
|
||||
Node::ZERO
|
||||
}
|
||||
@@ -783,6 +784,7 @@ impl Codec for ModuleStats {
|
||||
constructs,
|
||||
loops,
|
||||
inert,
|
||||
entry_weight,
|
||||
} = self;
|
||||
functions.put(w);
|
||||
blocks.put(w);
|
||||
@@ -791,6 +793,7 @@ impl Codec for ModuleStats {
|
||||
constructs.put(w);
|
||||
loops.put(w);
|
||||
inert.put(w);
|
||||
entry_weight.put(w);
|
||||
}
|
||||
fn get(r: &mut Reader<'_>) -> Result<Self, Malformed> {
|
||||
Ok(ModuleStats {
|
||||
@@ -801,6 +804,7 @@ impl Codec for ModuleStats {
|
||||
constructs: Codec::get(r)?,
|
||||
loops: Codec::get(r)?,
|
||||
inert: Codec::get(r)?,
|
||||
entry_weight: Codec::get(r)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -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 = 2256;
|
||||
pub const SEMANTICS_VERSION: u32 = 2257;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
@@ -71,7 +71,7 @@ pub const SEMANTICS_VERSION: u32 = 2256;
|
||||
/// re-typed in an encoded type, its `codec` body or its `envelope`. A variant removed while its tag
|
||||
/// stays unused needs no bump: an entry holding it fails to decode, which is a miss. The commit that
|
||||
/// bumps it says what changed; this comment keeps no history.
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 587;
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 588;
|
||||
|
||||
/// The version of what this crate's runtime does with a compiled pipeline: instantiating a binding
|
||||
/// plan (`BindingPlan::instantiate_*`: descriptor ranges, push bytes, root, argument, and handle
|
||||
|
||||
@@ -12,11 +12,8 @@
|
||||
//! names the Metal construct, and its [`Needs`] says what would change the answer:
|
||||
//! [`Needs::AnyOf`] lists alternative sets of device [`Capability`]s (a device that enables
|
||||
//! every capability of one set compiles it), [`Needs::NotImplemented`] is a gap of this
|
||||
//! translator version on every device, [`Needs::NotRepresentable`] has no Vulkan 1.2+
|
||||
//! mechanism, and
|
||||
//! [`Needs::StageBound`] is a stage the device's plan writes heavier than the translator hands
|
||||
//! any driver of a device [`Device::from_queries`](crate::device::Device::from_queries) made.
|
||||
//! The runtime adds
|
||||
//! translator version on every device, and [`Needs::NotRepresentable`] has no Vulkan 1.2+
|
||||
//! mechanism. The runtime adds
|
||||
//! [`Needs::MetalGpuFamily`]: Metal's own refusal
|
||||
//! on a device without the family, and [`Needs::MetalRefuses`]: Metal's own refusal of the
|
||||
//! form on the devices it was measured on. The translator does not return different output in place
|
||||
@@ -306,9 +303,7 @@ pub struct Unsupported {
|
||||
pub location: Option<Location>,
|
||||
/// The symbol the refused construct names, for diagnostics only: an unknown intrinsic, the
|
||||
/// callee of a call that needs linking, the pixel format a refused texture, view or copy
|
||||
/// holds, or, for a stage past the size the
|
||||
/// translator hands a driver ([`Feature::StageSize`]), the stage's entry weight and the bound
|
||||
/// it passed (`entry weight 532213, past the bound 99109`). Opaque like every [`DiagName`].
|
||||
/// holds. Opaque like every [`DiagName`].
|
||||
pub symbol: Option<DiagName>,
|
||||
}
|
||||
|
||||
@@ -460,13 +455,6 @@ pub enum Needs {
|
||||
NotImplemented,
|
||||
/// No Vulkan 1.2+ mechanism exists for these semantics.
|
||||
NotRepresentable,
|
||||
/// The stage, as this device's plan writes it, is heavier than the translator hands any
|
||||
/// driver: its entry weight passes the heaviest stage measured to compile within host-sized memory
|
||||
/// ([`Unsupported::symbol`] names the weight and the bound). The weight is the plan's, so a
|
||||
/// device whose plan writes the stage lighter translates it: one that keeps its widest
|
||||
/// simdgroup mode pinned where this one emulates simdgroups. A gap of the translator rather
|
||||
/// than of the device: no device is handed a stage past the bound.
|
||||
StageBound,
|
||||
/// A device that claims this Metal GPU family (`MTLGPUFamily`'s raw value, 1010 for Apple10),
|
||||
/// which the device does not: Metal itself refuses the input on a device without the family,
|
||||
/// so the refusal is Metal's own answer rather than a gap. Only the runtime refuses so, by the
|
||||
@@ -606,10 +594,6 @@ pub enum Feature {
|
||||
ImageAtomics,
|
||||
/// Too many descriptors of one kind in a stage or pipeline.
|
||||
DescriptorCount,
|
||||
/// A stage module heavier than the translator hands the device's driver: past the heaviest
|
||||
/// measured to compile within host-sized memory, on a device
|
||||
/// [`Device::from_queries`](crate::device::Device::from_queries) made ([`Needs::StageBound`]).
|
||||
StageSize,
|
||||
/// A buffer window beyond the descriptor range limits.
|
||||
BufferRange,
|
||||
|
||||
|
||||
@@ -16,10 +16,6 @@ fn one_of_each() -> Vec<Error> {
|
||||
Feature::IndirectRenderState,
|
||||
1010,
|
||||
)),
|
||||
Error::Unsupported(Unsupported {
|
||||
needs: Needs::StageBound,
|
||||
..Unsupported::not_implemented(Feature::StageSize)
|
||||
}),
|
||||
Error::NeedsInput(RuntimeInput::VertexDescriptor { attribute: 3 }),
|
||||
Error::InvalidInput(InputError::new(
|
||||
InputErrorKind::Container(ContainerError::BadMagic),
|
||||
@@ -54,16 +50,14 @@ fn retry_table() {
|
||||
Error::Unsupported(u) => match u.needs {
|
||||
Needs::AnyOf(_) => Retry::Never,
|
||||
Needs::NotImplemented | Needs::NotRepresentable => Retry::Never,
|
||||
// A defect of the device's driver: another device translates the input. A stage
|
||||
// past the bound: another device's plan may write it lighter. A Metal GPU
|
||||
// family the device does not claim: another device, one that claims it, may. A
|
||||
// A defect of the device's driver: another device translates the input. A Metal
|
||||
// GPU family the device does not claim: another device, one that claims it, may. A
|
||||
// form Metal refuses on the measured devices: an unmeasured device is not refused
|
||||
// so. A device capability outside the compile layer's vocabulary: a device with
|
||||
// it runs the input.
|
||||
Needs::StageBound
|
||||
| Needs::DeviceCapability(_)
|
||||
| Needs::MetalGpuFamily(_)
|
||||
| Needs::MetalRefuses(_) => Retry::Never,
|
||||
Needs::DeviceCapability(_) | Needs::MetalGpuFamily(_) | Needs::MetalRefuses(_) => {
|
||||
Retry::Never
|
||||
}
|
||||
},
|
||||
Error::NeedsInput(_) => Retry::Never,
|
||||
Error::InvalidInput(_) => Retry::Never,
|
||||
|
||||
@@ -322,8 +322,8 @@ pub struct SimdPlan {
|
||||
|
||||
/// Whether [`widest_pin`] weighs a kernel for the `Emulated` tier, or the kernel keeps the
|
||||
/// `Direct` tier's pin to the device's widest mode whatever its pressure: a kernel whose emulated
|
||||
/// module passed the bound every stage of a profile `Device::from_queries` built is held under is
|
||||
/// planned again keeping it (`pipeline::compile`'s stage bound, `device::profile::StageBound`).
|
||||
/// module passed the compiled stage bound is planned again keeping it (`pipeline::compile`'s stage
|
||||
/// bound).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum WidestPin {
|
||||
/// [`widest_pin`] weighs the kernel.
|
||||
|
||||
@@ -330,6 +330,13 @@ pub struct ModuleStats {
|
||||
/// name as reading or computing alone (an interlock, a ray query) makes it not inert.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub inert: bool,
|
||||
/// The entry's weight: its instructions with each call counted as its callee's body, as a
|
||||
/// driver inlines every call, after the repeated regions are rolled. A stage that weighs more
|
||||
/// than [`COMPILED_STAGE_WEIGHT`](crate::pipeline::COMPILED_STAGE_WEIGHT) is one whose
|
||||
/// creation may take the host's memory: `metal2vulkan-runtime` compiles it only in a helper
|
||||
/// process the consumer caps. 0 for a stage the link makes itself.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub entry_weight: u64,
|
||||
}
|
||||
|
||||
/// A precision note a stage records only where a specialized module runs an arm that keeps its
|
||||
|
||||
@@ -65,6 +65,7 @@ use crate::spirv::ir::TypedModule;
|
||||
|
||||
pub use entry::{EntryDescriptor, EntryPlan, StandaloneModule};
|
||||
pub(crate) use stage_bound::StageBounds;
|
||||
pub use stage_bound::COMPILED_STAGE_WEIGHT;
|
||||
|
||||
/// Which entry of a bitcode module to compile.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
@@ -3159,6 +3160,7 @@ fn lower_bounded<K>(
|
||||
merged,
|
||||
held,
|
||||
},
|
||||
entry_weight,
|
||||
) = stage_bound::emit(r, p, bounds, m)?;
|
||||
let function_tables = spec.function_tables.clone();
|
||||
let reaches_command_buffers = spec.may_encode_indirect_commands();
|
||||
@@ -3257,7 +3259,10 @@ fn lower_bounded<K>(
|
||||
precision.push(PrecisionNote::DeviceSampling);
|
||||
precision.sort_unstable();
|
||||
}
|
||||
let stats = crate::spirv::verify::verify(&module, p, m)?;
|
||||
let stats = crate::pipeline::artifact::ModuleStats {
|
||||
entry_weight,
|
||||
..crate::spirv::verify::verify(&module, p, m)?
|
||||
};
|
||||
let kept = keep(&module);
|
||||
let mut symbols =
|
||||
crate::pipeline::link::contract::stage_symbols(&module, &plan.families.stage_io.interface)?;
|
||||
|
||||
@@ -166,8 +166,8 @@ impl DeviceProfile {
|
||||
|
||||
/// Everything [`DeviceProfile::compile_entry`] does before emission (decode, specialize,
|
||||
/// analyze, select), and what it cost against `budget`: its first plan, which a kernel whose
|
||||
/// emitted module passes the bound every stage of a profile `Device::from_queries` built is
|
||||
/// held under replaces (`device::profile::StageBound`).
|
||||
/// emulated module passes the compiled stage bound replaces with a plan keeping its pin
|
||||
/// (`pipeline::compile`'s stage bound).
|
||||
pub fn plan_entry(
|
||||
&self,
|
||||
d: &EntryDescriptor<'_>,
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
//! The stage bound: every module kept under the compiled bound, on every device.
|
||||
//! The stage bound: every module weighed, and a kernel kept under the compiled bound where a lighter
|
||||
//! plan of it is.
|
||||
//!
|
||||
//! A driver's compiler takes memory that grows faster than the stage, in the process that creates
|
||||
//! the pipeline, so one creation past the largest stage measured to compile may take the host's
|
||||
//! memory. No Vulkan query states how large a stage a device's compiler takes, so every stage, on
|
||||
//! every device, is held under the compiled bound, the heaviest stage measured to compile on the
|
||||
//! slowest compiler measured, one form for every device.
|
||||
//! memory. No Vulkan query states how large a stage a device's compiler takes, so the bound is the
|
||||
//! heaviest stage measured to compile on the slowest compiler measured, one bound for every device.
|
||||
//!
|
||||
//! A module whose entry weighs more than the bound (`spirv::roll::entry_weight`: the entry's
|
||||
//! instructions with each call counted as its callee's body, as the driver inlines every call)
|
||||
//! after the repeated regions are rolled is past it:
|
||||
//!
|
||||
//! - 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 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::StageBound`, naming as its symbol the module's
|
||||
//! entry weight and the bound it passed): a device whose compiler would take a heavier stage is
|
||||
//! refused it all the same, a known gap of `metal2vulkan-runtime`.
|
||||
//! Every module's entry is weighed (`spirv::roll::entry_weight`: the entry's instructions with each
|
||||
//! call counted as its callee's body, as the driver inlines every call) after the repeated regions
|
||||
//! are rolled, and the weight is the module's ([`ModuleStats::entry_weight`]). A kernel past the
|
||||
//! bound 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 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 the bound, a
|
||||
//! kernel planned again that still is among them, is made as it weighs: whoever creates its
|
||||
//! pipeline reads the weight against [`COMPILED_STAGE_WEIGHT`] (`metal2vulkan-runtime` compiles
|
||||
//! such a kernel only in a helper process the consumer caps).
|
||||
//!
|
||||
//! **The compiled bound.** [`COMPILED_STAGE_WEIGHT`] is the heaviest entry measured to compile
|
||||
//! within host-sized memory: on ANV, Mesa 26.2.6, on the Iris Xe of RPL-P, compute modules created
|
||||
@@ -28,20 +26,26 @@
|
||||
//! entry weight 532,213 passed 16 GiB at 358 s without finishing, where it was stopped. No margin
|
||||
//! is taken below it, as no weight above it is measured to compile; it rises when a larger compile
|
||||
//! is measured within host-sized memory.
|
||||
//!
|
||||
//! [`ModuleStats::entry_weight`]: crate::pipeline::ModuleStats::entry_weight
|
||||
|
||||
use super::{analyze_one, Planned, Request};
|
||||
use crate::budget::Meter;
|
||||
use crate::device::DeviceProfile;
|
||||
use crate::error::{DiagName, Error, Feature, Needs, Unsupported};
|
||||
use crate::error::Error;
|
||||
use crate::lower::emit::Emitted;
|
||||
use crate::lower::simd::WidestPin;
|
||||
|
||||
/// The heaviest entry ([`crate::spirv::roll::entry_weight`]) every stage is handed: the largest
|
||||
/// measured to compile (the module docs' compiled bound).
|
||||
pub(crate) const COMPILED_STAGE_WEIGHT: u64 = 99_109;
|
||||
/// The heaviest entry weight ([`ModuleStats::entry_weight`]) measured to compile within host-sized
|
||||
/// memory (the module docs' compiled bound). A stage that weighs more is one whose creation may
|
||||
/// take the host's memory.
|
||||
///
|
||||
/// [`ModuleStats::entry_weight`]: crate::pipeline::ModuleStats::entry_weight
|
||||
pub const COMPILED_STAGE_WEIGHT: u64 = 99_109;
|
||||
|
||||
/// The entry weight past which no module is handed to the device: the measured one in production
|
||||
/// ([`StageBounds::MEASURED`]), another in a test, so it reaches the bound with a small module.
|
||||
/// The entry weight past which a kernel is planned again keeping its pin: the measured one in
|
||||
/// production ([`StageBounds::MEASURED`]), another in a test, so it reaches the bound with a small
|
||||
/// module.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct StageBounds {
|
||||
/// Every stage's bound.
|
||||
@@ -55,16 +59,15 @@ impl StageBounds {
|
||||
};
|
||||
}
|
||||
|
||||
/// `r`'s function planned and emitted with its repeated regions rolled, under `bounds` (the
|
||||
/// module docs): planned again keeping the widest mode's pin where only that pin's emulation
|
||||
/// passed the bound, else refused, naming the module's entry weight and the bound
|
||||
/// ([`past_bound`]).
|
||||
/// `r`'s function planned and emitted with its repeated regions rolled, with its entry weight:
|
||||
/// planned again keeping the widest mode's pin where only that pin's emulation passed `bounds`
|
||||
/// (the module docs).
|
||||
pub(super) fn emit(
|
||||
r: &Request<'_>,
|
||||
p: &DeviceProfile,
|
||||
bounds: StageBounds,
|
||||
m: &mut Meter,
|
||||
) -> Result<(Planned, Emitted), Error> {
|
||||
) -> Result<(Planned, Emitted, u64), Error> {
|
||||
let analyzed = analyze_one(r, p, m)?;
|
||||
let mut widest = WidestPin::Weighed;
|
||||
loop {
|
||||
@@ -83,11 +86,9 @@ pub(super) fn emit(
|
||||
crate::spirv::hoist::hoist_uniform_loads(&mut emitted.module, p.robustness(), m)
|
||||
})?;
|
||||
let weight = crate::spirv::roll::entry_weight(&emitted.module, m)?;
|
||||
if weight <= bounds.compiled {
|
||||
return Ok((analyzed.planned(plan, kernel), emitted));
|
||||
}
|
||||
if widest == WidestPin::Kept || !plan.families.simd.widest_pin {
|
||||
return Err(refused(weight, bounds.compiled));
|
||||
if weight <= bounds.compiled || widest == WidestPin::Kept || !plan.families.simd.widest_pin
|
||||
{
|
||||
return Ok((analyzed.planned(plan, kernel), emitted, weight));
|
||||
}
|
||||
// The emulated plan and module go, and with them what they hold of the ledger.
|
||||
drop((plan, emitted));
|
||||
@@ -96,18 +97,3 @@ pub(super) fn emit(
|
||||
widest = WidestPin::Kept;
|
||||
}
|
||||
}
|
||||
|
||||
/// The refusal of a module of entry weight `weight` past `bound`.
|
||||
fn refused(weight: u64, bound: u64) -> Error {
|
||||
Error::Unsupported(Unsupported {
|
||||
feature: Feature::StageSize,
|
||||
needs: Needs::StageBound,
|
||||
location: None,
|
||||
symbol: Some(past_bound(weight, bound)),
|
||||
})
|
||||
}
|
||||
|
||||
/// What a stage's refusal names as its symbol: the module's entry weight and the bound it passed.
|
||||
fn past_bound(weight: u64, bound: u64) -> DiagName {
|
||||
DiagName::new(format!("entry weight {weight}, past the bound {bound}"))
|
||||
}
|
||||
@@ -143,6 +143,7 @@ pub use compile::api::{CompileReport, RenderPipelineKeys};
|
||||
// Translating one entry of a bare module.
|
||||
pub use compile::{
|
||||
EntryDescriptor, EntryPlan, EntryRef, LinkedSource, StageEntries, StandaloneModule,
|
||||
COMPILED_STAGE_WEIGHT,
|
||||
};
|
||||
pub use facts::{Mechanism, RuntimeFact, UniformViewChoice};
|
||||
// The `DispatchRegion` push field's bytes, which a consumer of the identity domains pushes with
|
||||
|
||||
@@ -2325,16 +2325,15 @@ fn a_pressured_kernel_takes_the_emulated_tier_in_place_of_the_widest_mode() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Every stage is held under the compiled bound (here bounds the test sets), whatever the driver:
|
||||
/// the pressured kernel of `a_pressured_kernel_takes_the_emulated_tier_in_place_of_the_widest_mode`,
|
||||
/// whose emulated module passes the bound, is planned again keeping the `Direct` tier's pin to 32
|
||||
/// lanes, its answers Metal's; under a bound its `Direct` module passes too, it is refused
|
||||
/// (`Feature::StageSize`, `Needs::StageBound`, and as its symbol the module's entry weight and the
|
||||
/// bound it passed).
|
||||
/// Every stage is weighed against the compiled bound (here bounds the test sets), whatever the
|
||||
/// driver: the pressured kernel of
|
||||
/// `a_pressured_kernel_takes_the_emulated_tier_in_place_of_the_widest_mode`, whose emulated module
|
||||
/// passes the bound, is planned again keeping the `Direct` tier's pin to 32 lanes, its answers
|
||||
/// Metal's; under a bound its `Direct` module passes too, it is made as it weighs, its stats naming
|
||||
/// its entry weight (`ModuleStats::entry_weight`), for the runtime to compile apart.
|
||||
#[test]
|
||||
fn every_stage_from_queries_keeps_the_widest_pin_or_is_refused() {
|
||||
fn every_stage_from_queries_keeps_the_widest_pin_or_states_its_weight() {
|
||||
use crate::device::Device;
|
||||
use crate::error::{DiagName, Feature, Needs};
|
||||
use crate::lower::simd::{WIDEST_PIN, WIDEST_PIN_FLOOR, WIDEST_PIN_WORDS};
|
||||
use crate::pipeline::compile::{compile_bitcode_bounded, StageBounds};
|
||||
use crate::pipeline::testing::meter;
|
||||
@@ -2357,28 +2356,24 @@ fn every_stage_from_queries_keeps_the_widest_pin_or_is_refused() {
|
||||
assert_eq!((plan.simd.1, uses(&plan, WIDEST_PIN)), (Tier::Emulated, 1));
|
||||
let emulated = weight(&emulated);
|
||||
// Under a bound the emulated module passes: planned again keeping the pin, exact at 32 lanes.
|
||||
let (_, plan, module) = compile(queries, compiled(emulated - 1)).expect("planned again");
|
||||
let (function, plan, module) = compile(queries, compiled(emulated - 1)).expect("planned again");
|
||||
assert_eq!((plan.simd.1, uses(&plan, WIDEST_PIN)), (Tier::Direct, 0));
|
||||
assert_eq!(plan.subgroup.size, Some(32));
|
||||
let pinned = weight(&module);
|
||||
assert!(pinned < emulated, "pinned {pinned}, emulated {emulated}");
|
||||
assert_eq!(function.module_stats().entry_weight, pinned);
|
||||
assert_eq!(run_words(&plan, &module, 64, SubgroupSize::W32), want);
|
||||
// Under a bound the pinned module passes too: refused, naming its weight and the bound.
|
||||
match compile(queries, compiled(pinned - 1)).expect_err("past the bound") {
|
||||
Error::Unsupported(u) if u.feature == Feature::StageSize => {
|
||||
let named = format!("entry weight {pinned}, past the bound {}", pinned - 1);
|
||||
assert_eq!(u.symbol, Some(DiagName::new(named.as_str())), "{u}");
|
||||
assert!(u.to_string().contains(&named), "{u}");
|
||||
assert_eq!(u.needs, Needs::StageBound);
|
||||
}
|
||||
refused => panic!("{refused:?}"),
|
||||
}
|
||||
// Under a bound the pinned module passes too: made as it weighs, pinned, its weight stated.
|
||||
let (function, plan, module) = compile(queries, compiled(pinned - 1)).expect("past the bound");
|
||||
assert_eq!((plan.simd.1, uses(&plan, WIDEST_PIN)), (Tier::Direct, 0));
|
||||
assert_eq!(weight(&module), pinned);
|
||||
assert_eq!(function.module_stats().entry_weight, pinned);
|
||||
}
|
||||
|
||||
/// One input, one answer, whichever path compiles it: on the Iris Xe, the pressured kernel of
|
||||
/// `every_stage_from_queries_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
|
||||
/// `every_stage_from_queries_keeps_the_widest_pin_or_states_its_weight`, past a bound its emulated
|
||||
/// module passes and past one its pinned module passes too (planned again keeping the pin, its
|
||||
/// weight stated, both times), 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
|
||||
@@ -2388,7 +2383,7 @@ fn every_stage_from_queries_keeps_the_widest_pin_or_is_refused() {
|
||||
#[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::error::Limit;
|
||||
use crate::library::Library;
|
||||
use crate::lower::simd::{WIDEST_PIN_FLOOR, WIDEST_PIN_WORDS};
|
||||
use crate::pipeline::compile::{
|
||||
@@ -2422,15 +2417,17 @@ fn a_kernel_past_the_stage_bound_gets_one_answer_through_either_path() {
|
||||
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.
|
||||
// Its answer, as a planned-again `Direct` module's word count and entry weight, or the limit.
|
||||
let answer = |compiled: Result<crate::library::CompiledFunction, Error>| 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)),
|
||||
Ok(c) => Ok((
|
||||
c.artifact().module.words.len(),
|
||||
c.module_stats().entry_weight,
|
||||
)),
|
||||
Err(Error::LimitExceeded(limit)) => 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)] {
|
||||
for cap in [emulated - 1, pinned - 1] {
|
||||
// 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();
|
||||
@@ -2442,10 +2439,7 @@ fn a_kernel_past_the_stage_bound_gets_one_answer_through_either_path() {
|
||||
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!(want.map(|(_, weight)| weight), Ok(pinned), "bound {cap}");
|
||||
assert_eq!(
|
||||
(made, found),
|
||||
((want.clone(), w), (want.clone(), w)),
|
||||
@@ -2453,7 +2447,7 @@ fn a_kernel_past_the_stage_bound_gets_one_answer_through_either_path() {
|
||||
);
|
||||
// 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 (budget, expected) in [(w, want.clone()), (w - 1, 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, at(cap)));
|
||||
@@ -2471,11 +2465,7 @@ fn a_kernel_past_the_stage_bound_gets_one_answer_through_either_path() {
|
||||
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, at(cap)));
|
||||
assert_eq!(
|
||||
got,
|
||||
Err(Err(Limit::WorkUnits)),
|
||||
"bound {cap}, charged twice"
|
||||
);
|
||||
assert_eq!(got, Err(Limit::WorkUnits), "bound {cap}, charged twice");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2485,14 +2475,12 @@ fn a_kernel_past_the_stage_bound_gets_one_answer_through_either_path() {
|
||||
/// offers the widest mode's pin and which has maximal reconvergence, the kernel emulates its
|
||||
/// simdgroups, a module past the compiled bound, and is planned again keeping the pin, a module
|
||||
/// under it. The same description without maximal reconvergence emulates its simdgroups for the
|
||||
/// lockstep pair, so it has no pin to keep: it is refused as `Needs::StageBound`, its symbol
|
||||
/// naming the emulated module's weight and the bound, under any driver (Intel's Windows driver
|
||||
/// too).
|
||||
/// lockstep pair, so it has no pin to keep: it is made as it weighs, past the bound, its stats
|
||||
/// naming the emulated module's weight, under any driver (Intel's Windows driver too).
|
||||
#[test]
|
||||
fn the_stage_bound_fixture_keeps_the_pin_or_is_refused() {
|
||||
fn the_stage_bound_fixture_keeps_the_pin_or_states_its_weight() {
|
||||
use crate::device::profile::DeviceProfile;
|
||||
use crate::device::{Device, DeviceDescription};
|
||||
use crate::error::{DiagName, Feature, Needs};
|
||||
use crate::lower::simd::WIDEST_PIN;
|
||||
use crate::pipeline::compile::{compile_bitcode_bounded, compile_bitcode_kept, StageBounds};
|
||||
use crate::pipeline::testing::meter;
|
||||
@@ -2557,14 +2545,10 @@ fn the_stage_bound_fixture_keeps_the_pin_or_is_refused() {
|
||||
assert_eq!((plan.simd.1, uses(&plan, WIDEST_PIN)), (Tier::Emulated, 0));
|
||||
let alone = weight(&module);
|
||||
assert!(alone > bound, "emulated {alone}");
|
||||
match kept(p) {
|
||||
Err(Error::Unsupported(u)) if u.feature == Feature::StageSize => {
|
||||
let named = format!("entry weight {alone}, past the bound {bound}");
|
||||
assert_eq!(u.symbol, Some(DiagName::new(named.as_str())), "{u}");
|
||||
assert_eq!(u.needs, Needs::StageBound);
|
||||
}
|
||||
got => panic!("{:?}", got.map(|_| ())),
|
||||
}
|
||||
let (function, plan, module) = kept(p).expect("made as it weighs");
|
||||
assert_eq!((plan.simd.1, uses(&plan, WIDEST_PIN)), (Tier::Emulated, 0));
|
||||
assert_eq!(weight(&module), alone);
|
||||
assert_eq!(function.module_stats().entry_weight, alone);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -526,6 +526,7 @@ const metal2vulkan::cache::SEMANTICS_VERSION pub const SEMANTICS_VERSION: u32
|
||||
const metal2vulkan::metal::format::BICUBIC_TEXELS_UNBOUND pub const BICUBIC_TEXELS_UNBOUND: u32
|
||||
const metal2vulkan::metal::sampler::NOT_MIPMAPPED_MAX_LOD pub const NOT_MIPMAPPED_MAX_LOD: f32
|
||||
const metal2vulkan::metal::vertex::MAX_VERTEX_ALIGNMENT pub const MAX_VERTEX_ALIGNMENT: u32
|
||||
const metal2vulkan::pipeline::COMPILED_STAGE_WEIGHT pub const COMPILED_STAGE_WEIGHT: u64
|
||||
const metal2vulkan::pipeline::DEEP_THREADGROUP pub const DEEP_THREADGROUP: u32
|
||||
const metal2vulkan::pipeline::GRID_TILE_THREADS pub const GRID_TILE_THREADS: u32
|
||||
const metal2vulkan::pipeline::NONUNIFORM pub const NONUNIFORM: u32
|
||||
@@ -605,6 +606,7 @@ const-value metal2vulkan::bind::indirect_commands::WRITTEN_FLAG_BYTES 4
|
||||
const-value metal2vulkan::metal::format::BICUBIC_TEXELS_UNBOUND crate::metal::bicubic::BicubicTexels::NEUTRAL.0
|
||||
const-value metal2vulkan::metal::sampler::NOT_MIPMAPPED_MAX_LOD 0.25
|
||||
const-value metal2vulkan::metal::vertex::MAX_VERTEX_ALIGNMENT 4
|
||||
const-value metal2vulkan::pipeline::COMPILED_STAGE_WEIGHT 99_109
|
||||
const-value metal2vulkan::pipeline::DEEP_THREADGROUP 64
|
||||
const-value metal2vulkan::pipeline::GRID_TILE_THREADS 256
|
||||
const-value metal2vulkan::pipeline::NONUNIFORM 1
|
||||
@@ -778,6 +780,9 @@ enum metal2vulkan-runtime::RenderPassKind #[derive(Clone, Copy, Debug, PartialEq
|
||||
enum metal2vulkan-runtime::RenderPipelineKind #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum RenderPipelineKind
|
||||
enum metal2vulkan-runtime::Resource #[derive(Clone, Copy)] #[non_exhaustive] pub enum Resource<'a>
|
||||
enum metal2vulkan-runtime::Stage #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum Stage
|
||||
enum metal2vulkan-runtime::StageBreach #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum StageBreach
|
||||
enum metal2vulkan-runtime::StageFill #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum StageFill
|
||||
enum metal2vulkan-runtime::StageGap #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum StageGap
|
||||
enum metal2vulkan-runtime::StageSource #[derive(Clone, Debug, PartialEq, Eq)] pub enum StageSource
|
||||
enum metal2vulkan-runtime::StorageMode #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum StorageMode
|
||||
enum metal2vulkan-runtime::StoreAction #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum StoreAction
|
||||
@@ -1687,6 +1692,7 @@ field metal2vulkan-runtime::Metrics.pipeline_cache_lock_waits pub pipeline_cache
|
||||
field metal2vulkan-runtime::Metrics.pipeline_cache_looks_skipped pub pipeline_cache_looks_skipped: u64
|
||||
field metal2vulkan-runtime::Metrics.pipeline_creation_nanos pub pipeline_creation_nanos: u64
|
||||
field metal2vulkan-runtime::Metrics.pipelines_created pub pipelines_created: u64
|
||||
field metal2vulkan-runtime::Metrics.pipelines_from_stage_fills pub pipelines_from_stage_fills: u64
|
||||
field metal2vulkan-runtime::Metrics.preprocess_regions_remade pub preprocess_regions_remade: u64
|
||||
field metal2vulkan-runtime::Metrics.private_arena_allocations pub private_arena_allocations: SiteAllocations
|
||||
field metal2vulkan-runtime::Metrics.private_arena_blocks pub private_arena_blocks: u64
|
||||
@@ -1714,6 +1720,7 @@ field metal2vulkan-runtime::Metrics.shared_long_reuses pub shared_long_reuses: u
|
||||
field metal2vulkan-runtime::Metrics.shared_remade_after_frees pub shared_remade_after_frees: u64
|
||||
field metal2vulkan-runtime::Metrics.shared_take_allocations pub shared_take_allocations: SiteAllocations
|
||||
field metal2vulkan-runtime::Metrics.sparse_binds pub sparse_binds: u64
|
||||
field metal2vulkan-runtime::Metrics.stage_fills pub stage_fills: u64
|
||||
field metal2vulkan-runtime::Metrics.staging_buffer_allocations pub staging_buffer_allocations: SiteAllocations
|
||||
field metal2vulkan-runtime::Metrics.staging_region_allocations pub staging_region_allocations: SiteAllocations
|
||||
field metal2vulkan-runtime::Metrics.staging_sleeps pub staging_sleeps: u64
|
||||
@@ -3054,6 +3061,7 @@ field metal2vulkan::pipeline::MeshPipelineDescriptor.support_indirect_command_bu
|
||||
field metal2vulkan::pipeline::MeshPipelineDescriptor.texture_write_rounding_mode pub texture_write_rounding_mode: metal::TextureWriteRoundingMode
|
||||
field metal2vulkan::pipeline::ModuleStats.blocks pub blocks: u32
|
||||
field metal2vulkan::pipeline::ModuleStats.constructs pub constructs: u32
|
||||
field metal2vulkan::pipeline::ModuleStats.entry_weight pub entry_weight: u64
|
||||
field metal2vulkan::pipeline::ModuleStats.functions pub functions: u32
|
||||
field metal2vulkan::pipeline::ModuleStats.inert pub inert: bool
|
||||
field metal2vulkan::pipeline::ModuleStats.instructions pub instructions: u64
|
||||
@@ -3350,6 +3358,7 @@ fn metal2vulkan-air::specialize pub fn specialize(d: Decoded, r: &SpecRequest, m
|
||||
fn metal2vulkan-air::specialize_dynamic pub fn specialize_dynamic(d: Decoded, r: &SpecRequest, (linked, dynamic): (&[LinkedModule], &DynamicLinks), m: &mut Meter) -> Result<Entry, Error>
|
||||
fn metal2vulkan-air::specialize_linked pub fn specialize_linked(d: Decoded, r: &SpecRequest, linked: &[LinkedModule], m: &mut Meter) -> Result<Entry, Error>
|
||||
fn metal2vulkan-runtime::host_time pub fn host_time() -> u64
|
||||
fn metal2vulkan-runtime::serve_stage pub fn serve_stage(instance: &Instance, mut options: DeviceOptions, mut from_parent: impl Read, mut to_parent: impl Write) -> io::Result<()>
|
||||
fn metal2vulkan::ash_interop::sampler_create_info pub fn sampler_create_info<'a>(desc: &vk::SamplerDesc, reduction: &'a mut ash::vk::SamplerReductionModeCreateInfo<'static>, border: &'a mut ash::vk::SamplerBorderColorComponentMappingCreateInfoEXT<'static>) -> ash::vk::SamplerCreateInfo<'a>
|
||||
fn metal2vulkan::bind::alpha_test_code pub fn alpha_test_code(reference: f32) -> u32
|
||||
fn metal2vulkan::bind::clamped_depth pub const fn clamped_depth(bits: u32) -> u32
|
||||
@@ -6533,7 +6542,7 @@ method metal2vulkan-runtime::ComputePipelineState::dispatch_variant pub fn dispa
|
||||
method metal2vulkan-runtime::ComputePipelineState::imageblock_memory_length_for_dimensions pub fn imageblock_memory_length_for_dimensions(&self, _dimensions: [u32; 3]) -> Result<u64, Error>
|
||||
method metal2vulkan-runtime::ComputePipelineState::max_total_threads_per_threadgroup pub fn max_total_threads_per_threadgroup(&self) -> u32
|
||||
method metal2vulkan-runtime::ComputePipelineState::precision_notes pub fn precision_notes(&self) -> Vec<PrecisionNote>
|
||||
method metal2vulkan-runtime::ComputePipelineState::prepare_dispatch pub fn prepare_dispatch(&self, dispatch: Dispatch, threads_per_threadgroup: [u32; 3], threadgroup_memory_lengths: &[(u32, u32)])
|
||||
method metal2vulkan-runtime::ComputePipelineState::prepare_dispatch pub fn prepare_dispatch(&self, dispatch: Dispatch, threads_per_threadgroup: [u32; 3], threadgroup_memory_lengths: &[(u32, u32)]) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::ComputePipelineState::required_threads_per_threadgroup pub fn required_threads_per_threadgroup(&self) -> [u32; 3]
|
||||
method metal2vulkan-runtime::ComputePipelineState::static_threadgroup_memory_length pub fn static_threadgroup_memory_length(&self) -> u32
|
||||
method metal2vulkan-runtime::ComputePipelineState::support_indirect_command_buffers pub fn support_indirect_command_buffers(&self) -> bool
|
||||
@@ -6549,6 +6558,7 @@ method metal2vulkan-runtime::Device::counters pub fn counters(&self) -> Counters
|
||||
method metal2vulkan-runtime::Device::dma_buf_granule #[cfg(unix)] pub fn dma_buf_granule(&self) -> Option<u64>
|
||||
method metal2vulkan-runtime::Device::extensions pub fn extensions(&self) -> &[CString]
|
||||
method metal2vulkan-runtime::Device::features pub fn features(&self) -> &[ConsumerFeature]
|
||||
method metal2vulkan-runtime::Device::fill_stage pub fn fill_stage(&self, request: &StageRequest, mut to_helper: impl Write, mut from_helper: impl Read) -> Result<(), StageFill>
|
||||
method metal2vulkan-runtime::Device::grant_indices pub fn grant_indices(&self, class: IndexClass, first: u32, count: u32) -> Result<IndexGrant, Error>
|
||||
method metal2vulkan-runtime::Device::has_unified_memory pub fn has_unified_memory(&self) -> bool
|
||||
method metal2vulkan-runtime::Device::heap_buffer_size_and_align pub fn heap_buffer_size_and_align(&self, length: u64, _options: u64) -> SizeAndAlign
|
||||
@@ -6583,6 +6593,7 @@ method metal2vulkan-runtime::Device::pixel_format_info pub fn pixel_format_info(
|
||||
method metal2vulkan-runtime::Device::quiesce pub fn quiesce(&self, timeout: Duration) -> bool
|
||||
method metal2vulkan-runtime::Device::raw pub fn raw(&self) -> RawDevice<'_>
|
||||
method metal2vulkan-runtime::Device::read_write_texture_support pub fn read_write_texture_support(&self) -> ReadWriteTextureTier
|
||||
method metal2vulkan-runtime::Device::record_stage_breach pub fn record_stage_breach(&self, request: &StageRequest, breach: StageBreach)
|
||||
method metal2vulkan-runtime::Device::release_block pub fn release_block(&self, block: Block) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::Device::report_loss pub fn report_loss(&self, loss: DeviceLoss)
|
||||
method metal2vulkan-runtime::Device::supports_texture_sample_count pub fn supports_texture_sample_count(&self, count: u32) -> bool
|
||||
@@ -6705,6 +6716,7 @@ method metal2vulkan-runtime::SharedEvent::notify_listener pub fn notify_listener
|
||||
method metal2vulkan-runtime::SharedEvent::set_signaled_value pub fn set_signaled_value(&self, value: u64)
|
||||
method metal2vulkan-runtime::SharedEvent::signaled_value pub fn signaled_value(&self) -> u64
|
||||
method metal2vulkan-runtime::SharedEvent::wait_until_signaled_value pub fn wait_until_signaled_value(&self, value: u64, timeout: Duration) -> Result<bool, Error>
|
||||
method metal2vulkan-runtime::StageRequest::weight pub fn weight(&self) -> u64
|
||||
method metal2vulkan-runtime::Surface::buffer pub fn buffer(&self) -> Result<Buffer, Error>
|
||||
method metal2vulkan-runtime::Surface::external_writes_done pub fn external_writes_done(&self) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::Surface::handle pub fn handle(&self) -> Option<ExportHandle>
|
||||
@@ -7626,6 +7638,7 @@ struct metal2vulkan-runtime::ScissorRect #[derive(Clone, Copy, Debug, PartialEq,
|
||||
struct metal2vulkan-runtime::SharedEvent #[derive(Clone)] pub struct SharedEvent
|
||||
struct metal2vulkan-runtime::SiteAllocations #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[non_exhaustive] pub struct SiteAllocations
|
||||
struct metal2vulkan-runtime::SizeAndAlign #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct SizeAndAlign
|
||||
struct metal2vulkan-runtime::StageRequest #[derive(Clone)] pub struct StageRequest(Arc<Request>)
|
||||
struct metal2vulkan-runtime::StencilDescriptor #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct StencilDescriptor
|
||||
struct metal2vulkan-runtime::Surface pub struct Surface
|
||||
struct metal2vulkan-runtime::SurfaceExport #[derive(Debug)] #[non_exhaustive] pub struct SurfaceExport
|
||||
@@ -7984,6 +7997,11 @@ trait-impl metal2vulkan-runtime::RenderPipelineState impl crate::kept::Uncount i
|
||||
trait-impl metal2vulkan-runtime::ResourceUsage impl BitOr impl BitOr for ResourceUsage
|
||||
trait-impl metal2vulkan-runtime::SamplerDescriptor impl Default impl Default for SamplerDescriptor
|
||||
trait-impl metal2vulkan-runtime::SamplerState impl crate::kept::Handle impl crate::kept::Handle for SamplerState
|
||||
trait-impl metal2vulkan-runtime::StageFill impl fmt::Display impl fmt::Display for StageFill
|
||||
trait-impl metal2vulkan-runtime::StageRequest impl Eq impl Eq for StageRequest
|
||||
trait-impl metal2vulkan-runtime::StageRequest impl PartialEq impl PartialEq for StageRequest
|
||||
trait-impl metal2vulkan-runtime::StageRequest impl fmt::Debug impl fmt::Debug for StageRequest
|
||||
trait-impl metal2vulkan-runtime::StageRequest impl std::hash::Hash impl std::hash::Hash for StageRequest
|
||||
trait-impl metal2vulkan-runtime::StencilDescriptor impl Default impl Default for StencilDescriptor
|
||||
trait-impl metal2vulkan-runtime::Surface impl std::fmt::Debug impl std::fmt::Debug for Surface
|
||||
trait-impl metal2vulkan-runtime::Texture impl TextureObject impl TextureObject for Texture
|
||||
@@ -9203,6 +9221,7 @@ variant metal2vulkan-runtime::Error::NoDirectDriverLoading NoDirectDriverLoading
|
||||
variant metal2vulkan-runtime::Error::NoSuchBlock NoSuchBlock(BlockId)
|
||||
variant metal2vulkan-runtime::Error::Quiesced Quiesced
|
||||
variant metal2vulkan-runtime::Error::Refused Refused(Refusal)
|
||||
variant metal2vulkan-runtime::Error::StageUnfilled StageUnfilled(crate::StageRequest)
|
||||
variant metal2vulkan-runtime::Error::Thread Thread(io::Error)
|
||||
variant metal2vulkan-runtime::Error::Translation Translation { error: metal2vulkan::error::Error, functions: Box<[String]> }
|
||||
variant metal2vulkan-runtime::Error::Unsupported Unsupported(Gap)
|
||||
@@ -9231,6 +9250,7 @@ variant metal2vulkan-runtime::Gap::PartialSimdgroups PartialSimdgroups { threads
|
||||
variant metal2vulkan-runtime::Gap::PartialThreadgroups PartialThreadgroups { threads_per_grid: [u32; 3], threads_per_threadgroup: [u32; 3] }
|
||||
variant metal2vulkan-runtime::Gap::RenderPass RenderPass { kind: RenderPassKind }
|
||||
variant metal2vulkan-runtime::Gap::RenderPipeline RenderPipeline { kind: RenderPipelineKind }
|
||||
variant metal2vulkan-runtime::Gap::StageSize StageSize { weight: u64, cause: StageGap }
|
||||
variant metal2vulkan-runtime::Gap::StorageElement StorageElement { slot: Option<u32>, pixel_format: PixelFormat }
|
||||
variant metal2vulkan-runtime::Gap::SurfaceUsage SurfaceUsage { pixel_format: PixelFormat, missing: u32 }
|
||||
variant metal2vulkan-runtime::Gap::SwizzledReadWrite SwizzledReadWrite { slot: u32 }
|
||||
@@ -9500,6 +9520,20 @@ variant metal2vulkan-runtime::Stage::Kernel Kernel
|
||||
variant metal2vulkan-runtime::Stage::Mesh Mesh
|
||||
variant metal2vulkan-runtime::Stage::Object Object
|
||||
variant metal2vulkan-runtime::Stage::Vertex Vertex
|
||||
variant metal2vulkan-runtime::StageBreach::Compile Compile
|
||||
variant metal2vulkan-runtime::StageBreach::CompileRequired CompileRequired
|
||||
variant metal2vulkan-runtime::StageBreach::Memory Memory
|
||||
variant metal2vulkan-runtime::StageBreach::Time Time
|
||||
variant metal2vulkan-runtime::StageFill::Compile Compile(vk::Result)
|
||||
variant metal2vulkan-runtime::StageFill::Enables Enables
|
||||
variant metal2vulkan-runtime::StageFill::Ended Ended
|
||||
variant metal2vulkan-runtime::StageFill::NoDevice NoDevice
|
||||
variant metal2vulkan-runtime::StageFill::Unkept Unkept
|
||||
variant metal2vulkan-runtime::StageFill::Version Version
|
||||
variant metal2vulkan-runtime::StageGap::Breach Breach(crate::StageBreach)
|
||||
variant metal2vulkan-runtime::StageGap::NoCacheDirectory NoCacheDirectory
|
||||
variant metal2vulkan-runtime::StageGap::NoPipelineCache NoPipelineCache
|
||||
variant metal2vulkan-runtime::StageGap::RenderStage RenderStage
|
||||
variant metal2vulkan-runtime::StageSource::Compiled Compiled(CompiledFunction)
|
||||
variant metal2vulkan-runtime::StageSource::Function Function(FunctionDescriptor)
|
||||
variant metal2vulkan-runtime::StorageMode::Managed Managed
|
||||
@@ -10524,7 +10558,6 @@ variant metal2vulkan::error::Feature::SimdgroupMatrix16x16x16 SimdgroupMatrix16x
|
||||
variant metal2vulkan::error::Feature::SparseTexture SparseTexture { slot: SlotRef }
|
||||
variant metal2vulkan::error::Feature::SparseTextures SparseTextures { missing: SparseNeed }
|
||||
variant metal2vulkan::error::Feature::Stage Stage(u8)
|
||||
variant metal2vulkan::error::Feature::StageSize StageSize
|
||||
variant metal2vulkan::error::Feature::StageStoresAndAtomics StageStoresAndAtomics
|
||||
variant metal2vulkan::error::Feature::StaticInitializer StaticInitializer
|
||||
variant metal2vulkan::error::Feature::StencilExport StencilExport
|
||||
@@ -10635,7 +10668,6 @@ variant metal2vulkan::error::Needs::MetalGpuFamily MetalGpuFamily(i64)
|
||||
variant metal2vulkan::error::Needs::MetalRefuses MetalRefuses(&'static [&'static str])
|
||||
variant metal2vulkan::error::Needs::NotImplemented NotImplemented
|
||||
variant metal2vulkan::error::Needs::NotRepresentable NotRepresentable
|
||||
variant metal2vulkan::error::Needs::StageBound StageBound
|
||||
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.
|
@@ -311,6 +311,7 @@ surface! {
|
||||
fn grid_tile;
|
||||
const GRID_TILE_THREADS;
|
||||
const DEEP_THREADGROUP;
|
||||
const COMPILED_STAGE_WEIGHT;
|
||||
struct ComputePipeline N;
|
||||
struct ComputePipelineMetalInfo N;
|
||||
struct CompileReport N;
|
||||
|
||||
+8
-3
@@ -508,6 +508,14 @@ assert!(stats.reachable_blocks <= stats.blocks);
|
||||
a program far larger than its own blocks; the two read alike in `blocks` alone. Lowering emits
|
||||
such functions itself: the handle-table search (unrolled branch-free steps) and the root-table
|
||||
search (a loop), each emitted once and called at every access.
|
||||
- `entry_weight` is what a driver compiles once it has inlined every call: the entry's
|
||||
instructions with each call counted as its callee's body, after repeated regions are rolled
|
||||
into loops. A stage past `pipeline::COMPILED_STAGE_WEIGHT` (99,109, the heaviest measured to
|
||||
compile within host-sized memory on the slowest compiler measured) is one whose creation may
|
||||
take the host's memory: the translator makes it all the same, and `metal2vulkan-runtime`
|
||||
compiles such a kernel only in a helper process the consumer caps (its README, "Kernels past
|
||||
the stage bound"). A kernel past the bound only because it emulates its SIMD groups is planned
|
||||
again keeping the device's widest subgroup mode pinned, where that plan is lighter.
|
||||
- Compare one module against the next of the same shader, not one shader against another. Measured
|
||||
cost per block differed several-fold between a synthetic module and a real workload, so a
|
||||
per-block figure taken from one shader predicts nothing for the next; `instructions` is the
|
||||
@@ -1614,9 +1622,6 @@ match floor.compile_function(&min_lod, &LoweringInputs::new(), &Budget::standard
|
||||
- `AnyOf`: alternative sets of device capabilities; a device that enables every capability of one
|
||||
set compiles it.
|
||||
- `NotImplemented`: a gap of this version. `NotRepresentable`: no Vulkan mechanism exists.
|
||||
- `StageBound`: a stage that the device's plan writes heavier than the translator hands any
|
||||
driver (the heaviest measured to compile within host-sized memory); `symbol` names its entry
|
||||
weight and the bound. A device whose plan writes it lighter compiles it.
|
||||
- `MetalGpuFamily`: a Metal GPU family the device does not claim, where Metal itself refuses the
|
||||
input without it.
|
||||
|
||||
|
||||
+6
-6
@@ -26,7 +26,7 @@ Columns:
|
||||
|
||||
| Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| Translator and front-end refusals | 135 | 120 | 8 | 33 | 73 | 21 | 0 |
|
||||
| Translator and front-end refusals | 134 | 119 | 8 | 33 | 72 | 21 | 0 |
|
||||
| Binder refusals at a device limit | 9 | 9 | 0 | 1 | 7 | 1 | 0 |
|
||||
| Translation caps | 14 | 14 | 0 | 0 | 7 | 7 | 0 |
|
||||
| Rate maps the compile layer does not compile | 5 | 5 | 0 | 0 | 4 | 1 | 0 |
|
||||
@@ -34,13 +34,13 @@ Columns:
|
||||
| Devices below the runtime's floor | 8 | 8 | 0 | 0 | 0 | 0 | 0 |
|
||||
| The runtime's `Refusal` | 77 | 77 | 0 | 0 | 0 | 0 | 0 |
|
||||
| The runtime's `Limit` | 17 | 17 | 0 | 0 | 0 | 0 | 0 |
|
||||
| The runtime's `Gap` | 30 | 30 | 0 | 0 | 0 | 0 | 0 |
|
||||
| The runtime's `Gap` | 31 | 31 | 0 | 0 | 0 | 0 | 0 |
|
||||
|
||||
## Totals by basis
|
||||
|
||||
| Kind | `metal-measured` | `metal-documented` | `metal-takes` | `device` | `ours` | `unknown` | `delegated` | `-` |
|
||||
|---|---|---|---|---|---|---|---|---|
|
||||
| Translator and front-end refusals | 0 | 0 | 0 | 44 | 54 | 0 | 0 | 37 |
|
||||
| Translator and front-end refusals | 0 | 0 | 0 | 43 | 54 | 0 | 0 | 37 |
|
||||
| Binder refusals at a device limit | 0 | 0 | 0 | 9 | 0 | 0 | 0 | 0 |
|
||||
| Translation caps | 0 | 0 | 0 | 0 | 14 | 0 | 0 | 0 |
|
||||
| Rate maps the compile layer does not compile | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
|
||||
@@ -48,7 +48,7 @@ Columns:
|
||||
| Devices below the runtime's floor | 0 | 0 | 0 | 8 | 0 | 0 | 0 | 0 |
|
||||
| The runtime's `Refusal` | 22 | 21 | 0 | 0 | 34 | 0 | 0 | 0 |
|
||||
| The runtime's `Limit` | 0 | 0 | 0 | 13 | 4 | 0 | 0 | 0 |
|
||||
| The runtime's `Gap` | 0 | 0 | 0 | 2 | 28 | 0 | 0 | 0 |
|
||||
| The runtime's `Gap` | 0 | 0 | 0 | 3 | 28 | 0 | 0 | 0 |
|
||||
|
||||
## 1. Translator and front-end refusals (`Unsupported`: a `Feature` and its `Needs`)
|
||||
|
||||
@@ -90,7 +90,6 @@ Columns:
|
||||
| `Int64Atomics` | 64-bit atomics | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`) | `device` | 2: `crates/metal2vulkan/src/lower/access/atomic.rs (select, 2 sites)` | `rare`: 64-bit atomics |
|
||||
| `ImageAtomics` | Image atomics beyond 32-bit integers | devices without a capability the site computes (`gaps`) | `device` | 1: `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format)` | `rare`: texture atomics beyond 32-bit integers |
|
||||
| `DescriptorCount` | Too many descriptors of one kind in a stage or pipeline | devices short of a device limit the site names; devices without VkLimit::MaxUniformBufferRange | `device` | 3: `crates/metal2vulkan/src/lower/access/mod.rs (accept_placement)`, `crates/metal2vulkan/src/lower/select.rs (finish)` (+1) | `app`: many textures or buffers in one stage on a smaller device |
|
||||
| `StageSize` | A stage module heavier than the translator hands the device's driver | devices whose plan writes the stage past the stage bound | `device` | 1: `crates/metal2vulkan/src/pipeline/compile/stage_bound.rs (refused)` | `rare`: a kernel heavier than the heaviest stage measured to compile within host-sized memory, as the device's plan writes it (from_queries), or too large for a driver measured to corrupt one past its bound or to outgrow host memory below it |
|
||||
| `BufferRange` | A buffer window beyond the descriptor range limits | devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism) | `device` | 6: `crates/metal2vulkan/src/bind/graphics.rs (patch_binding, 3 sites)`, `crates/metal2vulkan/src/bind/instantiate.rs (bind_buffers)` (+2) | `app`: a buffer window past a device's descriptor range |
|
||||
| `Int64Arithmetic` | 64-bit integer arithmetic | devices without VkFeature::ShaderInt64 | `device` | 2: `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`, `crates/metal2vulkan/src/lower/select.rs (selector_form)` | `rare`: 64-bit integers on a device without shaderInt64 |
|
||||
| `Float64Arithmetic` | 64-bit float arithmetic | devices without VkFeature::ShaderFloat64 | `device` | 2: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)` | `rare`: doubles (MSL has none outside Apple's own code) |
|
||||
@@ -390,6 +389,7 @@ Columns:
|
||||
| `RenderPass` | A render pass of something the runtime does not build yet (`CommandBuffer::render_command_encoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams' passes render into one to two color attachments and a stencil or a depth attachment, each a level of a 2D texture of one sample, with no resolve and a clear depth of 1, none naming two textures for its depth and stencil; each other kind is built when a replay stream makes one; `DepthStencilViews` and `ClearDepth` are what Vulkan's rendering under the floor takes no form of | 6: `crates/metal2vulkan-runtime/src/pass.rs (check)`, `crates/metal2vulkan-runtime/src/pass.rs (ops)` (+4) | `-` |
|
||||
| `Draw` | A draw or render encoder state the runtime does not build yet (`RenderCommandEncoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams draw lines and triangles through one viewport Vulkan's is, with pipeline states of their pass's formats, filled and clipped; each other kind is built when a replay stream draws one), and device for [`DrawKind::DividedBaseInstance`] (a device that does not report `supportsNonZeroFirstInstance` | 12: `crates/metal2vulkan-runtime/src/render_encoder.rs (attachment_reads, 3 sites)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (checked)` (+8) | `-` |
|
||||
| `LinearPlanePass` | A render pass over a surface plane that renders as a linear colour attachment alone, in a shape the device does not render... | at the device's limit | `device`: VK_NV_linear_color_attachment renders such a format as a colour attachment only "as long as all the color attachments in the render pass instance have VK_IMAGE_TILING_LINEAR tiling"; the RTX 3090's driver lost the device rendering a linear colour attachment beside a depth or stencil attachment | 1: `crates/metal2vulkan-runtime/src/pass.rs (check)` | `-` |
|
||||
| `StageSize` | A pipeline of a function whose module weighs more than the compiled stage bound (`metal2vulkan::pipeline::COMPILED_STAGE_WEIGHT`, the heaviest... | at the device's limit | `device`: ANV, Mesa 26.2.6, took 3.65 GiB to compile a stage of entry weight 99,109 and passed 16 GiB on one of 532,213; a driver whose helper's compile met its cap or time, or that keeps no pipeline cache data, gives no data to make the pipeline from | 3: `crates/metal2vulkan-runtime/src/pipeline.rs (past_stage_bound)`, `crates/metal2vulkan-runtime/src/render.rs (of)` (+1) | `-` |
|
||||
|
||||
## Appendix: every site
|
||||
|
||||
@@ -431,7 +431,6 @@ Each refusal's sites, with the function that builds it.
|
||||
- `feature::Int64Atomics`: `crates/metal2vulkan/src/lower/access/atomic.rs (select, 2 sites)`
|
||||
- `feature::ImageAtomics`: `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format)`
|
||||
- `feature::DescriptorCount`: `crates/metal2vulkan/src/lower/access/mod.rs (accept_placement)`; `crates/metal2vulkan/src/lower/select.rs (finish)`; `crates/metal2vulkan/src/pipeline/link.rs (limit_error)`
|
||||
- `feature::StageSize`: `crates/metal2vulkan/src/pipeline/compile/stage_bound.rs (refused)`
|
||||
- `feature::BufferRange`: `crates/metal2vulkan/src/bind/graphics.rs (patch_binding, 3 sites)`; `crates/metal2vulkan/src/bind/instantiate.rs (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs (select)`; `crates/metal2vulkan/src/lower/access/mod.rs (place_slots)`
|
||||
- `feature::Int64Arithmetic`: `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`; `crates/metal2vulkan/src/lower/select.rs (selector_form)`
|
||||
- `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`
|
||||
@@ -676,4 +675,5 @@ Each refusal's sites, with the function that builds it.
|
||||
- `rt:Gap::RenderPass`: `crates/metal2vulkan-runtime/src/pass.rs (check)`; `crates/metal2vulkan-runtime/src/pass.rs (ops)`; `crates/metal2vulkan-runtime/src/pass.rs (resolve)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (later_store)`; `crates/metal2vulkan-runtime/src/texture.rs (attachment_view)`; `crates/metal2vulkan-runtime/src/texture.rs (resolve_attachment)`
|
||||
- `rt:Gap::Draw`: `crates/metal2vulkan-runtime/src/render_encoder.rs (attachment_reads, 3 sites)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (checked)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_patches)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_patches_indirect)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_scissor_rects)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_triangle_fill_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_viewports)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_visibility_result_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (shadow_copies)`
|
||||
- `rt:Gap::LinearPlanePass`: `crates/metal2vulkan-runtime/src/pass.rs (check)`
|
||||
- `rt:Gap::StageSize`: `crates/metal2vulkan-runtime/src/pipeline.rs (past_stage_bound)`; `crates/metal2vulkan-runtime/src/render.rs (of)`; `crates/metal2vulkan-runtime/src/stage.rs (gap)`
|
||||
|
||||
@@ -38,7 +38,6 @@ feature CoherentMemory rare coherent(device) accesses
|
||||
feature Int64Atomics rare 64-bit atomics
|
||||
feature ImageAtomics rare texture atomics beyond 32-bit integers
|
||||
feature DescriptorCount app many textures or buffers in one stage on a smaller device
|
||||
feature StageSize rare a kernel heavier than the heaviest stage measured to compile within host-sized memory, as the device's plan writes it (from_queries), or too large for a driver measured to corrupt one past its bound or to outgrow host memory below it
|
||||
feature BufferRange app a buffer window past a device's descriptor range
|
||||
feature Int64Arithmetic rare 64-bit integers on a device without shaderInt64
|
||||
feature Float64Arithmetic rare doubles (MSL has none outside Apple's own code)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 17 and column 65.
|
@@ -378,8 +378,6 @@ def conditions(kind, needs_text):
|
||||
return {"devices without " + c for c in caps}
|
||||
if kind == "MetalGpuFamily":
|
||||
return {"devices that do not claim the Metal GPU family"}
|
||||
if kind == "StageBound":
|
||||
return {"devices whose plan writes the stage past the stage bound"}
|
||||
return {"varies (" + kind + ")"}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user