The commit before this one. A guest-RAM import that a second no-copy buffer over the same bytes lay in was held for
good, whatever the buffers' reads (read_apart_second_buffer): on reims's Valley walk on the RX 7900 XTX about 1,268 of
1,330 live dma-buf imports, each listed in every kernel submission (RADV lists every imported BO), about 0.57 ms of
each 0.835 ms vkQueueSubmit. Such an import now stays releasable while every read of each buffer in it is a blit's or
none (a holder over the whole view that nothing reads included), released once idle and imported again as the
one-buffer case is. A binding, an argument word, a resident use, a handed-out address, a heap's bytes or a rebound
buffer lying in it, a buffer bound inside its memory, or a range_of share keeps it held as before. The read-apart
gauge is split into host_imports_read_apart_inside, _shared_range, _heap and _rebound; host_imports_joined_releasable
counts the imports the new rule keeps releasable. host_residency's and WorkCounts' docs follow.
Verified (on the branch, debug test binary): 780M RADV (m3-max-23761) host_residency and host_import_counts 15/15, the
new test (a never-read holder plus a blit-read buffer: released, re-imported by a blit, released again, then a kernel
binding one and reading the other's address) included; the same binary with the old exposure fails it ("the second
buffer kept the import for good", held for good 1 against 0). Clippy all features and m2v_gpu, rustdoc (23710); api
signature tests 16, runtime suite 1502, lavapipe host import, residency and alias tests 39 (23713), one test-only
commit before the tip.
A no-copy buffer made over exactly the bytes a live one covers lies in that
buffer's import (host_aliases.rs, "One memory, one import"). Until now its
making read the import apart (ReadApart::SecondBuffer), which keeps a
releasable import imported for good. Such a buffer reads the import the way
the first one does, through the import: its blits take the import's objects,
imported again where released, and any other read of it exposes the import
just as a read of the first buffer would. So the import now stays releasable
while every read of each buffer in it was a blit's, or there was none. A
buffer that is never read, made only to keep the bytes imported, keeps the
import no more than a buffer read only by blits does.
Why: on the RX 7900 XTX (RADV), a guest's 3D benchmark kept 1,000 to 1,330
dma-buf imports live. RADV lists every one of them in every kernel submission,
at 0.43 to 0.44 us each (docs/FAST-PATHS.md, known gaps). Of those imports,
1,262 were held for good, and every held one had a second buffer lying in it.
The consumer keeps a holder for each view of guest pages: a no-copy buffer
over the whole view that nothing reads, with the block's buffer lying in its
import. The frames named about 0.6 imports per command buffer, while the
scheduler thread spent 0.63 to 0.90 s of each second in vkQueueSubmit, at
0.835 ms per call. Our own blocks on that device are plain VRAM, which RADV
makes local and lists in no submission.
What still keeps such an import imported for good:
- a no-copy heap's own bytes lying in it: the heap's placed buffers'
addresses are the heap's, handed out without any read of the import noted;
- a rebound buffer lying in it, as a rebind's own import is kept;
- a buffer bound inside its memory with a VkBuffer of its own;
- a buffer made to share its buffer's range (BufferDescriptor::range_of),
which is handed that buffer's address.
Counters: the gauge host_imports_read_apart_second_buffer is split into
host_imports_read_apart_inside, _shared_range, _heap and _rebound. The new
host_imports_joined_releasable counts the buffers that came to lie in a
releasable import beside another and left it releasable; a walk shows the
path ran when it is non-zero. host_residency.rs ("Several buffers in one
import"), host_aliases.rs, the WorkCounts docs, docs/HOWTO.md and the API
signature table say so.
Test: tests::host_residency::an_import_two_buffers_lie_in_is_released_while_idle_and_read_right_again.
It makes a never-read holder and a second buffer over the same 4 pages of a
udmabuf-backed memfd. Joining keeps the import releasable (nothing held for
good, no read apart) and imports nothing new. Read by a blit, the import is
released. The file's writes made while it is released are read by the next
blit through the second buffer, imported again from the kept descriptors. It
is released again. Then a kernel binds the second buffer, makes the holder
resident (useResource:, as Metal reaches a no-copy buffer through an address
only once a command buffer used it) and loads the holder's Metal address from
set_bytes; the binding imports the import again for good. The words the kernel
reads through the address, and the words it writes through it, are checked
against the pages. The source is called once, and the import leaves the gauges
once its buffers go.
host_import_counts now expects a second buffer over the same bytes to read
nothing apart.
Verified (the runtime's debug test binary, --cfg m2v_gpu, not a release build):
- m3-max-23710 (msi-laptop): cargo clippy --workspace --all-targets
--all-features -D warnings, the runtime's clippy under --cfg m2v_gpu, and
the runtime's rustdoc with -D warnings: clean.
- m3-max-23713 (msi-laptop): the API signature tests, 16 passed; the
runtime's suite, 1502 passed, 6 skipped; on lavapipe (--cfg m2v_cpu_icd)
the host_import_counts, host_residency, pointer_residency and host_aliases
tests, 39 passed.
- m3-max-23761 (Radeon 780M, RADV PHOENIX): the host_residency and
host_import_counts device tests, 15 passed, the new test among them ("1
chunks of two buffers released twice, imported again twice"). The negative
control, the same binary with a joining buffer reading the import apart as
before, fails the new test at "the second buffer kept the import for good"
(held for good 1, expected 0).
The lint and suite jobs ran one commit before the test's last change (the
holder made resident before the kernel reads through its address), a
test-only change that the 780M run's binary carries.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The five commits before this one. On NVIDIA after an Xid 109 the device's queues stopped: no batch completed and every
completion wait answered VK_TIMEOUT, never VK_ERROR_DEVICE_LOST, so the program's command buffers waited without end.
The completion's waiters keep a device-wide stall clock (command_buffer/stall.rs) that runs while a wait ran out with
its front batch pending and stops whenever any queue's timeline advances. Past 10 s one waiter probes the staging
queue with an empty submission and for up to 2 s reads the probe, the stuck front's fence and its timeline; a loss
takes the failed wait's path, an answered probe or an advanced front fails nothing and restarts the clock, so a device
that still makes progress is never failed whatever its work's length. An unanswered probe marks the generation
stopped and lost (the oldest command buffer GpuHang, the rest GpuRecoveryVictim), the line recovers, and the
VkDevice is parked: never destroyed, none of its objects released, its queues never waited for, its teardown returning
before vkDeviceWaitIdle. New public query Device::is_parked(vk::Device) -> bool (no Metal counterpart); counters
stall_probes_sent, wedges_declared, longest_stall_nanos; the DeviceRecovered notice says the VkDevice stopped and was
parked. The queue-switch check's waits end for a parked device. FAST-PATHS known gaps: no probe without a staging
queue, the parked device's leak, NVIDIA's exit handler waiting on a parked device's work, Metal's own bounds.
Verified (on the branch, archive c010d899ff, validation layer 1.4.363 on, NVIDIA 620.70.06): um870 RTX 3090
(m3-max-23757) 5/5 and um790 RTX 2080 (23758) 5/5: an answered stall sends 2 probes that complete in 81-197 us and
fails nothing (longest stall 200 ms), a stopped one fails after 2.3 s with 1 probe, 1 wedge, 1 recovery, the device
made again in 512-549 ms and the next command buffer running; the managed-copy rounds 0 wrong on all three routes, the
layer's whole-pool vkResetQueryPool report (VUID-vkResetQueryPool-firstQuery-02741, the documented layer gap) claimed
through layer_claim::Watched. lavapipe 95/95 (23685, at 1f24262fad). Clippy default, m2v_gpu, m2v_cpu_icd, rustdoc
and the api tests at c010d899ff (23748).
On NVIDIA (620.70.06; um870's RTX 3090 and um790's RTX 2080) the stopped
test passed and its process never exited: under gdb (job 23736) the test
reported ok in 21.5 s, and the main thread then spun in exit(), in an exit
handler of libEGL_nvidia that tears down every VkDevice left and waits for its
work. The parked VkDevice's batch waits for the event's semaphore, which the
test never signalled. The test now keeps the stopping generation's functions
and semaphore and signals the reserved counter on the parked VkDevice once it
has checked the recovery, so its queue drains. It prints when the stuck
command buffer failed and when the next one ran.
docs/FAST-PATHS.md's known gap and stall.rs's module docs say a driver may
wait for a parked VkDevice's work at the process's exit (NVIDIA's did, for
that stand-in wait); a GPU that truly stopped is not measured there.
Verified: cargo fmt. The NVIDIA runs follow with this commit's archive.
The did_modify_range rounds tests (two timed command buffers in flight, on one
queue or two) failed on the um790's RTX 2080 with the validation layer 1.4.363:
ten VUID-vkResetQueryPool-firstQuery-02741 reports, each 'can't be called on
VkQueryPool 0x660000000066 that is currently in use by VkCommandBuffer 0x...'
(job 23407). That is the layer's whole-pool check of a host query reset that
tests/query_reset_gap.rs and the validation crate's
candidate/runtime_case/query_reset_gap.rs document from the layer's source
(cc_query.cpp, PreCallValidateResetQueryPool: a query of the range neither
AVAILABLE nor UNKNOWN calls ValidateObjectNotInUse on the whole pool): a slot
whose last holding completed and was read is reset as another command buffer
takes it while other slots of the same pool are in flight. The runtime gives a
slot back only in the completion turn's read_stamps, after its command
buffer's work completed, or at commit where nothing was submitted
(Stamped::NoWork); so the report names another slot's holder.
These tests collected every error message themselves, so they failed on the
gap. They now ask for the layer and claim its silence through Watched, as the
other layer-claiming tests do: the gap passes on 1.4.363 only, where the
source was read, and fails marked for a re-read on any other release; where
the host has no layer the test says LAYER-ABSENT.
Verified: cargo fmt. The 2080 run follows with the wedge's archive.
On the RTX 2080 the stall test's teardown hung after the generation stopped:
the old generation's queue-switch check thread looped in its waits (a slice at
a time, VK_TIMEOUT each) for a round whose batches sat behind the stuck one on
the parked device, and the teardown waited for that thread to end. Its two
wait loops, and a dma-buf binding's settle, now end as on a lost device once
release::parked answers for their VkDevice.
Verified: the 2080 run of tests::stall follows on this commit.
On NVIDIA after an Xid 109 the device's queues stopped: no batch completed and
every completion wait answered VK_TIMEOUT, never VK_ERROR_DEVICE_LOST, so the
program's command buffers waited without end.
The completion's waiters now keep a device-wide stall clock
(command_buffer/stall.rs): it runs while a wait ran out with its front batch
pending and stops whenever any queue's timeline advances. Past 10 s one waiter
probes the staging queue (NVIDIA's copy engine) with a submission of nothing
that waits for nothing, and for up to 2 s reads the probe's answer and the
stuck front's fence (a wait of no time) and timeline
(vkGetSemaphoreCounterValue); a loss either read answers takes the failed
wait's path at once. One informational message, metal2vulkan-stall-probe,
names the stall, the probe's answer and each read's last VkResult. A probe
answered, or a front that advanced, fails nothing and restarts the clock, so a
device that still makes progress is never failed whatever its work's length.
A probe unanswered in 2 s stops the generation: Device::mark_wedged marks it
stopped and lost, the wait fails as a lost device's (the oldest command buffer
as GpuHang, the rest GpuRecoveryVictim), and the line recovers; the
DeviceRecovered notice says the VkDevice stopped and was parked.
Parked: release.rs's door leaves every object of a parked VkDevice, the device
itself included; DeviceShared::queues_idle waits for none of its queues, and
its teardown returns before vkDeviceWaitIdle, keeping the instance. New public
query Device::is_parked(vk::Device) -> bool (no Metal counterpart), for a
consumer that holds the stopped generation's handles. Counters:
WorkCounts::stall_probes_sent, wedges_declared, longest_stall_nanos. A device
without a staging queue sends no probe (FAST-PATHS known gap, with the leak and
Metal's bounds: about 5 s on the M3 Max, 20.2 s and 16.1 s on x86 Macs' AMD and
Intel GPUs).
Tests (tests::stall, through the line's hooks: the clock's bound 200 ms, and
no probe seen answered): a command buffer waiting on its VkQueue for a reserved
event signal is pending; with the probe answered nothing fails and it
completes once the host signals; with none answered it fails as GpuHang, the
old VkDevice is parked, the new one is not, and a command buffer runs after.
Verification follows on this commit.
Its product fingerprint follows the runtime-sources pin and SEMANTICS_VERSION since the last re-bless (b0e379733d at
43d2308170). 2287 cases on 21 profile-legs (48,027 cells), 0 failed, 0 regressions, 27 differences: 11 new cases (the
nine tns_mm_v2 cases and two other authored cases committed since), 14 cells of two cases that now compile where they
were refused for private memory above FunctionStorageBytesPerThread (17,408 of 16,384 bytes) on rdna3, Iris Xe,
roadmap-2022 and RTX 50, and those two cases' vk12-floor cells now refused first for MaxPerStageDescriptorStorageBuffers
(9 of 4) instead. The rest of the file's changed lines are artifact hashes (7,271 moved).
Verified: corpus-triage --audit authored-compile --bless on the M3 at 3af1ca2dc4 (m3-max-23746, release, 107 s wall,
slowest compile 588 ms, parent peak 113 MiB), the private sources read in place through the index.
The translator changes since the last bless move five golden-hash rows and the engine inventory: SEMANTICS_VERSION 2070
makes generic_pointers' generic_captured and generic_functor translate again on every profile (38 inventory cells,
Unsupported to ok); SEMANTICS_VERSION 2071 adds the tns_mm_v2 fixture (its inventory row, ok on all 19 profiles, its
golden rows and its engine printout, recorded under LLVM 21). The one commit between 6b5f4b19ed and this one's parent
(RUNTIME_VERSION 2176) changes only the runtime, so no table it covers moves.
Verified: bless on the M3 at 6b5f4b19ed (m3-max-23726): golden hashes blessed, engine goldens pass; merged check at the
same sha on msi (m3-max-23712): clippy every crate with --cfg m2v_gpu, api_signatures, api_surface, fast_paths, the
engine and fixture-inventory tests (1553/1556, the three failing exactly the rows this commit blesses), the runtime's
exit_guard and compile_memory tests, rustdoc -D warnings.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The three commits before this one. After a device recovery a heap over the caller's memory was left refused with the
buffers and textures placed in it, and every texture placed in a heap was left (reims's forced recovery on a 3090:
44 no-copy heaps and 929 heaps' textures; WindowServer's command buffers refused 3424 setFragmentTexture binds and the
desktop came back mostly black). A no-copy heap is now made again over the same pages, as a no-copy buffer is: its
identity kept, its placed buffers carried at their offsets with their bytes as they are (its own buffer's pages keep
what they were made of). Textures placed in any carried heap, Private or no-copy, are made again after the heaps
through the path that placed them, over the same range (sharing its makeAliasable flag), a texture buffer's buffer
with it; a Private heap's texture reads as a new one (counted by storage mode), a no-copy heap's reads the pages. The
heap keeps its texture numbering; a texture the recovery leaves is forgotten so no useHeap makes it resident. Textures
over a carried heap's buffer carry too. Left as before: Shared, sparse and detached no-copy heaps. Docs: heap.rs,
texture/carry.rs, device/carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs, API.md), the
runtime README, FAST-PATHS' known gap on lost texture contents (now naming Private heap textures).
Verified (on the branch, lavapipe): the no-copy heap test fails before the fix ("left refused: ... 1 no-copy heaps, 1
heaps' textures", m3-max-23705) and device_recovery passes 32/32 at the tip (23715): after the recovery the heap's
buffer keeps its address, the buffer and both textures read the pages' bytes, a GPU fill reaches the pages and the
texture over the buffer, and a new buffer and texture placed after it read the pages; the Private heap test's texture
is carried with lost contents and made resident by useHeap; the touched tests (heap, no_copy, aliasable, numbered,
placed) 167/167 one process each. Clippy plain, m2v_gpu, m2v_cpu_icd and rustdoc at 6f41668b95 (23706..23708).
REFUSALS and the signature table unchanged.
What: tests::device_recovery_exportable looks for " 1 textures over the
buffers carried,": the notice now goes on to count the textures placed in
the no-copy heaps carried after that count.
Why: the heap carry's notice change broke the test's match (lane
m3-max-23705: "1 textures over the buffers carried, 0 textures placed in
the no-copy heaps carried").
Verified: the lane that follows.
What: a heap over the caller's memory (new_heap_with_bytes_no_copy) is
carried as a no-copy buffer is: its own buffer made again over the same
pages (Buffer::carry_no_copy, now for a heap's own buffer too, kept among
no program resources; its pages keep what they were made of, a heap's own
included), its identity kept, the buffers placed in it carried at their
offsets (Buffer::carry_placed), their bytes as they are. The textures
placed in a carried heap, Private or no-copy, are made again there after
the heaps (Remake::Heap, Device::heap_texture_again): as the runtime's own
texture over the same range of the heap's bytes, through the making that
placed them (a texture buffer's buffer carried with carry_placed), sharing
the range's makeAliasable flag (HeapPlace::aliasable is an Arc), the range
handed to the newest image (HeapPlace::again, hand_range_to), so it is
given back once. A Private heap's texture reads as a new one, a no-copy
heap's reads the pages. The heap keeps its textures numbered as they were
(no forget_held); one the recovery leaves is forgotten (Numbered::forget,
Heap::forget_texture). A texture over a carried heap buffer is made again
over it, as over any carried buffer. Heap::carry answers what its bytes'
carry did with their contents and None where it was carried already, so
the notice counts no-copy heaps apart (", and N no-copy heaps with the M
buffers placed in them, over the same pages") and textures placed in
no-copy heaps apart ("N textures placed in the no-copy heaps carried"),
a Private heap's textures by storage mode. Docs: heap.rs, texture/carry.rs,
device/carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs,
API.md), the runtime README, and FAST-PATHS's known gap on lost texture
contents, which now names a Private heap's textures.
Why: reims's forced recoveries (3090 m3-max-23482, XTX m3-max-23547) left
44 no-copy heaps and 929 heaps' textures refused: 3424 refused texture
binds in one compositor's command buffers, 82 placements in those heaps
refused, the desktop mostly black after. Metal keeps a heap and what is
placed in it. The owner's call: a Private heap's textures are carried with
their contents lost, as new_texture's are.
Verified: a check of the runtime's lib and tests under plain and
m2v_cpu_icd was clean (m3-max-23688, on a probe commit of this change);
the lane that follows runs the tests.
What: tests/device_recovery_no_copy_heap.rs makes a placement heap over a
private mapping (new_heap_with_bytes_no_copy) with a buffer at offset 0 and
an RGBA8Unorm texture placed after it, the pages' bytes set by the host
under each, then recovers: the notice counts one no-copy heap carried with
its buffer and one texture placed in the no-copy heaps carried, and leaves
no heap's buffer or texture refused; the heap, the buffer and the texture
are the new generation's, the buffer keeps its address, both read the
pages' bytes, a GPU fill of the buffer reaches the pages, and a buffer and
a texture placed in the heap after the recovery read the pages' bytes
there. The no-copy test file's helpers it reuses are pub(super).
Why: a recovery leaves a heap over the caller's memory and what is placed
in it the lost generation's, refused at their next use; reims's forced
recovery on a 3090 left 44 such heaps and 929 heaps' textures, and 46
placements in them answered nil after it. Metal keeps a heap and what is
placed in it.
Verified: the lane that follows runs it before and after the fix.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The two commits before this one. A rate-mapped pass drew every draw once per region of the map's plan (2074 regions on
a 3648 by 1734 screen), so a guest frame's command buffer took 514 ms of an Iris Xe's GPU and 462 ms of a Radeon
780M's. At a host step, under the default RateMapRegionPolicy::FanOut and where the device enables geometryShader,
shaderClipDistance and vertexPipelineStoresAndAtomics, the pass is probed first (the fan-out variant's geometry stage
writes a flag and a copy count per command and emits nothing); a command whose flag is clear is drawn once through the
fan-out variant over the whole target, a copy per region it touches; a flagged command, every command after a barrier,
after a memory-writing draw or at a mesh or patch draw is drawn region by region as before, and a refused fan-out
variant falls back to region by region. RateMapRegionPolicy::Exact (DevicePolicy::exact_answers()) keeps every draw
region by region. FAST-PATHS row and known gap (the encoder's own draws and the draws commit records stay region by
region), API.md bullet, WorkCounts for probes, flagged and fanned-out draws and probe GPU time. The pieces lane runs
both policies, its commit frame over a named range.
Verified (on the branch, release, --cfg m2v_gpu): the runtime's rate_mapped tests pass on the 780M (m3-max-23637), the
Iris Xe and lavapipe (at e55e6ebd01, the same code but the lane), the fan-out test counting one probe, one flagged draw
and six fanned out with pixels equal to the region-by-region draws; the pieces lane's host-step frame 87 ms fanned out
against 300 ms Exact on the 780M (23637; commit 284 ms in 20 pieces), 111 ms against 514 ms on the Iris (probe 1.1
ms). Clippy with --cfg m2v_gpu over translator, runtime and validation (23638), rustdoc, the API reference check, the
surface, signature and fast-paths tests.
The lane now runs the host-step frame under `RateMapRegionPolicy::FanOut` (checked for its probe
and fanned-out draws) and under `Exact` (`rate_mapped_pieces_host_step_exact`, checked for pieces
and ranges), and prints the probes, the flagged and fanned-out draws and the probe's GPU time.
Its commit frame executed over a range read from a buffer, which `commit` declines where the CPU
alone writes the records ("an execution of the pass whose records the CPU alone writes reads its
range from a buffer"), so a host step recorded it and fanned it out: it now names its range in the
call, which `commit` records.
Verified: at e55e6ebd01 the host-step frames passed on an Iris Xe and a Radeon 780M (Mesa 26.2.6)
and the commit frame failed as described (one probe, 64 draws fanned out); the commit frame's fix
is checked on both devices at this commit.
A rate-mapped pass drew every draw once per region of the map's plan: an executed command's
triangles ran their vertex function 2074 times on a 3648 by 1734 screen's plan, and the command
buffer of a guest frame's shape took 514 ms of an Iris Xe's GPU and 462 ms of a Radeon 780M's.
At a host step, where the default `RateMapRegionPolicy::FanOut` holds and the device enables
`geometryShader`, `shaderClipDistance` and `vertexPipelineStoresAndAtomics`, the pass is now
probed first: each execution's commands, read once, are replayed in probe mode into a segment of
their own (one middle render pass per instance, the fan-out variant's geometry stage writing a
flag and a copy count per command and emitting nothing), submitted and waited for. A command
whose flag is clear (no triangle crosses w = 0 or touches more regions than the copies) is drawn
once through the fan-out variant over the whole target, its geometry stage emitting a copy per
region it touches; a flagged command, and every command after a barrier, after a draw that writes
memory or at a mesh or patch draw, is drawn region by region as before. A fan-out variant the
compile refuses falls back to region by region at the settle.
`RateMapRegionPolicy::Exact` (`DevicePolicy::exact_answers()`) keeps every draw region by
region. The FAST-PATHS row, the API.md bullet and a known gap (the encoder's own draws and the
draws commit records stay region by region) describe it; `WorkCounts` counts the probes, the
flagged and fanned-out draws and the probes' GPU time. `CommandBuffer::submit_waited` is the
loop check's waited submission, shared with the probe.
Verified (release, `--cfg m2v_gpu`, e55e6ebd01 before the rebase onto aacde9f2ad, which applied
cleanly): the runtime's `rate_mapped` tests pass on an Iris Xe and a Radeon 780M (Mesa 26.2.6) and
on lavapipe, the fan-out test counting one probe, one flagged draw and six fanned out with pixels
equal to the region-by-region draw's; the pieces lane's host-step frame takes 111 ms of the Iris
Xe's GPU fanned out against 514 ms under Exact, 125 ms against 462 ms on the 780M, the probe 1.1
ms and 0.5 ms. Clippy, rustdoc, the API reference check, the surface and signature tests and the
fast-paths tests pass; the golden table's changed cells are development's drift, re-blessed there.
The five commits before this one. macOS 27's MSL 4.1 headers spell matmul2d's runs in a _v2 form whose tensor operands
carry a scale type, block sizes and static extents; every such run was refused ("a matmul2d run of the single-thread
or v2 form"), among them the 12 MPS rows of the macOS 27 census. Run::of_call now takes a _v2 run whose operands have
scale type __tensor_ops_datatype_invalid (0), block sizes 0 and both static extents dynamic_extent (-1) as the earlier
form's run; scale factors and a static extent are refused with their own messages, the single-thread form alone as
before. New owned fixture tns_mm_v2 (tns_mm_float built for macOS 27, variants 10-15 a transposed B as a cooperative
right input and in threadgroup memory), nine authored cases over it (float, half, bfloat x B in device memory, as a
cooperative right input, in threadgroup memory) and their Metal rows on the M3 Max (macOS 27.0.1). The _v2 helpers
are crate-private; the API tables are unchanged.
Verified (on the branch): the engine v2 tests refuse before the change and engine_matmul2d, tensor_ops and matmul2d
pass 30/30 after (m3-max-23486); on Metal the three B placements give identical bytes within each element type, equal
to tns_mm_float's nt-right-device case on the same Mac (23519); lavapipe candidate 18/18 Match over the 9 cases and
both legs at the stacked tree (23671); translator suites 4070/4074 at 57b4ac923c, the 4 re-bless items only (the
inventory's new fixture, 38 golden cells of SEMANTICS_VERSION 2070's two kernels, part_5_of_8's same cells plus the
new row, ok on all 19 profiles, and the new printout, recorded under LLVM 21 on development); validation 1387/1387;
fmt, clippy all features, m2v_gpu, m2v_cpu_icd and rustdoc (23553, 23555). A release census of the 12 MPS rows (RDNA3,
23502, before SEMANTICS_VERSION 2069): all 12 now stop at LinkedFunction (a pipeline input the command line cannot
supply), the matmul2d expansion passing on every row; not re-run at this tip. The venues have no rows yet for the nine
new cases.
NO_SCALE, DYNAMIC_EXTENT and RunForm::v2_tensor_args serve only the matmul2d lowering in this
crate, so they are pub(crate) and the public API (api_surface, api_signatures) stays as it was
(both tables failed on the public items, m3-max-23554).
corpus-metal at cf48013638 (m3-max-23519), three runs each. Each element type's three cases
(B in device memory, as a cooperative right input, in threadgroup memory) answer the same
bytes, and those are the bytes tns_mm_float's nt-right-device case of that type answers on the
same Mac: Metal's _v2 runs compute what its earlier runs do.
Nine cases, tns_mm_float's three nt-right-device cases (float, half, bfloat) on tns_mm_v2, each
with B in device memory, as a cooperative right input (variants 10 to 12) and in threadgroup
memory (13 to 15): the same buffers and tiles, so each answers the same sums. Installed through
corpus-case-check --install (m3-max-23490).
A _v2 run passes, after each tensor operand's descriptor type, its scale type
(__tensor_ops_datatype_invalid without tensor_plane_scales), the scale factors' two block sizes
(0 without) and the tensor's two static extents (get_static_extent, dynamic_extent passed as
the int -1 for a dynamic one). With no scale factors and only dynamic extents the operand is the
earlier form's: the descriptor object and descriptor type are the same, so Run::of_call takes it
as that run. A scale or a static extent stays refused, each by name, and so does the
single-thread form, now named alone.
The header spells every matmul2d run in its _v2 form for a deployment target of 27.0: after
each tensor operand's descriptor type come its scale type, its scale factors' two block sizes
and its two static extents. tns_mm_v2 is tns_mm_float compiled for macOS 27 (MSL 4.1), with
variants 10 to 15 adding a transposed B as a cooperative right input and in threadgroup memory,
the forms macOS 27's quantized matmul kernels run. engine_matmul2d's fused-sum test runs it on
the three profiles against the same reference.
What: the fuel transform reads the module's !air.version and, from AIR 2.9 on, declares and
calls the status load, add and or with the mem_flags i32 between the scope and the volatile flag
(0, no flags, as a relaxed atomic passes): `i32 (i32 addrspace(1)*, i32, i32, i32, i1)` for the
load. A module that states AIR 2.8 or earlier, or no version, keeps the form it had.
Why: Apple's compiler for macOS 27 writes AIR 2.9, whose atomic intrinsics take that operand,
and metal-opt refuses the AIR 2.8 form in a module that states AIR 2.9. So no macOS 27 case whose
entry reaches a loop could be qualified on Metal: every case of the tns_mm_v2 fixture (the Tensors
work, landing next) failed with "invalid AIR function air.atomic.global.load.i32 (i32 (i32
addrspace(1)*, i32, i32, i1))" (m3-max-23501).
Verified, one run each:
- oracle_fuel's tests, 80 of 80, among them the new
the_status_atomics_take_the_form_of_the_modules_air_version (no version, 2.8 and 2.9: the
declarations' forms, and every call's operand count equal to its declaration's)
(m3-max-23527, the same patch on the Tensors branch).
- The nine tns_mm_v2 cases on the M3 Max (macOS 27.0.1): refused by metal-opt before
(m3-max-23501), all qualified after (m3-max-23519).
- fmt, clippy (all features, --cfg m2v_gpu, --cfg m2v_cpu_icd) and rustdoc over the Tensors
branch that carries this patch (m3-max-23553).
The commit before this one. Since the alignment lattice (SEMANTICS_VERSION 2069), the provenance GEP fact over a base
not yet reached (PtrFact::BOTTOM) took its indices' alignment, so it differed from BOTTOM in `align` alone, with no
roots, range or shape; every check that skips an unreached operand compares the whole fact with BOTTOM (the store
pass, the load transfer, the zero fills), so a pointer with no roots passed as reached. generic_pointers'
generic_captured and generic_functor (SEMANTICS_VERSION 2068) were refused at lowering on every profile on the merged
tree (Lowering(Access) at the store of &local[0] into refs.b; DereferenceLoadedPointer without int64 or a device
address), where they translated before the lattice. The GEP now returns BOTTOM for a BOTTOM base, after the
displacement walk refuses what it cannot size, as before the lattice.
Verified (on the branch): at development aacde9f2ad engine_generic_pointers fails (lavapipe generic_captured:
Lowering(Access), block 0, instruction 15) and the inventory refuses both rows on every profile (m3-max-23579); at the
fix engine_generic_pointers, the 8 public_fixtures_engine parts, engine_access (SEMANTICS_VERSION 2069's placement test
included), engine_copy and memory 141/142 (23616), the one the engine inventory part whose only difference is the two
rows now ok in all 19 cells (re-blessed on development); runtime_lane::generic_pointers 2/2 on lavapipe, the M3's words
(23639); golden_hashes lists the same cells with and without the fix (23640). fmt, clippy all features, rustdoc
(23646).
Since the alignment lattice (786bae34a5), a GEP's fact over an unreached base (PtrFact::BOTTOM)
took the indices' alignment, min(cap, gep_twos), and so differed from BOTTOM in align alone
while its roots, range and shape were empty. Every check that skips an operand not reached
compares with BOTTOM whole (the store pass, the load transfer, the zero fills), so such a
pointer passed for reached with no roots. generic_pointers' generic_captured and
generic_functor, whose lambda and functor objects hold thread pointers, stopped translating on
every profile (Unsupported{Lowering(Access); NotImplemented}, and DereferenceLoadedPointer on
the profiles without int64 or a device address), where they translated at 88e6e2bce2. The GEP
now returns BOTTOM for a BOTTOM base, after the displacement walk refuses what it cannot size,
as it did before the lattice.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
What: the 14 device() accessors that answer an owned handle say so in
their docs, after Metal's retained device; the rest of each doc stands.
Why: the docs should name the change a caller sees (an owned Device where
a borrow was).
Verified: docs only; the lane and lint that follow build them.
What: the public device() of every object whose borrow reached a handle a
recovery lets go of answers an owned Device, a clone of the generation
handle it read: Buffer, Texture, Heap, IndirectCommandBuffer, Event, Fence,
SamplerState, Library, Function, DepthStencilState, AddressPool,
DynamicLibrary, BinaryArchive and SharedTextureHandle (whose device is its
texture's). The runtime's own reads keep a borrow through a crate-private
generation() on the types they read it of (Buffer, Texture, Heap,
IndirectCommandBuffer, SamplerState, Function, BinaryArchive): 301 call
sites, so no hot path pays a clone. Each changed item's doc says the handle
is the caller's and keeps its generation, VkDevice included, while held,
past a recovery that carries the object on; MadeOn's doc states that no
borrow of it reaches the program. The validation lane's four callers that
passed the borrow on take a reference of the handle. Signature table
re-blessed (14 rows).
Why: these accessors answered a borrow into device/carry.rs's MadeOn (a
Buffer's or Event's parts, or a LineDevice's GenerationLink), whose
let_go drops that Device at the lost generation's rest while the object
lives. Safe code that held the borrow across a recovery and that rest read
a dropped Device. Metal's device property answers a retained device. The
other objects' device() (queues, command buffers, argument encoders, rate
maps, pipeline states and their function tables) answer a borrow of a
handle the object owns for its life, which no recovery lets go of.
Verified: the lane that follows runs tests::device_recovery_handles before
(it fails: one live VkDevice while the borrow is held) and after the fix;
a workspace check of the accessor change was clean under the plain cfg and
found the four validation callers under m2v_gpu and m2v_cpu_icd (job
m3-max-23584 on a probe commit).
What: tests/device_recovery_handles.rs holds the device a fence, a
sampler state, a Private buffer and an event answer, each made before a
recovery, across that recovery and the lost generation's rest, then uses
it: the lost VkDevice lives while the handle is held (two live VkDevices),
the handle names a generation that serves no more and its new_buffer goes
to the one serving, and the lost VkDevice goes once the handle is let go.
Why: each answers a borrow of the object's own handle of its generation
(device/carry.rs's MadeOn, through LineDevice for a fence and a sampler
state), which the recovery lets go of at the lost generation's rest while
the object lives: safe code holding the borrow across the rest reads a
dropped Device. The test fails before the fix at its first check (one
live VkDevice: the borrow keeps nothing), before it touches the borrow.
Verified: the lane that follows runs it before and after the fix.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The three commits before this one. After a device recovery a Private buffer in exportable memory was left refused
(MadeBeforeRecovery), failing, for example, a video session's frames over device caches that VA-API decodes into. The
recovery now exports the lost block's payload once from the lost VkDevice (vkGetMemoryFdKHR, which the spec lets a
lost device answer), keeps that descriptor on the block, and the new VkDevice imports a clone of it once for every
buffer carried from the block, as memory of the block's own type and size (dedicated where the lost block was a
dma-buf's dedicated allocation), binding each buffer at its offset. The buffer is not cleared: another API's import may
reach the same memory, so it keeps whatever the memory holds (the documented exception to the Private-reads-zero
rule). Its exports, and a texture image over it, answer the kept descriptor's clone, so textures over it carry as
over any carried buffer. Left refused: Shared and Managed exportable buffers (their contents pointer is the lost
mapping) and an opaque descriptor's dedicated allocation, a new left kind in the notice (Left::DedicatedOpaqueFd:
Vulkan does not define VUID-VkMemoryDedicatedAllocateInfo-buffer-01879's identical buffer across devices). Docs:
exported_memory.rs, carry.rs, buffer.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs, API.md),
error.rs, the runtime README.
Verified (on the branch): lavapipe m3-max-23522, the test fails before the fix (the notice left "2 buffers in
exportable memory, 1 textures over the buffers left"); at the test fix 0dda2df1ff device_recovery 30/30 on lavapipe
(23574) and on the 780M RADV (23583), OpaqueFd and DmaBuf both carried with the export after the recovery matching the
one before (64 MiB, offset 0, same memory type, same inode); the touched tests one process each 208/208 (lavapipe,
23522) and the export, dma_buf and handed tests 88/88 on the 780M (23552). Clippy plain, m2v_gpu, m2v_cpu_icd and
rustdoc at a8d9a42934 (23523..23525). REFUSALS unchanged.
What: the exportable carry test checks that the recovery's notice leaves no
buffer in exportable memory (nor in a dedicated opaque-fd allocation)
refused and counts its texture among those over carried buffers, in place
of counting one buffer carried with its contents; the export after the
recovery still checks the buffer's memory.
Why: the buffers carried with their contents counted two on lavapipe and
the 780M (lanes m3-max-23522, m3-max-23552): another buffer the test made
(a read buffer let go of, as far as the test can tell) was among them, so
the count is not the test's to fix.
Verified: the lane that follows.
What: Buffer::carry takes a Private buffer in exportable memory (no host
copy) to the new generation over its block's payload imported again
(Device::buffer_in_carried_export, memory::place_carried_export): the lost
block is exported once from the lost VkDevice (memory::carried_payload,
vkGetMemoryFdKHR, which the spec lets a lost device answer) and that
descriptor is kept on the block (Block::payload); the new VkDevice imports
a clone of it (Handed) once for every buffer carried from the block, as
memory of the block's own type and allocation size with the device-address
flag of the device's blocks, dedicated to the buffer where the lost block
was a dma-buf's dedicated allocation, and binds each buffer at its offset.
The buffer is not cleared: another API's import (VA-API) reaches the same
memory and may be writing it, so it keeps whatever the memory holds, counted
among the buffers carried with their contents. Its exports after the
recovery answer a clone of the kept descriptor, and so does the dma-buf a
texture's image over it imports (ExportedTexels::payload), so textures over
it carry as over any carried buffer. Left refused: Shared and Managed
exportable buffers (their contents pointer is the lost mapping), and an
opaque descriptor's dedicated allocation, a new kind in the notice
(Left::DedicatedOpaqueFd: VUID-VkMemoryDedicatedAllocateInfo-buffer-01879
names a buffer identical to the payload's, which Vulkan does not define
across devices). Docs: exported_memory.rs, device/carry.rs, buffer.rs,
MadeBeforeRecovery, the device-recovered cost (degradation.rs, API.md) and
the runtime README, with the exception to the Private-reads-zero rule.
Why: reims's NV12/P010 device caches are Private exportable buffers
(STORAGE_PRIVATE in surface_cache.rs and vaapi.rs, read-only check) that
VA-API decodes into; a recovery left them refused, failing a video
session's frames, where Metal keeps the buffer.
Verified: the lane that follows runs the test before and after on lavapipe;
REFUSALS.md regenerated (no change).
What: device_recovery_exportable::a_recovery_carries_a_private_exportable_buffer_over_its_own_memory
makes, for each handle type the device exports (an opaque descriptor, a
dma-buf), a Private exportable buffer with an RGBA8Unorm texture over it,
fills it and reads the fill back through the texture, exports it, and
recovers the device. It checks that the notice counts the buffer among
those carried with their contents and the texture among those over carried
buffers, that an export after the recovery answers the same allocation
size, offset, memory type and file (inode) as before, and that a fill on
the new VkDevice reads back through the texture.
Why: a recovery leaves every exportable buffer refused (Left::Exported,
MadeBeforeRecovery), where Metal keeps the buffer; a consumer's video
decode writes such buffers through another API's import of their memory.
Verified: runs in the lane with the fix that follows.
123 golden-hash rows move, from the translator changes since the last bless: SEMANTICS_VERSION 2065 (flat simdgroup
dispatch), 2066 and 2067 (the fan-out variant), 2068 (generic pointers captured by reference) and 2069 (vector
placement: engine/kernel_read_through_constant's char-buffer float4 loads as 4 words). The generic_pointers printout
moves with SEMANTICS_VERSION 2066-2068, and the engine inventory gains generic_pointers' generic_captured and
generic_functor rows (both refused at lowering, Lowering(Access), on every profile; DereferenceLoadedPointer on the
profiles without the 64-bit or device-address feature).
Verified: bless on the M3 at aacde9f2ad (m3-max-23541): golden hashes blessed, engine goldens pass; merged check at the
same sha on msi (m3-max-23538): clippy every crate with --cfg m2v_gpu, api_signatures, api_surface, fast_paths,
the runtime's exit_guard and compile_memory tests, rustdoc -D warnings.
The seven commits before this one. A 16-byte leaf whose AIR says align 16 was one uvec4 unit at off / 16 of its slot's
view, and a memcpy whose call sites say align 16 moved such units; Metal places such an access at its address (a
float4 cast from a float pointer 84 p bytes in is only 4-byte aligned), so the unit put it k floats low (Geekbench
302's softmax rows: 728,687 of 774,144 outputs wrong). Provenance's PtrFact gains an alignment lattice (the base-2 log
of a power of two dividing every offset a pointer value may take; it only falls), MemoryPlan::proven_align combines it
with the roots' bases (a buffer's bind offset is a multiple of its air.arg_type_align_size by Metal's bind contract),
and Path::Vec4 and memcpy's 16-byte units need proven 16. Every other path is unchanged. Metal's placement measured
on the M3 Max (probe vector_access_placement.m, m3-max-23317) and, for the device float4 row, the Radeon Pro 5300M;
the table lives in memory/leaf.rs.
Verified (on the branch): the device test tests/vector_placement.rs reproduces reims's guest rows before the fix
(lavapipe 23503/23504, stale 0xEEEEEEEE where the guest read -1) and matches Metal after on lavapipe (23503, 23504),
the 780M RADV (23531) and the XTX RADV (23376, stores); the interpreter test
a_float4_aligned_only_to_its_lanes_is_placed_at_its_address (4 profiles x 2 encodings, residuals 0 and 4) fails on the
base and passes (23373); translator suite 3503/3505 then the written-slot test fixed (engine_access, engine_copy,
memory 167/167, 23431); 19 golden cells moved, all engine/kernel_read_through_constant.ll (a char buffer's float4
struct loads become 4 words), every other plain-.ll cell byte-identical; release translation of the plain-.ll golden
batch x 19 profiles 1.85 s / 155 MiB base, 1.19 s / 167 MiB tip (one run each, msi 23461). Clippy workspace all
features, m2v_gpu runtime, rustdoc clean. The golden table and the .air.ll cells are re-blessed on development.
The loads kernel reads each row's four float4s from a buffer whose float j holds j and stores
their lanes as floats; Metal's answer is the input, row for row. Placed at the offset rounded down
to 16 bytes, a row's vectors are read (84 p mod 16) / 4 floats early, as the guest's reads were on
the XTX.
every_view_of_a_written_slot_stays_writable moved a <4 x i32> at byte 16 of a uint buffer; a
uint buffer may be bound at any multiple of 4, so that unit is no longer proven a multiple of 16
and takes the words. As a uint4 buffer it keeps its uvec4 view, which the test is about.
reims's scout ran the misaligned float4 rows on a 2019 MacBook Pro's Radeon Pro 5300M under
macOS 26.7.1 from the same library as the M3 Max: loads and stores land at the exact 4-aligned
address (0, 4, 8 or 12 mod 16), every value of every row exact. The half4, uchar4, threadgroup,
constant and bind-offset rows stay the M3 Max's alone.
The runtime's device test runs the rows kernel (a float4 every 16 bytes from a row start 84 p)
and a float4 grid, and compares with Metal's answer from the conformance probe.
A 16-byte leaf whose AIR says align 16 was one uvec4 unit at off / 16 of its slot's uvec4 view
(or of a UniformVec4 view), and a memcpy whose call sites say align 16 moved such units. Metal
does not place an access at the alignment its AIR states. A float4 cast from a float pointer at
a row start 84 p bytes in is only 4-byte aligned, and Metal reads and writes it there; the unit
put it k floats low, losing the first k values and leaving k stale floats at classes 16 - k to
15 (a softmax over 21 classes, 728,687 of 774,144 outputs wrong).
Measured on an Apple M3 Max under macOS 27.0.1, rows of 21 elements one thread a row
(crates/metal2vulkan-conformance/probes/vector_access_placement.m, job m3-max-23317):
float4 (align 16), device, threadgroup and constant memory, loads and stores,
at 4, 8 or 12 mod 16 -> at the address
half4 store (align 8), device, at 2 mod 4 -> the multiple of 4 below
uchar4 store (align 4), device, at an odd one -> the multiple of 4 below
float4 * buffer bound at offset 4 -> at the address; API validation fails the
bind: "must be a multiple of 16"
So the words at off / 4, which every other path reads, are Metal's in each row, and only the
uvec4 unit at off / 16 was wrong.
Provenance's PtrFact gains `align`, the base-2 log (at most 4) of a power of two dividing every
offset a pointer value may take from its roots: a GEP's base and terms (a constant's
displacement, a dynamic index's stride times the factor of two its index carries through shl,
mul, and, add, sub, or, xor, select and extensions), the least over a phi's or select's values
and a cell's stored pointers. It only falls and is never widened; only offset changes count
toward widening. MemoryPlan::proven_align is the least of that and its roots' bases: a buffer
parameter's residual is congruent to its bind offset modulo 16, a multiple of its
air.arg_type_align_size by Metal's bind contract (the validation message above); an arena
object's or blob constant's base is its offset; a threadgroup region's 16; any other root's 1.
leaf_of takes the proven alignment, and Path::Vec4 needs it at 16 as well as align 16; memcpy's
16-byte units need it on every buffer endpoint. Every other path is unchanged, so a kernel whose
offsets are proven (a float4 buffer at its own indices, 16-aligned struct members, constant
offsets from a 16-aligned argument) keeps its uvec4 unit.
Tests: engine_access's a_float4_aligned_only_to_its_lanes_is_placed_at_its_address runs the
rows kernel as Apple's compiler emits it (loops kept) in the interpreter on four profiles in both
encodings at residuals 0 and 4, and must equal Metal's rows; a float4 grid keeps its uvec4 view.
sixteen_byte_leaves_move_as_one_uvec4 now runs each 16-byte leaf at a byte offset read from a
buffer (words, whatever its align) and at an offset in 16-byte units over uint4 buffers (the
uvec4 unit where align is 16).
A float4 at a byte offset that is a multiple of 4 and not 16, a half4 at one of 2 and not 8, a
uchar4 at an odd one, in device, threadgroup and constant memory, stored and loaded, and a float4
buffer bound 4 bytes past a 16-byte boundary. The AIR of each such access carries the vector
type's alignment, which the address does not have.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
What: the tests of pipeline/compile_memory.rs (holds, waits and lent turns on threads of their own) move from an
in-file test module to src/tests/compile_memory.rs, unchanged but for their imports; Limit::census becomes pub(crate)
(still cfg(test)).
Why: tests::exit_guard::threads_and_the_program_s_code_go_through_the_guard scans the runtime's non-test sources for
thread spawns outside exit_guard.rs, and the in-file module's three std::thread::spawn calls (from c6fa636665) made it
fail on development (perdraw5's lavapipe run at 70c666b243). The crate keeps tests that reach internal items in
src/tests/, which the scan skips.
Verified: the merged check after this landing runs the guard test and the moved tests.