Commit Graph
6839 Commits
Author SHA1 Message Date
Anees Iqbal c65a4fb740 harness: each row prints the submissions and submit infos a timed run made
The runtime's submissions and submit infos (Device::submit_infos, Metrics::submit_infos on the
new runtime, none on the old) over the timed runs, two in flight, per run: what grouping and
shared submit infos made of a run, where the row's submissions column counts one run done alone.
2026-11-17 21:55:44 -08:00
Anees Iqbal 45d18535d3 rt: a group's command buffers share one submit info where no event wait or signal separates them, and a group holds sixteen
The planner's ruled form. A submission's segments go in as few VkSubmitInfo2s as its event waits
and signals allow: a segment that waits on nothing joins the info before it where that one
signals nothing (submit::infos), the upload with the first. Each command buffer keeps its own
timestamps and its commands, barriers and completion are unchanged: only the info boundaries
move. The UHD 630's driver paid about 160 us for each info (probe 06860a3848, job m3-max-43935:
burst_160 at a group of eight 1.9-2.9 ms merged against 28-30 ms in separate infos and
11.6-25.8 ms on the old runtime); the 2080, RX 550 and 3090 ran merged within 1% of separate.

A group holds sixteen command buffers, by the ruled rule (no bound if the UHD without one is
within 3% of its best arm, else sixteen): on the UHD, merged burst_160 ran 1.85 ms at sixteen
and 3.6-4.1 ms unbounded (job m3-max-44105).

Metrics::submit_infos counts the infos passed, so the merged path shows it ran.

Tests: tests::submit_infos (the merge rule: shared until an event wait or signal, a signal-only
info, one segment, none); every_device_shares_submit_infos_within_a_group_and_records_what_it_
records_alone (a group mixing a Private fill, a Shared fill whose end barrier reaches the host, an
empty command buffer, an event signal and its wait: barriers, passes, bytes copied and the words
equal to the same command buffers committed one at a time; fewer infos than command buffers in
groups, one each alone).
2026-11-17 21:55:44 -08:00
Anees Iqbal 1d460b2efd translator: the from_queries path keys a render descriptor by fixed-width words (queried_render_descriptor_key)
The new runtime keeps its map of contents under the key of a render descriptor, and a seen
render state cost 2.4 us (harness m3-max-44304, create_render_state p50 at aacdf481ce) against a
compute state's 0.8: render_descriptor_key took 2.27 us of it (bench m3-max-44376 at 7c9918994d,
32.8k instructions against compute_pipeline_key's 7.2k), most in writing the descriptor's fields
in their Debug form (0.41 us for the eight colour attachments alone).

Device::queried_render_descriptor_key keys the same fields as render_descriptor_key, each stage by
its compile key under the default inputs, the profile and SEMANTICS_VERSION, but writes every other
field as fixed-width little-endian words, tags and counts before optional and repeated parts,
under its own domain. Every field of the descriptor and of each struct it holds is destructured,
so a new field does not compile until the key writes it. metal2vulkan-rt keys render contents on
it. render_descriptor_key, the old runtime's (which keeps answers in its cache directory under
its values), is not touched and goes at the cutover.

Tests: the old key of one known descriptor is pinned to its value at 7c9918994d
(9d941806..., read by the bench m3-max-44376); the new key differs from the descriptor's for a
change in each field group and on another profile, and the old key tells each apart too.

Verified: cargo fmt; api_signatures blessed. Lint, the bench and the harness follow as potluck
jobs.
2026-11-17 21:50:59 -08:00
Anees Iqbal d3adc366cf harness: a render state's first creation is its first_create_us too
time_states timed a render state's first creation as first_us and left first_create_us None, so
the row printed no first and first_create_us's doc (the part of first_us the creation paid) held
for compute alone. A first creation time_states times itself is now both; the row prints it as
the creation alone. Render's first gets its first draw with the draws.

Verified: cargo fmt; lint and the harness rows follow as potluck jobs.
2026-11-17 21:50:59 -08:00
Anees Iqbal 30985352a4 rt tests: the pooled-take-beside-a-kept-dedicated-block test releases the block by its handle
The deadlock fix's test (8f4d6a1066) was written before the block handle (6dab612810) landed
and still called release_block with a BlockId, so rt's lib tests did not compile under
--cfg m2v_gpu or m2v_cpu_icd (quick check m3-max-44401). It now keeps the dedicated block's
number, gives the handle to release_block, and holds each pooled take's handle to the end, as
the numbers were held before, so the second take still waits for the block maker instead of
taking the first take's block back.

Verified: cargo fmt; clippy for both device cfgs and the lavapipe run follow as a potluck job.
2026-11-17 21:50:33 -08:00
Anees Iqbal 8f4d6a1066 rt: the block-maker thread makes a class's next pooled block whatever dedicated blocks it keeps idle
Since given-back dedicated blocks are kept idle (208887e13a), a class's
idle list holds pooled and dedicated blocks, but the block-maker thread
still judged a class ready by the idle list's length. Pool::take hands
out only pooled blocks, so once a class kept READY or more dedicated
blocks and no pooled one, the maker slept while a pooled take waited for
it forever: replay's play of a recording stalled in Device::take_block
(job m3-max-44321, gdb stacks from the replay lane).

The maker now counts only the class's idle pooled blocks (State::ready),
as does the tests' Pool::idle, which waits for the ready ones. Take,
keep (the ready block is the latest pooled one), take_held and remaining
already told the two apart.

Test: every_device_makes_pooled_blocks_while_it_keeps_dedicated_ones
keeps a dedicated Shared block idle beside the ready block, then takes
two pooled blocks, each under a 30 s timeout; without the fix the second
take waits forever.
2026-11-17 21:44:43 -08:00
Anees Iqbal 363088e6c4 rt README: a kernel observing its partition pays the UHD 630's address penalty in narrow square workgroups
A kernel that observes its threadgroup partition keeps its own threadgroup size as the Vulkan
workgroup. On Intel's Windows driver (101.2145) for the UHD 630, a per-thread buffer access
through a device address is about twice as slow in 16x16 workgroups as in the 256-thread tiles
or in 128x2 workgroups, and storage-buffer descriptors remove the difference. Descriptors are not
taken: the runtime binds buffers by address alone, so this is recorded as a known gap of pipeline
states.

Measured on a probe build (4f8a9df6b5, on development 80bd8ca764, post-pace), potluck jobs 44328
and 44329 on the UHD 630, the median over two rounds of 100 runs' GPU time (p50):
- texture read + 16-byte buffer store, 2048x2048: tiles 3,721 us, 128x2 3,735 us,
  16x16 7,775 us, 16x16 through descriptors 3,585 us;
- 16-byte buffer read + texture write, 2048x2048: tiles 4,634 us, 128x2 4,735 us,
  16x16 6,554 us, 16x16 through descriptors 4,605 us.
The share of threads (2.0% and 3.4%) is the replay count of observing kernels at threadgroups 32
threads wide or narrower that store to device memory, over the two recorded streams.

Docs only; nothing built or run for this commit.
2026-11-17 21:40:17 -08:00
Anees Iqbal 4c5257d3ec replay: the report's first line names the runtime and whether the play took snapshots
A timing table must never come from a snapshotting play unnoticed: the device line reads
device NAME runtime old|rt snapshots yes|no for both runtimes.

Verified: cargo fmt only; clippy, replay tests and the release build next.
2026-11-17 21:38:16 -08:00
Anees Iqbal fd0f8fcaef replay: --snapshots no plays every m2v.privateBytes dispatch as it is on either runtime, so old's and rt's plays do the same work
Old's play of gb on the 3090 with snapshots read 0.54 of 1.9 GB of stream in about 5 minutes
(m3-max-44322, cancelled before its 15-minute limit): the player's own splits and readbacks around
12,000 dispatches dominate it, and rt declines them, so their frame times and memory would not
compare. Player::without_snapshots takes none on any backend.

Verified: cargo fmt only; clippy, replay tests and the release build next.
2026-11-17 21:38:16 -08:00
Anees Iqbal 6dab612810 rt: take_block returns a Block handle, and dropping a block's last handle gives the block back
A block was plain data (BlockInfo) owned by the device's claims map until release_block(id) or
the device's teardown, so a block whose number the consumer lost was held until the device died:
memory unreachable but held, a leak by construction, which the "zero at device drop" gauges do
not see (the player's play ran out of memory at frame 1074). The planner ruled the handle as
proposed:

- take_block returns Block, rt's own handle with no Metal counterpart, which derefs to the
  block's BlockInfo. Clones share one claim (Claim); the drop of the last handle runs what
  release_block ran: the device forgets the block's number and the work's pending upload counts
  it, and the block is zeroed and kept or freed once no buffer, command buffer or upload uses it.
- The device keeps claims by number as weak references, now in the core (Core::claims), so every
  call that takes a block number still does (new_buffer, new_managed_buffer, heap ranges); a
  number whose handles are all gone answers Error::NoSuchBlock.
- release_block(block: Block) consumes a handle: the drop made explicit; another device's block
  is Refusal::OtherDevice.
- The device's teardown frees every block still claimed after halt, that is after the consumer's
  BlockMappings::unmap returned for each handed block (contract 6A's order: the claims' slots are
  emptied only then); a handle dropped after the teardown finds its slot empty and does nothing.

The harness keeps each pooled block's handle and gives a dedicated block's to its buffer; the
replay backend keeps a stream block's handle in its object and a dedicated place's in the place.
rt's tests hold their handles where they used to hold numbers.

Tests (device cfg, command.rs): a dedicated block whose last handle drops with no release_block
while a held command buffer uses it answers NoSuchBlock for its number at once, stays live
(Gauges::blocks one up) until the command buffer completes, and is then freed (back to where it
was); of two clones, dropping one gives nothing back and the number still names the block,
releasing the other frees it; a handle that outlives its device finds every gauge zero after the
teardown, and its drop does nothing. README, the BlockInfo, NoSuchBlock and OtherDevice docs,
docs/REFUSALS.md and api_signatures.tsv follow.
2026-11-17 21:36:45 -08:00
Anees Iqbal 7c9918994d rt render: a state keys the device's map of contents on its descriptor's key, as a compute state does
A seen render content cost 220.9 us a creation (harness 44254, create_render_state, p50 at
80b8705d4f) against compute's 0.8 us: the map's key was Device::render_variant_key, which decodes
and specializes both functions on every creation. Compute keys the same map on
Device::compute_pipeline_key, which reads no function. Render now keys it on
Device::render_descriptor_key (every field, each function by its compile key under the default
inputs; the old runtime's memo key too), and decodes, keys for the compile and lowers only on a
miss. The one map stays bounded at 1,024 entries; a device test fills it past a cap of 2 with
render contents and checks the gauges and the frees. The cost: two descriptors that differ only in
a field their compile does not read compile apart (README, module doc).

Verified: cargo fmt; lint, device tests and the harness rows follow as potluck jobs.
2026-11-17 21:32:51 -08:00
Anees Iqbal 5abc08895a harness: the creation test takes render states as it takes compute states 2026-11-17 21:32:51 -08:00
Anees Iqbal 7abf8df6a3 rt render step 1: fix forward the lint (PipelineKey is Copy, CREATES holds five, a harness doc link as plain code) 2026-11-17 21:32:44 -08:00
Anees Iqbal 11b77a466e rt: render pipeline states on the content key, sharing the device's map of contents
Device::new_render_pipeline_state(&RenderPipelineDescriptor) is
newRenderPipelineStateWithDescriptor:error: without reflection. A state's content is the
translator's render_variant_key of its descriptor; render contents and compute kernels share the
one bounded map of 1,024 contents (kernel_map::Content), so a state of a held content costs the
key and a lookup. Each content lowers its vertex and fragment functions through the cache
directory's translations, and makes its triangle-class VkPipeline at creation through its own
pipeline file (the per-pipeline cache use is now one helper, made_through_cache, shared with the
compute path, and the layout's words one function, layout_words). A point or line class's
VkPipeline comes with the draws. Everything Vulkan 1.3 leaves dynamic is dynamic state; the
pipeline renders dynamically into the attachments' formats.

Built: one vertex and at most one fragment function, colour and stencil attachments, one sample.
Refused by Gap::RenderPipeline with a RenderPipelineKind: depth, multisample, amplification,
tessellation, synthesized stages, framebuffer fetch, imageblock, shader stencil, alpha to one,
step rate, numbered samplers, constant data, other specializations, dynamic state beyond 1.3,
and a feature or extension device creation does not enable. Gauges::render_contents counts the
contents alive.

The harness gains create_render_state, create_state's render twin: colored_vertex and
colored_fragment of the public examples fixture into one BGRA8Unorm attachment, the first
creation (a content unseen) timed apart, then 1,000 of the seen content, on old and new.

Tests (tests/render.rs, every device of the cfg's kind): a second state of a content lowers and
makes nothing and shares the first's; another format, a blended attachment and a stencil
attachment with two colours are contents of their own; depth, four samples and a constexpr
sampler are refused by kind with no pipeline; a device on a cache directory a device before it
used reads both lowerings and writes nothing.
2026-11-17 21:32:33 -08:00
Anees Iqbal 21b5fb6c3d replay: the rt backend's counters add dedicated blocks taken again and dispatches without effects, and its frame ends the idle Shared and Private bytes the pool keeps 2026-11-17 21:14:28 -08:00
Anees Iqbal 27b870d2af replay: old's allocation and free counts are its ObjectChurn's, the process's vkAllocateMemory and vkFreeMemory calls 2026-11-17 21:14:04 -08:00
Anees Iqbal c2ab6cc79a replay: the rt backend times each compute pipeline state's making and says whether its kernel was new, on a pipeline line of the report
The planner asks whether NVIDIA's first-pipeline cost is paid once per process or once per
kernel: each state's making's wall time, in order, with whether another specialization of its
kernel (a library's function by name) was made before. Backend::lines carries the backend's own
report lines; command-replay prints them after the player's.

Verified: cargo fmt only; build, clippy and replay tests next.
2026-11-17 21:14:04 -08:00
Anees Iqbal 1a615bd802 replay: old's executed counters add its vkAllocateMemory and vkFreeMemory calls 2026-11-17 21:14:04 -08:00
Anees Iqbal dbe3450966 replay tests: the frame-end test reads the line's end with ends_with 2026-11-17 21:13:05 -08:00
Anees Iqbal 9ab646922d replay: the rt backend gives the stream's blocks and heaps back at their release; old plays what only the scratch player did; each frame's end reports wall time, resident memory and the backend's gauges
- The rt backend dropped a released m2v block or heap without Device::release_block, so every
  block gb made and released stayed allocated; the 3090 play stopped at frame 1074 on
  vkAllocateMemory (m3-max-44161).
- The old backend skips a library from source (no device here compiles Metal source), what is
  made of a skipped object, and the draws of a render encoder whose pipeline state is one, all
  counted; it takes MTLRenderPassDescriptor.renderPassDescriptor and the copyFromBuffer:...
  toTexture: form without options. Those were the scratch player's alone, so old could not play
  gb from development.
- Each frame's end line: wall nanoseconds, VmRSS, and the backend's gauges as they stand (rt's
  live blocks, buffers, textures, pipelines, kernels, command buffers, spilled bytes and the bytes
  of the blocks the backend holds by class; old's live, empty and dedicated memory blocks). Old's
  counters add device memory allocated and pooled blocks made and freed. The skipped and gaps
  lines are printed for both backends, before ok or error as documented.

Verified: cargo fmt only so far; build, clippy and the replay tests run next on msi.
2026-11-17 21:13:05 -08:00
Anees Iqbal c64e299830 Re-pin the runtime sources at the landing tip
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.
2026-11-17 21:12:53 -08:00
Anees Iqbal 9769864acf translator: the identity gate counts descriptors, not a fragment function's colour attachments 2026-11-17 21:08:25 -08:00
Anees Iqbal aeea5f1721 translator: vertex and fragment functions lower under the identity domains on the floor's push window
identity_admits took kernels alone. On Device::from_queries' profile (PushWindow::Floor) it now
takes a vertex or fragment function under the same conditions as a kernel: every buffer slot
reached through its pushed device address (SlotGuestBase), textures and runtime samplers by
resource ID, constexpr samplers by pushed index, no descriptor, no unsourced fact. Device::new's
profile refuses them as before (Unsupported{IdentityDomains}, not implemented), so its output is
unchanged. The stages keep their fixed windows (vertex [0, 64), fragment [64, 128)) until the
render push layout is ruled.

Test (tests/engine_identity_render.rs, no GPU): colored_vertex and colored_fragment of the owned
examples fixture compile on from_queries' lavapipe and moltenvk-m3 profiles, the vertex function
pushing its two buffer addresses in its window with no descriptor, root table or parameter
block, both modules passing L3; Device::new's profile still refuses them.
2026-11-17 21:08:25 -08:00
Anees Iqbal 208887e13a rt: given-back dedicated blocks are kept idle with the pooled ones, up to a byte bound per class
A block given back, pooled or dedicated, is now zeroed by the block-maker thread and kept as
its class's latest idle block. It keeps its number, address and mapping, so the consumer's
mapping stays too. Each class keeps at most a bound of idle bytes, MemoryClass::idle_bound:
256 MiB Shared and 128 MiB Private. The class's ready block (its latest idle pooled block) is
a reserve outside that bound. Past the bound, the oldest kept block is freed through
BlockMappings::unmap, whether it is pooled or dedicated. A block longer than the bound, or a
spilled one, is freed at once. This byte bound replaces the count IDLE_MAX = 2.

A take past the pooled length first takes the shortest kept dedicated block that it fits
and fills at least half of (memory::fits), and only allocates when none does. Each reuse
counts in Metrics::dedicated_blocks_reused. Gauges::shared_idle_bytes and
private_idle_bytes count what is kept, the ready block included, and read zero after
teardown.

Why: a program that makes and releases large buffers frame after frame paid a fresh
vkAllocateMemory each time, and the driver's hold on the device's other calls with it. On an
RTX 3090 (NVIDIA's Linux driver, probe ecb66a34eb, job 44126) a 32.6 MB Managed buffer's
dedicated Shared block cost 8.3-10.8 ms in the call and held submissions for up to 7-19 ms.
Old took 1.6-1.8 ms for its second such buffer, a range in a 64 MiB block it already had.
Under the hold, only the first pair pays. Probe 4b48aa5c9b (jobs 44208-44210) made the pair,
gave it back and made it again. The second pair took 0.01-0.02 ms with no submission held
(longest round trip 0.10-0.19 ms, against 0.09-0.11 median), and dedicated_blocks_reused
went 0 to 2 with no block made. That held on the RTX 3090 and the RTX 2080. On the RX 550
the first pair took 3.8-4.6 ms and the second 0.01 ms. On that probe a fresh block's
create, bind, address and map took 18-75 us, the allocation 6.0-11.1 ms and the zeroing
1.2-1.7 ms. Under the hold the zeroing runs on the block-maker thread at give-back.

Tests: a_kept_dedicated_block_serves_a_request_it_fits_and_that_fills_half_of_it (the rule).
every_device_keeps_given_back_dedicated_blocks_for_requests_they_fit: of three 100 MiB
Shared blocks given back, two are kept beside the ready block and the oldest is freed
through the hook. A 60 MiB request takes a kept one, zeroed, as it was, with nothing made;
40 MiB and 101 MiB requests make their own. A dedicated Private block is kept beside the
Private ready block and taken again. Gauges read zero after teardown.
every_device_keeps_idle_blocks_up_to_the_bound_and_frees_the_oldest replaces the two-block
test: 18 Shared blocks given back leave 16 kept beside the ready one, and the oldest is
freed. The hand-out test's dedicated block is past the bound, so it is still freed on
release. API table re-blessed.
2026-11-17 21:02:00 -08:00
Anees Iqbal 32d511d17d harness, matrix: long_4cb runs one size on both runtimes: --size gives a sized row its size, the matrix passes the first runtime's to the later runs, and a row run at two sizes fails uncompared
A workload whose size follows the device (long_4cb) was sized by whichever runtime ran it first in
its process. The matrix times each runtime in its own process, so each sized it from its own base
time, and they could run different work: the RX 550's long_4cb ran at different sizes on the two
runtimes at 594b86d1f2, and its ratio compared unlike runs.

- run_each takes the size where the caller gives one (ScaledTo::base_us is then None) and times no
  base; a size for a workload of one size is an error.
- The command takes --size NAME=N (repeatable; a name it does not know is an error) and prints each
  sized row's size as an `M2V-MATRIX size harness-<runtime>/<row> <size>` record.
- The matrix reads the first runtime's "sized to" lines and passes them as --size to every later
  run: the main run, the warm run and the re-timed pairs.
- results.harness_budget fails a row whose two runtimes' size records differ (or only one has
  one), uncompared; `size` is a record kind.

Verified: python3 scripts/matrix/test_results.py, 29 OK; with the size check removed, the new test
fails (negative control). The matrix's harness script, rendered and run against a stand-in harness,
passes `--size long_4cb=4096` from the first runtime's line to the second's run. Harness unit test
a_scaled_workload_given_its_size_runs_at_it_and_times_no_base: build and run in the check job.
2026-11-17 20:57:07 -08:00
Anees Iqbal b96e61afa3 docs: VALIDATION.md's matrix says a harness time is host time and a ceiling is only ruled
The `time` record kind is what a program waits on, timed on the host (commit-to-complete where the
workload times it, else the wall time a run adds), since the harness's matrix_time change on this
branch; the harness budget lists no ceiling now, and one is given only by a ruling after the work
on its row. The doc said GPU time and measured-ratio ceilings.

Verified: the text only; python3 scripts/matrix/test_results.py, 28 OK on this branch.
2026-11-17 20:55:18 -08:00
Anees Iqbal a1a5ada454 matrix: the harness budget lists no ceiling: a ceiling is ruled after the work on its row, never taken from a measured ratio
The 2080's frame_5cb ceiling of 1.166 was its measured commit-to-complete ratio at 594b86d1f2,
which turned a red into a budget without a ruling. The GPU-time ceilings dropped earlier on this
branch were ratios of another measure. With none listed, every row over HARNESS_BUDGET fails its
leg until a ruling, made after the work on that row, gives it a ceiling.

Verified: python3 scripts/matrix/test_results.py, 28 tests OK.
2026-11-17 20:55:18 -08:00
Anees Iqbal 8b8e9e5475 harness tests: frame times its command buffer's commit to completion too
The matrix judges frame by its commit-to-complete time now (check job m3-max-44116 failed on the
old assertion that frame does not time it).
2026-11-17 20:55:18 -08:00
Anees Iqbal b74e1a50b9 harness, matrix: a row is judged by host time: commit-to-complete where the row times it, else the wall time a run adds; the GPU time is a diagnostic
The matrix judged every plan row by its GPU time (first command buffer's GPUStartTime to the
last's GPUEndTime), which is not what a program waits on, and whose placement changed between
builds. The harness's matrix time is now run::matrix_time: the steady time of each run's mean
commit-to-complete time where the plan times its command buffers' (frame, frame_5cb, long_4cb;
frame now times it too), else the steady time of the host wall time each run adds
(Report::wall_us, the timed loop's period with two runs in flight). The GPU time stays in the
table as a diagnostic; a new line per row prints the matrix time, what it is, and the wall p50.

results.py's ceilings were GPU-time ratios. They are now host-time ratios: frame_5cb on the 2080
keeps a ceiling of 1.166, its commit-to-complete ratio at 594b86d1f2; the others are dropped, and
the first matrix on host time sets the ceilings of the rows still over the budget.

Re-judged from the 594b86d1f2 matrix's harness output (c2c p50 of every command buffer, new over
old; the records hold no host wall time, so the burst rows and frame cannot be re-judged):
- frame_5cb: 780M Phoenix 0.671, 780M HawkPoint 0.693, RX 550 0.820, XTX 1.003 (pass, as on GPU
  time); 2080 1.166 (GPU 0.928: now over the budget, its ceiling 1.166); 3090 0.760 (its GPU
  ceiling 1.137 leaves the list); UHD 3.535 (GPU 2.395; fails either way).
- long_4cb, both runtimes at one size: 780M Phoenix 1.273, 780M HawkPoint 1.309, XTX 1.291,
  2080 1.345, 3090 1.266, UHD 1.154: pass on GPU time (0.99-1.01), fail on host time: a group's
  first command buffers are seen complete with its last. RX 550: the runtimes ran different sizes
  (1024 and 2048), so its ratio (1.014) is not comparable until both run the same work.

Test: tests::a_row_is_judged_by_host_time_never_its_gpu_time (wall time without commit-to-complete,
the mean of a run's places with it, the steady time of those means, none without host times).
scripts/matrix/test_results.py passes (28 tests).
2026-11-17 20:55:18 -08:00
Anees Iqbal 80bd8ca764 rt: pooled blocks are 16 MiB of Shared memory and 64 MiB of Private
A pooled block's length is now per memory class, MemoryClass::block_len: 16 MiB Shared and
64 MiB Private on every device. It replaces the one 256 MiB BLOCK_LEN. take_block gives a
pooled block up to the class's length and a dedicated one past it. Textures are placed in
texture blocks up to the Private length. The harness and the replay player's places take
blocks of the class's length.

Why: a driver may hold the device's other calls for the whole of a block's
vkAllocateMemory, and the hold grows with the bytes, so the length sets how long one hold
lasts. On an RTX 3090 (NVIDIA's Linux driver, probe at 70d7cae48e, jobs 44050 and 44053
with the RTX 2080), a pipeline creation beside a Shared block's making took 40-45 ms at
256 MiB and 6-8 ms at 16 MiB (3-4 ms settled). 16 MiB is the largest piece a guest's
allocator takes. Private holds less: 3.4-4.6 ms beside a 64 MiB block, at most 1 ms more
than beside a 32 MiB one. At 64 MiB, a texture or a Managed buffer's device copy of 32 MiB
takes a pooled block.

Tests: every_device_pools_16_mib_shared_and_64_mib_private_blocks covers the lengths, the
dedicated block past each, and a 32 MiB texture placed in a texture block. The memory,
command, places, spill and upload tests use the class's length. The memory test reads a
Private block back a Shared block's length at a time. API table re-blessed (the BLOCK_LEN
const goes, MemoryClass::block_len comes).
2026-11-17 20:51:54 -08:00
Anees Iqbal 9dada05c84 Re-bless the golden hash table after SEMANTICS_VERSION 2170
The pinned-subgroup-size change (48833908aa) bumped SEMANTICS_VERSION and
changed the simdgroup fixtures' modules; golden_hashes_match_the_table failed
with it, and AGENTS.md re-blesses on development after the merge. Blessed by
job m3-max-44193 at 1cd01ce3d7 (inventory, golden hashes and printouts all
exit 0; only golden_hashes.tsv changed, 280 rows); the commits since touch rt
only.
2026-11-17 20:50:16 -08:00
Anees Iqbal 50a09b553a rt README: the Managed copy form's known gap: a write reaches a texture over the device copy from the next submission
A command that writes a Managed buffer, or another texture over a range that meets the texture's,
reaches a texture over the device copy in an image of its own only from the upload that leads the
next submission: later commands of the same command buffer, or of a command buffer submitted with
it, read the older texels. A command buffer that wrote such a texture and is never committed
leaves its entry with the buffer until the buffer is released. Both were in the code's docs; the
known gaps of textures now say so where a user reads them.
2026-11-17 20:49:10 -08:00
Anees Iqbal 0277ef8dfe rt README: an M3 Max shows a texture over a Managed buffer an untold host write; the documented contract stays the rule
The probe managed_texture_stale_write.m (job m3-max-44076, macOS 27.0.1): after a host write with
no didModifyRange:, the texture over the Managed buffer shows the written bytes, as after a told
write; the macOS 27 SDK marks Managed storage as having no effect on Apple silicon. The runtime
keeps Metal's documented contract (copies in only at Managed events), which leaves the untold
write's visibility undefined.
2026-11-17 20:47:55 -08:00
Anees Iqbal 23633ab1f1 conformance probes: what a texture over a Managed buffer shows after an untold host write
The stale case of Metal's Managed contract (a host write with no didModifyRange:), run on a Mac
only to record what Metal does there, beside the told write as its control. Apple GPUs may alias
Managed memory, so the documented contract, not this answer, is the runtime's rule.
2026-11-17 20:47:55 -08:00
Anees Iqbal 4b88203551 rt: a texture over a Managed buffer's device copy that the device's linear image does not take is copied at Metal's Managed events
Where the device's linear image does not hold a texture over a Managed buffer's device copy in
place (another pitch, an offset off the image's memory alignment, a format or usage the linear
tiling lacks), the texture was refused (Gap::TextureOverBuffer). It is now an optimal image of
its own, copied from and to the device copy only at Metal's own Managed events, with no tracking
of commands:

- in, from the device copy, by the upload that leads the next submission using the texture,
  where a did_modify_range met its range (after the upload's copy of that range) or submitted
  device work wrote the buffer (a binding whose compiled interface writes it: the translator's
  uses, not the declared access; a blit or fill into it) or another texture over a range that
  meets its;
- back, where device work wrote the texture, before the next reader of the device copy (a
  binding that reaches the buffer, a blit from or into it, a copy into another texture over a
  range that meets its, a synchronize_resource, a did_modify_range over it). A reader recorded
  after the write takes it in its own commands; the upload that leads a submission, which runs
  before the submission's commands, takes it only once the write's segment was submitted
  (Segment::managed_wrote; the segment's submission settles each write it made).

The buffer keeps each such texture's entry (ManagedOvers). A texture released while its copy
back is owed leaves its image with the buffer until a reader takes it or the buffer is released;
a lookup by id skips a released entry, whose id a texture made since may hold. The Shared rules
(crate::over's per-submission copies) now apply only to textures over a buffer of no device copy
(copied_shared). The planner ruled that Managed keeps its device side; this is that side's copy
form.

Tests (device cfg): the Managed device test (100 uses copy in once; a modify over the range
copies once, one outside it not at all; a kernel's write owes one copy, a read none; a written
texture read through its buffer by a blit; a synchronize; two textures over one range; a
released texture whose buffer goes copies nothing back and frees its image; one released before
a kernel reads its buffer goes back first), and a kernel that declares a Managed buffer
read-write and never touches it owes no copy. README, Gap::TextureOverBuffer's doc and
docs/REFUSALS.md follow.

Verified: lint m3-max-44117 and device legs m3-max-44136 (780M HawkPoint, 3090), 44137 (RX 550),
44138 (XTX, 2080, 780M Phoenix, lavapipe), 85/85 each with the validation layer on, on the same
tree based on ed6d11d477. The Managed tests ran on the six GPUs and took the Shared rule on
lavapipe. An earlier form, which marked a write's copy back owed at its encoding, failed the last
step on five GPUs (m3-max-44101, 44102, 44103): the upload leading the write's own submission
took it before the write ran.
2026-11-17 20:47:55 -08:00
Anees Iqbal 1cd01ce3d7 Re-pin the runtime sources at the landing tip
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.
2026-11-17 20:46:36 -08:00
Anees Iqbal 48833908aa translator: a flattened kernel takes its pinned subgroup size as a constant, never SubgroupSize
In the flattened tiers (Direct and Cluster32) a kernel's linear local index is
lin = SubgroupId * S + SubgroupLocalInvocationId, and S was the SubgroupSize builtin. If a driver
answers that builtin wrongly, lin is wrong, and so are the positions of every simdgroup in a
threadgroup larger than one subgroup. On the UHD 630's Windows driver, a SPIR-V 1.3 compute
module (glslang) read SubgroupSize as 0 under a required size of 32 with full subgroups, while its
SubgroupId and lanes were right. rt's own SPIR-V 1.5 module for the harness's reduce_sum read it
right on the same GPU: simd_reduce matched the CPU reference.

Where the tier's requirement pins a size (SubgroupRequirement::size: 32 for Direct, the cluster
size for Cluster32, on a stage in requiredSubgroupSizeStages), the pipeline is created with that
required size, so the subgroups run at it. lin now multiplies by it as a constant, and the module
declares no SubgroupSize builtin. The same holds on every device, with no query and no device
identity. Where the stage pins no size, lin still reads the builtin, as before.

The constant is a literal from the same requirement that sets the pipeline's required size, not a
specialization constant: the size is fixed when the module is lowered for the profile, and no
pipeline of the module runs at another size.

SEMANTICS_VERSION 2170: flattened modules change.

Test: lower::dispatch::tests::a_pinned_subgroup_size_reads_no_subgroup_size_builtin. With a
pinned size of 32 or 64, the serialized module holds no OpDecorate BuiltIn SubgroupSize, and every
kernel builtin keeps Metal's value on the CPU interpreter at that subgroup width. Unpinned, the
module still declares the builtin. Without the change, the pinned module declares it and the test
fails.
2026-11-17 20:45:50 -08:00
Anees Iqbal 5a8d7521f1 rt tests: the in-place texture's allocation count is taken with the block-maker thread settled on both sides
Matrix d2fa098f0c's XTX leg (m3-max-44061) failed every_device_holds_a_texture_over_a_buffer_in_place
once: live allocations 4 against 3 around buffer.new_texture, texture blocks 0 on both sides, every
alignment answer 256 (as in the passing runs). Since 5c9ca33c48 the device makes its ready blocks
in Device::new, and the block-maker thread refills the ready Shared block the test's take_block
used, off the test's thread: the count read before the texture could miss the refill and the one
after see it.

Both counts are now taken once the pool holds a ready block of each class (settled), so the
refill falls before the first; a block the texture took from the pool would show as the refill it
causes, and one it allocated as a live allocation, so the claim stays exact (no tolerance). A
negative check: the plain texture the test makes later moves the same settled count.
2026-11-17 20:40:15 -08:00
Anees Iqbal 37f83d74a4 replay: the rt backend reads useResource:usage: and synchronizeResource: arguments as the stream's resource, {Buffer: object} or {Texture: object} (gb on the 3090 stopped there, m3-max-44112) 2026-11-17 20:39:21 -08:00
Anees Iqbal d7d9beaf7d harness: create_state keeps its float constants apart from the Metal constant values it makes of them; the texture view's doc links the trait's new_texture
The first state's check reads the constants as float pairs (check job m3-max-44075 failed to
compile where the Metal values shadowed them). The rt adapter's new_texture_view doc linked
Self::new_texture, which rustdoc does not resolve in a trait impl: cargo doc -p
metal2vulkan-harness failed with -D warnings on development.
2026-11-17 20:38:12 -08:00
Anees Iqbal a285ce86db harness: create_state's first is the creation and one dispatch of the new state through to completion, the creation alone beside it
The row timed new_compute_pipeline_state alone. The new runtime makes the VkPipeline there,
while the old one makes none and compiles at the first dispatch, so the row compared unlike
work. `first` is now the fair sum for both runtimes: the creation, then one dispatch of the new
state (one thread, one round of signed_zero_products into a Shared buffer) committed and waited
for, its float4 checked against the kernel's arithmetic. The row also prints the creation alone
(CreateReport::first_create_us), so the time can still be placed. The matrix line `first` is the
sum. The 1,000 creations of a seen content are unchanged.

The authored harness test checks that the first state's timed work makes a VkPipeline on each
runtime; on the old runtime it fails without this change, where the creation makes none.
2026-11-17 20:37:57 -08:00
Anees Iqbal 9d136f70ad rt: a released slot's command buffer gauge falls before the slot goes back
QueueInner::release pushed the slot and woke a waiting command_buffer() before the gauge fell,
so a command buffer made in that slot could raise the gauge first: the 2080 leg read 65 live
command buffers on a queue of 64 (m3-max-44097, every_device_keeps_its_gauges_flat_under_ten_
thousand_empty_commits at 80fcfd0d5c). The gauge now falls first, so it never reads more live
command buffers than the queue holds, which is what the test asserts.
2026-11-17 20:37:03 -08:00
Anees Iqbal f1c73d60bc A dispatch of a kernel that writes no memory records nothing
The translator states on a pipeline's interface whether some stage writes memory another
invocation or a later command can read (PipelineInterface::writes_memory, the union of the
stages' StageInterface::writes_memory: a store to a buffer or through a device address, a
texture write or an atomic update, in the entry or any function it calls; the
ExecutionStatus words are the product's and do not count). The cache's artifact format and
semantics versions move with the new field.

rt reads it into the compute state's interface. A dispatch of a kernel without it, direct
or indirect, is checked as Metal checks it and then records nothing: no bind, no push, no
vkCmdDispatch, and the indirect buffer is not kept or read. Metrics gains
dispatches_without_effects, which counts them. Such a kernel has no effect a program can
observe, so the only difference is less GPU and encode time than Metal's.

Tests: the translator's a_compute_pipeline_states_whether_its_kernel_writes_memory (a kernel
that returns at once, one that only reads, one that writes only its own thread's array: no;
a store behind a branch, a noinline callee's store: yes, on the function and the linked
pipeline, each validated), and rt's
every_device_records_nothing_for_a_dispatch_of_a_kernel_without_effects (a direct, an
indirect and an unbound dispatch of a kernel the interface says writes nothing leave the
buffer unchanged and count three).
2026-11-17 20:35:35 -08:00
Anees Iqbal be3426c673 harness: new_texture_view's doc names new_texture as plain code, not an intra-doc link
Rustdoc cannot resolve Self::new_texture from the trait impl's method, and
'cargo doc --workspace --all-features --no-deps' with -D warnings failed on it
(matrix d2fa098f0c, lint job m3-max-44059: unresolved link at
crates/metal2vulkan-harness/src/rt.rs:479). Verified by the doc job that
follows this commit.
2026-11-17 20:30:40 -08:00
Anees Iqbal 3fd4b72b2c replay: the report counts the recorded ranges a newer one met in part (parted), on both backends; the rt backend counts the compute pipeline IDs it cannot give as a typed gap (gap_pipeline_ids), summed on a gaps line 2026-11-17 20:28:46 -08:00
Anees Iqbal ad33c4269f replay: the rt backend plays fences on compute and blit encoders (rt's Fence, 05ce4db691); a render encoder's fence calls stay skipped with it 2026-11-17 20:28:46 -08:00
Anees Iqbal d0b7ead2c3 replay: a recorded range that meets a live one in part ends the older range, as the program reused that memory; gb's stream places a buffer over one still live in its block (m3-max-44056, 44065) 2026-11-17 20:28:46 -08:00
Anees Iqbal 5733e58c4e replay: the rt backend answers a compute pipeline state's resource ID as none, reported as differing, where the play stopped (gb, lavapipe, m3-max-44039) 2026-11-17 20:28:46 -08:00
Anees Iqbal 0383fdbded rt: the timestamp read waits for the two values, and reads only a command buffer that wrote both
On MoltenVK 1.4.2 (M3 Max) the timeline semaphore signals before the timestamp queries are
available for most command buffers: a read without VK_QUERY_RESULT_WAIT_BIT then answered
NOT_READY and the command buffer had no GPU times. Probe jobs on the M3 (MoltenVK admitted past
its floor items for the measurement only): m3-max-43673 read both ways at retire, 58 of 72 reads
NOT_READY with both availability bits 0, one NOT_READY then available a moment later, 13 Ok;
m3-max-43654 read with WAIT: every one of the test's 34 command buffers got its times, the read
holding the completion thread p50 2.0 us, p90 21.8 us, p99 76.3 us, max 80.5 us.

A WAIT read of a query never written may never return, so the completion thread reads only a
command buffer whose segments wrote both queries (stamps_written == 2); one that wrote fewer has
no times, as before. The readback site's bound and the README's list of sites say so.
2026-11-17 20:23:53 -08:00
Anees Iqbal 59f4094a65 Reflow the import lists the rebase resolution unioned 2026-11-17 20:23:03 -08:00