2137a20004e2b5658aedd0bdfdafc99e043606ce
1530
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
11edfb6daf |
A commit counts its buffers' host imports without making a list for the first sixteen
Buffer::distinct_host_imports, which every commit calls for WorkCounts::host_imports_used, collected the import of each used buffer over host pages into a Vec, sorted it and removed the repeats. It now tells the first 16 distinct imports apart in a stack array (FEW_IMPORTS), and lists and sorts them only past that. The count is the same. The audit proposed a per-import epoch stamp instead. The call runs outside any device-wide lock (command_buffer/mod.rs, in the commit), so two command buffers committed at once on two threads would share the stamps and miscount each other's imports; the stack array is exact under any concurrency and makes no allocation in the common case. The other half of the audit's commit-cost finding, the scheduler's wake broadcast, is the owner's question (spinning, or the committing thread submitting itself) and is not changed here. Checks: - host_ab percall now holds commit_one_dispatch to 4 allocations and commit_no_copy_dispatch (its two buffers over host pages) to 9. Before this change the latter makes 10, so the gate fails without it. - tests::host_import_counts::a_commit_counts_each_import_once_past_the_few_it_tells_apart_in_place checks the count at 1, 15, 16, 17 and 18 imports, each buffer twice and one import holding two buffers, on both sides of the fallback. Verified on MoltenVK with the other host-import tests (6 passed). Release, M3 Max, MoltenVK 1.4.2, host_ab percall, before (9f56956ef3) and after interleaved twice: | row | before | after | |---|---:|---:| | commit_no_copy_dispatch allocs/call (both rounds) | 10 | 9 | | commit_one_dispatch allocs/call (both rounds) | 4 | 4 | | commit_no_copy_dispatch self, ns/call (round 1, round 2) | 2414, 1477 | 2354, 1495 | The times ran under a load average of 30-60 from other builds and moved more between rounds than between builds. (cherry picked from commit 7b1b75bdddfafd3cb3dd835d4b5f87ab2db2f7a0) (cherry picked from commit e3b963bdc0e5c41766b6a42892860a4eec7c005b) |
||
|
|
6b13f54c5e |
host_ab percall: time a commit whose dispatch binds two no-copy buffers
commit_no_copy_dispatch is commit_one_dispatch with the dispatch's two buffers made over host pages of their own (Objects::no_copy), so the commit counts the host imports its used buffers lie in (WorkCounts::host_imports_used), which commit_one_dispatch's buffers, the runtime's own, never reach. The group is declared in TIMED under CommandBuffer::commit; the API cost coverage is unchanged (commit was timed already). (cherry picked from commit 506eccf91672f23d8f669b7a519e5449735124a6) (cherry picked from commit cf0e5cf9513d17c21e539e0ed9354fc780066470) |
||
|
|
535c931153 |
The translator's spec_key makes its two lists at their whole size at once
spec_key, which each instantiated dispatch region and each plan calls, pushed its entries and its data one constant at a time, so both lists grew by reallocation (the audit measured about 35 of 88 instantiate_dispatch samples there). It now reserves room for every constant of the layout: one entry each, and each constant's low size bytes (at most 8). The same keys. Check that fails without it: bind::plan::compute::tests::specialization_lists_are_made_whole_at_once (five constants, each given a value: each list's capacity equals its length; without the reserve the entries hold 8 and the data 32). Release, M3 Max, MoltenVK 1.4.2, host_ab calls, before (d16266d2af) and after interleaved twice, allocations per call (deterministic; the same both rounds): | row | before | after | |---|---:|---:| | many_dispatch | 41 | 38 | | many_dispatch_resident | 44 | 41 | | wide_dispatch | 27.516 | 24.516 | | wide_dispatch_resident | 27.406 | 24.406 | The times of those rounds ran under a load average of 50-60 from other builds on the host and moved by more between rounds than between builds (dispatch_offsets encode 4.96/4.43/3.36 us before against 4.18/2.85/3.04 after), so they show no measured change either way. (cherry picked from commit 0f89c223969badc3cec18909810ff26032c9c577) (cherry picked from commit 75e22ef43b50e68fec19c2a40da02ead2bd33230) |
||
|
|
0c696948bc |
Pin the runtime sources after noted textures' pattern reads logged without an allocation per draw
(cherry picked from commit 94431cc652aff19bee45088740ef01dc9b97b88a) |
||
|
|
ce8ec6c9c1 |
Bump RUNTIME_VERSION to 1746: noted textures' pattern reads logged once each, with no allocation per draw
A run of an unchanged artifact and plan records the same first-use answers for noted textures, taken at the commit in commit order as before, but a draw logs an event only for a texture noted now that the record weighs (a write for any, a read for any but a signed-depth texture, a depth load for a signed-depth one), skips a repeat of its texture's last entry, and builds no temporary list: host_ab percall's draw rows are back to 0.039 allocations per draw (from 1.055) and end_render to 25 per call. 1746 is the lane's 1745 (VkQueue sharing) plus one. (cherry picked from commit 2b83f5fe6084569b6a7f2d988d629b003d57d230) |
||
|
|
549609b26f |
device-color-conversion: state the measured unorm rounding at a tie
The note's doc said every Vulkan driver measured but MoltenVK rounds the f32 product with ties to even and that Metal "rounds a half toward zero". Neither fits an exact tie in an 8-bit unorm attachment: Metal stores 0x80 for 0.5 (127.5), and the RTX 5080 stores 0x7f, which ties to even would not give. "A half" meant a half-float channel, which read as 0.5. Measured over every 8-bit code's exact value and every tie with two f32 steps either side, BGRA8Unorm and RGBA8Unorm: - Apple M3 Max, macOS 27.0.1, plain Metal (a probe of our own): all 1531 inputs store the exact product rounded to nearest, the tie up; 128 of them differ from the f32 product rounded with ties to even. 0.5 -> 0x80, f32(1.5/255) -> 2, f32(2.5/255) -> 3. - RTX 5080 Laptop GPU, NVIDIA 615.71.09, through the runtime (the color_writes lane's pipeline, plain draw and an indirect command buffer's draw of the same state): plain and ICB identical in every channel; every input on a tie or up to two f32 steps above one stores the lower code (0x7f, 1, 2 for the three above), every other input Metal's code; 638 of 1531 inputs differ from Metal. The doc now says so (artifact.rs, the color_writes module, API.md's catalogue entry), names the half-float channel plainly, and keeps the ties-to-even claim for ANV, RADV and lavapipe only, as earlier measured; the RTX 5080 is no longer among them. The fragment stage records DeviceColorConversion on the 5080 for that pipeline, plain and ICB alike (verified: both stages' notes printed, and with device-color-conversion asked at every occurrence the plain draw and the ICB's replayed draw each announced it once). Docs and comments only. (cherry picked from commit 5021f1c4ba7f29a6dc54f76f4d12402795af7162) (cherry picked from commit e21d7c945b383ddfbfe54a8d82fc89342e6f7d13) |
||
|
|
e2f928c57a |
Log only noted textures' pattern reads and writes, once each, with no allocation per draw
What: FreshLog::push, which took a Vec of events a command built for every image it read or wrote while any noted texture was live, is replaced by FreshLog::add, which logs one event at a time and only where the record weighs it. That means a write of a noted texture, a read of a noted one other than a SignedDepth one, and a pass's depth load of a SignedDepth one. It also skips an event equal to its texture's last entry within the last 8 (REPEATS). observe_reads, begin_pass, loads_signed_depth, cleared, resolved and wrote build no temporary Vec. The commit takes the log with mem::take of the command buffer's own Vec of events. Why: since the pattern reads moved to the commit ( |
||
|
|
885e1211e9 |
Pin the runtime sources after command queues share VkQueues
(cherry picked from commit 1bb0b87a5af181dca452943fd31629e40e1592df) |
||
|
|
94f09127ec |
Bump RUNTIME_VERSION to 1745: command queues share VkQueues where the GPU idles at each switch
A run of an unchanged artifact and plan on a device whose self-check finds the GPU idles at each switch between VkQueues (the RTX 5080: about 50 µs) now puts a command queue with nothing in flight on a busy VkQueue (QueueSharingPolicy::Adaptive, the default), keeping queues apart once one goes long; DevicePolicy's PerQueue keeps one VkQueue per queue as before, and new_command_queue_unshared never shares. Degradation::QueueSharing announces it. Elsewhere the mapping is unchanged. 1745 is the lane's 1744 (function handles, volume mipmaps) plus one. (cherry picked from commit 706b3929eec500d0959edab2269ffa7884ffff96) |
||
|
|
be47523f80 |
State queue sharing's residual stall and the unshared form for queues that must never wait
What: docs/FAST-PATHS.md's queue sharing row, docs/API.md's policy bullet and the runtime README's new_command_queue_unshared entry now state the residual stall exactly: once per logical queue that goes long, for a queue that joined its VkQueue during its short phase, about one long command buffer's length. They also say a queue that must never wait (a compositor's) is made with Device::new_command_queue_unshared. The row's cost column carries the measured rates. The queue_share example's rates mode takes --threads, --in-flight and --one-vk-queue for one shape. It prints each command buffer's GPU end and commit to its completed handler, the submission, scheduler and wake counts per command buffer, and the busiest threads' CPU from /proc (Linux). Why: on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, release, 3 runs a side), the trap and slow-alternating shapes cost a shared compositor 64 completions over 10 ms, at most 29.4 to 30.6 ms, in every run, with one join each. That is the first long command buffer of the application it joined during the application's short phase. PerQueue had none in 5 of those 6 runs and 4 in the sixth (at most 3.7 to 10.7 ms). An unshared compositor had none over 10 ms in any run. No join rule built on what a queue has shown can avoid the first one: the long command buffer gives no sign before it runs. A re-pick at submission would not either: the compositor holds about 4 uncompleted command buffers at each commit (p50 commit to handler 0.78 to 0.87 ms at a 208 us period), and the stall is all or nothing in a queue's own order. So the docs name the unshared form as the answer for such a queue. The probe settled the 2 threads x 3 in flight drop (15.4k against 26.0k a second in one run): it was the lock hold's warm-up. In the hold's first runs both policies ran slow (11.1k and 10.4k), and later runs gave Adaptive 46.5k and 39.7k against PerQueue's 25.2k and 26.5k. Two queues on one forced VkQueue ran 38.1k to 46.6k under PerQueue and 41.4k to 49.9k pinned under Adaptive, so one VkQueue is not slow in the runtime's path. No runtime thread was busy in the slow runs (scheduler 10%, handler threads 5%, waiters 3%), and every shape made one vkQueueSubmit per command buffer. Verified: tests::fast_paths, degradation_catalogue and degradation_sites (25 passed); clippy of the example with all features. (cherry picked from commit b1dbea95dad3a5a156191df01084db0f86cb67a0) (cherry picked from commit 24af60dbf8175da8e60ea24f38f9103c20c23e8b) |
||
|
|
4fc55c4758 |
Hold the isolation tests' latency bounds only where the device shares VkQueues
The two isolation tests of tests::queue_share_device asserted the compositor's p99 under 5 ms wherever its queue and the application's took VkQueues of their own. On MoltenVK on the M3 Max (macOS 27.0.1) they do, the runtime moves no queue (the device has no two VkQueues of one family), and the driver's own latency beside the 30 ms command buffers was a p99 of 57.4 and 59.9 ms with 1,583 and 1,650 stalls: the driver's behaviour, not the runtime's sharing, which these tests are about. They now run only where the device shares (each policy still asserts no move elsewhere), and record from 50 ms after their start condition, so the backlog that queued behind the long command buffer which marked its queue long (drained within about 1 ms of its end) is not counted as stalls of the steady state. Verified: clippy of the runtime with --cfg m2v_gpu, all targets and features. The M3 run that found it: 22 of the 24 selected runtime and lane tests passed, these two failed as above. (cherry picked from commit 5e93afdefa8c327cc4116c5ae45c11792c9469c5) (cherry picked from commit 4e5713311772f83600db9ed37d02c14ab1263ae9) |
||
|
|
510e0c0cca |
Share VkQueues between command queues where the GPU idles at each switch, with an unshared opt-out
What: a new DevicePolicy switch, queue_sharing: QueueSharingPolicy { Adaptive (default),
PerQueue }; exact_answers() selects PerQueue. Under Adaptive, on a device whose own self-check
finds its GPU idle when consecutive work comes from another VkQueue, a command queue chooses its
VkQueue again each time it makes a command buffer while it holds no other uncompleted one (the
slot take with held.all == 1, under its slots lock): it joins the busy VkQueue of its family
whose oldest batch has run under 0.5 ms, the most batches in flight first, then the latest
submission (Device::pick_vk_queue: one pass of atomics over the round robin's VkQueues, no lock).
A queue whose batch ran over 2 ms as its VkQueue's oldest is marked long by the waiter that saw
it complete, under the completion's pending lock, before the turn that finishes it
(command_buffer/completion.rs); no queue joins a long queue's VkQueue, and the long queue moves
once more at its next idle point, to the least recently used idle VkQueue no long or unshared
queue holds. Its mark moves with it and a dropped queue subtracts its marks. Presenting queues and
a queue that lent its VkQueue (with_vk_queue, pinned from then on) never move. A queue's vk_queue
is now an atomic; everything that reads it does so between a command buffer's make and its
completion, when no move can happen.
The self-check (queue_switch_check.rs) is the runtime's own, kept like the in-place check's, not
a DriverFact row: on a thread of its own, once per driver, release and runtime, 24 rounds of two
timestamp-only batches held behind one host-signalled gate on two same-family VkQueues against
24 on one; the switch cost is the difference of the median gaps; Idles above 20 us, DoesNotIdle
below, Unchecked where the device has no calibrated timestamps, no two VkQueues of one family, or
a run failed. Its verdict is written as one record in the shader cache's content directory and
read back as the next device of the same driver, release and runtime is made. Before the verdict,
every queue keeps the VkQueue it took at creation.
Device::new_command_queue_unshared(count): a queue that never moves and that no adaptive queue
joins; a queue already on its VkQueue leaves at its next idle point. Placement where the device
shares: a round-robin VkQueue no command queue holds, least recently used first; else one no
long or unshared queue holds, the fewest queues first; else the round robin's next. Why that
order: an empty VkQueue gives isolation at once, with no wait for another queue's idle point; of
the empty ones the least recently used is the one least likely to hold a moving queue's work in
flight (a queue that just left it may still have batches there, and the unshared queue would
wait behind those); where none is empty, the least held one has the fewest queues to move off,
each at its own next idle point, so isolation arrives soonest, and a VkQueue a long or unshared
queue holds is never taken since that would put the opt-out behind exactly the work it opts out
of. A queue's claim of a VkQueue and an unshared queue's are ordered so that two at once never
both succeed: each counts itself there first, then reads the other's count (SeqCst both sides).
Under PerQueue, and where the device does not share, it is
new_command_queue_with_max_command_buffer_count. A count of 0 and a lost device are refused.
Why: NVIDIA 615.71.09 on the RTX 5080 Laptop GPU leaves the GPU idle 56 to 62 us whenever its
next work comes from another VkQueue, so one VkQueue per command queue, round robin, capped eight
threads' one-draw command buffers at 25,800 to 29,500 a second (GPU idle 60% of its time at the
switches), where one VkQueue ran 54,700 to 58,700 (the audit that set this design). Moving only
at idle points keeps every queue's own order without a cross-queue fence. The cost is the
runtime Degradation kind QueueSharing ("queue-sharing", performance), announced once per device
at the first join, in CommandQueue::command_buffer on the making thread: the first long command
buffer of a queue that shared holds the command buffers committed behind it on its VkQueue for
its whole length. The opt-out exists so a compositor never pays even that one stall.
Counted: WorkCounts::queue_moves, queue_joins, queues_gone_long, long_queue_settles,
queue_moves_off_unshared, joins_withheld_from_unshared, queue_switch_checks_run and
queue_switch_checks_recalled. The policy keys no profile (tests::fast_paths), so
SEMANTICS_VERSION does not move. Docs: FAST-PATHS row, docs/API.md (the policy and the notice
catalogue), the runtime README (the opt-out, with_vk_queue's pin), queue.rs's module doc on
isolation; REFUSALS regenerated (the new site of MaxCommandBufferCount); api_surface and
api_signatures (additions only). The example queue_share runs the workloads under either policy.
Verified: cargo clippy --workspace --all-targets --all-features -D warnings, and the runtime and
validation crates with --cfg m2v_gpu; RUSTDOCFLAGS=-D warnings cargo doc --workspace
--all-features --no-deps; nextest of tests::queue_share (the choice, settling, the unshared order,
the record), tests::fast_paths, tests::degradation*, api_surface, work_counts: 66 passed. On the
RTX 5080 Laptop GPU (release) the check answered Idles at 51.3 us, and its form measured 49.0 to
50.7 us in five more runs, where a chained form measured 53.2 to 59.3 us. The device tests
(tests::queue_share_device, runtime_lane::command_queues::a_queue_joining_...) are not yet run
on a GPU in this commit.
(cherry picked from commit a2f17a5132faf0312fb3953d634e21c927cde62e)
(cherry picked from commit 862b2cb49a9481d0a2a19fb1bc3acec79932d1bd)
|
||
|
|
c8a0481cf8 |
Add the bit-manipulation authored cases, qualified on Metal
What: two loop-free authored cases over `bit_ops` of the owned fixture
`engine/kernel_bit_manipulation` (f19e887e4a adds the fixture; this
commit needs it), and their Metal rows:
- `bit-manipulation-edge-words`, 16 threads:
- the words are 0, all ones, the top bit of each width alone, one, each
32-bit half alone, alternating bits, irregular words, 0x7f, 0x7fff
and 1 << 32;
- the amounts are 0, 1, 7, 8, 15, 16, 31, 32, 33, 63, 64, 65, 3, 100,
255 and 0xffffffff.
- `bit-manipulation-mixed-words`, 32 threads in two threadgroups:
- the words are splitmix64 of multiples of 0x1234567;
- the amounts run from 2 to 0xfffffffe.
Each thread writes 43 words of its 48-word block: every bit intrinsic MSL
compiles to (llvm.bitreverse, bswap, fshl, fshr, ctpop, ctlz and cttz at
the fixture's widths and flags). The five other words keep the 0xab fill.
Why: the Metal evidence for the bit-manipulation lowering of f19e887e4a.
Verified (M3 Max, macOS 27.0.1, Xcode 27B52, Metal 32023.922):
- Both cases qualify on Metal. Metal's outputs (768 and 1536 words)
equal an independent Python model of each intrinsic's LangRef
definition: 0 mismatches.
- The MoltenVK candidate (apple-m3-max-moltenvk, moltenvk-m3, MoltenVK
1.4.2, the product at f19e887e4a) is a Match on both cases, on the
stated and the robustness-off legs (4 of 4).
- No RTX 5080 run: the lowering differs by device only through
`shaderInt64`, which both the M3's MoltenVK and the 5080 have. The
path without it (two 32-bit words) is checked against the same
definitions on the CPU interpreter (tests::engine_bit_manipulation).
- The Metal rows are recorded under `local-metal`, as for the asm cases:
the reference list still declares Xcode 27A266a. Neither the scratch
reference rows nor the candidate rows are committed.
- corpus-case-check passes for both cases. The metal observation shards
stay in (case, environment) order with one row per slot.
Golden tables: the authored compile census gains these two cases
(re-blessed on development).
(cherry picked from commit df3841734a84cce05f233bf6d0524d3c94062654)
(cherry picked from commit f7d9974009bb66bfd91270462ea1d202814b85d8)
(cherry picked from commit 160e904cc612d4dd373c57b8b4da8a53e8927bdf)
|
||
|
|
7d7e7f3f69 |
Add the empty inline assembly's authored cases, qualified on Metal
What: two authored cases over the owned fixture `engine/kernel_inline_asm`
(public source, loop-free or authored-bounded), and their Metal rows:
- `empty-asm-in-a-loop-body-runs-every-iteration` (`asm_in_loop`):
- n = 6 comes from a buffer, so no compiler can fold the trip count;
- each of 4 threads stores its six partial sums of i ^ t to words
8 + 8t + i, its sum to word 2t and its iteration count to word 2t + 1;
- the other words keep the 0xab fill;
- so a loop shortened or removed once the barrier is gone shows as a
mismatch.
- `empty-asm-in-an-inlined-helper` (`asm_in_helper`): the asm sits in a
noinline helper the translator inlines after decode drops the call; each
thread writes 3t + 1.
Why: the evidence for dropping `asm sideeffect "", ""` at decode
(8b418fbd6c, 53c6faaf4d). The output must prove the loop that held the
asm still runs every iteration.
Verified (M3 Max, macOS 27.0.1, Xcode 27B52, Metal 32023.922):
- Both cases qualify on Metal. Metal's outputs equal the expected words
exactly: all 40 words of the loop case, with every count 6, and 3t + 1
for the helper.
- The MoltenVK candidate (apple-m3-max-moltenvk, moltenvk-m3, MoltenVK
1.4.2, the product at 53c6faaf4d) is a Match on both cases, on the
stated and the robustness-off legs (4 of 4 runs).
- The Metal rows are recorded under `local-metal`. The reference list
still declares Xcode 27A266a / Metal 32023.921, so this host cannot
record under the reference ID. The MoltenVK comparison ran against a
scratch copy of the list naming this host's toolchain. Neither those
reference rows nor the candidate rows are committed. The reference is
being re-measured on the new toolchain separately.
- corpus-case-check passes for both cases. The metal observation shards
stay in (case, environment) order with one row per slot.
Golden tables: the authored compile census gains these two cases
(re-blessed on development).
(cherry picked from commit 2412d6f2f75996de81ae10a2bd0dec7826e35fda)
(cherry picked from commit aa76cb8c8ecb75900ebc1c7468970fb7bf17bf4b)
(cherry picked from commit db70519af7bf585fcf2fbfea6e17d75c385649ad)
|
||
|
|
888dbbbf2f |
Refuse each constants-block record outside the typed model by LLVM's name
What: `Feature::Constant { code: u32 }` becomes
`Feature::Constant { record: ConstantRecord }`, in the front end and the
translator, which re-exports the new `ConstantRecord`. ConstantRecord is
non-exhaustive, one variant per LLVM name:
- Select, ExtractElement, InsertElement, Compare;
- ShuffleVector (CE_SHUFFLEVEC and CE_SHUFVEC_EX);
- BlockAddress, UnaryOp, DsoLocalEquivalent, NoCfi, GepWithInrange;
- PtrAuth (PTRAUTH and PTRAUTH2), Byte (BYTE and WIDE_BYTE);
- PtrToAddr: a CE_CAST of `CAST_PTRTOADDR`.
Each record is matched from its code (`codes::cst_unsupported`). A code
LLVM does not define stays `UnknownRecord`.
A refusal now reads `Constant { record: Select }` where it read
`Constant { code: 13 }`. The names and codes come from
`LLVMBitCodes.h` of the local LLVM 21.1.8 and 23.1.4 toolchains
(`ConstantsCodes`, `CastOpcodes`).
WIDE_INTEGER stays malformed, on purpose, with a comment that says why.
LLVM writes it only for an integer wider than 64 bits. The type table
already refuses those types (`Feature::Type`). So a WIDE_INTEGER that
reaches the constants block has a type of at most 64 bits, which LLVM
never writes.
Why: a refusal should name what it refuses. The inline assembly record
(code 30) reached a consumer as a bare `Constant { code: 30 }`; it now
decodes, and this names the rest of the class.
Verified (debug):
- metal2vulkan-air suite passes, including `constant_errors_are_typed`:
- each of the 15 refused codes yields its name;
- CE_CAST opcode 13 yields PtrToAddr, opcode 14 is malformed;
- WIDE_INTEGER of an i32 is malformed;
- code 60 is UnknownRecord.
At the base the test does not compile (no ConstantRecord), and the
refusal there was the bare code.
- The translator's api_surface, api_signatures (blessed: the new enum,
its variants, the changed variant) and refusal_surface tests pass.
- clippy -D warnings, workspace, all targets, plain and --cfg m2v_gpu.
- docs/REFUSALS.md regenerated (the row's doc text).
The census changes no outcome: no private-corpus row was refused with a
constants-block code at d3e66f9415 or after the bit-manipulation change
(nvidia-rtx5080-laptop and moltenvk-m3).
SEMANTICS_VERSION 1954 -> 1956 (a refusal's class changes): the lane's
value plus one after f19e887e4a takes 1955.
Golden tables: none move (no fixture holds such a record).
(cherry picked from commit 2af3e7891ee1ce7893107ff69f32ea879a06a56c)
(cherry picked from commit 94412279d2b277a2b9cfc11a83fc1e231ef91ecb)
(cherry picked from commit 3f5560c3fd7da0edab9a10d6b951986d8fcc6f80)
|
||
|
|
a8b1d49d13 |
Bless the golden hashes and engine fixture expectations for the bit-manipulation fixture
engine/kernel_bit_manipulation's two spellings (.air.ll and .ll) are new rows in both tables; no row is removed or changed. (cherry picked from commit 64816f3e7c3fc6d3d8604de15bb8c2d8968c0833) (cherry picked from commit 5ef57725f6f177863226386c0b4d5a363f282cf1) |
||
|
|
e716449716 |
Bump SEMANTICS_VERSION to 1955: llvm.bitreverse translates at every integer width
A module calling llvm.bitreverse used to refuse as UnknownIntrinsic and now translates: OpBitReverse at 32 bits, the 32-bit reversal shifted right for i8 and i16, two swapped halves for i64, and per lane for vectors, with no precision note. The cherry-picked commit's own bump (1950 to 1954) met the lane's 1954 (the half-NaN carve-out), so this takes the lane's 1954 plus one. (cherry picked from commit d3da33d361125303fb2e843007d6ea432ab045c5) (cherry picked from commit 85c016a183e4ec0ac4593bb227e7fcb22b7b2a1c) |
||
|
|
c7f6a4b61d |
Decode llvm.bitreverse at every integer width: the bit-manipulation class translates
What: `llvm.bitreverse` joins the kept integer `llvm.*` operations
(`LlvmIntOp::BitReverse`, arity one, any integer width and vector of one)
and lowers to the existing exact `IntFn::ReverseBits`. Before, a compute
pipeline with it was refused `UnknownIntrinsic llvm.bitreverse.i32`.
An owned MSL fixture, `engine/kernel_bit_manipulation` (written for this
project, `.ll` and `.air.ll` from `scripts/regen-air-fixtures`, Metal
32023.922, SDK 27.2), holds every bit-manipulation intrinsic Metal's
compiler emits from MSL. Its kernel `bit_ops` calls:
- llvm.bitreverse at i8, i16, i32, i64 and <4 x i32>;
- llvm.bswap at i16, i32, i64 and <4 x i32>;
- llvm.fshl at i8, i16, i32, i64 and <4 x i32>, and llvm.fshr at i8, i16,
i32 and i64 (rotations);
- llvm.ctpop at i32 and i64;
- llvm.ctlz and llvm.cttz at i16 (zero-poison flag true) and at i32 and
i64 (flag false and true).
They come from clang's builtins (`__builtin_bitreverse*`,
`__builtin_bswap*`, `__builtin_rotateleft*/right*`, `__builtin_popcount*`,
`__builtin_clz*/ctz*`) and from the shift-and-mask idioms LLVM recognizes
(a 32-bit bit reversal, byte swap and rotation of `uint4`). MSL's own
`reverse_bits`, `popcount`, `clz`, `ctz` and `rotate` compile to `air.*`
calls instead.
How each lowers: only `llvm.bitreverse` was missing. The other six already
decoded and lowered exactly at every width; the new tests prove it. Vulkan
allows `OpBitReverse` and `OpBitCount` only on 32-bit operands without
`maintenance9` (VUID-RuntimeSpirv-None-10824), and `DeviceProfile` states
no `maintenance9`, so 32 bits is the one native width:
- an i32 is one `OpBitReverse`;
- an i8 or i16, held zero-extended in a 32-bit container, is the 32-bit
reversal shifted right by 32 - n;
- an i64 is the two 32-bit halves reversed and swapped, in a 64-bit
container with `shaderInt64` or as two words without it (`wide.rs`);
- a vector is the same per lane.
Every answer is exact, so no precision note is recorded.
Why: a game engine's launch failed on `llvm.bitreverse.i32`.
Verified (this tree, debug, CPU interpreter; no GPU):
- tests::engine_bit_manipulation, 9 tests, all pass:
- `bit_ops` translates, links and passes spirv-val on all 19 committed
profiles in both spellings, with an empty precision-note set on every
one.
- On the interpreter, all 16 threads' 48 words equal a Rust reference
of each intrinsic's LangRef definition, on moltenvk-m3 with
`shaderInt64` and without it (the test asserts the feature's
absence), in both spellings. The 16 inputs are edge words (0, all
ones, 1 << 63, 0x80, 0x8000, 0x80000000, 1, the halves, patterns)
with amounts 0, 1, 7, 8, 15, 16, 31, 32, 33, 63, 64, 65, 100, 255 and
0xffffffff.
- Synthetic modules (llvm-as) cover each of the seven intrinsics at
i8, i16, i32 and i64 (bswap from i16), scalar and 2-, 3- and 4-lane:
- ctlz and cttz with the flag false (zero answers the width) and true
(non-zero operands);
- fshl and fshr on two distinct operands with amounts 0, 1, n - 1, n,
n + 1, 2n - 1, n / 2 and all ones;
- each against the reference on both profiles.
- Negative control: with the `bitreverse` entry removed, the bitreverse
family test and both fixture tests fail (refused); the other six
families pass, as at the base.
- tests::air_*, the api_surface and api_signatures checks pass.
- metal2vulkan-air suite: 493 pass, including a new decode test for
llvm.bitreverse at i8 to i64 and vectors, and mismatching declarations
refused.
- clippy -D warnings, workspace, all targets, plain and --cfg m2v_gpu.
- Translation census of the private corpus, release, nvidia-rtx5080-laptop
and moltenvk-m3:
- before: the lane base d3e66f9415, 16872 rows;
- after: this tree, discovery, then a --current-fingerprint sweep of
every previously translated row;
- no row regressed, and the refusal classes are identical (none was
UnknownIntrinsic or a constants-block code);
- the 4 public rows of the two new fixtures (the base retired them from
the index), now translate: 15499 -> 15503 and 15431 -> 15435
translated;
- slowest row 1803 -> 489 ms on NVIDIA (the before run ran at load
average above 110) and 687 -> 664 ms on moltenvk-m3;
- peak worker RSS 213 -> 222 MB and 224 -> 221 MB;
- largest allocator peak 176706368 bytes in both;
- 0 budget stops, gates pass.
SEMANTICS_VERSION 1950 -> 1954 (the lane's value at hand-over).
Golden tables to re-bless on development: golden_hashes (38 new cells, the
fixture's one entry on 19 profiles in both spellings; no moved cell) and
public_fixture_expectations_engine.tsv (the new fixture's rows). The
fixture's air_input printout is blessed here (pinned LLVM 21; no other
printout moved). Authored cases over `bit_ops`, qualified on Metal and
compared on MoltenVK, follow in their own commit.
(cherry picked from commit f19e887e4a59510370cb4bd05c97b58cd27e7ad8)
(cherry picked from commit 46366e0c8e37c3715bbc76fe5c54c5926c1a170d)
(cherry picked from commit 93422f39d1454bdbe24d133846b72ad1fc57f634)
|
||
|
|
0e1d6be65a |
Expect a volume's compute filter in the filter test where the driver's blits do not filter it
formats_the_blits_cannot_filter_take_the_compute_filter_level_by_level requires every format to take one route across its seven shapes. Since the VolumeBlitsUnfiltered defect (7e77515bee), a format whose blits filter takes its blit chain in every shape but the 3D one on MoltenVK, where `generate_mipmaps` takes the compute filter. Stack7's lane on the M3 failed there, for A8Unorm: [Blits(2), Blits(4), Blits(3), Blits(2), Blits(2), Blits(2), Filter]. What changed: - The test reads the device's driver defects. Where VolumeBlitsUnfiltered is listed, it expects the 3D shape to take the compute filter. - Everywhere else it still expects one route for every shape, and a blit-chain format's other shapes still take its chain. - A volume taking the filter is held to the filter's bound, level by level, as every filtered shape is. - The doc says so. Verified: the whole mipmap_chains file on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu); see the message that carries this sha. (cherry picked from commit 200c18ea5c542235ea1340ed205e46b104442b19) (cherry picked from commit 26222950fb49e4190253bb4663802515bc22402b) |
||
|
|
4a758879c9 |
pipeline_records: read the records only once their device is gone
a_later_device_makes_every_pipeline_an_earlier_one_made_from_its_records read the cache directory while its device was live: right after the state's creation, after the draws, and on the second device at creation and after the draws. A making hands its record to the device's cache thread, which writes it after the call returns (shader_cache/store.rs's write_record_soon, worker.rs), so a read right after the making could come before the thread wrote it. That is the failure seen at pipeline_records.rs:640 (made.len() one short of makings.creation), 2 of 5 runs alone on stack4. The module docs already say every file claim is read once the device is gone, and the other tests here do so. The test now makes its per-phase claims from the counters, which move inside the making: driver_saves (the creation's makings, then the points'), loads, found, unchanged and the driver's hits and misses at creation and at the draws. The files are read once each device is dropped: the first device's records, one per making, and driver.assert_records; the second device's records changed against the first's, as many as its saves over both phases, and no record but the makings'. assert_loaded returns the saves it counted instead of taking a file count, and each caller holds it to the files it read after the drop. two_processes_making_one_pipeline_leave_one_whole_record read the directory the same way while its device was live (after the creation and before the draw). Its claims move the same way: the draw's "wrote nothing" is the counters' (loads and saves unchanged by the draw), and the files changed since the makers' are read after the drop, as many as the creation's saves. No runtime change, so no RUNTIME_VERSION bump: the test file is outside the runtime pin. No sleep or polling. Verified on the M3 (MoltenVK, whose data is whole, so every claim above ran): the test alone with --stress-count 10, 10/10 passed; the file's four tests with --stress-count 5, 20/20 passed. cargo clippy -p metal2vulkan-validation --all-targets --all-features -D warnings, with and without --cfg m2v_gpu. (cherry picked from commit 5ccb69eca1889d503126228417dbe97dfe9e57aa) (cherry picked from commit 8411e1c6f72cb815e9f107352d144d78ea95a1f7) |
||
|
|
284cc6dff2 |
Pin the runtime sources after function handles however made and 3D mipmap chains by compute
(cherry picked from commit a53988a1decb8aea23abb5c1c4289f66f404d28d) |
||
|
|
da4441300c |
Bump RUNTIME_VERSION to 1744: function handles however made, and 3D mipmap chains by compute on MoltenVK
`function_handle` answers a stage's handle for a function object made by name, by descriptor or as a binary, however the stage linked it (Metal's answer, measured on the M3 Max); it had answered None across those forms on every driver. And on MoltenVK (RuntimeDriverDefect::VolumeBlitsUnfiltered, every version) `generate_mipmaps` of a 3D texture takes the runtime's compute filter where it computes the format, in place of vkCmdBlitImage, whose linear blit of a volume does not filter in depth. Other drivers keep the blit chain. No note or notice changes. 1744 is the lane's 1743 (compute bind state, commit_and_submit) plus one. (cherry picked from commit 5cf13d68bf749c203fed1bed5892be821cb511b5) |
||
|
|
f6921a5488 |
Bump SEMANTICS_VERSION to 1954: a mixed select merged with another widened half keeps the device's NaN bits
A module that merges a select of a widened half against a value not held widened (a bounds-checked read against 0) with another widened half, at a phi or through a function variable's stores, is no longer inside MoltenVK's MetalNanMoves carve-out. It keeps the device's NaN bits and records PrecisionNote::NativeNanEncoding, because Metal's compiler was measured to quiet 2045 of the 2046 half NaN patterns there on the Apple M3 Max. Only drivers that take MetalNanMoves (MoltenVK on the M3 Max's identity) are affected. Among the committed fixtures only hwd_half_reads changes its notes. 1954 is the lane's 1953 (inline assembly) plus one. (cherry picked from commit f4327a703589dadd79150706615514d95f0299ef) |
||
|
|
a1ee191fd1 |
Filter a 3D mipmap chain by compute where the driver's blits do not filter a volume
the_device_s_blit_chain_filters_each_level_and_is_announced failed on the
Apple M3 Max through MoltenVK 1.4.2 for its 3D textures only. Measured there:
vkCmdBlitImage with VK_FILTER_LINEAR from level 0 of an 8 x 8 x 4
R8G8B8A8_UNORM image into level 1 does not answer Vulkan's linear filter, the
average of the eight texels around each destination centre. Of the level's
128 bytes, 4 lie within a code of it, 67 within a code of source slice
2z + 1's four texels alone, and 2 of slice 2z's alone. 2D, 2D-array and cube
blits filter as Vulkan states. NVIDIA 615.71.09 on the RTX 5080 Laptop GPU
filters the same 3D image correctly, and the test passes there. So this is a
driver difference, and FAST-PATHS row 73's claim of the blit chain "where its
blits filter the format" did not hold for a volume on MoltenVK.
Following the runtime's driver-defect pattern:
- New RuntimeDriverDefect::VolumeBlitsUnfiltered, with Affected { MOLTENVK,
clean: &[] } in driver_defects.rs, keyed by driver as the other defects are,
never by the release. Its doc holds the measurement.
- `plan_mipmaps` takes the driver's defects. A 3D texture on such a driver
takes the compute filter (MipmapPlan::Filter) where the filter computes the
format. Elsewhere the blit chain stays, announced as before
(device-filtered-mipmaps). Nothing is refused, and no note is added.
- blit_texture.rs passes the device's defects. The mipmap_plan unit tests pass
them too.
- New unit test a_volume_takes_the_compute_filter_where_the_driver_s_blits_do_not_filter_it.
It fails without the change.
- tests/driver_defects.rs lists the defect for MoltenVK.
- api_signatures.tsv has the new variant, and FAST-PATHS row 73 names the
defect. REFUSALS.md regenerated with no change.
- mipmap_chains expects the compute filter for 3D textures where the device
has the defect, each level still within a code of the filter. Its diagnostic
print is removed.
Verified: cargo nextest run -p metal2vulkan-runtime for the mipmap_plan and
driver_defects tests passes, and the new test fails without the change. The
lane test's M3 rerun follows.
(cherry picked from commit a160bb01e43d7e5f4916b700012663a4020cf2a7)
(cherry picked from commit 7e77515beeb4d938a67de4b659ad31b8bed3394f)
|
||
|
|
7cc6570d70 |
Keep the device's half NaN bits where a mixed select meets another widened half
The MetalNanMoves carve-out (`narrow::moves_unfolded`) records no NativeNanEncoding for a module whose half moves Metal's compiler folds, as measured. hwd_half_reads falls inside it. Its read is a bounds-checked select of a widened half against 0, merged at a phi with another widened half. There MoltenVK on the Apple M3 Max quiets 2045 of the 2046 half NaN patterns to 0x7e00, so the stage answered the device's NaN with no note. (runtime_lane::driver_deviations::half_loads_the_device_widens_answer_as_metal failed.) The cause was measured with a probe of plain Metal on the M3 Max (macOS 27.0.1, MSL 3.0, fast and safe math), every half bit pattern widened, moved and narrowed: - Metal's compiler loses the payload in exactly one shape. A select of a widened half against a value it does not hold widened (`b ? float(h) : 0.0`) is merged with another widened value, `float(h2)` or `b ? float(h2) : 0.0`. - These shapes keep every NaN's bits: the select alone, a merge of widened values alone, the select merged with a constant, a select of two widened values merged with a third, a merge then a select, two selects, two merges, the select carried to a later block, and a select of the half bits before the widening. What changed: - `moves_unfolded` now answers unfolded for a module where that shape occurs (`merges_mixed_selects`). The merge may be a phi, or a function variable that takes the select and another widened store. The decision is by IR structure (selects, phis, stores and the widened set), not by any name. The meter's charge grows to eight bits per value for the two extra bit sets. - The MetalNanMoves fact's doc records the measured exclusion. - half_moves_are_metals_only_where_the_device_folds_them gains `merged_selection`, a phi of the select with the half itself, which must record the note, and `merged_selection_constant`, a phi of the select with a constant, which stays folded. The test fails without the rule. Note-set change on MoltenVK: a census of all 1518 committed fixture entries under the moltenvk-m3 facts, before and after, changes exactly one fixture. hwd_half_reads (.air.ll and .ll) gains PrecisionNote::NativeNanEncoding. Other drivers do not take MetalNanMoves and are unchanged. The private corpus has not been run. Verified: cargo nextest run -p metal2vulkan half_moves_are_metals_only_where_the_device_folds_them passes, and fails with the rule removed. The lane test's M3 rerun follows. (cherry picked from commit 93e75f343f814b66f0e53d2d7c1919ede193714d) (cherry picked from commit e753f582ec0dac067332fc7b39b007ec29e89fbc) |
||
|
|
3b07779331 |
Compare bfloat draws with a model of Metal's codes, a NaN's bits the device's
bfloat_draws_store_metal_s_codes held each draw's target bytes to Metal's
digest. Since
|
||
|
|
ef37fb2af8 |
Expect a constexpr YCbCr filter's notice to name its bound format
a_ycbcr_sample_through_an_unmeasured_filter_is_announced expected a constexpr
sampler's unmeasured filter (anisotropic, a linear mip filter, differing min
and mag filters) to announce the generic float-sample-filter. Since
|
||
|
|
7dbc98a73b |
Hold an sRGB RGBX write within the device encode's bound of its twin's
rgbx_writes_store_green_as_x writes the same floats into an RGBX texture and its RGBA8 twin, and requires equal bytes with X equal to green. For the sRGB twin, both writes are the MSL transfer by the device's `Pow` (FAST-PATHS row 67: an 8-bit sRGB storage texture through its UNORM alias). Each is within one code of Metal's (PrecisionNote::DevicePackConversion). The two modules' `Pow` answer otherwise for two of the 256 texels on the Apple M3 Max through MoltenVK 1.4.2, a code apart. What changed: - An sRGB texel passes if its X field is its own green exactly and each field is within SRGB_WRITES_APART (2) codes of the twin's, one code from Metal's on each side. - Where such texels occur, device-pack-conversion must have been announced. - Non-sRGB formats are still held to the twin's bytes. Verified: the test passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu), with two texels within the bound. (cherry picked from commit 178ae2f517cbf03bfbb6d918c600072292f9a12f) (cherry picked from commit fca95e4b465dc4b0ac71cb6c9d3521198443b5fc) |
||
|
|
f91b2c3a5f |
Expect draws carried across encoders in draw_work's shape test
Since 1924161016 a drawing state keeps the shape of a draw by value across encoders (WorkCounts::draw_shapes_carried), and the scissor rectangle is a dynamic state, not a shape input. The test expected the old per-encoder reuse, [0, 1, 0, 1, 0, 1, 0, 1]. The warm-up's encoder drew both pipeline states. So the first draw, and the first of the second state, are carried from it, and a draw under a changed scissor reuses its encoder's shape. Only the draw after a blend-color change derives its own. The test now checks both counters per draw: reused [1,1,1,1,1,1,0,1] and carried [1,0,1,0,0,0,0,0]. Its pixels are checked as before, and its doc says what each draw takes. Verified: runtime_lane::draw_work::draws_take_their_shape_from_their_encoder_s_draws_of_the_same_inputs passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu). (cherry picked from commit e8705d839ba20b75e8e57934f9036fd567e5d63e) (cherry picked from commit 44e920d792906d474d416783030da13b7ee95776) |
||
|
|
8aa0be310f |
Accept a heap sample's half a unit apart where it records HalfTexelConversion
heap_linear_samples_answer_as_slot_samples compares a heap texture's linear samples through its argument buffer's sampler with the same samples through a runtime sampler slot. On the Apple M3 Max through MoltenVK 1.4.2, 21387 `half` lanes of RGBA32Float differ by one ulp. FAST-PATHS row 67 states the contract: a `half` result is the device's `float` texel rounded to nearest even, where Metal rounds a 32-bit float texel's sample toward zero. The stage records PrecisionNote::HalfTexelConversion, whose bound is one `half` ulp. The slot's sample takes Metal's rounding; the argument buffer's takes the device's. What changed: - Each heap kernel's notes are read (`stage_notes`). Where a kernel records HalfTexelConversion, a `half` lane within one ulp of the slot's (`within_half_ulp`) is counted, not failed. Every other lane, and every `float` lane, is held as before. - Where such lanes occur, half-texel-conversion must have been announced. Verified: the test passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu), with 21387 half lanes within one ulp and none past it. The announcement check is new since that run, and the next M3 run covers it. (cherry picked from commit c0ec49ab8dad020627119cdc1e10f66b4d1cfba9) (cherry picked from commit b320f461e81c9193ca908063f4a5af972bd204ef) |
||
|
|
041c172223 |
Accept a minimum's zero of either sign where its stage records NativeMinMax
The denormal cases of owned_float_fixtures_answer_metal hold row 14, `fmin(a, b) * c`, to Metal's bits. Where the stage's `fmin` is the device's `NMin` (PrecisionNote::NativeMinMax), the note's documented bound lets the pick between +0 and -0 (or two denormals the device flushes) be either zero, so the product is a zero of either sign. Metal answers the second operand. Such words differ on the RTX 5080 Laptop GPU. What changed: - A zero of the other sign in that row is counted, and fails only where the stage does not record NativeMinMax. Any other word is held as before. - Where such zeros occur, NativeMinMax must have been announced. The test prints the count. Verified: the test passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu). There the stage records no NativeMinMax, and no zero of the other sign occurs. The RTX 5080 run is not done yet. (cherry picked from commit 314d98e383dfa071c389bed218497228b53ed728) (cherry picked from commit b788705cbb5ac646501f475a36f23f19167a9497) |
||
|
|
822263b1b7 |
Hold the precise trig at NaN operands to what its stage records
The owned fixture precise-trigonometric-functions-at-nan-operands-under-fast-math calls precise sin, cos, tan and sincos in a fast-math entry. MoltenVK compiles an entry in one math mode, so those precise calls take their fast forms. On the Apple M3 Max through MoltenVK 1.4.2, sin, cos and sincos of a NaN answer 0 (and other words keep payloads such as ffc00000 or 7fc12345) where Metal answers 7fc00000. The live stage already records PrecisionNote::DeviceTranscendentals and NativeNanEncoding, and the runtime announces both. Apple states no answer at a NaN operand under fast math. The test, though, held every NaN word to Metal's canonical NaN on a profile with MetalCanonicalNans. What changed: - owned_float_fixtures_answer_metal takes the case's notes. A NaN word's bits are the device's where the stage records NativeNanEncoding. A function's answer word (not the operand word, DFL_TRIG_OPERAND) may be a number where it records DeviceTranscendentals. - Each note the answers needed must be recorded. Every recorded note must be announced, checked once over the test's notices, so a once-per-device announcement is not lost between cases. - DeviceTranscendentals' doc (pipeline/artifact.rs) and its docs/API.md entry now say that a NaN operand may answer a number in such an entry. No note is added: the stage recorded both before the change. Verified: runtime_lane::driver_deviations::owned_float_fixtures_answer_metal passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu), together with the next commit's minimum rows. (cherry picked from commit 91f122b133c93af4b155a258d088e0001ff55a72) (cherry picked from commit 54a9b15a1fe0a27e8bf9d2a3a236813b9c117347) |
||
|
|
3f82c7841c |
Hold the fused pairs' half results within what their stage records
Two driver_deviations tests held a fast-math kernel's two `half` results, `fma(a, b, c)` and the contractible `a * b + c`, to Metal's bits. Two documented contracts allow them to differ: - FAST-PATHS row 60 and PrecisionNote::FastMathRewrites: a fast-math multiply contracting into an add is the device compiler's choice, unbounded where one side alone fuses it. MoltenVK on the Apple M3 Max does not fuse where Metal does (559 of 1024 threads, e.g. 7c00 against 7bff). - PrecisionNote::NativeFma: the device's `Fma` of the operands in `float`, its result rounded to `half`, is within one ulp. The RTX 5080 Laptop GPU answers a unit in the last place from Metal's in 300 threads. What changed: - half_fused_multiply_adds_the_device_answers_are_metals no longer requires Metal's high half where the stage records FastMathRewrites. The fma half is still held exactly. - fused_pairs_answer_metals_nans_and_denormals judges each half by the new `half_pair_within`. A half passes if it is Metal's (NaN bits as before), or within one ulp under NativeFma, or, for the high half, under FastMathRewrites. Both tests print how many words the notes cover. Verified: both tests pass on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu). The RTX 5080 run is not done yet. (cherry picked from commit 96d473efe5e9fece86ee5a8a85cb4fb32221cea4) (cherry picked from commit c14c15a0aed0b4d5bbab884c226d392a4d7187b2) |
||
|
|
9316966a50 |
Drop the fast tanh from the words float_functions holds to Metal's
Since
|
||
|
|
e60bffbd92 |
Expect the precise division's NativeDivision on MoltenVK in native_maths
The kernel's `a / b` is an `fdiv` without `arcp`, Metal's precise division,
which since
|
||
|
|
b26e5fe732 |
Answer a stage's function handle for its function however either was made
`LinkedFunctions::function_handle` matched the asked function against the stage's with `LinkedKey::same_function`, which tells a specialized function from an unspecialized one for the compile. Since functions made by descriptor are specialized (`Library::linked_function`), a stage that links `table_sub` by descriptor and compiled to a binary answered nil for `table_sub` made by name, where plain Metal answers its handle: `runtime_lane::function_tables::tables_and_handles_answer_as_metals_do` failed on the M3 Max (MoltenVK 1.4.2) and the RTX 5080. A probe of plain Metal on the M3 Max under macOS 27.0.1, with and without the validation layer: a stage linking `table_add` by name answers its handle for another by-name object and a by-descriptor object of it; one linking it by descriptor answers for a by-name object; one linking `table_sub` in `binary_functions` compiled to a binary answers for a by-name and a by-descriptor object of it, and nil for `table_add`. The handle lookup now matches with `LinkedKey::same_definition`: the same AIR, name, specialized name and constant values, whichever way each was made. The compile key, the handle numbering and the linking still tell specializations apart. Verified: the new `tests::engine_tables::a_handle_answers_for_its_function_made_any_way` passes and fails without the change (None for Some(3)); the engine_tables and pipeline::table tests pass. The lane test on the device is to be rerun. (cherry picked from commit cb9a0befe36a68b6aaa1f4bd736a642dc5fc2368) (cherry picked from commit 24d03525e7b37ea7ed86e1932e35dfe291dd292e) |
||
|
|
78f6377e4a |
FAST-PATHS: an empty command buffer is not submitted, so drop its old commit-to-completion number
The commit-to-completion entry measured an empty command buffer against a bare barrier (51.6 µs against 45.1 µs on a Radeon 780M). Empty command buffers make no vkQueueSubmit now; the submit path's bench measured commit and wait at 2.6 µs on the RTX 5080 and 1.8 µs on the M3 (p50). The timestamp cost on MoltenVK and its switch are unchanged. (cherry picked from commit f7abac8bbb7971b7bb9fd2c8638af94d7f96f51e) (cherry picked from commit bef265b91124cc376bbeda1fead475bd87ebf805) |
||
|
|
f559a257af |
Pin the runtime sources after compute's live bind state, commit_and_submit and the scheduler's wake
(cherry picked from commit d84bfecb47ea12c56e83deeda13bc91f0b021025) (cherry picked from commit 034037b93692a1291f817efea6dc35168de511e9) |
||
|
|
05734e88ab |
Bump RUNTIME_VERSION to 1743: compute bind state kept, holds once each, commit_and_submit and the scheduler's wake
A run of an unchanged artifact and plan now records what its compute dispatches did differently: the encoder keeps its bind state between dispatches and encoders (compute/live.rs) and its pipeline states four plans, which WorkCounts states in the new dispatch_shapes_made, dispatch_shapes_found, dispatch_used_resources_listed, resident_textures_looked_at and heap_tables_worked_out; and its encoders hold each shared object once and no resource twice (retained.rs, made_resident, blit_at's callers), so the command buffer's holds differ in number while everything stays held until completion. Command buffers gain commit_and_submit, which submits on the committing thread and runs submission handlers in ticket order on whichever thread passed, with new WorkCounts fields (scheduler_passes_at_commit, batches_submitted_at_commit); the scheduler's first waker of a sleep clears it as it notifies, so later commits make no system call. The Vulkan commands, barriers, notices and refusals keep their meaning at the same calls. 1743 is the lane's 1742 (shadow carries counted per queue) plus one; it stands for the compute bind branch's 1741 and the submit path's 1739. (cherry picked from commit 008ce90e680fc4521e386e5f23fc86a96fbb7839) (cherry picked from commit b53d0efcdda8081673cd3c36f4447d6c2532493e) |
||
|
|
8967688e5b |
scheduler: a waker notifies the sleeping thread once a sleep
A commit, or any waker, marks the scheduler's state under its lock and notifies the thread where it sleeps on its condition variable. The mark read `asleep`, which only the thread cleared, once it ran again. So every commit made between the first notify and the thread's run found it "asleep" and notified again: a pthread_cond_broadcast system call each, for a thread already woken. On the M3 the scout found 75 of the 153 commit samples in that broadcast. Now State::mark clears `asleep` as it answers OnCondvar. The waker that found the thread asleep notifies it; the thread then holds `dirty` and will pass, which takes in what any later waker posted, so a later waker answers No and makes no call. The nudge already worked this way (on_gpu cleared once signalled). No wake can be lost: - the mark is made under the lock while the thread is inside its wait (it sets `asleep` and waits with the lock released atomically), so the notify reaches it; - a waker after the notify finds `dirty` set, and the thread's loop exits on `dirty` before it can sleep again. The notify is notify_one: the scheduler's thread alone waits on that condition variable (stop keeps notify_all). Docs: the module doc's "Handed to the thread", State::mark, the asleep field, Asleep::No and WorkCounts::scheduler_wakes_commit (at most one waking a sleep). Tests (tests::scheduler_wakes, device tests): - a_burst_of_commits_wakes_the_sleeping_thread_once: 10 bursts of 48 commits made back to back after an idle gap. The wakings counted by commit, completion and host are at most the sleeps. M3: 10 wakings over 10 sleeps for 480 commits. Negative control (the clear removed): 242, 119 and 217 wakings over 10 sleeps, failed 3 of 3. - commits_with_idle_gaps_lose_no_wake: 4 threads, 400 commits each, with gaps of 0, 200 us and 2 ms, alternating commit and commit_and_submit. They never wait for a command buffer, which would submit for itself, and every one must complete with no 20 s stall. M3: 64 wakings over 64 sleeps, no sleep ended at its slice, 108 passes at commit. Commit cost, RTX 5080 Laptop, release, one thread never waiting (the committer's CPU per command buffer, before -> after): - cpu mode: 6.66 -> 6.69 us; - threads 1: 6.95 -> 6.92 us; - threads 8: 7.96 -> 7.89 us. That is no change within noise on that driver: its scheduler is awake for most commits at full rate. The M3 legs are measured separately. clippy -D warnings with and without --cfg m2v_gpu, and rustdoc, clean. (cherry picked from commit edb03d776967d2134e0d95ddb2362b5191b35a08) (cherry picked from commit 8952b8b88d7019389b920da104d72fbd03d7357d) (cherry picked from commit c1fe67d64055f93757b084afb0cc7ba3a88f7dcf) |
||
|
|
c6d2d52f0e |
video_interop: accept the first signal seen landed before the reads
a_raw_submission_is_ordered_by_a_shared_event_s_semaphore failed now and then on a loaded M3, either with "a submitted signal's counter: Reached" or with reserve_vk_signal giving (2, None) for (2, Some(1)). The test read the wait for value 10, and reserved the raw signal, right after wait_until_scheduled. Its first command buffer is a 4 KiB fill. Where the test thread woke from that wait late, the fill had completed and its signal had been seen landed by then. vk_wait then answers Reached, and the reserved signal comes after nothing. Both are answers the two calls document; the test assumed the first signal still pending. It now checks either: - counter 1 and after Some(1) (or None, where it landed between the two reads); - or Reached and after None. The raw submission waits for the fill's counter, 1, in every case: a wait for a value reached ends at once and keeps the copy ordered after the fill. Not a race in the runtime, and not from the empty-command-buffer or idle-wait changes. Measured on the M3 Max under a load average of 82 to 88, 250 runs each, one process per run: - c87df4e91a: 15 failed (12 Reached, 3 after None); - its base 17a1c34c1c: 13 failed (8 Reached, 5 after None). With a 20 ms sleep put in after wait_until_scheduled (a probe, not committed), the old test failed 20 of 20 at c87df4e91a, and this one passed 20 of 20. (cherry picked from commit ae9e4e9833a8878d6aebb9de7c8dec52ef912fbf) (cherry picked from commit 7157a14ae7c2d1b08d1d99d6c980b6be87a6d467) (cherry picked from commit 31f004aaec5cf5b3d52261b2227e282e649cd24a) |
||
|
|
65c0371cbf |
submit_path: the committing threads' own CPU
The threads mode's committing threads ended before the process-wide reading after the run, and their per-thread CPU went with them, so the CPU that commit_and_submit moves onto them was not counted. Each thread now reads its own CPU (CLOCK_THREAD_CPUTIME_ID) before it ends, and the mode prints their sum per command buffer. The main thread is grouped by the name's prefix too, since a copied binary runs under another name. Verified: clippy -D warnings on the example; run on the 5080 for the M1 and wake numbers. (cherry picked from commit 7822ca3293633c6da2fa4a1a734e137dc792ddbc) (cherry picked from commit 951eb7841e4274bce6b276d36ae89245ad554ba4) (cherry picked from commit 9e2d82e104f88da4f98cc14073a48f3eaaff97d8) |
||
|
|
431ebb90ad |
submit_path: --at-commit and a threads mode
--at-commit makes the latency, cpu and threads modes commit with CommandBuffer::commit_and_submit instead of commit. The new threads mode runs the cpu shape (a 16-byte fill with a scheduled and a completed handler, never waited for) on 1 and on 8 threads at once, each with its own queue, and prints command buffers a second in all and the CPU per command buffer. These measure the committing thread's own submission. Verified: builds in release; run on the M3 Max and the RTX 5080 Laptop GPU for the M1 numbers. (cherry picked from commit b100c3aa5c52d7d071223f7b6e500902afba5ccf) (cherry picked from commit a3d3d6ca16bd783b23298ac4d14b9fbe127dfe84) (cherry picked from commit dca3e8460fb5dfdb5d0bef3131af99776aebaeb3) |
||
|
|
36f5029870 |
commit_and_submit: the committing thread submits for itself
A runtime extension. CommandBuffer::commit_and_submit commits as commit
does, with the same checks and refusals. Then, where no submission pass is
under way, the calling thread becomes the passer (Scheduler::
submit_at_commit, Inbox::pass_once_then). It takes in the inbox and submits
the ready heads committed first, in commit order, up to PASS_SUBMISSIONS,
while each needs no host step, no submission check, no group, no storage-
form switch and no rebind (plain_ready with Passer::Committing:
submits_without_the_program's handler exclusion dropped, the rest kept).
Still counted as the passer and outside the state lock, it runs their
submission handlers, then lets go of what the pass held; a last reference
goes through let_go_elsewhere. It then counts out, wakes the scheduler's
thread where it left work or a commit was handed to it meanwhile, and makes
an owed completion turn. The commit is posted with no mark and no wake
(Inbox::post_quietly, Hand::Pass), so the scheduler's thread is not woken
for work the committer takes. A plain transition to Scheduled runs inline
as its batch is published; one with scheduled or submission handlers goes
to its queue's context as before. Called from the runtime's own threads (a
handler on the scheduler's thread or a waiter) it commits as commit does.
Plain commit is unchanged: Metal's commit returns before scheduling.
Submission handlers keep submission order whichever thread runs them.
Each pass that takes batches with submission handlers takes a ticket
under the scheduler's lock, in pass order (State::handler_ticket), and
runs them once every earlier ticket's ran (Turns). This departs from
the design's "handlers then count out": the scheduler's own pass counts
out before running its handlers, so a counted committer alone cannot
keep them in order. The new order test showed it: without the turns its
handlers ran out of commit order in 4 runs of 4.
Counted: WorkCounts::scheduler_passes_at_commit,
batches_submitted_at_commit (the conformance cost's scheduler_ and
batches_ prefixes already cover them). Docs: the method, the scheduler
and inbox module docs, add_submission_handler's thread bullet, the
runtime README's extensions, RUNTIME-PORTING, and FAST-PATHS's "commit
returns at once". api_signatures blessed (3 added); REFUSALS regenerated,
unchanged.
Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu:
- tests::commit_and_submit, 6 runs:
- the submission handler ran on the caller inside the call, reading
Committed, 40 of 40, with the scheduled handler on a handler thread;
- 1000 command buffers from 2 threads alternating commit and
commit_and_submit: handlers in commit order, 362 to 449 of them on a
committing thread;
- a checked head and the one behind it were left to the scheduler's
thread, with 0 batches at commit.
- Negative control: Turns::wait made to return at once failed the order
test 4 of 4 (e.g. 238, 239, 240, 255, 256, 241).
- The runtime suite: 1512 passed.
- clippy -D warnings with and without --cfg m2v_gpu, and rustdoc
-D warnings, clean.
RUNTIME_VERSION and the runtime-sources pin follow at hand-over, on the
lane tip.
(cherry picked from commit 5909e96c63004822e2a22d4cbf27b998f90e75a8)
(cherry picked from commit 40a67ba10398c38f13494fcdf3f64c2925f7eba8)
(cherry picked from commit 4270a52b85cfcd8c5a3cd8ea201b1a731a261eac)
|
||
|
|
29b5417902 |
submit_path: time GPU end to the handler, a bare variant, idle wakes
The bench example gains what the numbers for the completion path need: - latency rows also time the command buffer's GPUEndTime to the handler's start, both on the runtime's host clock (host_time), next to commit to the handler's start; - --bare adds the same rows with no scheduled handler: a lone 16-byte fill and its one callback; - an idle mode: after one fill, wakes a second over 3 s with nothing committed, as voluntary context switches by thread group on Linux (/proc/self/task/*/status) and, everywhere, the scheduler's sleeps and sleeps ended at its slice from the work counts. macOS's per-process switch counts read back inconsistently, so none is printed there. Verified: built in release on the M3 Max and run against 17a1c34c1c (completion-seen calls mapped to completed handlers) and c87df4e91a. (cherry picked from commit 32643c1ccb4ff129a5c799aeca0f2fa85a7ee844) (cherry picked from commit 793f74e38f19a26cdf1c510489daae307fa62219) (cherry picked from commit 85547774368e2efc0d2d29aa2fba7c1075448d88) |
||
|
|
4550740f2e |
Draw-again's check counts a hold found among those held lately as asked
Rebased onto draws again: an encoder now holds a shared object only where it is not among the last
eight it held (retained.rs), so a draw that takes every step and retains its index buffer again
finds it held already and keeps no second hold. Draw-again's debug check compared the encoder's
kept holds before and after that step and expected one more for the index buffer, so
tests::draw_again::indexed_draws_from_the_same_indices_draw_again failed ("a draw again held what
its kept draw did not").
Retained now counts, in builds with debug assertions only, the shared objects it found among the
last held (found_lately), and Retained::asked is the holds kept plus those. EncoderCore's
retained_holds, which the check reads, answers with asked, so the check still sees every hold a
step asked for, exactly as before: one more for the index buffer, none for anything else. Release
builds count nothing.
Verified on MoltenVK: draw_again, shared_draw_locks, draw_shape_notices and retained tests, 12/12
(indexed_draws_from_the_same_indices_draw_again failed before this change).
(cherry picked from commit 2225b740248dd5ec9f6656be1b4d4dbcb3910107)
(cherry picked from commit 8dcf1bba426b50089c00183b87f546df43223a6f)
(cherry picked from commit 4ed53997e5eb9f25363efabe584f06a1bea4f073)
(cherry picked from commit e157fe3a8ff0cac8d50d43675b927f3afb02616e)
|
||
|
|
e1c53c37ed |
A compute variant works out its heap tables once, and its commands take the heaps lock once
Each compute command whose layout binds the device's texture or sampler table read the layout again for those bindings and the table kind (allocating their lists), and took the device-wide heaps lock three times: for the highest texture ID placed and the texture table, for the sampler table, and in heap_sets::bind. - heap_sets.rs: TextureTableAt and SamplerTableAt work out from a layout where it binds the tables, over how many entries and of which kind, and keep each table's descriptor once read (the device makes each table once and never replaces it). HeapTables holds both; texture_table and sampler_table (render's calls, unchanged) build them per call as before. - The highest texture ID placed, for UnnamedTexturesPastCapacity, is stored under the lock as textures are placed and unplaced (DeviceShared::heap_textures_end) and read without it, so the notice is made at the same commands. - pipeline/objects.rs: VariantObjects::heap_tables makes HeapTables at a variant's first command; compute's record takes it there. TextureTable and SamplerTable borrow the bindings. - WorkCounts::heap_tables_worked_out counts the layout reads. The same descriptors, sets and notices. heap_sets::bind keeps its one lock. Check that fails without it: runtime_lane::resource_ids::a_variant_reads_its_layout_for_the_device_tables_once (four dispatches of a kernel reading a texture handle: [1, 0, 0, 0] layout reads; with the per-call form beside it, [3, 2, 2, 2]). Release, M3 Max, MoltenVK 1.4.2, host_ab encode, before (d6779a26d9) and after interleaved three times, us per dispatch (medians of 3 rounds; one thread, so no lock contention is measured): | workload | before | after | |---|---:|---:| | dispatch_handles | 1.075-1.115 | 1.047-1.076 | | dispatch_handles (process CPU) | 8.95-9.72 | 8.20-9.07 | | dispatch_static | 0.674-1.009 | 0.664-0.685 | dispatch_handles_rt_heap_tables_worked_out: 0.000 a dispatch after the first runs. Verified on MoltenVK: the runtime GPU suite 1505/1505; the validation runtime lanes 534/536 (the two failing the same at the base); resource_ids, heaps and argument-buffer lanes 153/155, the two (extended_range_two_planes::two_plane_heap_textures_read_and_write_as_metal_does, argument_linear_samples::heap_linear_samples_answer_as_slot_samples) failing the same at the base. (cherry picked from commit b9f35448fd3e947bb02a440a79eec2f9caf705ca) (cherry picked from commit c327b2e68c82f88698e85637569461b102bc51be) (cherry picked from commit c6ad3ecd67471216711b5410fbf35201c423f091) (cherry picked from commit 78be3664f4474a26221b82842cbe5c8df76fead3) |
||
|
|
05d0732d6b |
host_ab: dispatch_handles, dispatches of a kernel reading a texture through a handle
The encode workload's dispatch_handles variant dispatches tiny_handle_kernel, which reads a resident texture through its handle in an argument buffer (Gpu::texture_id writes the gpuResourceID on both sides), so each dispatch binds the device's texture table: the per-command heap-table cost is measured. encode takes the library to make its pipeline only where the variant runs. Verified: the example builds (clippy, all features). (cherry picked from commit 1d8f613081eec7cae21b1279e8661dfa2ab4b50d) (cherry picked from commit ec5573c6f17c7f404729a9811025beb688f46250) (cherry picked from commit de3aaea45f86a76432e6c459262f5612845d0194) (cherry picked from commit ca61dcb9423979f8397c674ef8a6b0809a1c99fd) |
||
|
|
81681968e4 |
Compute encoders look at their resident textures once a change, and usage shadows read without a lock
Each compute dispatch walked every resident texture for its shadows (shadow::shadow_uses), taking each texture's usage-shadow mutex, and each dispatch reading texture handles walked them again for one a carrier holds (pvrtc::degrade_unreadable); each encoder open walked every resident resource for shadowed textures (Residency::shadows). - shadow.rs: ResidentShadows keeps the resident textures' shadow copies, listed again only where the residency's generation or the device's count of usage shadows made (DeviceShared::usage_shadows_made) moved; shadow_uses_of takes the bound textures fresh, then the kept list, in the order shadow_uses took them. - pvrtc.rs: ResidentUnreadable keeps the first resident texture a carrier holds, found again only where the generation moved (a carrier and a decoded twin are fixed at a texture's making); the announcement is made at the same dispatches as before. - compute/live.rs: the encoder's kept state holds both lists, emptied when it goes to the spares. - texture/usage_shadow.rs: the usage shadow is a OnceLock read without a lock, made under its own mutex, and counted on the device once readable. - residency.rs: Residency::shadows walks the textures alone, in the order they were made resident. - WorkCounts::resident_textures_looked_at counts the looks. Bound textures are still looked at per command, now without a lock each. The same copies, barriers and announcements at the same commands. Render's draw and tile dispatch keep calling shadow_uses (render code; they can take ResidentShadows the same way). Check that fails without it: runtime_lane::dispatch_work::dispatches_list_what_their_encoder_made_resident_once_a_change now also makes 16 textures resident and counts the looks: (1, 0 per offset move, 1 after a buffer made resident); with the list made at every dispatch, each offset move looks again (1 for 0). Release, M3 Max, MoltenVK 1.4.2, host_ab encode, before (1b3fe1c315) and after interleaved twice, us per dispatch (medians of 3 rounds): | workload | before | after | |---|---:|---:| | dispatch_resident_textures_4096 | 35.4-35.7 | 0.76-0.78 | | dispatch_resident_textures_256 | 2.63-2.69 | 0.64-0.65 | | dispatch_resident_256 | 0.633-0.640 | 0.640-0.653 | | dispatch_resident_moving_256 | 1.569 | 1.575-1.581 | | dispatch_static | 0.655-0.669 | 0.673-0.676 | Verified on MoltenVK: the runtime GPU suite 1505/1505; the validation runtime lanes 533/535 (the two failing the same at the base); the shadow, usage-shadow and carrier lanes 52/52. (cherry picked from commit b01779101c7b6e05d435274ddd929da7441816df) (cherry picked from commit 0c35f13441cf9d4c8d1b788632b5edf65afaa78f) (cherry picked from commit 686656d2b2899865da6e5425125cdaf973e154c4) (cherry picked from commit a984fef4d783b985883318703f93b0f72c55e90d) |
||
|
|
255bf1401b |
host_ab: dispatch_resident_textures variants, 256 or 4096 textures made resident
The encode workload's dispatch_resident_textures_256 and _4096 make 4-by-4 RGBA8 textures resident (Gpu::use_textures, useResources:count:usage: on both sides) before the dispatches, so the per-command look at the resident textures (their shadows, their carriers) is measured. Verified: the example builds (clippy, all features). (cherry picked from commit 0e5d4af70d96037a4e4b37b20e385f94b883f1a2) (cherry picked from commit ac301360190ebbcce5a78c779c380a34c17c7326) (cherry picked from commit 1aba21ca33e4d78094ec95b1c02a5fb6e533d9ca) (cherry picked from commit e55669c56870f4127a1a264e447c8dff7bb2cf4f) |