- golden_hashes.tsv re-blessed on the M3 at 64f96fa242 (job m3-max-65087): 30 rows moved, none added or
removed, and no row changed between compiled and not_supported. It takes the device profile's smaller
fingerprint (the 19 unread fields deleted in 99b915bfc6) and semantics 2263 -> 2264 (a structurizer
variable no later trip reads is ended at each trip's top, 2fbfafe0fe).
- authored-compile.tsv: artifact hashes only, no status word changed (same job).
- The old render descriptor key's pinned value is the one the test printed at 64f96fa242 (m3-max-65100).
What: spirv::carry's tick helper returns the meter's refusal through ? (the meter's error type is
the front end's), and the empty predecessor and loop lists are taken with unwrap_or_default rather
than a full-range slice.
Why: 2fbfafe0fe did not compile (job m3-max-64064 at the product build: mismatched types at the
tick's return).
Verified: the compile job on this commit.
What: spirv::carry::end_dead_carries, run in the stage bound after the uniform-load hoist (and in
pipeline::testing's typed module), stores an undefined value into a demoted value's or a phi's
Function variable at the top of the first block of each loop whose body holds every whole store of
the variable, where the variable is live into that block and the block does not read it before a
store. P8 marks those variables LocalVar::trip_local, only in a walk that is not predicated: the
predicated walk runs a loop's later trips for an invocation that left it, which reads the value of
its own last trip after the loop. The new field rides through roll's renumbering with its variable;
roll's own variables are unmarked. Terminator::for_each_target is the read-only twin of
for_each_target_mut. cache::SEMANTICS_VERSION 2263 to 2264. docs/ARCHITECTURE.md names the pass.
Why: the exit dispatches and pending guards P5 to P7 add give paths from a back edge to a read of
such a variable that pass no store of it. No execution takes them, but the driver keeps the
variable around the back edge as a phi live through the whole loop. In the source the value's
definition dominates each use and the loop's header dominates the definition, so no trip reads the
value an earlier trip left; the store ends it at each trip's top and the driver keeps nothing of it.
Jobs m3-max-65023 (780M and RTX 3090) and m3-max-65024 (Iris Xe) timed the same form, written by a
probe after roll and hoist, cold through the runtime's helper against development, arms alternating
in one job: helper peak and CPU time fell on all three cards.
Tests: tests::engine_trip_carries runs a loop with three exits, the second reading a value its trip
defined, on six profiles: a value is ended at a trip's top, carry::dead_carries finds no variable
left that no later trip reads but the module keeps around a back edge, the module passes spirv-val,
and the interpreter gives the source's words. tests::engine_divergent_barriers adds a vote loop
whose early leavers read their last trip's value after it (loop_leaver_k), run predicated on six
profiles under Vulkan's barrier rule. The compile job, the two tests' red runs without the form and
without the predicated rule, and the states-only plays run on this commit.
A device test that returns early (the draw test, where llvm-as is missing) passes without
running; the printed line is the evidence the compile job's --no-capture run reads.
Refusal::IndirectOffset covered two cases under one `ours` basis. Metal's headers document
the first: "indirectBufferOffset must be a multiple of 4" (MTLComputeCommandEncoder.h for
dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:,
MTLRenderCommandEncoder.h for the indirect drawPrimitives and drawIndexedPrimitives; Apple's
page for the indirect drawPatches sends its offset to the feature set tables, whose minimum
constant buffer offset alignment is 4 bytes). The headers state no rule for the second,
arguments that run past the buffer's end, which is the runtime's own check because Vulkan's
indirect commands read inside the buffer (VUID-vkCmdDispatchIndirect-offset-00407,
VUID-vkCmdDrawIndirect-drawCount-00487, VUID-vkCmdDrawIndexedIndirect-drawCount-00539).
- IndirectOffset { offset, length } is now the offset-off-4 case alone, Basis:
metal-documented.
- New IndirectArgumentsPastEnd { offset, length, needed }, Basis: ours, for arguments at a
multiple of 4 with fewer than `needed` bytes (12 dispatch, 16 draw, 20 indexed draw) after
the offset, or an end that overflows.
- Both raise sites (the indirect dispatch, and the indirect draws' shared check) test the
alignment first, then the length.
- Regenerated docs/REFUSALS.md and error/basis.rs (refusal_surface.py), and
api_signatures.tsv (one variant added). The runtime README's indirect-draw paragraph
names both refusals.
Tests: every_device_refuses_an_indirect_dispatch_off_4_or_past_the_buffer_s_end (compute)
and every_device_refuses_an_indirect_draw_off_4_or_past_the_buffer_s_end (draw) assert each
variant and its basis(): off 4 at 2 and at an offset that is also past the end (alignment
first), past the end at a multiple of 4 and at an overflowing offset, an indexed draw's 20
bytes where a plain draw's 16 fit; then the arguments in each buffer's last bytes dispatch or
draw and their results are read back. The compute refusal test's two IndirectOffset asserts
moved into the dispatch test.
Checked here: refusal_surface.py --check and signatures.py --check pass (source only).
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The first commit of this branch drops 19 device-profile fields that nothing
reads. The render descriptor key hashes the profile's fingerprint, so the key
pinned for moltenvk-m3 moves:
- the pin development holds (8ca94bca19, SEMANTICS 2263): ac15f365...
- with the smaller profile: d4257e6b...
The test's first assert pins the fixture's bytes, and it held, so neither the
fixture nor any lowering changed.
Verified: m3-max-64928 (msi-laptop) printed d4257e6b... as the key at
1fb65bf3ef, this commit's parent.
The previous commit taught the committed-profile form of the profile test to
exempt the README's "Enabled, not stated" features. The device form, under
--cfg m2v_gpu or m2v_cpu_icd, kept its own copy of the check, which read only
the "Not enabled" table. On the RTX 3090 (m3-max-64890), the Radeon 780M
(m3-max-64892) and the Iris Xe (m3-max-64891) it still failed on maintenance5,
which those devices report and which creation withholds there or never
states.
Both forms now call one check, all_recorded.
On the RTX 3090 (m3-max-64885), the Radeon 780M (m3-max-64887) and the Iris Xe
(m3-max-64886), the device form of the profile test found that maintenance5
changes the translator's profile and that creation withholds it.
That is now true wherever its rule holds: the previous commit stopped telling
the translator of maintenance5 even where indirect command buffers enable it.
The README's "Enabled, not stated" table records it, so the test exempts what
that table lists as well as what the "Not enabled" table records. The
committed profiles never met this, because they do not hold the feature as one
creation withholds.
The per-card runs are next to verify.
Two commits back, the translator's description began to state maintenance5 and
VK_KHR_maintenance5 wherever device creation enabled them. Creation enables
them only on a device that offers indirect command buffers.
The translator holds A8Unorm in A8_UNORM where its profile has
VK_KHR_maintenance5, and in R8_UNORM read as (0, 0, 0, r) otherwise. So
stating them made A8Unorm take a second form, chosen by the indirect-command
query, which is outside the nine query-chosen forms. On lavapipe, which offers
indirect command buffers, two device tests failed:
- tests::texture_buffers ... every_device_refuses_what_metal_refuses_of_a_texture_buffer:
A8Unorm texel buffers were no longer refused;
- tests::view ... every_device_samples_an_a8_view_of_an_r8_texture: the A8 view
was refused.
Both failed in m3-max-64830.
Changes:
- The INDIRECT_COMMAND_FEATURES entry for maintenance5 carries no translator
name again, and shader_extension no longer maps VK_KHR_maintenance5.
- The README gets an "Enabled, not stated" table listing both, with the reason.
- tests::feature_enables reads that table. An item creation enables that the
translator names must reach the description unless the table lists it. Each
row must be an item creation enables, that the translator names, and that
the description does not state.
The README's sentence on borders and A8Unorm ("where indirect command buffers
enable VK_KHR_maintenance5, that changes nothing here") holds again.
New test module tests::feature_enables, with three tests and a fourth under
--cfg m2v_gpu or m2v_cpu_icd:
- Every feature in the tables device creation enables (floor::ENABLED) that
the translator's vocabulary names (VkFeature, by its Vulkan member) carries
that name in its table entry, so shader_enables states it.
- Every extension creation may enable that the translator names maps through
shader_extension.
- Not-enabled features, on the committed profiles:
- For each committed device profile, and the floor's, the test derives the
translator's profile with each feature the device reports that creation
does not enable, and checks whether that profile differs from the one
derived from what is enabled.
- Any such feature must appear in the README's new "Not enabled" table.
- Every feature in that table must stay un-enabled.
- Every feature in that table must be read where some profile reports it.
- The device test does the same check on each device of the cfg's kind.
The exemptions come only from the README table, which records each feature
with the form or the typed refusal a program meets without it. The test keeps
no list of its own.
The table holds:
- the five features held to one form on every device: native float atomic add,
exact fma, 8-bit floats, raster-order attachment access, robustBufferAccess;
- vertexAttributeInstanceRateZeroDivisor;
- the typed refusals ImageAtomics, StorageImageMultisample, ComputeDerivatives
and RasterOrderGroups (the per-sample interlock: taking it where a device has
it would be a second form chosen by a query, outside the nine);
- the storage-buffer update-after-bind and non-uniform indexing pair, which the
translator's function table never needs (the runtime supplies none).
floor.rs: shader_extension becomes pub(crate) for the test; tests::floor's
at_the_floor and table become pub(super).
Verified (m3-max-64818, msi-laptop, release of this tree's content):
- feature_enables and tests::floor passed 38 of 38 at the profiles;
- the same passed 40 of 40 on lavapipe under --cfg m2v_cpu_icd.
Committed profiles checked: 15 (14 devices plus the floor). The device test
saw the same ten features on llvmpipe.
The previous commit gives the translator its names for borderColorSwizzle,
borderColorSwizzleFromImage, VK_EXT_border_color_swizzle and
VK_EXT_custom_border_color. This test still asserted that the translator is
never told of them, so it failed on the commit that made it tell.
It now asserts that the description states each of those features and
extensions exactly where device creation enables it, and nothing else.
Verified: tests::floor passed in full (38 of 38) together with the
feature-enable test, both at the floor profile (m3-max-64818, msi-laptop) and
on lavapipe (40 of 40).
What: shader_enables, the enable set the translator's description of the device is restricted to
(DeviceDescription::with_enabled), now reads every table of features device creation enables
(floor::ENABLED: the floor, the portability subset, the optional features, the attachment
reads, step rates, min-LOD clamps, fill modes, quad control, the pixel interlock, barycentrics,
the border swizzle, linear attachments, fault reports, and the indirect commands' features, now a
table of their own, INDIRECT_COMMAND_FEATURES, which indirect_commands sets). Each entry the
translator names reaches it where creation enabled it. Entries that were enabled but unnamed now
carry the translator's name: depthBiasClamp, drawIndirectFirstInstance, bresenhamLines and
occlusionQueryPrecise (floor), attachmentFeedbackLoopLayout (the attachment reads),
borderColorSwizzle and borderColorSwizzleFromImage, and maintenance5 (indirect commands).
shader_extension names the extensions those need, and the others creation enables that the
translator names: VK_EXT_line_rasterization, VK_EXT_attachment_feedback_loop_layout,
VK_EXT_border_color_swizzle, VK_EXT_custom_border_color, VK_EXT_external_memory_host and
VK_KHR_maintenance5.
maintenance4 joins the floor (REQUIRED, the README's floor table, runtime-floor.json's
m2v_runtime_floor block and regen_device_profiles.py's RUNTIME_FLOOR): Vulkan 1.3 requires it
of every device, so no device at the floor lacks it. The translator's profile reads it for
spirv-val's --allow-localsizeid alone.
Why: the planner's feature-enable walk (lane texoff, 11-21) found these features enabled at
vkCreateDevice and absent from the translator's profile, the class maintenance8 was in before
38dcc857dd. None changes what the runtime does on its own paths: the runtime sets depth bias,
border colors and indirect draws itself, and the translator's readers of these features
(metal::state::depth_bias, the bind plan's indirect_first_instance_missing, metal::sampler's
opaque-black border) are not on them. The profile now states what the device has. Its fingerprint
moves on every device, and with it every cache key.
64-bit image atomics stay off, and the features the translator reads that the runtime does not
enable are the feature-enable test's (next commit).
Device::from_queries derived these profile fields from the description's features, and no code
consulted any of them: only the profile's fingerprint rendered them, so a device that listed one
moved every cache key and changed nothing a module holds. They go, with the feature reads that
filled them:
- LeafCaps (crate-private): uniform_buffer_8bit, push_constant_8bit, uniform_buffer_16bit,
push_constant_16bit, workgroup_explicit_layout, workgroup_explicit_layout_8bit,
workgroup_explicit_layout_16bit, buffer_float32_atomic_min_max, shared_float32_atomic_add,
shared_float32_atomic_min_max, image_float32_atomic_add, image_float32_atomic_min_max, fma16;
- ImageCaps (public): sampler_filter_minmax, compute_derivative_quads;
- DescriptorCaps (public): variable_descriptor_count;
- FragmentCaps (public): geometry_shader, cull_distance, dynamic_rendering_local_read.
The six public fields are removed from a published crate. The consumer's checkouts hold no use of
any of them: ~/Projects/steelbrain/reims-vgpu at 047a8d162d and clean-slate-reims-vgpu, 0 hits
for each of the six names (and for LeafCaps). This tree holds none outside derive.rs and
profile.rs. tests/api_signatures.tsv loses exactly their six records
(scripts/api-signatures/signatures.py --bless).
The features stay in the vocabulary (VkFeature): requirements name some of them, and a Khronos
profile or a queried device still lists them. Where the translator reads one of these features to
choose a form, it reads it elsewhere (float add: buffer_float32_atomic_add; fma: fma32), unchanged.
Why: the planner's feature-enable walk (lane texoff, 11-21) found every profile field the
translator derives from a feature, and these are the ones nothing reads (R4: delete). Under the
no-dead-code rule a field no code consults is deleted, and the feature-enable test compares the
profile a device's features derive, which an unread field would make differ for no reason.
The profile fingerprint changes on every device that lists one of these features; it is in every
cache key, so no stale artifact is taken. No module changes.
- golden_hashes.tsv re-blessed on the M3 at b20dc87d22 (job m3-max-64905): 1,851 rows moved and 2 added
(the two kernel_signed_remainders fixtures). No row changed between compiled and not_supported; only
hashes moved, under semantics 2259 -> 2263 (2260 kept routines, since removed; 2261 signed remainder and
funnel shift; 2262 arena slot; 2263 the kept routines removed).
- authored-compile.tsv: artifact hashes only; no status word changed (same job).
- The old render descriptor key's pinned value is the one the suite printed at b20dc87d22 (m3-max-64865).
- tests/air_input/kernel_signed_remainders.txt and the fixture's two inventory rows (all profiles ok) were
written by bless_engine_goldens under LLVM 21 and bless_engine_inventory on the M3 at 16d3037930 (job
m3-max-64853). Nothing else changed in either. They were missing since the fixture landed, and their absence
failed three tests.
What: spirv::outline (a repeated region of 500 or more instructions written once, as a kept
routine declared DontInline) is deleted with its tests, its call in the stage bound and in
pipeline::testing, its notes in weights.rs, ir::Function::kept, ModuleBuilder::kept_routine and the
serializer, docs/API.md and docs/ARCHITECTURE.md. roll's items and its spine take back their own
visibility and signature (the loop-body sequences only the outline search read). The
bounded-growth test's chain is all one group again: no pass now folds a repeated graph.
cache::SEMANTICS_VERSION 2262 to 2263. The sampling and texel routines stay kept routines,
DontInline as before.
Why: a regression on NVIDIA. Job m3-max-64837 (RTX 2080, 620.70.06, um790, exclusive) made k7
(610e4b3d of the Iris capture's library, weight 320,401) cold through the runtime's helper, arms
A db5fefc2ce (before the pass), B 71014cd7bc's product (the pass in), C 36ed0d15b2, alternated
A B C A B C. The helper's CPU time and peak resident set (VmHWM):
- A: 37.74 s, 1,749 MiB; 37.90 s, 1,750 MiB.
- B: 85.82 s, 2,040 MiB; 87.44 s, 2,041 MiB (10 kept routines; largest function 195,769
instructions against A's 336,129).
- C: 87.35 s, 2,049 MiB.
B is 2.3 times A's CPU and 16.6% more memory. The pass's only gain on file was synthetic (one
function called from 50 places, m3-max-64453). RADV and ANV cannot gain from it: Mesa 26.2.6
inlines every function before either backend sees the shader, RADV in radv_shader_spirv_to_nir
(src/amd/vulkan/radv_shader.c:574, nir_inline_functions) and ANV through the common runtime
(src/intel/vulkan/anv_device.c:792 sets the shader ops; src/vulkan/runtime/vk_pipeline.c:211 calls
vk_spirv_to_nir, whose src/vulkan/runtime/vk_nir.c:176 runs nir_inline_functions).
Verified: the compile job of this commit and a states-only play of nine streams against
development follow; the golden table and the render key are re-blessed at the pin.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The slot test's kernel wrote the arena in its entry block, so the body's first
block re-derived the slot in the block the entry hooks end in, and every later
block recalled that one: the test passed without the slot fix on the
derivation count and failed only on the push loads.
Its entry block now reaches no private memory; the arms of its branch and the
join do. As a kernel whose threadgroups may be partial, the hooks end past the
partial guard's construct, in a block other than the one the slot was asked
for in, so without the fix each arm and the join derive the slot again, as the
real arena kernels did (one derivation per block). The test asserts one
derivation per module on every identity profile that keeps the arena in device
memory.
The device-arena commits before this one change emitted modules: the
slot is made in the function's first block and placed as a pointer to
its words, a word is one access chain, and the tail guard reuses the
tail field's first load. Output changes under unchanged keys, so the
golden table is bless-due on development.
ArenaMem::ptr made each word's address from the slot's device address:
a shift, a widening, an add, an OpConvertUToPtr and an access chain, 5
instructions before the load or store (6 for a word at a run-time
index). EmitCx::arena_slot now places the slot once, in the function's
first block, as a PhysicalStorageBuffer pointer to a runtime array of
u32 (device_place, stride 4), and a word is the access chain to its
element: the same address, slot + 4 * word, still Aligned 4.
Test: tests/engine_device_arena.rs measures one access of each shape
as the entry-weight difference between a kernel making it once and
twice (as engine_access_size does). On every identity profile, before
-> after (m3-max-64710, 64737):
- word load at a run-time index: 16 -> 12
- word store at a run-time index: 15 -> 11
- float4 load at a run-time index: 39 -> 23
- word load at a constant index: 6 -> 3
The bounds are the after costs, so the before form fails them.
EmitCx::arena_slot remembered the slot where it was first asked for.
dispatch::emit_entry asks in the entry hooks, after the floor's tail
guard (push::emit_tail_guard) closed a construct, and the memo keeps an
entry only where it was made in the entry block, the block the hooks
end in or the open block's spine: a later hook construct leaves the
slot behind, and every block that reaches the arena derives it again
(24 instructions each). Lane ksizeread counted 2,965 such derivations
in the 780M library's 628,489-weight kernel.
- The slot is now made in the function's first block wherever it is
first asked for (FunctionBuilder::in_entry_block, remembered at
entry): its operands are the pushed arena address load_push_fields
loads there, the invocation's built-ins and constants.
- The entry block is recorded before the hooks run (begin_hooks), so a
hook after the tail guard's construct recalls the push fields the
first block loaded instead of loading them again.
- The tail guard reads the tail field from that same load where the
function reads the field from its member (EmitCx::derives names the
fields a function derives elsewhere); the tail word, and a derived
field, are still loaded by the guard.
Test: tests/engine_device_arena.rs, an owned kernel whose 7176-word
arena is reached in four blocks. On every identity profile, with the
default inputs and with partial_threadgroups, the slot is derived once
and each push member is loaded once. Without this change, on the same
kernel at 0429ff1bd4 (m3-max-64752), one member was loaded twice by
default and one three times with partial threadgroups; the slot was
derived once there, so the kernel does not reproduce the re-derivation
the 628,489 kernel shows.
A reader of a Managed buffer's device copy took, as it was encoded, the copy back of any texture
over it that any command buffer had written, submitted or not, and cleared the flag the write's
submission reads. On one queue Metal runs command buffers in commit order, whichever was encoded
first, so:
- W (writes the texture) encoded before R (reads the buffer), R committed first: R copied the
image back before W ran and cancelled W's copy back; a reader after both completed read the
old bytes.
- R encoded before W, W committed first: R took nothing as it was encoded and nothing took the
copy back at R's submission; R read the old bytes. The same held for R on another queue
committed once the guest saw W complete, or ordered behind W by an event.
Now a reader takes as it is encoded only the copies back owed by earlier writes of its own
command buffer (each segment's written textures carry whether their copy back is still owed).
Those owed by other command buffers' writes, set at the write's submission, are taken by the
upload that leads the reader's submission, as take_into and the capture's copy-in already do:
on the device's one VkQueue that is where the order is known. A segment that reaches a Managed
buffer a texture over which an earlier segment of its held group wrote, its copy back owed,
leads its own group, so the write is submitted first (the capture fix's split). Entry.fresh
goes. No copy is added; the same copies back move to where their order is known.
Tests: three arms of one device test (tests/managed.rs): W encoded first and R committed first;
R encoded first and W committed first; R on another queue encoded first and committed once W
completed. Before this change all three were red on the RTX 5080 where run (64770: arms one and
two; the third arm was added with the fix).
Two device tests on one queue: W copies a pattern into a texture over a Managed buffer in an image
of its own, R copies the whole buffer out; the one encoded later is committed first, then L reads
the buffer once both completed. R reads what the commit order leaves (the buffer's bytes where R
went first, W's pattern where W did) and L reads W's pattern. The line prints the form and the
copies R recorded as it was encoded.
Development's 2260 is the kept routines of repeated regions (9356f81e51), which landed first. The signed
remainder's own bump (64d9946757 on its branch, 2259 to 2260) is not replayed; this commit takes the next
number instead. A cached lowering made under 2260 may hold OpSRem or OpSMod, or the six-instruction funnel
shift, where this tree emits the defined remainder and the two-shift rotate.
The case signed-remainders was recorded without times, so the conformance suite's
times::every_case_is_timed::every_case_carries_its_timing failed on it (job m3-max-64669).
`conformance times --runs 8 --write signed-remainders` on the M3 Max (job m3-max-64714) took
Metal's per-call figures into the case's recording: seven calls (buffer, zeroed_buffer, library,
compute_pipeline, dispatch_threads, wait, read_buffer) over 8 rounds. The recorded answers are
unchanged; only the recording's times list is added.
llvm.fshl, llvm.fshr and air.rotate whose amount operand is an integer constant (const_int at
selection) take ArithStrategy::IntFnBy, with k = the amount modulo the width taken at
translation. math::funnel_by emits a (b for fshr) for k = 0, else (a << k) | (b >> (N - k)) left
and (a << (N - k)) | (b >> k) right (a rotate's b is a): three instructions, both shifts in
1..N-1, where the run-time form takes six (OpUMod of the amount, the shift by one, the OpISub
of N - 1 - s, two shifts and the or) so that no shift reaches the width, which SPIR-V leaves
undefined. A run-time amount keeps that form; a vector amount is not a constant here and keeps
it too. The strategy is named arith.int_fn.by_constant.
Why: ksizeread's count found every llvm.fshl in the heavy kernels to be a 32-bit scalar rotate
by a constant amount (8,546 in k7, 8,560 and 8,569 in the two heaviest, 4,273-8,569 in the other
780M kernels), and no llvm.fshr. Each loses three instructions and two constants' worth of work.
Tests: lower::arith::tests::funnel_shifts_by_a_constant_answer_their_definition runs
math::funnel_by for rotate, fshl and fshr at 8, 16, 32 and 64 bits for every amount in 0..2N
against int_ref (the run-time form's reference), over the width's edges and random values.
tests::engine_arith::a_funnel_shift_by_a_constant_shifts_by_constants compiles fshl(a, a, 13),
fshr(a, b, 37) and fshl(a, b, 32) on moltenvk-m3, runtime-floor and amd-rdna3-radv: no OpUMod
and no OpISub in the module (the run-time form holds both), and LLVM's answer on the
interpreter.
Under SEMANTICS_VERSION 2260 with the signed remainder: the same pin, no version of its own.
The case signed-remainders runs the owned fixture kernel_signed_remainders: each of 238 threads
reads a 64-bit dividend and divisor (17 dividends by 14 divisors: both signs, the most negative
long and int, low words that are the most negative short and char, values past 32 bits) and
writes eight words: the remainder of the low words as int, short and char, the 64-bit remainder's
two words, the exclusive-or of an int2 remainder's lanes, and the low word's remainders by 3 and
-8. Apple's compiler writes srem i32, i16, i64 and <2 x i32> by run-time divisors and srem i32 by
the constants 3 and 8 (x % -8 is x % 8). A remainder MSL leaves undefined (by zero, or of the
most negative value by -1) is never taken: the fixture writes 0xdeadbeef there. Every column
compares exactly.
It holds every device to Metal's answer where the translator's signed remainder (the commit
before last) replaced OpSRem, which Vulkan makes poison for a negative operand without
maintenance8.
Recorded on the M3 Max, macOS 27.0.1 (job m3-max-64656, which also compiled the fixture's
companions with scripts/regen-air-fixtures under Apple metal 32023.922 and LLVM 21; TOOLCHAIN
records the fixture's line). Metal's 1,904 recorded words equal C's truncating remainder for
every operand pair (checked from the recording against a reference written apart from the
fixture). docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py).
The counter of folded results in signed_remainder_kernels was named k, which shadowed the file's
fn k(name, body, want) at the call that builds each kernel (E0618 in job m3-max-64645's clippy).
It is now folds.
Vulkan makes OpSRem and OpSMod poison when either operand is negative unless the device enables
maintenance8 (the Vulkan spec, "Precision and Operation of SPIR-V Instructions"; maintenance8 is
optional, and the UHD 630's Windows driver does not list it). LLVM's srem and Metal's % are
defined for every sign but a zero divisor and the most negative value by -1, so a negative
operand gave a guest an undefined answer on such a device.
One form on every device, with no query: FunctionBuilder::signed_remainder takes the operands'
magnitudes (negated where negative, read unsigned, so the most negative value's is 2^(w-1)),
their OpUMod, negated where the dividend is negative; RemainderSign::Divisor then adds the
divisor where the remainder is not zero and the signs differ (OpSMod's sign). A scalar constant
operand's magnitude and sign are computed at translation. Scalars and vectors of every width;
a signed-typed operand is bitcast to the unsigned type for OpUMod and back. The IR's BinOp has
no SRem or SMod any more, so no lowering can emit either: arith's srem (lower/arith/ops.rs) and
the bicubic emulation's repeat and mirror wraps (lower/sampler/bicubic.rs) take the helper; the
wide (two-word) 64-bit path already divided magnitudes. The interpreter's SRem and SMod go with
the variants.
Size, before building (job m3-max-64604, a probe counting sites in every serialized module, no
GPU): every site in the app's two libraries is a 32-bit scalar srem, none an smod. k7 (436,848
function-body instructions) holds 54 and gains about 414 instructions (0.095%); the heaviest
kernels gain 0.07-0.12%. The only rows past 1% are modules of 257 to 787 instructions with one
to four sites.
Tests: tests::engine_arith::no_module_holds_a_signed_remainder_opcode (fails before this
change: every kernel's module holds OpSRem) over srem of i8, i16, i32, i64, <2 x i32> and
<2 x i64> by run-time and constant divisors of both signs, the most negative value among them,
on moltenvk-m3, runtime-floor and amd-rdna3-radv; the same kernels compute LLVM's srem on the
CPU interpreter in arith_kernels_validate_and_compute_on_every_profile. engine_bicubic's
reference test now requires no OpSMod or OpSRem in its modules. The serializer's family test
validates the form on each integer type with both signs; the interpreter's integer test reads
-7 rem 2 = -1 and -7 mod 2 = 1 through the helper.
SEMANTICS_VERSION 2259: srem and the bicubic wraps emit different words.
What: DeviceOptions::stage_memory_ceiling (bytes, default 0) is the memory ceiling the consumer
gives its stage helper. Device::record_stage_breach keeps it after a StageBreach::Memory entry's
byte (the entry grows from 58 to 66 bytes); at a make, a memory breach kept under a ceiling below
the device's is a miss, removed like any miss, so the make answers Error::StageUnfilled with its
request and the consumer's next fill (or a breach kept under the new ceiling) takes the entry's
place. At the breach's ceiling or below it refuses (Gap::StageSize) as before. A memory breach of
its byte alone reads as kept under 0. Time, Compile and CompileRequired breaches keep their one
byte and refuse under every ceiling; data entries are unchanged.
Why: a breach kept under the consumer's lower helper cap kept refusing the pipeline after the
consumer raised the cap, until the driver's version changed, so a host that gains memory stayed
refused for good. The ceiling is a fact about the consumer's helper that rt only stores with a
memory breach and compares at a make; no other path reads it. The entry form changes by a length
rule, with no version: WIRE_VERSION is in every stage key, and bumping it would drop every filled
entry.
Tests: a_memory_breach_holds_to_its_ceiling_and_is_a_miss_above_it (host): a memory breach kept at
A holds at 0, A-1 and A and is a removed miss at A+1; a fill replaces a breach of its key; a breach
of the byte alone holds at 0 and is a miss at 1 and at A; the other three breaches stay 58 bytes
and hold at 0, A and u64::MAX; data reads back at u64::MAX. The foreign-entry test adds a time
breach followed by a ceiling and a memory breach followed by half of one, each a removed miss. The
device test adds: the breach kept at ceiling 0 is StageUnfilled with the same request on a device
given ceiling 1, and a breach kept there refuses there (runs only where the driver writes a
pipeline cache header, so not on lavapipe).
What: over_write_before_a_capture reads, once R is scheduled and while the busy work still holds
the GPU, whether a submission went since W's commit, prints it on the path line, and asserts it
went exactly where W is in the group held and the device keeps two copies.
Why: AGENTS.md asks evidence that a device-shaped path ran, not only that the run passed. With two
copies, R takes the copy-in over the buffer W's texture lies over, so it leads its own group
(Captured::names_written) and W's group is submitted as R comes, before the busy work ends; held
for room, or with one copy (no Managed device copy, no split), nothing is submitted before then.
How verified: the compile job and the lavapipe rt suite, and the 5080 and XTX runs of this commit,
are in the lane's report by job id.
What: the test of eighty equal regions asserts that the first search's set holds all eighty, then
that the outlined module is valid and writes what the regions wrote; it no longer asserts that the
whole pass makes exactly one routine called eighty times.
Why: once the eighty regions are calls, the calls are equal items themselves; with the test's
regions of about 44 instructions and a smallest region of 1, a later search can write runs of 16
or more calls as a routine of their own (calls are CONST_OK operands, as roll's varying_ok says),
so "one routine, eighty calls in the entry" depended on that second search failing. The set the
first search takes is the property the fix (f0a204d6a0) gives: the search as it was took at most
65 of them.
Verified: not yet run; it runs in the next compile job with the rest of spirv::outline.
What: cache::SEMANTICS_VERSION 2259 to 2260.
Why: the outline pass (a repeated region of 500 or more instructions written once, as a kept
routine) changes the words of any module that holds such a region under an unchanged key. Its
first commit bumped 2258 to 2259; development reached 2259 for the device-address leaf
(d97bf60431) before it landed, so the rebase took that line as already equal and the pass's own
bump is this one.
Verified: the golden table and the old render key are re-blessed at the pin, as for every bump;
the compile job of this branch's tip reports them.
What: find_in compares an extent against every repeat of its seed window in the function (ranges
of keys by prefix hashes), not only the first 64 repeats it extends against, so one search makes
one routine for every occurrence of a region. The context keeps, by layout position, whether a
loop holds it, and the set of loops' continue blocks; apply drops the gone regions' first blocks
from the switches-at-use list once. The bounded-growth test's chain draws each group's two
operations from four by a hash of the group's index.
Why: the compile job of 08455481c5 (m3-max-64636) failed
engine_bounded_growth::compile_cost_grows_linearly_with_the_block_count: doubling its chain of
equal groups multiplied total compile allocation by 3.43 (49,119,827 to 168,331,419 bytes), 26,005
to 83,028 words. A set held at most 65 occurrences and its saving was counted over them, so a
function of N repeats was searched about N/64 times, each search linear in the function: the
quadratic term. Two scans per occurrence over every loop of the module (in_loop, the continue
check) and a retain over switches-at-use per region were the same shape. The test's chain is all
one group repeated, which the pass rightly writes as one routine, so its module stops growing with
the chain ("the generated graph was folded away"); its groups now differ, so the graph it
measures survives whole.
Verified: not yet run; the new test
a_region_repeated_past_the_repeats_tried_is_one_routine_called_at_every_repeat (80 equal regions
are one routine with 80 calls; the search as it was makes two) and the bounded-growth test run in
the next compile job.
What: a new pass, spirv::outline, runs on every module after rolling and hoisting. It finds a set
of regions of one function that are the same code (one sequence of the function's spine, loop
bodies included; entered only at the start and left only at the end), each of at least 500
instructions with a call of a kept routine counting one, writes the first as a new kept routine
(Function::kept, declared DontInline, the form ModuleBuilder::kept_routine makes) and replaces
every region with a call of it, then looks again, at most 64 times. Values from before a region
are parameters (one per distinct set of the regions' values; a constant that differs only where
any value may stand); a pointer parameter is a Function, Private, Workgroup or UniformConstant
variable itself or a PhysicalStorageBuffer pointer; values read after a region are the routine's
results (several in a struct). A Function variable only its region uses becomes the routine's
own where the region is in no loop or its first use stores the whole variable in a block the
region always runs; otherwise it is passed. Anything else that differs keeps the regions in line.
Candidates come from the spine's keys (16-item windows hashed, extended both ways); a set whose
exact comparison fails at an operand or result is compared again without that item. The spine
(roll::spine) takes a flag to walk loop bodies as sequences; rolling passes false and is
unchanged. SEMANTICS_VERSION 2259. API.md and ARCHITECTURE.md say the routines exist.
Why: NVIDIA's driver compiles a DontInline routine once and Mesa's drivers inline it either way.
On the RTX 3090 (620.70.06, job m3-max-64453) a generated kernel calling a 1,984-instruction
function from 50 places was created in 21.5 s inlined and 52 ms as a kept routine (51.8 s and
75 ms with 64 values live across every call); its dispatch GPU time was the same with few values
live and 20.6% lower as a routine with 64 live. A 497-instruction function: 0.1% and 19.7% lower.
500 is the smallest size measured within 3%. RADV and ANV (Mesa 26.2.6) compiled identical code
for the call, DontInline and inlined forms (jobs m3-max-64357, m3-max-64379).
How verified: spirv::outline::tests build kernels with three equal regions (a variable, a
selection's phi, a counting loop), a chain where each region reads the previous one's result, a
middle region that differs, and two regions in a loop whose accumulator is read before it is
written; each checks the routine and call counts, the module through the verifier and spirv-val,
and the words the interpreter writes against the unrewritten module's and the expected ones.
The named pin carries memleaf (d97bf60431, fffff6e96b: a device-address leaf of whole words is one access, and
under the identity domains a wide pointer is its device address), which bumped SEMANTICS 2258 to 2259.
- golden_hashes.tsv: 1,980 rows re-blessed on the M3 (m3-max-64644 at db5fefc2ce, GOLDEN=0), header semantics 2259.
- authored-compile.tsv: artifact hashes only; no case changed status (2,378 rows, 0 status changes; 64644).
- the_old_render_descriptor_key_keeps_its_value: b3da28b0..., the value the suite at db5fefc2ce printed
(m3-max-64624); the key hashes the translation's semantics, which moved.
Under the resident-table domains a pointer loaded through a wide pointer is
two whole words reached through PsbMem, which now reads them as one
PhysicalStorageBuffer access (Aligned 4) instead of two word loads. The
test counted two volatile loads; it now counts one and still checks the
value the chased pointer reaches.
Verified: the suite job m3-max-64513 at 428ff0fedd failed this assertion
(left 1, right 2) on moltenvk-m3 robust=true; rerun below.
A wide pointer under the identity domains was u64vec4(0, a, 0, 0): three
zero fields carried through every GEP (four extracts and a construct around
the 64-bit index arithmetic), phi and select, and extracted at every access.
It is now the address alone, a u64 (DemoteTy::Address): a GEP is the
address's own arithmetic, an access reads no field, a parameter is its slot's
address, a loaded or converted pointer is the loaded word, and the null wide
pointer is 0. Off the identity domains the root-table form keeps its fields.
dynamic::fields gives an identity pointer's fields as constants, and add64
folds the zero host.
Rides SEMANTICS_VERSION 2259 with the whole-word access (both change
device-address modules).
A load or store of a Path::Vec4, Vec2 or Aligned leaf through a device
address (psb::PsbMem: static slots, wide pointers, the vertex fetch's
sources) moved each 32-bit word with its own address arithmetic, place and
access: a float4 at an unproven 16-byte offset was four loads and about 38
instructions. It is now one PhysicalStorageBuffer access per 16 bytes at the
device address of its first word: the leaf's own type where its register
value is its words' bits in 32-bit lanes (float, int and their vectors), else
a u32 or uvecN converted as the words were. The Aligned operand is what the
offset is proven to be (16 or 8 from a slot's own address, else 4), which
VUID-StandaloneSpirv-PhysicalStorageBuffer64-06314 allows for every type the
form uses. The words read and written are the word path's, at the word
holding the leaf's first byte, so Metal's placement holds. A store ending
inside a word keeps the word path. Descriptor views keep theirs. The
device-address uvec2/uvec4 units this replaces are deleted, and the word
below an access is one mask (psb::split_word) instead of a mask and a
subtract.
SEMANTICS_VERSION 2258 -> 2259: device-address modules change.
Each shape is two kernels, one access and two, everything else equal: the
second's entry weight less the first's is one access's instructions, and its
device-address loads and stores less the first's the SPIR-V accesses it
makes. Shapes: wide float, int, float2, float4 loads and a float4 store; a
pointer loaded at a run-time offset of an align-1 constant buffer and a float
through it; a float4 load and store at a uint offset (alignment 4 proven);
a float4 load at a float4 offset (16 proven). On every identity profile each
access of a leaf of whole words must be one device-address access, within
its bound. It fails on the word-by-word form this branch replaces.
floor::MAINTENANCE8, floor::Maintenance8Features (with its maintenance8 member and its chain
impls), floor::Features::maintenance8 and floor::Capabilities::texel_offset_operand are new, and
OPTIONAL_EXTENSIONS's value ends with MAINTENANCE8. For a consumer: a struct literal of
floor::Features or floor::Capabilities that names every field no longer compiles (both take the
new field); nothing else moves.
The device-cfg floor test creates each device with the floor's features and destructures them;
the new field broke its build under --cfg m2v_gpu and m2v_cpu_icd (job m3-max-64512).
The owner allowed a ninth query-chosen form (Telegram 2465): "I allow the ninth query. Use it
where you can". This answers the texel-offset question inside his compile-time order ("Multi
minute compiles are unacceptable").
What: the floor reads VK_KHR_maintenance8 and its feature maintenance8 where the device lists the
extension (one of OPTIONAL_EXTENSIONS, and one of the OPTIONAL features, each of which chooses one
of two forms; VkPhysicalDeviceMaintenance8FeaturesKHR is bound by hand, as ash 0.38 lacks it, its
layout checked as the crate compiles). Device creation enables both, Capabilities answers
texel_offset_operand, and the translator's description is told of Maintenance8 and
KhrMaintenance8 (shader_enables). The translator already takes a run-time offset on a sample as
the Offset operand where its profile has maintenance8 (lower::sampler::select::dynamic_offset).
Until now the runtime never enabled the feature, so with_enabled dropped it, and every run-time
offset that reached lowering became a switch of up to 256 ConstOffset arms. NVIDIA's compiler
takes minutes to create that switch (lane stagesize: 255 arms 193 s on an RTX 3090, the operand
80 ms). Canonicalization's unroll of a proven small nest is unchanged on every device.
A device without the feature keeps the branch: Intel's Windows driver for the UHD 630 (101.2145)
lists no VK_KHR_maintenance8 (vulkaninfo, job 64024). The runtime README records the branch's
compile time as a known gap of pipeline states, and its floor tables gain the extension and the
optional feature. AGENTS.md rule 2 changes in this commit: "for eight only" becomes "for nine
only", and the list gains run-time texel offsets.
Spec (1.4.366): VUID-RuntimeSpirv-Offset-10213 is the only gate on Offset outside a gather. The
value is OpBitFieldSExtract(v, 0, 4), in [-8, 7], inside the required minTexelOffset <= -8 and
maxTexelOffset >= 7 (VUID-RuntimeSpirv-OpImageSample-06435/06436). Gathers already took Offset
through shaderImageGatherExtended, which the floor requires. Enabling maintenance8 changes no
other path the runtime takes: its blits stay within one 3D image, it names no queue family
ownership transfer flag, and it merges no pipeline caches.
Caches: the translator is unchanged, so SEMANTICS_VERSION stays. The translator's profile
fingerprint (DeviceProfile::fingerprint, over every profile field, ImageCaps::dynamic_sample_offset
among them) moves on a device that has the feature, and with it every FunctionCompileKey and render
record name in the cache directory. A lowering made without the feature is not taken by a device
with it (tests::filter_nest's every_device_keeps_the_operand_s_and_the_switch_s_lowerings_apart).
Tests: tests::floor's a_run_time_texel_offset_is_the_sample_s_operand_where_maintenance8_is_reported
fails without the change (no Maintenance8 among the enables); the_optional_features_decide_the_
capabilities takes the eighth case. tests::filter_nest (device cfgs): the unrolled kernel, the
operand and the switch (a translator told of no maintenance8 on the same device, test-only) write
the same 64 sums; the module needs maintenance8 and holds no OpSwitch where creation enabled it,
and holds a switch otherwise.
every_device_writes_its_lowerings_off_the_creating_thread_and_drops_them_past_its_queue hung on
lavapipe after 7a9458f983 (capover's check m3-max-64386: SLOW past 300 s; it passed at 8bef47758f
in m3-max-64358). The stall made the reaper pop a file and then spin in write_kept, so the queue
could be empty when the test set its bound to the bytes waiting. Since 7a9458f983 an empty queue
takes a file of any size, so the second kernel's lowering was kept, not dropped; the assertion
failed with the writes still stalled, and the device's teardown waited forever on a reaper spinning
in write_kept.
Now the stall is taken where the reaper takes a write: next_write answers none while stalled, the
queue keeps every file handed over, and the test pokes the reaper when it lets them go. The
product path is unchanged (the stall is test-only).
The room rule's paragraph said a run not yet known passes the 16 ms test. It does not:
an unknown run counts as u64::MAX (submit::room, and a group's run saturates), so a queue
whose command buffers have not yet retired with their GPU times has room for two
submissions only, and its third command buffer waits for one seen complete. That is what
the Iris A/B's frame_5cb_from_idle (+4.0%, about 6 us, m3-max-64375) reads as the room
rule's price from idle.
Verified: docs only; the check is fmt, Rustdoc and the API reference.
What: a didModifyRange: capture's copy-in no longer records the copies back owed to the textures
over its ranges in images of their own at the commit. The submission that takes the copy-in takes
them (CopyIn::backs, by the existing rule for submitted writes, ManagedOvers::backs_before) into the
upload that leads it, ahead of the copy-in. A command buffer that would take a copy-in over a
Managed buffer, a texture over which a command buffer of its queue's group held wrote, leads its
own group (Captured::names_written), so the write is submitted, and owes its copy back, first. The
split fires only then: a group held that holds a write of a texture over a Managed buffer's device
copy, and a later command buffer joining it that takes a copy-in captured after the group's last
lead over that same buffer.
Why: Metal's device copy keeps a GPU write outside a didModifyRange:'s range, and a command buffer
committed after the capture reads that write and the range's new bytes (MTLBuffer.h). The copy-in
copies the texture's whole range from the device copy into its image, so a write that runs before
it must be copied back first. Taken at the commit, only writes already submitted were copied back:
a write committed before the capture and still held (in its queue's group held, or held for room)
ran before the copy-in and was overwritten. Which writes run before the copy-in is known only as the
submission that takes it goes: a write of another queue not yet submitted runs after it, and taking
its copy back at the commit (the commit-time form) would copy an image never filled over the device
copy and drop the write's own copy back.
How verified: before, at d910296ac6 on the RTX 5080 (job m3-max-64324), both forms of
over_write_before_a_capture failed: R read the buffer's old bytes outside the named row, the new
bytes in it, with two copies, an image of its own, its buffer's entry owing it, and W not yet
submitted as R's commit took the capture. A third arm,
every_device_keeps_a_managed_texture_over_s_write_held_behind_a_passing_capture, runs the copy-in
ahead of the write (B1 passing A's group held with A3 the writer) and checks B1's read, A4's and the
buffer's after. The after-runs are in the lane's report by job id. The capture tests now read W's
submission state before R's commit, which takes the capture: W's group may now go as R is staged.
What: over_write_before_a_capture, in two forms. Behind the busy gate, W copies a pattern into a
texture over a Managed buffer in an image of its own and is held (in the queue's group held, or held
for room behind UNSEEN_JOINS joins); then the consumer writes and names the texture's last row and
R, committed after on the same queue, takes the capture and reads the whole texture. R must read
W's pattern outside the named row and, with two copies, the consumer's bytes in it. The test prints
the path: two copies, an image of its own, owed by its buffer's entry, W held for room, the
queue's submissions in flight and group held as R commits, and W not yet submitted as R's commit
took the capture.
Why: Metal's device copy keeps a GPU write outside a didModifyRange:'s range, and the range's new
bytes reach a command buffer committed after it (MTLBuffer.h). Read from the code: the capture's
copy-in takes only the copies back of submitted writes (ManagedOvers::backs_before), then copies the
texture's whole range from the device copy into its image, so a write committed before the capture
and not yet submitted is overwritten once it runs.
How verified: its run on the RTX 5080 at this commit is in the lane's report, by job id.
What: section 10's Draws entry on a filled primitive past a viewport edge that crosses a pixel. It
said a Vulkan device covers such a pixel where its sample lies in the clipped primitive; it now says
what was measured: RADV (RX 7900 XTX, two Radeon 780Ms, RX 550) and NVIDIA's driver (RTX 3090,
RTX 2080, RTX 5080) cover every pixel the viewport overlaps, as Metal on the M3 Max does; lavapipe
covers such a pixel only where its sample lies in the clipped primitive; the Iris Xe (ANV) covers
every pixel the near edges cross and none the far edges cross, the accepted difference where that
pixel's sample is outside or on the edge and a driver bug (the runtime README's known gap) where it
is inside.
Why: the entry claimed more than was measured; seven GPUs show no difference at all.
How verified: replays of fractional-viewport-coverage through the runtime, each differing pixel
printed against Metal's recording: m3-max-64279 (XTX), 64288 (780M 1002:15bf), 64280 (780M
1002:1900), 64323 (RX 550), 64286 (3090), 64287 (2080), 64282 (5080): 0 differing pixels;
m3-max-64281 (Iris Xe): 120 pixels, all far columns and rows; lavapipe's 344 elements from its
ledger row. The entry's bold lead-in (the allowance slug) is unchanged.
What: the reaper's write queue (cache::Pending) refused any lowering that would take it past
PENDING_BYTES (8 MiB), even when it was empty, so a single lowering larger than 8 MiB was never
written to the cache directory and every later device lowered it again. An empty queue now takes a
file of any size; one larger than the bound waits alone, and the next is dropped until it is taken.
Why: the consumer's cold launch of a modelling app (Radeon 780M) remade its pipelines after the
fills and translated again for exactly the three heaviest kernels (661, 934 and 1114 ms, weights
742,949, 628,489 and 489,281), while the five lighter ones hit in 12 to 30 ms. A cache that drops
its heaviest entries drops the ones that cost the most to make again. Memory stays bounded: the
queue holds 8 MiB of lowerings or one larger lowering, bytes already in memory before the push.
Verified: the queue's unit test gains an empty-queue push of a file past the bound (kept), a push
behind it (dropped) and room again after the pop; it fails without the change by construction (the
old check refused any push past the bound). Docs: the module doc, PENDING_BYTES, keep_translation,
Metrics::cache_writes_dropped and the README's cache paragraph say the same.