The harness now counts each timed run's user-space instructions across the whole process. The
counts repeat run to run where the times do not: rt's p50 spread across processes was 0.16 to
0.27%. The matrix gates the frame and burst rows (WALL_ROWS) on those counts, beside the host-time
judgement and floors they keep under the GPU-p50 rule.
devtools: ProcessInstructions opens one user-space instructions counter per core type with
inherit set, so every thread started after it opens counts: the runtimes' and the drivers'
threads too. The harness opens it first thing in main, before any device starts a thread, and
each timed run records the counted delta. A node that refuses perf_event_open, and every
non-Linux host, records none.
harness: each row whose runs were not sized prints
`M2V-MATRIX instructions harness-<runtime>/<row>/per_run <p50>`.
matrix: a frame or burst row with a count on both runtimes passes the instructions gate as well as
its time's limit:
- it fails when rt's count is over old's;
- it fails when rt's count is past 1.03 times the stored count in scripts/matrix/instructions.tsv
(one column per driver family, `all` where the legs agree within 3%);
- it is named when its count is more than 1% under the stored count, which then ratchets down;
- it is named when no count is stored, and is then gated against old alone.
The single-kernel rows stay judged on their GPU p50 as before, and every row's count is shown
beside its times. The old runtime's harness counts are parked from the per-record
instructions-versus-base check, like its times. instructions.tsv starts empty: a matrix run's
counts seed it. VALIDATION.md describes the time rules and the gate in one paragraph.
Verified: scripts/matrix tests (python3 -m unittest discover, 45 OK) on this Mac, over this rule
and the GPU-p50 rule together. Before the rebase, check m3-max-45591 on msi (at c597bb3603) passed
clippy x4, nextest for devtools, harness and rt (118 passed, with the process counter's test), and
the release harness build. Count job m3-max-45641 on the 2080's node recorded the per_run count of
every row on both runtimes except long_4cb, which is sized.
The planner's ruling on the old-against-old GPU-p50 floors. On the XTX, whose host-time floors
reach 1.2-1.3 on the shader rows (8 runs, m3-max-45546), the same runs' GPU p50 spreads 1.004 on
simd_reduce (36.96-37.12 us, host time 44.9-55.8 us), 1.008 on narrow_ints, 1.012 on image_filter
and 1.024 on constexpr_sampling: the host time's spread is the host's, not the card's. So:
- A row with a GPU time on both runtimes is judged on its GPU p50, new over old, against the old
runtime's GPU-time floor on that leg (the new scripts/matrix/gpu-floors.tsv), with its host
times shown beside it. A ceiling applies to the time its row is judged on.
- The frame and burst rows (WALL_ROWS) stay on their host time and its floor, with the
instructions gate: their GPU time spans the gaps between their command buffers and spreads as
widely on several GPUs (1.68 on the Iris Xe's frame_5cb, 1.43 on the UHD 630's
burst_160_shared). gpu-floors.tsv lists no such row.
- CARD_VARIANCE names rows whose GPU time varies on the card itself: the XTX's sampling (GPU p50
16.3-20.3 us over the 8 runs; 1.264 in the earlier 4-run set, m3-max-45424) and
constant_managed (66.8-69.2 or 74.4 us). They are judged like any other row, never fail a leg,
and are named on its line as the card's variance.
- A re-timed run keeps the row's GPU time too (RETIME_KEEP, harness-retime-gpu/), and the re-time
selection chooses by the same measure (RETIME_SELECT with GPULIMITS and WALLRE), so a row judged
on its GPU time is re-timed and judged on its re-timed GPU pairs.
gpu-floors.tsv comes from the runs behind floors.tsv, no new job: the harness of 4cc7963005, 4
runs of `harness --runtime old` per leg (8 on the XTX), jobs m3-max-45422 (1002:15bf), 45430
(1002:1900), 45423 (1002:699f), 45546 (1002:744c), 45425 (10de:1e87), 45426 (10de:2204), 45437
(8086:3e9b) and 45427 (8086:a7a0). Its header notes that the UHD 630's texture_read (1.075) and
the Iris Xe's wide_bindings (1.097) are those GPUs' floors, not reds.
Verified: the matrix's Python tests (42, 4 new: a row with a GPU time judged on it and a frame or
burst row on its time, the GPU floor and the re-timed GPU pairs, a card's variance named and
failing nothing, the re-time keeping both times), run locally; the harness runs' shell renders
and passes `bash -n` for a leg with limits.
A render pipeline state the runtime answers with a typed gap or the translator
refuses is skipped and counted, and nothing said which one or why: the replay
device test's draw was skipped on every device (legs 45244, 45245, 45246) with
skipped_render_states=1 and no reason. The backend now keeps the first such
state's object id and the runtime's answer, and its lines print
`skipped render states N, the first #ID: WHY`. The device test prints the
backend's lines after the player's.
REPLAY-STREAM.md names the line.
Verified: the next job builds the validation crate in every cfg and runs the
replay test on lavapipe.
The new runtime builds draws (its render encoder, render pipeline and
depth-stencil states), so the player's rt backend stops skipping render
encoders whole. It plays, on rt's API:
- newRenderPipelineStateWithDescriptor:error:, its constexpr samplers numbered
as a compute pipeline state's are (one helper, `numbered`, for both);
newDepthStencilStateWithDescriptor:; MTLRenderPassDescriptor.new and
.renderPassDescriptor with their m2v.setPass, m2v.setColorAttachment,
m2v.setDepthAttachment and m2v.setStencilAttachment setter records;
- renderCommandEncoderWithDescriptor: and the render encoder's calls the old
runtime's backend plays, with the vertex stage's textures and samplers, both
stages' bytes, cull mode, winding, blend color, and the draws' instance,
base-vertex and base-instance forms.
What rt does not build stays skipped and counted, honestly: a render pipeline
state rt answers with a typed gap or the translator refuses
(skipped_render_states); a parallel render encoder, or a render encoder of a
pass that holds what rt's descriptor does not (resolve textures, depth planes,
store action options, a visibility result buffer, layered or tile rendering, a
skipped texture) or that rt answers with a typed gap (skipped_encoders); and a
draw whose pipeline state, bound buffer or texture, or index buffer is a
skipped object (skipped_draws).
The render pipeline, depth-stencil and pass-key parsing moves from the old
backend's descriptors.rs to replay/translator.rs, shared by both backends, as
the sampler's is. docs/REPLAY-STREAM.md says what the rt backend plays and
counts.
Verified: lint of the validation crate (clippy in every cfg, the replay
tests, rustdoc); the device test that follows plays a draw on every device.
Planner ruling 11-18 (final): fixed-function vertex input for every attribute on every device,
the form native Vulkan uses and the fastest measured on every device, one form. Nothing of the
pulled form is taken on Device::from_queries' profile. Before this, the translator's
containment rule (contain::encoding is Check::InShader without buffer robustness) moved every
[[stage_in]] attribute into the shader, a form that reads through a descriptor the identity
domains refuse, so every rt render state with a vertex descriptor was refused as
Unsupported(IdentityDomains).
Translator (metal::vertex::fetch_as, pipeline::link::vertex::resolve), under the identity domains
only (lower::access::identity), so Device::new's profile and the old runtime are unchanged:
- the containment rule no longer moves an attribute: the device bounds the fetch as it bounds
any (no buffer robustness: a fetch outside its buffer reads what the device gives);
- an unnormalized signed-integer format (Char*, Short*, Int*) is fetched in fixed function into
a variable declared int, VertexFetch::SignedFixedFunction (new): Vulkan's numeric-type match
lets a SINT format feed only a signed variable, and the device sign-extends as Metal does. The
module reads the variable's bits by OpBitcast. Elsewhere such an attribute is still pulled and
sign-extended in the shader;
- every case that pulled is a typed refusal by what it needs, never a second fetch form.
Metal's vertex descriptor on the rt floor:
- Maps directly:
- formats: every Metal vertex format to the Vulkan format of its layout and conversion, by the
device's VERTEX_BUFFER format query. 8/16-bit integer formats read into float attributes go
through USCALED/SSCALED, signed integer formats into int variables, UChar4Normalized_BGRA is
B8G8R8A8_UNORM, the 10:10:10:2 formats are A2B10G10R10, and FloatRG11B10 is
B10G11R11_UFLOAT_PACK32. The validation crate's profiles of RADV (780M x2, RDNA3), ANV (Iris
Xe, UHD 770), NVIDIA (Pascal, RTX 50) and lavapipe report VERTEX_BUFFER for all of them but
FloatRGB9E5;
- steps: PerVertex is VERTEX rate; PerInstance at rate 1 is INSTANCE rate;
- offsets and strides: the descriptor's, baked into the VkPipeline.
- No fixed-function equivalent on the floor, so a typed refusal:
- PerInstance rate > 1 and Constant: Unsupported{VertexStepRate}, by query. They need
VK_KHR_vertex_attribute_divisor's vertexAttributeInstanceRateDivisor (plus ZeroDivisor for
Constant) and supportsNonZeroFirstInstance, which the floor does not enable, so it is
refused on every rt device today. Its needs name the missing feature, or the
maxVertexAttribDivisor limit;
- a format the device does not report for VERTEX_BUFFER: Unsupported{Format} with that format
usage, by query;
- FloatRGB9E5: Unsupported{Format}, not implemented, by need. Of the profiles above only
lavapipe's reports it, and its fetch answers 0 for the fourth component, where Metal and
Vulkan give 1;
- an offset or stride off the format's component alignment (Metal takes any byte multiple on
Apple5+), and an offset, stride, attribute count or layout count past
maxVertexInputAttributeOffset, maxVertexInputBindingStride, maxVertexInputAttributes or
maxVertexInputBindings: Unsupported{VertexInputLayout}, with the limit where one is passed;
- PerPatch and PerPatchControlPoint: Unsupported{Tessellation}, as before.
rt: RenderPipelineKind::StepRate is deleted: the translator's VertexStepRate refusal comes first
on every rt device, so no pipeline states a divisor. README: the vertex input bullets, their
refusals, and the known gap that a vertex fetch outside its buffer returns what the device gives.
docs/API.md: the identity domains' vertex input. REFUSALS.md regenerated, with reach marks for the
two new features (VertexStepRate app, VertexInputLayout rare); api_signatures blessed.
Tests:
- engine_identity_render from_queries_fetches_every_attribute_in_fixed_function (lavapipe and
moltenvk-m3 profiles with buffer robustness and the divisor withheld): ima_vertex's float2
and short attributes are R32G32_SFLOAT and R16_SINT, nothing pulled, L3-valid; a rate-2 layout
is VertexStepRate needing vertexAttributeInstanceRateDivisor. It fails without this commit (the
attributes were pulled, then refused as IdentityDomains);
- rt draw every_device_fetches_a_signed_attribute_in_fixed_function: a short of -2 reaches the
fragment's uint output as 0xFFFFFFFE on every texel; a rate-2 layout is refused as
VertexStepRate. The existing stage-in test (vertex buffer and set_vertex_bytes) now makes its
pipeline.
Verified: the next lint job and the device legs on every device.
Identity's Refusal::BufferOffsetAlignment (89bf650d2e) checked dispatches alone; a draw rounded the
address down to the argument's alignment (`address & !mask`) and drew from another place. The
draw now applies the same check to each buffer its vertex and fragment functions reach
(FieldValue::BufferAddress's mask, from RuntimeFact::AddressAlignment), after its other checks and
before anything is recorded, and pushes the address unrounded. The check is one function,
encoder::check_alignment(slot, mask, buffer, offset), which the compute encoder's
check_alignments loops over and the draw calls too; the refusal's doc names draws.
Test: every_device_refuses_a_draw_whose_buffer_is_off_its_alignment binds colored_vertex's float2
positions at 20 (alignment 8) and its float4 colours at 24 (alignment 16): each draw is refused
with the slot, offset and alignment; the buffers bound at 16 then draw the top half green, and the
pass is one submission, three barriers and one pass. REFUSALS.md regenerated.
A render encoder now draws. It holds Metal's render state (a pipeline state, the
vertex and fragment functions' buffers, bytes, textures and sampler states, one
viewport and scissor rectangle, cull mode, winding, a depth-stencil state, the
stencil references and the blend color) and records draw_primitives and
draw_indexed_primitives as one vkCmdDraw or vkCmdDrawIndexed each, setting the
dynamic state that changed and pushing each function's fields in the one push
range. Draws take no barrier, as Metal orders none within an encoder.
- render: a content's Draws (slots with accesses, push fields, vertex bindings),
derived from the translator's interface; a state numbers its functions'
samplers through the compute path's numbering (number_samplers), so
new_render_pipeline_state takes sampler_ids, and RenderPipelineKind::Samplers
goes; DrawInput refuses what a draw does not supply. Vertex strides are baked
(the descriptor key holds them): VERTEX_INPUT_BINDING_STRIDE leaves the dynamic
states, so a per-bind stride is refused by DynamicState. The line class's
pipeline is made at its first draw, a first-use wait.
- pass: both store actions store, so a pass can end its rendering early (a memory
barrier after a draw that wrote memory, or a copy a draw needs first) and begin
it again with LOAD; Pass::begin serves both.
- PUSH_STAGES: one constant for the layout's push range and every push.
- Device::new_depth_stencil_state; IndexBuffer, Viewport, ScissorRect; Refusal
VertexBufferOffset, IndexBufferOffset, ViewportNotFinite, StencilAttachment;
Gap::Draw with DrawKind (Points, DepthTest, Viewport, AttachmentFormats,
AttachmentRead).
- ring: a write answers its block buffer and offset, so set_vertex_bytes feeds
fixed-function vertex input.
- harness: one sampler_ids for compute and render states.
The census of the gb and b2 render contents (m3-max-44704) set the scope: every
translated content reads only SlotGuestBase and ConstexprSampler fields, facts
AddressAlignment, DeviceAddresses and MovableStorageWrites, no parameter block,
writes no memory; 146 of 267 number samplers; 93 have one vertex binding.
Tests: host tests for the viewport mapping; device tests for triangles where
Metal's clip space puts them (direct, indexed through a scissor, through a
viewport; 3 barriers, no pipeline made, no bytes copied), the line pipeline made
once, stencil replace and test, a constexpr sampler sampling each texel,
stage_in from a buffer and from bytes, and the refusals and gaps. Not yet run.
The UHD leg of matrix e060958855 lost its Windows build twice to memory:
45442 at 3 GiB (137), then the retry 45471 at 6 GiB (rustc-LLVM out of
memory, 137), and the leg failed with no tests run. The sizing took the
last three runs' peaks, incremental builds in a kept workspace that peak
far below a build of most of the tree, and a job short of RAM ran once more
only, at twice its room.
Now a job's RAM is 1.3x the largest peak of the last three runs that
started in a fresh workspace (each run records whether it did), else the
kind's default; minutes still follow the last three runs of either form.
A job short of RAM runs again with twice its room until it reaches the
kind's default (16 GiB for winbuild).
Verified: scripts/matrix tests, 39 OK, run locally. The new test_matrix.py
fails on the old code (it sized from incremental peaks and retried once:
dispatches 4 and 8 GiB, not 4, 8 and 16).
scripts/matrix/floors.tsv held floors seeded from old-runtime runs under the nearest-rank
statistic, some of them the old runtime's paired completions read as a fast run (alu 22.066 on
the 780M leg, 19.640 on the Iris). Measured again with the harness of 4cc7963005 (a row's time the
lowest mean of its windows of 10 timed runs, an untimed run after each gauge read): 4 runs of
`harness --runtime old` per leg, A B B A, each its own process on a fresh driver shader cache and
store, a sized row at the first run's size; a row's floor is the largest of its 4 times over the
smallest. Legs: 1002:15bf (gem10's 780M, m3-max-45422), 1002:699f (m3-max-45423), 1002:744c
(m3-max-45424), 10de:1e87 (m3-max-45425), 10de:2204 (um870's 3090, m3-max-45426), 8086:3e9b
(m3-max-45437) and 8086:a7a0 (m3-max-45427). 1002:1900 (um870's 780M) is not measured yet; a leg
the file does not list keeps a floor of 1. The seed's 1002:15bf column came from runs on
1002:1900.
With the table measured, the seeded-floor naming goes: SEEDED_FLOOR_OPEN, seeded_floor() and their
uses in harness_budget, its test, and VALIDATION.md's sentence on the seed.
Verified: the matrix's Python tests in the check job named in the report.
The matrix at cbd4644463 failed long_4cb's blocks gauge on the XTX, 2080
and 3090 (9 at iteration 100, 8 at 200). The cause, from the quiet probe
(each idle free logs the time since the last commit): the pool frees an
allocation an earlier workload left idle once the most bytes in use over
its window falls and the device has been quiet for 20 ms, and long_4cb is
the first row after the earlier rows' peak whose runs leave 20 ms gaps
between submissions. On the RTX 5080 (b5080 entry quiet5080, q10
0c0e50688a / q3 6b8cd2b793, 2 runs each) the 10 s window freed a 16 and
two 64 MiB allocations 6.5 and 7.5 s into long_4cb (11 -> 8), the 3 s
window the two 64 MiB ones 0.53 s in (8 -> 8); every free in every run on
the 5080, XTX (m3-max-45392) and 2080 (m3-max-45391) began 20.0 to 52 ms
after the last commit, so the quiet clock saw every commit.
Per the planner's ruling, the pool's gauges (blocks) now fail only if
they rise between @100 and @200; @drop still has to be 0, and every other
gauge stays flat. Verified: scripts/matrix tests, 37 OK, run locally; the
new test fails without the change (a fall of blocks is a problem there).
The commit before this one (1f41099948) shows each row's GPU p50
(store2's harness-gpu-<runtime>/<row> records, parked) beside its time
in the budget's lines and in a list of every row that run and show print
under each leg, and names a row that passes only on a seeded floor over
1.10. Its tests (36 OK at that commit) pin the line formats.
The new runtime's backend skips render pipeline and depth-stencil states, so nothing in its play reads their IDs; b3's play counted 8,082 of them as differing. It now counts them (skipped_resource_ids) and command-replay leaves them out of differing_ids, as it leaves the compute pipeline states' typed gap. The id lines stay.
The planner's timing rule for the matrix's harness legs:
- The harness takes `--skip NAME,...`, and a name ending in `*` in `--only` or `--skip` names
every workload it starts. A name that names no workload is an error.
- Each runtime's harness run skips the creation rows (`--skip 'create_*'`); they then run alone
(`--only 'create_*'`) in five processes per runtime, each with a fresh driver cache and store,
so no row before them moves their times. The first process's records are kept whole, its
device's gauges at drop renamed to harness-<runtime>/creates/device/... so every key is
recorded once; the later processes keep only the creation rows' first samples, as
harness-first/<row>/<n>/<runtime> (parked records).
- A creation row's first sample (/first, /first_take, /next_take, /first_allocation_total) is
judged by the ratio of the medians of its five processes; a single first sample is never red.
- A row's limit is 1.03 times the greater of its ceiling and its floor: the widest ratio between
two of the old runtime's own runs of the row on that GPU (scripts/matrix/floors.tsv, seeded
from store2's noise table's "widest" column; 1002:1900 has no column there, so its floors are
1). Ceilings are unchanged.
- A row past its limit is re-timed once, A B B A (two pairs), and fails only if the median of
the pairs' ratios is past the limit too.
Deterministic counts are untouched. docs/VALIDATION.md describes the new runs and rule.
Verified: scripts/matrix/test_results.py, 33 tests OK locally (new: a row within its floor
passes, past it but back within on its re-time passes, past both fails; first samples by the
median of five, never one alone; the creation processes' sed programs record each key once; the
floors table reads). The generated harness_runs shell passes bash -n for a Linux and the Windows
leg. The harness's selection tests and lint run in the check job.
Whether rt must capture a Managed texture's bytes at replaceRegion (rather than when the GPU copy
is next used) turns on how often a program writes one while a command buffer that used it may
still be running. The report now says.
- The player keeps, from the stream alone (replay/texwrites.rs): the textures and each view's
texture; each encoder's command buffer; the textures each command buffer used (an encoder call
naming the texture or a view of it, or an encoder made with an MTL...Descriptor object, or one
made on such an object, that names one); each texture's latest committed user per queue; and the
completions the stream records, which are only the program's CPU waits (waitUntilCompleted of a
command buffer or a later one of its queue, waitUntilSignaledValue:timeoutMS: reaching a value
one of its queue's command buffers signals). The play itself waits at each commit, so this is the
recording's order, not the play's.
- At each call on a texture that carries bytes (replaceRegion:...), blobs resolved, it asks the
backend whether the texture is Managed (Backend::managed_texture, default None; the rt backend
answers from the texture's descriptor) and counts the write, and where a committed user has no
recorded completion, counts it by the presents since that user's commit (0, 1, 2, 3+) and names
the first eight.
- Report::texture_writes (TextureWrites) carries the counts and the report's texture_writes line
says them, with the writes into textures whose storage the backend does not tell.
REPLAY-STREAM.md section 10 documents the line.
Verified: a replay test (Kept backend) writes a Managed texture used through a view by a committed
command buffer, before and after a present, writes a texture that is not Managed, and writes again
after the CPU waited: 3 writes, 2 with the user not seen complete (one per present bucket), the
first two named; clippy and the plays in the check job.
Metal's useHeap: names a heap the encoder's work may reach. rt had no such call, so the player
skipped and counted each one. ComputeCommandEncoder::use_heap takes the heap's block number (a
HeapRange's block, or the block a placement heap's buffers sit in) and keeps that block in the
command buffer until it retires, exactly as use_resource keeps a buffer's block (keep and the new
keep_block share one list). Metal states no retention for useHeap:, so keeping is the safe
reading. The call declares no access: a kernel that reaches a heap's resources through addresses
outside its slots already orders against every write since the last barrier. A number no handle
names answers Error::NoSuchBlock, as new_buffer's does.
The player's compute encoders now call use_heap with the heap's block, and still skip and count
a useHeap: of a skipped object. REPLAY-STREAM.md's skip list and the rt README say so.
Test: heap::every_device_holds_a_used_heap_until_its_command_buffer_retires takes a Private
block, uses it twice in one encoder (the command buffer holds it once), releases it while the
encoder is open (the command buffer still holds it, and a new use of its number answers
NoSuchBlock), commits, and waits for the block's last holder to go once the command buffer
retires. api_signatures.tsv regenerated (one new method); REFUSALS.md unchanged.
A play that hangs (gb's fault at frame 1095, b2's at 312) wrote no report: report.txt got its frame
and end lines only at the play's end, so every hung play left 0 frames in its timing table, and the
cold and warm plays of the frames before each fault could not be read.
- Player::until_frame(F) stops after frame F's present (frames counted from 0 as Report::frames
counts them), completes the work committed so far and reports as at the stream's end;
command-replay's --until-frame F sets it and says `until-frame F`.
- Player::with_frame_lines(out) writes each frame's lines (Report::frame_lines: its frame and end
lines) to out as the frame ends, flushed; command-replay passes its open report.txt and writes
the rest at the end (Report::lines_but_frames). Report::lines keeps every line, the completed
groups' first.
- The rt backend's report gets an `unwritten N` line: the Shared buffers made without bytes that a
compute encoder bound or used and whose command buffer committed before any recorded write,
upload or GPU pass reached their bytes since their making, with the first few named and the
command buffer that read each. It is where a recording that missed the program's writes shows
(b2's uniform ring #58725 had no recorded byte in its life). What reaches a buffer: an m2v.write
into it, into its block over it or into another buffer of the block over it; a blit or render
encoder call naming it or such a buffer (skipped encoders included); the commit of a dispatch
binding it. It counts and stops nothing (new_runtime/unwritten.rs, hooks in the make paths,
write, release, the encoder calls and the commit).
REPLAY-STREAM.md section 10 documents --until-frame, the per-frame lines and the unwritten line.
Verified: replay tests for the frame stop and the per-frame lines (Kept backend) and for the
unwritten count (the tracker alone: block writes, a blit naming, a write before the commit, a
release, a later commit, an alias made later); clippy and the device plays in the check job.
Record mode (job m3-max-44847 at 09c51a35ef, an Apple M3 Max, macOS 27.0.1) took the case's two
Metal facts:
- Plain Metal ran the pass: every step answered Ok, and the command buffer is Completed with no
error, over 3 runs folded into one outcome.
- Metal's API validation stopped it at the pass: "Compute Function(vwp_words): the offset into the
buffer src that is bound at Buffer index 0 must be a multiple of 4 but was set to 2.", and the
same for dst at index 1.
docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py): 167 case
modules, 1,282 recordings.
Verified: the recording's facts as listed (read from the file); coverage.py --check passes.
The planner ruled that the bind-offset mask becomes a typed refusal. The binder pushed a bound
buffer's address, its gpuAddress plus the offset, rounded down to the alignment the kernel takes
it to have (FieldValue::BufferAddress's mask, from RuntimeFact::AddressAlignment), where Metal's
API validation refuses the bind offset ("must be a multiple of 4 but was set to 2" for a uint *
argument, probe vector_access_placement.m in the conformance crate). Plain Metal runs such a
dispatch at addresses of its own: an M3 Max reaches each element at its address rounded down to
the smaller of its alignment and 4. That is not the rounding the binder did for 8- and 16-byte
arguments.
The dispatch now refuses it with Refusal::BufferOffsetAlignment { index, offset, alignment }
before it records or keeps anything. check_alignment runs after the threadgroup size check and
before a kernel without effects returns, so both direct and indirect dispatches take it.
fill_parameters pushes each address as it is. A set_bytes copy sits at a multiple of 16 in the
ring, which every mask divides, so it is never refused.
Docs:
- docs/API.md: the identity-domain paragraph and the section 10 entry (renamed: "A dispatch that
reaches a buffer bound off its argument's alignment is refused"); no case names its slug.
- RuntimeFact::AddressAlignment's doc and the mechanism comment.
- The rt README paragraph and FieldValue::BufferAddress's doc.
- docs/REFUSALS.md regenerated (44 rt refusals); api_signatures.tsv gains the variant's row.
Tests (device, under --cfg m2v_gpu or m2v_cpu_icd):
- every_device_refuses_a_bound_address_off_its_alignment (was ..._rounds_a_bound_address_down_...):
at alignments 2, 4, 8 and 16, each of 17 binds 1 to 15 bytes past a multiple of 16 that the
alignment does not divide is refused and leaves the buffer unchanged, and the same buffer bound
at 48 runs. Without the check every one of the 17 dispatches returns Ok.
- an_argument_bound_off_its_alignment_is_refused (was ..._runs_at_the_address_rounded_down):
the translated vector_word_phases kernels with one argument off its alignment are refused,
naming the index, offset and alignment, and the command buffer completes with every buffer
unchanged.
The pool handed a take of up to a block length a whole pooled block and kept one ready block per
class, which the block-maker thread made again as soon as a take used it. A 16-byte Shared buffer
took the ready block, and the 16 MiB allocation that followed held the consumer's next pipeline
creation for its whole length on NVIDIA's driver.
Now each block is a range of one of its class's allocations, with its own VkBuffer:
- A take is a kept block of its length, else the first free range that fits, else the start of an
allocation made in the call: 16 MiB, or the block's own length where that is longer. Lengths
round up to 64 KiB (or bufferImageGranularity); a block starts at its length rounded up to a
power of two, up to 2 MiB.
- Device::new makes one 16 MiB allocation per class. After that, the block-maker thread makes
another only while the class's free bytes are under 8 MiB. A take never waits on it for memory.
- A take that no free range fits, while the class keeps blocks of other lengths, allocates at once.
It also asks the block-maker thread to give those blocks' bytes back, after the consumer's hook.
Only when its own allocation fails does it wait for those bytes, then look for a free range once
more.
- An allocation holding no live block is idle. A class keeps its idle allocations while their
bytes plus those of its allocations in use stay at or under the most bytes it had in use over the
last 10 seconds, and within an eighth of its memory type's heap. Past that it frees the oldest,
except the reserve that keeps 8 MiB free. The rule runs at takes and give-backs on an injectable
clock; there is no timer.
- Removed: the dedicated path, fits-and-fills-half, the 256 and 128 MiB idle bounds and the 64 MiB
Private block.
- Metrics: blocks_reused replaces dedicated_blocks_reused. New metrics: block_bytes_made, and the
vkAllocateMemory time on the consumer's threads (count, total, longest) apart from the
block-maker thread's.
Tests:
- Unit: rounding, base alignment, and the window and surplus rule.
- On device:
- the first allocations, and the trigger at 8 MiB free;
- kept blocks taken again with their number, address and mapping;
- an allocation beside kept blocks of other lengths, with their bytes given back;
- the failed-allocation path, at an answered maxMemoryAllocationCount;
- idle allocations following the window down, the reserve kept;
- a seeded 300-step stress of mixed takes and releases across both classes, each step under a
one-minute timeout.
- Tests that took a block of 1 byte and used more of it now take what they use.
- The replay's rt counters read the new metrics.
Verified: cargo fmt; api_signatures blessed; REFUSALS.md regenerated. Clippy, the suites and the
device legs follow as potluck jobs.
How a Managed buffer behaves depends on the recording device's hasUnifiedMemory: one copy where
it is true (a CPU write needs no didModifyRange), a GPU copy made at the buffer's making and
changed only by didModifyRange where it is false. The stream did not say which, and the rt backend
always made the runtime's Managed buffer: gb, recorded on a discrete GPU, wrote its no-copy
Managed buffers (#368205, #368202, #368214) once before first use with no didModifyRange, so their
GPU copies never got the bytes; b2, recorded with unified memory, relies on such writes legitimately.
The player now takes the form from the stream's new m2v.deviceIdentity record (it plays as nothing
and tells the backend hasUnifiedMemory through Backend::recorded_unified_memory), or for a stream
without one from command-replay's --managed one-copy|two-copy. One copy: every Managed buffer plays
as a Shared one. Two copies: the runtime's Managed buffer, its GPU copy from the bytes it was made
with: a copied buffer's, or the new create-time bytes a no-copy one's making now carries
(newBufferWithBytesNoCopy's first argument, a no-copy descriptor's contents). A stream with no
identity record gives none, so a no-copy buffer's GPU copy takes the writes recorded before its
first use (the commit of a command buffer whose encoder names it). With neither the record nor the
setting a Managed buffer stops the play with an error saying so. The report's managed line names
the form and its source, counts the Managed buffers and the no-copy ones with contents from first
use, not from create, and notes a two-copy recording played on a unified-memory device.
REPLAY-STREAM.md documents the identity record, the create-time bytes and the player's rule.
Verified: a replay test plays an identity record as nothing and sees the backend told
hasUnifiedMemory; the rt paths need a device play (gb on the 3090 next).
Rebasing the render encoder over 3201e09737 put both sides' Refusal
variants after HeapTexturePlace; the resolution kept both but dropped the
closing "}," of BufferCopyOverlap and the ")," of its Display arm, which the
two sides shared outside the conflict. The file did not parse
(signatures.py --check fell back to the translator's Limit). REFUSALS.md is
regenerated from the repaired file; signatures.py --check passes.
Verified: signatures.py --check rc=0 and refusal_surface.py locally; the
lint job compiles it.
CommandBuffer::render_command_encoder(&RenderPassDescriptor) is
renderCommandEncoderWithDescriptor:. It begins one vkCmdBeginRendering (dynamic
rendering, in the floor: floor.rs requires vulkan13.dynamicRendering) into the
pass's attachments, and end_encoding ends it with vkCmdEndRendering. Load and
store actions map one to one (Load/Clear/DontCare, Store/DontCare). A clear
color is a float in a float, normalized or sRGB channel (the device converts
it), and an integer channel's is truncated toward zero and saturated, NaN 0,
as Metal's; rotated formats and A8Unorm held in R8_UNORM go through the
format's rotation; a clear stencil keeps its low 8 bits. The render area is the
smallest attachment's level, cut to renderTargetWidth/Height where set.
Each attachment is one level and slice of a 2D texture, 2D array, cube or cube
array of one sample: the texture keeps an identity-swizzled image view of that
level and layer, made at the first pass and freed with the texture through the
reaper (new gauge attachment_views). A pass orders itself as a blit copy does,
two barriers: the first after every earlier command, moving shader-read-only
homes to the attachment layout (general and attachment homes render in place)
and paying an owed barrier; the second after the rendering, moving them home
and making the writes visible to every later command.
Refused as Metal's validation stops them: Refusal::AttachmentUsage,
AttachmentPlace, AttachmentFormat; past maxColorAttachments,
Limit::ColorAttachments. Not built, Gap::RenderPass naming RenderPassKind: a
depth attachment, more than one sample, a resolve, a 1D or 3D attachment, the
Unknown and CustomSampleDepthStore store actions, a clear of a format only a
shader clears, a pass with no attachment. The replay streams' passes (pass
census over gb and b2, counts only): one or two color attachments plus a
stencil in 11,187 of them, every attachment a level of a 2D texture of one
sample, no depth, no resolve, loads Load/Clear/DontCare, stores Store/DontCare.
Tests: tests::pass's host tests pin the action mapping and the clear values;
on_device clears a mip level of a shader-read texture (moved and back), an
integer texture and a stencil, loads and keeps, cuts the area, clears one
slice of a 2D array, and counts one pass alone as one submission, three
barriers, one pass and no bytes copied; each view is made once and freed with
its texture; refusals leave the command buffer open. README render encoder
section and known gaps; REFUSALS.md and api_signatures regenerated.
Verified: the lint job and the device legs are the check.
The planner's ruling makes the rule two lines. An image-only kernel that does not observe its
threadgroup partition is declared: 16x16x1 on a grid one deep, the grid's tile (grid_tile) on a
deeper one, at MultiRegion 0 with the extent test. Every other such kernel runs today's remap:
256-lane workgroups, each one tile the region carries. The fold no longer serves buffer-touching
kernels. Image-only kernels used it only where the grid's tile is past the device's
maxComputeWorkGroupSize, and that class is too small to keep a form for, so those dispatches take
the remap too.
The census (replay's job m3-max-44582, both recorded streams): image-only non-observer
dispatches whose tile is past a depth of 64 (NVIDIA's, the floor's limit) are 6 dispatches,
1,760 threads in each stream, one (spec, tile) pair of tile 1x1x256. That is 0.0004% of the
image-only non-observer threads in one stream and 0.0033% in the other. No tile is past a side of
1,024.
Deleted: SpecKey::FoldedTile and the select that took it in place of the region's tile
(lower::dispatch), its binder entry, codec tag, signature row and API guide sentence; rt's
Variant::fold, Constant::FoldedTile, Choice::fold and Last::fold. The cache versions stay at this
branch's single bump (SEMANTICS_VERSION 2171, ARTIFACT_FORMAT_VERSION 535, now for
KernelFacts::image_only and the edge test under MultiRegion 0 alone). An image-only kernel's
pipeline per tile stays: its workgroup is the tile, so a deeper grid's first dispatch at a tile
makes it, and waits once, as the square device test's two-deep dispatch checks.
Verified: cargo fmt; docs/REFUSALS.md regenerated (unchanged). The dispatch-choice tests pin a
tiling kernel's grids of every depth in the remap's tiles, and a 1,024-deep column in them past
a depth of 64. The translator's engine test runs the edge kernel at MultiRegion 0 in 16x16x1
workgroups and at the grid's tile.
Both recordings' guest-RAM copies (gb 106 before frame 1095, b2 14 before frame 312) land in
Private buffers, and the rt backend skipped them, so the bytes and addresses they carry never
reached the GPU. A buffer-to-buffer copy now plays as rt's copy_from_buffer_to_buffer. A copy from
the guest's RAM, the recording's plumbing, plays as its pieces' bytes in a Shared staging place of
the backend's own, then a buffer copy into the target in the same blit encoder, so the GPU's order
holds. A buffer copy takes whole 4-byte words at 4-byte offsets: a piece's edge bytes up to whole
words come from the target's mapping where it has one; a piece with such edges into a buffer
with none is skipped and counted. The staging place is given back at the command buffer's commit
and is free once it completes, so the staging stays bounded by the work in flight
(staged_guest_ram_bytes counts it). The player times these copies in a column of its own
(`upload`), the recording's share and not the runtime's.
The replay's rt backend skips buffer-to-buffer copies and the guest-RAM
copies that need one, so their destinations are never written on rt: the lead
suspect for gb's hang and b2's device loss on the 780M. This builds the copy.
One vkCmdCopyBuffer region between the bytes shaders reach (a Managed buffer's
device copy where the device keeps one), between a fill's two barriers: the
first after every earlier command (paying an owed barrier, hazard sets start
again), the second making the write visible to every later command; a copy
into a Shared buffer marks the segment so its end reaches the host. The
command buffer keeps both buffers until it retires; textures over either
device copy are settled as the other copies settle them. A size of 0 records
nothing.
Refused: another device's buffer (OtherDevice); a range past either buffer's
end (new Refusal::BufferCopyRange, Metal's validation); an offset or size not a
multiple of 4 (new Refusal::BufferCopyUnaligned, Metal's documented macOS
rule); a source and destination sharing bytes, one buffer's overlapping ranges
or two buffers overlapping in one block (new Refusal::BufferCopyOverlap:
vkCmdCopyBuffer forbids it, VUID-vkCmdCopyBuffer-pRegions-00117, and the
runtime does not emulate it).
Tests: a host test pins the checks (offsets in the device buffer, adjacent
buffers of one block, size 0 anywhere, each refusal); on_device copies between
two buffers of one block and within one buffer, the bytes checked and
everything around kept, one copy alone one submission, three barriers, one
pass and no bytes copied; a copy into a Managed buffer lands in the bytes
shaders reach, brought to the host by a synchronize. README blit section;
REFUSALS.md and api_signatures regenerated.
Verified: the lint job and the device legs are the check.
The rt backend skipped every texture over a buffer, every texture view and every IOSurface
texture, and with them each dispatch and blit that bound one: words in the program's memory
then named textures the play never made. Textures over a buffer now play as the runtime's
(Buffer::new_texture) and views as its views (Texture::new_texture_view). An IOSurface texture,
a tiled texture over a buffer, and a texture or view the runtime answers with a typed gap become
an ordinary texture of the same descriptor, counted as a substitution (the recording's artefact,
not the runtime's). optimizeContentsForGPUAccess plays as nothing; the blits still not built are
counted by kind: buffer copies, guest-RAM copies in and out, texture syncs and mipmaps.
The report's second line says how far relocation reached: words relocated, words left at 4
past 8, address arguments, writes into objects with no recorded range, and the objects whose ID
differs from the recording's, which now make the play an error.
The relocation tests assert the writes of no address are counted.
On Device::from_queries' profile (PushWindow::Floor) a vertex function's push window is [0, 256)
and a fragment function's [push_base, 256), where push_base (a new LoweringInputs field, keyed
only when set) is the vertex function's push end rounded up to 8
(CompiledFunction::fragment_push_base). compile_render_pipeline compiles the fragment from the
vertex it compiled; rt sets the base from the lowered vertex before lowering the fragment. Under
the identity domains a vertex or fragment function whose fields do not fit is refused,
Unsupported(IdentityDomains) with maxPushConstantsSize's limit, never spilled. Link refuses a
fragment whose fields start inside the vertex function's, InvalidDescriptor(PushBase). The fixed
windows of Device::new (vertex [0, 64), fragment [64, 128)) and a compute kernel's are unchanged;
a mesh pipeline's fragment keeps its start past the mesh window.
Why: the planner ruled the dense layout over the census of gb and b2 (job m3-max-44421, every
content's functions resolved at its creation): 267 and 259 translated pairs, at most 248 bytes,
none over 256; four fragment bases (8/16/24/40), and no fragment function meeting two, so the base
costs no extra lowering. A fixed 128/128 split loses 3 pairs in each stream; the old 64-byte
windows spilled 6 into a parameter block.
Tests: push.rs pins each kind's window on both profiles (a compute kernel's does not move with a
render base) and places a fragment from its base to the floor's end; engine_identity_render
compiles colored_vertex + sampled_fragment on from_queries with the fragment's fields at 16, and
refuses the fragment compiled apart at base 0 (PushBase) until it compiles under the vertex's base.
The floor already refuses a device under 256 bytes (tests::floor, maxPushConstantsSize 255 and 64).
Verified: cargo fmt; api_signatures blessed, REFUSALS.md regenerated. Lint and legs follow.
A spike frame's wall time needs a split by cause before two runtimes can be compared on it. The
player now times, on its own thread, each kind of work: reading and decoding the stream and its
blobs, writing bytes into the runtime's memory, reading back, waiting for command buffers, the
calls that make or release resources (with the longest one), the calls that make libraries,
functions and pipeline states (with the longest one), every other runtime call, and reading the
runtime's counters; what is left is the player's own work. Beside them, a frame's GPU busy time
is the union of the GPU intervals of the command buffers it waited for, which a new Backend
method gives: both runtimes' GPUStartTime and GPUEndTime. The end line carries them, and the old
runtime's counters add its vkCreate*Pipelines and shader-cache nanoseconds.
A test plays three command buffers, two of them overlapping on the GPU, and checks the frame's
GPU busy time counts the overlap once and the end line holds the times.
The old runtime's shader cache defaulted to the per-user ~/.cache/metal2vulkan, which every earlier
run on the node had filled, while the new runtime's harness device kept no store: create_state's
first state and the first-use rows timed old warm against rt cold (jobs 44170, 44171: old's first
on the 2080 2.9-3.2 ms on its warm cache, 8.9-9.7 ms on a fresh one).
- old::system_default and rt::system_default take the store (None: the runtime's default, for the
tests).
- The command takes --store DIRECTORY: each session keeps its pipelines in
<DIRECTORY>/<place>-<runtime>; without it, a directory made for the run under the OS temp
directory and removed when it ends. Each runtime's line and each create_state row say
"store fresh" or "store warm, N files".
- The matrix gives each runtime's main run a fresh empty store beside its fresh driver cache, and
its warm run the same store; a re-timed row's runs take the harness's own fresh store.
- VALIDATION.md and the harness docs say so.
Verified: the matrix's harness script, rendered and run against a stand-in harness, passes a fresh
--store to each runtime's main run (cygpath'd on Windows); the build, clippy and the authored tests
in the check job.
The planner's ruling on long_4cb's red: rt reports the command buffers committed while an earlier
one runs complete together, at the group's last end, which the owner accepted. The mean over a
run's places counted that lateness: on the 2080, long_4cb's #2-#4 came at 96.2-97.3 ms where the
old runtime's came at 71.7, 83.7 and 95.6 ms, while the last's own (96.6-97.2 against 95.6-95.8
ms) is not late (jobs 44196, 44197). The rule holds for every row of several command buffers, so
frame_5cb's too.
- run::matrix_time is the steady time of each run's last command buffer's commit-to-complete
time.
- The harness's completed handler is given its lateness, from the command buffer's GPUEndTime to
the handler's start on the runtime's host clock (rt::host_time, the old runtime's host_time);
Report::late_us holds it by place, and the table prints late_us_p50 and late_us_p99 beside the
c2c columns, with a line by place. It is no record: no ceiling until the first host-time matrix
shows it on every GPU.
- The rt README's queue known gaps carry the measured lateness; VALIDATION.md and the harness
docs say the last command buffer's time.
Verified: the matrix_time unit test asserts the last place's time where the mean differs; the
check job builds and runs it.
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.
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.
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.
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.
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.
- 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.
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.
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.
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).
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.
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).
Where the in-place linear image does not hold a texture over a Shared buffer (or a Managed one
without a device copy) for its pitch, place, memory type or format features, the texture is now
an optimal image of its own instead of a Gap::TextureOverBuffer. The device copies the buffer's
bytes into it and back, one vkCmdCopyBufferToImage or vkCmdCopyImageToBuffer region a texture,
with no CPU copy (crate::over):
- in, once a submission: the upload that leads it copies into every such texture a segment uses
before any command of the segment wrote the buffer; inside a segment, a use after a write of
the buffer copies in again first; a segment leaning on the leading copy for a buffer an earlier
segment of the held group wrote leads a new group;
- back, after a write of the texture: before the next command of the segment that reaches the
buffer, and at the segment's end, whose end barrier then reaches the host.
Commands track what they write only while such a texture lives (a device count); a command
recorded while none lived counts as a write through an unbound address, so a texture made later
never leans on a copy that could precede it. Each copy counts in Metrics::over_copies and its
bytes in bytes_copied. The accepted difference (a CPU write between two held members' commits
races an uncompleted command buffer, which Metal leaves undefined) is stated at the rule and in
the README.
A texture over a Managed buffer's device copy that the linear image does not take stays a
Gap::TextureOverBuffer: the Managed branch waits on the measurement of whether a Managed buffer
keeps a device side at all.
Tests: tests::copy_over (every device under the device cfgs): a render target over a Shared
buffer at one alignment past the device's pitch copies in once per command buffer and takes the
host's writes; a fill then a use in one command buffer copies once, after the fill; a fill and a
use in two command buffers committed back to back takes the filled bytes; a blit's write to the
texture is in the buffer once the command buffer completes.
A view of such a texture shares its parent's image and id, so it is tracked and copied as its
parent; the live count counts the parent alone. An ended segment keeps its tracking, cut to the
textures that lean on the leading copy, for the submit thread to read in place.