2137a20004e2b5658aedd0bdfdafc99e043606ce
1530
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7996b9a164 |
Mark a queue long by its command buffer's own GPU time, not the host's view of its head's age
What: a command queue is now marked long where one of its command buffers' own timestamps (its first batch's start to its last's end) span over LONG_HEAD (2 ms), in the completion turn that read them (CommandBufferShared::place_gpu_times), before the turn finishes it. The waiter's host-age check in command_buffer/completion.rs (HeadWatch, Device::head_watch) is removed, and went_long returns at once unless the device shares. A device whose command buffers write no timestamps the host reads (gpu_times_from_host, a driver whose timestamps wait for every queue's, or no calibrated timestamps) no longer shares: queue_switch_check::timed() gates the check, and recall settles Unchecked and counts the new WorkCounts::queue_sharing_untimed where the device has two VkQueues of one family to share. Two runtime extensions, doc-hidden, for the lanes and the probe: CommandQueue::vk_queue_sharing() (its VkQueue and long mark) and Device::shares_vk_queues(). Why: the host's view of a batch's age as its VkQueue's oldest also holds its wait for the GPU to start it and the waiter's lateness to see it complete, so short command buffers marked their queues long for good. On the RTX 5080 Laptop GPU, 2x3 runs in a slow stretch had each thread's queue marked long mid-run (at 20 ms to 1,238 ms) and settled apart, the PerQueue placement, at PerQueue's rates. Measured cause, with a diagnostic build printing each host-age mark beside the command buffer's own GPU span: beside another process's 30 ms command buffers, draws of 11 and 16 us of GPU time were seen 2.0 and 2.3 ms after they became their VkQueue's oldest, 1.8 and 2.1 ms of that before they started; that run's thread queue settled apart and ran at PerQueue's 4.1k. In the runs without contention, every true mark had a GPU span within 1.2 ms of its host age (the 30 ms command buffers and the probe's 2.7 ms sizing one); under contention the sizing command buffer's host age exceeded its span by 4.2 ms. Neither suggested alternative fits: the false marks came mid-run, not only in a queue's first command buffers, and decaying the mark after short heads would let the trap and alternating shapes' long queues rejoin and stall the compositor again. Tests: tests::queue_share_device gains a_device_that_answers_gpu_times_from_the_host_does_not_ share_and_counts_it (expected, not run, to fail without the gate on the 5080: there it printed "Unchecked ... could share: true", so the recorded Idles verdict would make it share), and asserts queue_sharing_untimed == 0 elsewhere; its isolation runs print each queue's VkQueue and mark over the run. The queues lane's a_queue_joining_another_s_busy_vk_queue_is_announced_once now makes its device under QueueSharingPolicy::Adaptive (over the lane's exact_answers()), lets the busy queue's fills be submitted first, and asserts queue_joins > 0 exactly where the device shares, saying why where it does not. cross_queue_shadows gains the signal-in-between and the waiting-writer cases on one VkQueue: no spin, Adaptive, the check settled, queue 2 joining queue 1's busy VkQueue; they assert the join, neither queue long, the hold still withheld while the waiting writer has not completed, and the bytes. Docs: QueueSharingPolicy::Adaptive, the FAST-PATHS row (the rule, the untimed exclusion, the new ranges), docs/API.md (the policy section and the notice), the queue-sharing notice's cost text, queue.rs and queue_share.rs; api_signatures blessed (additions only). Verified on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, msi, under gpu-locks, no VM), release probe: - 2 threads x 3 in flight, 10 runs each in turn: Adaptive 48.3, 28.0, 50.7, 52.9, 28.1, 53.7, 48.6, 29.9, 31.5, 53.0k against PerQueue 21.4, 24.9, 27.8, 28.0, 27.6, 27.4, 27.1, 23.3, 26.9, 27.3k, Adaptive above PerQueue in each pair; no thread's queue marked long in any run (gone long 1 each: the probe's sizing queue). The 28-31k runs keep the shared placement, with waiter parks 0.23 against 0.02-0.05 per command buffer in the fast ones: a host-side mode, not a move. - Beside another process's 30 ms command buffers, 3 runs each: the old rule 4.1k (a thread's queue marked long by its host age), 5.2k, 6.6k; this rule 6.7k, 5.4k, 5.1k (no mark); PerQueue 4.1k, 4.1k, 4.0k. There, draws' own spans reached 1.16 to 1.52 ms (timesliced), under the bound. - Isolation, 3 runs each: trap and slow-alternating 64 completions over 10 ms under Adaptive (the one first-long stall, at most 26.4 to 30.1 ms) against none under PerQueue (at most 5.6 to 9.7 ms); alternating none under Adaptive (at most 5.7 to 9.8 ms) against 7, 0, 0 under PerQueue. Unchanged from the host-age rule's runs. - 8 threads: 3 in flight 53.4k, 54.4k against 27.8k, 27.4k; 1 in flight 50.1k, 49.3k against 14.0k, 13.9k. - Device tests (debug, --cfg m2v_gpu): tests::queue_share_device 8/8, the joining lane test and cross_queue_shadows 7/7 (the one-VkQueue cases: X's and Y's queues both on VkQueue 1, neither long, holds withheld 2, gated copies in 2). The compositor isolation test, old rule and new in turn, 3 each: p99 2.66-2.94 ms against 2.16-2.83 ms, 0 stalls, the same placement (the compositor alone on VkQueue 1, the application long on VkQueue 0, gone long 1). Its one earlier failure under this rule (p99 7.93 ms, 20 stalls, 5,579 of ~9,600 commits made) ran right after a 74 s compile inside the hold, with the same placement and gone long 1: host load, not the rule. On the M3 Max (MoltenVK, no sharing), tests::queue_share*, command_queues, cross_queue_shadows, gpu_time and host_memory: 90/90. clippy -D warnings plain and --cfg m2v_gpu; RUSTDOCFLAGS=-D warnings cargo doc; fast_paths, degradation*, api_signatures, api_surface, work_counts pass. No RUNTIME_VERSION bump or pin here. (cherry picked from commit 4fd88b7564cd9cd3651543bb3f8cd529b021709e, two claims corrected to what was run) (cherry picked from commit eb0153e9d0fe6d272f2411c65f0a1ecda2c78bc2) |
||
|
|
3e55a67849 |
Re-measure the C3 reference under this host's toolchain: Xcode 27B52, metal 32023.922
The M3 Max's toolchain moved from Xcode 27A266a (metal 32023.921) to 27B52 (metal 32023.922) on macOS 27.0.1 (26A434). corpus-metal refuses to record under an identity the reference list does not declare, so the list moves to the new toolchain and every committed authored case is qualified again on Metal under it. What changed: - cutover/c3-references.json names xcode_build 27B52 and metal_toolchain "Apple metal version 32023.922 (metalfe-32023.922.4)". The device, GPU cores, OS and OS build are unchanged. - corpus/observations/metal holds one fresh apple-m3-max-macos27.0.1 row for each of the 2263 committed cases. They were measured through the indexed path (corpus-metal --batch, default jobs, under the Mac GPU lock) and installed with corpus-metal --batch-install, the store's validated write. No other environment's row moves and no slot goes away. The re-measured rows were compared field by field with the committed ones, leaving out only the environment identity, oracle_abi and timing: - 2259 are equal in every field: 2249 against the old reference row, and 10 against the local-metal row of a case that had none. - 4 cases had no row and now qualify (the msl-4-1 atomics cases). - 0 changed status. 2263 rows carry the new identity: 2259 qualified and 4 reference gaps (GPUFamily10 simdgroup_matrix 16x16), as before. One case needed a second run: 81c239f3…, "tile-threads-8x8-in-a-16x16-tile-take-their-places". In the batch, Metal refused it twice: "Metal tile dispatch asks for 64 threads a threadgroup ([8, 8, 1]), but the pipeline permits 16". The cause is Metal's pipeline cache, not the toolchain. A tile render pipeline with threadgroupSizeMatchesTileSize off, compiled for the first time, reports maxTotalThreadsPerThreadgroup as the product of its requiredThreadsPerThreadgroup (8x8 gives 64). A later pipeline of the same function that differs only in that size gets the first one's value, in the same process and in later ones. In the batch, the 4x4 case of the same fixture (16 threads) ran before the 8x8 one. A from-scratch kernel compiled at run time with a salt shows the same thing under 32023.921 and 32023.922, so the old toolchain behaves the same way. Run alone, the case qualifies with output 188e2242…, equal to its recorded row, in all six runs since, across two builds, two environments, and single and batch mode. Its row here is such a run. A bug report draft with the from-scratch kernel is staged outside the repository, in the orchestrator's bug-drafts folder. No validation test or case-index entry reacts: no status changed. Verified: the whole metal2vulkan-validation suite (1363 passed, 4 skipped) with the list and the 2262 batch rows installed. Then, after the tile row, its case, observation, store, reference, corpus and census tests (cargo nextest -E 'test(/case|observation|store|c3|reference|committed| corpus|cutover|census/)'): 405 passed. (cherry picked from commit 175d5f044aa526850b469ccfdb7758b36c442463) (cherry picked from commit b1fe02a98c37ef685ab933426bb166258e27852c) |
||
|
|
26ee8643da |
Re-bless the authored compile census: 10 new cases, artifacts at this build
The census on development
|
||
|
|
ee3b71ee64 |
Record the command recorder's sharded counts in the signature table
The recorder's commands! macro now reads per-thread shards (CommandsRecorded::read takes &[Shard; SHARDS] and each thunk counts into its thread's shard). The draw-fast commit that made the change left the table's record of the macro body at the single-array form, so the_public_signatures_are_the_committed_table failed on the stack. Verified: signatures.py --check passes after --bless; the diff is that one record. (cherry picked from commit 6c9d152e28a4057ddcd577d4876711a240a985d5) |
||
|
|
3684e795d8 |
Pin the runtime sources after draws rebound after buffer, texture and sampler binds
(cherry picked from commit cc91867c8a204aadfb14acf3099a584398388293) |
||
|
|
9d058c707a |
Bump RUNTIME_VERSION to 1751: draws rebound after buffer, texture and sampler binds
A run of an unchanged artifact and plan may now record other commands' timing and take other steps than before. A render encoder's direct draw that repeats its last one, after calls that bound other buffers, offsets, bytes, textures or sampler states at slots of its tables, rewrites those slots alone (render/draw_again/rebound.rs; WorkCounts::draws_rebound). It has the same commands, set-0 writes, dynamic offsets, push bytes, vertex buffers, uses, barriers, notices, refusals and retains as the draw taking every step, and records only the state commands that changed before its draw. A draw after a sampler state is made or released takes every step, as its kept draw read the device's sampler listing. Draws again and rebound draws count into per-thread shards as they record. 1751 is the lane's 1750 (shared linked pipelines) plus one. (cherry picked from commit 5f9d5720885ec8d303e703b76aac416cbd5964bf) |
||
|
|
df7b5d3310 |
Count the stage tables a rebind brings in where it reads them
A draw after calls that changed its tables brings the changed slots into the kept draw's bind state (rebound::bring_in) and marks the tables read, before it decides whether it is rebound. The draw rebound counted those reads (stage_tables_read and stage_tables_read_in_part), but a draw that then took every step did not: its rebind stopped (a slot it cannot rewrite, a changed shape), or it was the draw rebound that the debug check takes every step of. Its every step found the tables read and counted nothing, so the device's counts left out reads that happened. bring_in now counts the tables it reads in part as it marks them read (Counters:: tables_read_in_part), whatever the draw does next; draw_rebound counts the draw alone. This is what runtime_lane::draw_work's a_draw_reading_its_tables_in_part_brings_in_each_setters_slot, draws_read_only_the_stage_tables_a_call_changed and draws_reading_a_no_copy_buffer_s_binding_look_where_it_lies_once measured short on the M3 Max with debug assertions: 2 of 13 reads in part; no read where a bytes call changed 1 or 2 tables; 4 of 7 reads. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions: those three lanes pass, among the validation crate's runtime lanes (frame_costs, render, draw_*, hazards, sync_coverage, shadows, attachments, executions, degrade_notices), 288 of 288; the runtime's whole suite, 1545 of 1546 (the one failure, tests::scheduler_wakes:: commits_with_idle_gaps_lose_no_wake, passed 10 of 10 reruns). Clippy over the workspace, plain and --cfg m2v_gpu. (cherry picked from commit d8ceaa4b35d66283e8e13ffb91d919528b72b788) (cherry picked from commit 198956b1362eadd9d71bed11dbfb2f31440c437d) |
||
|
|
df985fbacb |
Check a draw again against its every step by digests: the check allocates nothing
In builds with debug assertions every second draw again (and rebound draw) takes every step and checks it against what the draw again would have done. The check boxed itself (Again::Check's Box<Checked>) and cloned what it compared: the drawn areas and coverage, the pass's reads and the instance's gathered uses (HeldReads, HeldGathered: copied lists), the noted uses, the pass's input and extended sets, and of a rebound draw its commands, set-0 writes, offsets, push bytes, vertex buffers, uses and resident keys. Those allocations count in the frame lanes' draw allocations, which CI runs with debug assertions: runtime_lane::frame_costs' a_frame_s_draws_and_pass_ends_allocate_within_their_bounds measured 22.30 allocations a draw on the M3 (bound 20) once draws rebind. Each part is now compared by a digest of its Debug form, streamed into a hasher through a fmt::Write adapter (draw_again::digest), which copies nothing. The encoder's held state is taken only for a plain draw again (Expected::Plain; a rebound draw's check compares what it worked out, Expected::Rebound). Checked is no longer boxed: the draw path hands draw_again an Option<Checked> on its stack, which kept_again takes as before. pass_start_reads::held and shadows::gathered lend their lists rather than copy them; binding::Info and NotedApart print their Vulkan values raw (ash's types print nothing without its debug feature). Release builds are unchanged. No bound changed. Measured on the M3 Max (MoltenVK 1.4.2), with debug assertions: that lane's draws make 18.21 allocations a draw (was 22.30; bound 20); a pass end 15.67, a pass open 5.00. Negative control: with binding::rebind_into's image descriptors left as they were (the rebind's texture path broken), tests::draw_again::draws_after_texture_and_sampler_changes_rebind_what_every_step_binds fails with "a draw rebound worked out other set-0 writes than its every step". Verified there, --cfg m2v_gpu, on a tree that also held the next commit's change: the runtime's whole suite, 1545 of 1546 (the one failure, tests::scheduler_wakes:: commits_with_idle_gaps_lose_no_wake, passed 10 of 10 reruns); the validation crate's runtime lanes listed in the last commit, 288 of 288. Clippy over the workspace, plain and --cfg m2v_gpu; release builds check clean. (cherry picked from commit 1b8e52fe2f58f01df507d4f9b345dcb901c16ca2) (cherry picked from commit 838786566146858e00b579ebc78240353fa87061) |
||
|
|
6980b529dd |
Count draws again and rebound draws as they record, into per-thread shards
A render encoder's draws again and rebound draws added their counts to the device's only at the encoder's next call that forgot the kept draw, or at its end (draw_again::Counted), so that no draw took a shared atomic add: draws_as_before, draws_rebound, commands_noted_as_before, draws_pushing_set_zero, provoking_last_pipeline_draws, the stage tables they read in part and the state commands and set-0 writes they recorded. A reader of WorkCounts between draws saw none of them. Those counts, and the other counts the draw paths add per draw (stage_tables_read and _in_part, draw_states_recorded, set_zero_writes_pushed), now live in per-thread shards: shards.rs holds the recorder's shard scheme, moved out of recorder/thunks.rs, and a generic Sharded<T> of 16 shards on 128-byte lines; each thread adds into its own shard (threads past 16 share them in turn) and WorkCounts sums them. A draw counts as it records: one thread-local lookup, and atomic adds on a line no other thread writes. The deferral and forget_again's flush are gone; the WorkCounts docs no longer say the counts wait for a call. Checks: tests::draw_again::draws_again_and_rebound_count_as_they_record reads draws_as_before and draws_rebound before each draw, with no call between but the binds a rebound draw takes; under the deferral every read is 0. tests::recorder_shards::a_sharded_count_is_every_thread_s_additions sums 19 threads' additions over the 16 shards. Cost, M3 Max, release host_ab encode, one session, per draw (instructions retired and cycles over 23 passes of 10000 and of 30000 draws), before -> after: - draw_static (draws again): 2018 instr, 450 cycles, 0.110 us -> 2042, 639, 0.115 us; - draw_offset (rebound draws): 12452 instr, 2376 cycles, 0.554 us -> 12357, 2442, 0.563 us. The same within the runs' spread: a draw's adds land on its thread's own line. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions, on a tree that also held the next two commits' changes: the runtime's whole suite, 1545 of 1546 passed (the one failure, tests::scheduler_wakes::commits_with_idle_gaps_lose_no_wake, passed 10 of 10 reruns); the validation crate's runtime lanes (frame_costs, render, draw_*, hazards, sync_coverage, shadows, attachments, executions, degrade_notices), 288 of 288. Clippy over the workspace, plain and --cfg m2v_gpu; the runtime's Rustdoc. (cherry picked from commit c26838fdd2abe5bcaa5e3ecb2ed9477721b017dc) (cherry picked from commit 643246f591c39b40c0d7d00f68f8768457673bdf) |
||
|
|
85c6c786d0 |
List the rebound draw's kept recording among the modules that keep device functions
A kept draw's recording (rebound::KeptRecording) holds its index bind (draw_source::IndexBind), which keeps the device's sized index bind command where the device has it. The exit guard's tests::exit_guard::only_the_listed_modules_keep_the_device_s_functions lists every module that keeps a copy of the device's functions with why it may, and failed on the unlisted render/draw_again/rebound.rs. It is listed: the recording is held by its encoder's bind state (a spare one by the device's, which the teardown ends) and recorded again only by the encoder that kept it. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions, on a tree that also held the next commits' changes: the runtime's whole suite, 1545 of 1546 passed, this test among them (the one failure, tests::scheduler_wakes::commits_with_idle_gaps_lose_no_wake, 69 wakings over 68 sleeps, passed 10 of 10 reruns on the same tree). (cherry picked from commit 921cfd22688850e5392ee455dec82c27cdeb1234) (cherry picked from commit 383e74af1eaf0aceb4e600d5502f6a408c9c1517) |
||
|
|
3a8b56ecc7 |
Take every step of a draw after a sampler state is made or goes: its kept draw read the listing
Every step of a render draw lists the device's live sampler states again where their slots changed since its bind state listed them (LiveBind::listed_at, Device::sampler_slots_changed). The listing goes into the bind state and so may change its shape. A draw again, and a draw rebound, took the kept draw's bind state as it was: after a sampler state was made or dropped between two draws, they skipped the listing and the reshape that every step would make. The kept draw's Under now holds the count of the sampler IDs' slots' changes. A draw under another count is not the kept draw again and takes every step. The count is one Acquire load a draw, with no read-modify-write. Check: runtime_lane::draw_work::draws_take_the_device_s_sampler_states_only_where_they_changed (draws rebound after set_vertex_bytes: a state made before column 3's draw, gone before column 6's). With the bind tail and without this, the M3 counted [0, 0, 1, 0, 1, 0]: the listing came one draw late, at the debug check's draw that takes every step. The test expects [0, 1, 0, 0, 1, 0]. (cherry picked from commit d8bf1bcf383b7e746916d8f0dbbf769e0a60d4ae) (cherry picked from commit 1a2b148ba4145da26a456ea52b6fc249b14aaeb4) |
||
|
|
50b41ecc54 |
Draw the kept draw again rebound after texture and sampler binds too: rewrite those slots alone
A vertex or fragment texture or sampler bind forgot the encoder's kept draw, so a draw after one
took every step: the compositor shape (a buffer and a texture bound before each draw) never
reached the bind tail.
Now:
- Texture and sampler binds keep the kept draw (log_keeping), as buffer binds do; the next draw
compares the tables' stamps.
- BindingPlan::rebind_draw_slots_into (was rebind_draw_buffers_into) takes buffer, texture and
sampler slots. A texture or sampler slot decides none of the commands. It answers Ok(false)
for a texture buffer's texel range and a YCbCr texture's planes.
- binding::rebind_into writes a changed texture's or sampler's image descriptor as bind_into
does (image_descriptor, through the encoder's memo, its samplers kept for retaining). It
answers Ok(false) for a changed texel buffer, YCbCr image or argument sampler.
- The draw rebound brings in texture and sampler slots and stops where every step would differ:
- a memoryless texture its functions use (the full path fails the command buffer there);
- runtime samplers' address modes other than the kept draw's;
- a changed shape (a sampler of other addressing, which the pipeline's specialization
reads, takes every step);
- a plan that samples or writes a color attachment's texture;
- an extended-range shadow.
It retains the new samplers and notes whether its uses read an image (Kept::reads_images).
- Docs: rebound.rs, WorkCounts::draws_rebound, docs/API.md, api_signatures.tsv.
Check: tests::draw_again::draws_after_texture_and_sampler_changes_rebind_what_every_step_binds
(tob_sample). It covers another texture each draw, another sampler of the same shape, both,
and samplers of other addressing. It checks rebound counts (0 for the last), commands, state
commands, noted uses and pixels against every step, with the debug cross-check on every second
hit. It fails without the change (0 rebounds). The buffer test's slot-of-another-class case is
now more slots than a draw rebound takes (samplers 0 to 8). Passes on the M3 (MoltenVK) with
the draw_again tests; clippy clean, plain and with --cfg m2v_gpu.
(cherry picked from commit ecf97956b214836a1309affe539aff8454239e97)
(cherry picked from commit 8472edf4c0ae174c3dab7bc667cecfa6874aa942)
|
||
|
|
01f40bb3f4 |
Hold a render encoder's current instance in its lowering's box: a pass open makes no box of it
1aaf95c79f boxed the current instance (1656 bytes) so that the encoder's moves at its pass end carried a pointer. That made one more allocation at every pass open, on every device: runtime_lane::frame_costs::a_frame_s_pass_opens_allocate_within_their_bound measured 6.00 a pass open on the M3 (bound 5.5) and 5.00 on NVIDIA (bound 4.5). The instance now sits unboxed in the RenderLowering, which is already boxed once where it is built. end_pass lists the pass's instances in the earlier instances' vector, the current one pushed last, in place of a vector of boxes; a split still boxes the new instance it hands back (Next::New) and unboxes it into its place. OPEN_ALLOCATIONS' doc says where the instance lives. Not done: keeping the emptied instance box in the draw room. end_pass moves the first instance's pieces, earlier steps, shape, positions and kept commands out to the pass's steps, so keeping its box would need placeholder moves or a change to how long the steps live. Verified: builds (cargo check, all features); the frame_costs lane runs next on MoltenVK. (cherry picked from commit e4fb5fcd47c4a3bd97e1ef9a021d3c466291ac19) (cherry picked from commit 15c0626814a8e8e75c30c105c1a69f7f8dd3ea0e) |
||
|
|
d6302220bf |
Count recorded commands in per-thread shards: threads that record at once write apart
The recorder counted each command with one relaxed fetch_add into a single array per device slot, so every thread recording at once wrote the same cache lines. On the 5080 a draw drawn again (a Vulkan draw alone) cost 0.060 us of thread CPU on one thread and 0.232 us on eight. Each slot now keeps 16 shards of its counts, each aligned to 128 bytes. A thread takes the next shard at its first count (a thread-local, one fetch_add per thread, not per command) and keeps it; threads past 16 share them in turn. WorkCounts::commands_recorded reads the sums, so the counts mean what they meant. Measured on the 5080 laptop (host_ab threads, 10000 draws, 32 timed passes, one round, under the GPU locks, SCHED_OTHER), landed tip vs the bind tail plus this (a static draw takes no part of the tail): - draw_static, one shared state, thread CPU us/draw at 1/2/4/8 threads: 0.060/0.092/0.149/0.232 -> 0.065/0.062/0.059/0.065; Mdraws/s 16.9/21.1/25.8/30.9 -> 14.1/30.8/49.7/87.8. - draw_static, a state per thread: 0.061/0.099/0.126/0.202 -> 0.058/0.062/0.059/0.062; Mdraws/s 16.2/19.9/31.0/35.1 -> 18.7/32.6/59.8/94.6. Check: tests::recorder_shards::threads_count_into_shards_of_their_own (as many threads as shards each count apart, and the next shares the first's): passes under nextest. clippy clean. (cherry picked from commit 43ac1c48e746d592055aa5e0606cf79e8ebaedd7) (cherry picked from commit ada254765fb0a09294b03a1ad17428a111c8192b) |
||
|
|
e3f2c95dfe |
Draw the kept draw again rebound: after buffer, offset or bytes binds, rewrite those slots alone
A render encoder's kept draw (render/draw_again.rs) drawn again after calls that bound other
buffers, offsets or inline bytes at vertex or fragment buffer slots now rebinds only those slots
(render/draw_again/rebound.rs, WorkCounts::draws_rebound), where it took every step of a draw.
- Translator: BindingPlan::rebind_draw_buffers_into(state, slots, commands) writes again, over
the same draw's commands of a state of the same shape, only what the buffer slots decide: their
descriptor ranges at their places, the SlotBindOffset, SlotGuestBase and pulled-stride push
fields that read them, and their vertex buffers' offsets. Ok(false) for a device-address slot,
an argument or root table, a per-bind stride's vertex binding, a mesh, patch or de-indexed draw,
or a uniform view a written slot may alias. docs/API.md says so; api_signatures gains it and
WorkCounts::draws_rebound.
- Runtime: buffer and bytes binds keep the kept draw (log_keeping); the draw compares its tables'
stamps with the kept draw's. On a difference, the tables' changes since (argument_table::
changed_since: buffer slots alone, at most 8) are brought into the kept bind state
(refresh_changed), and the draw goes on only where its shape stays, its variant and plan then
the bind state's kept settle (LiveBind::settles_kept). It rewrites the commands
(rebind_draw_buffers_into), set 0's writes and dynamic offsets (binding::rebind_into), push
bytes and vertex buffers, and its uses whole (command_uses_into), and takes the checks a draw
takes of them: a pulled attribute's reach, the stages' function tables, the attachments' reads;
it stops at a pass whose fragments wrote memory, a shadowed texture among its uses, a barrier
its fragments need after earlier geometry writes, or a detached buffer. It records with set 0
as any draw finds or writes it (EncoderCore::set_zero_of), its uses noted as any draw notes
them, through the kept draw's recording parts against what its command buffer holds; a notice
met at each occurrence forgets it once recorded, as every step does. The kept parts (set-0
writes that hold no keeper, dynamic states, the rest of its recording) live in the bind state's
storage (LiveBind::kept), filled at the keep alone: a draw that takes every step pays one
KeptStorage::keep and nothing per recording.
- Checked in builds with debug assertions: the first rebound draw of a kept draw and every second
after it take every step instead, which must keep the draw, with the same commands, set-0
writes, dynamic offsets, push bytes, vertex buffers and uses.
Tests: tests::draw_again::draws_after_buffer_changes_rebind_what_every_step_binds (MoltenVK, M3):
draws after offset and bytes changes rebind (draws_rebound == the draws again but those the check
takes), with the same commands of every kind, state commands, noted uses and pixels as the same
draws each taking every step, every draw at its own offset and color; a sampler bind between them
takes every step. Negative control: the translator not rewriting a changed slot's range fails it
at the cross-check ("other commands"). metal2vulkan's tests::engine_graphics_binder rebind test:
1360 rebinds over stage-io plans equal a full instantiate, and its negative control fails.
host_ab encode, release, 10k draws per command buffer, us/draw, offset case (one
set_vertex_buffer_offset before each draw), measured on this change before its last revision
(which moved the kept parts' fill from every full draw's recording to the keep and dropped three
Arc clones a keep; its own numbers come with the next landing):
Apple M3 Max, MoltenVK 1.4.2, three interleaved rounds (median / mean of round p50s / max p90):
lock fix 1.561 / 1.550 / 1.591 -> 0.550 / 0.548 / 0.592
RTX 5080 Laptop GPU, thread CPU per draw, host_ab threads workload, one thread:
lock fix 2.006 (shared PSO), 2.001 (own) -> 0.541, 0.585; on 8 threads 10.3 Mdraws/s (was 2.9)
The unchanged draw (static) holds: 0.044 -> 0.046 on the M3.
(cherry picked from commit 2ee3520ff104094afde523e2eebf7bc8a9a9626d)
(cherry picked from commit d00975ea7da92da4886a29f1ebda6397f64202b1)
|
||
|
|
658e5ced81 |
host_ab: the compositor stand-in, passes of 300 draws each binding its own buffer and texture
The encode workload's `draw_compositor` variant draws as a window server's frame draws: render passes of 300 draws (the first clearing the target, the rest loading it), before each draw another vertex buffer and offset and another fragment texture bound (as `draw_bind`), and every run of 10 draws drawn by the next of three pipeline states reused every frame: the two textured states (`quad_vertex` + `textured_fragment`, without and with blending) and a solid one (`quad_vertex` + `icb_draw_fragment`, blending, which reads no texture), the Scene's new `solid`. It stands in for the shape a guest compositor's main command buffer takes during a window drag: a few hundred draws a pass whose buffers and textures change between draws, its pipelines the same across frames. Per draw: the encoding thread's wall time and the process's CPU time, as every encode variant. Verified: the example builds (release) on the M3 and runs its variants; its numbers come with the commits that measure against it. (cherry picked from commit 89cd071b0d416127c483900ccbbcabee04dc6fa0) (cherry picked from commit f4d394f7d12a12f937e455f52ec6b5f3ce7b53f0) |
||
|
|
9ec100ba7c |
conformance cost: RACY holds 38 rows with linked_pipelines_shared beside commits_taken_in
Two commits each added one row to the racy-count table from bases that held 36 (the shared linked pipelines' linked_pipelines_shared, and the taken-in wait's commits_taken_in); the cherry-pick kept one length, so the array's stated length was 37 for 38 rows and the conformance crate did not compile. Verified: clippy -p metal2vulkan-conformance --all-targets --all-features -D warnings clean. (cherry picked from commit 357a76f214273dd25e3caa905336fce7b7548135) |
||
|
|
14a73185a2 |
Pin the runtime sources after the empty fresh log's skipped lock and the warm budget's docs
(cherry picked from commit 0222da037d4a9883995cf96dd7645081ad3f00ab) |
||
|
|
d07650b362 |
Warm passes: judge the byte budget on every device, and say what pipeline_bytes counts
What: tests::warm::a_byte_budget_stops_the_pass no longer skips its 1-byte leg when the pass counted no driver bytes. That leg runs over a directory of its own, which holds none of the records' driver data, so it now asserts that the pass wrote records' data (driver_saves > 0), counted it (pipeline_bytes > 0), and stopped after the first record, on every device. A new test, a_pass_over_its_records_own_directory_counts_only_what_it_writes, warms records over the directory whose creations made them and asserts that the pass counts driver bytes exactly where its makings wrote data. Where it wrote none, it asserts that a 1-byte budget stopped nothing. WarmStatistics::pipeline_bytes, Device::warm, the runtime README and docs/HOWTO.md now say that a making whose data the directory holds already adds nothing. Over that directory the budget binds only where a making writes new data. Why: the consumer read pipeline_bytes 0 on every boot of the RTX 5080, though the warm pass made 248 pipelines, and asked whether the counter is broken there (a making's keep on a thread without the pass, or a path that never keeps). Measured with a scratch diagnostic at 1bb0b87a5a, not committed: - RTX 5080, a fresh directory: 23,800 bytes counted, 3 records' data written. - The 5080 over the records' own directory: 0 bytes, 0 written, 2 unchanged, 2 found. - M3 Max on MoltenVK 1.4.2: 13,362 bytes and 3 found respectively. So keep() runs on the pass's thread and counts on NVIDIA too, and the consumer's 0 is the true value. Their records come from the boot before, over the same directory, whose creations wrote every making's data. The old test's skip branch could have hidden a broken counter; now a pass that writes data and counts none fails. Verified: tests::warm on the M3 (MoltenVK 1.4.2), 6 passed. The 1-byte pass over a fresh directory counted 8,003 bytes with 1 record's data written; the pass over its own directory counted 0 bytes, wrote 0 and found 3. cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings with --cfg m2v_gpu; public rustdoc clean. The RTX 5080 run is in the hand-over. (cherry picked from commit 83cc2dbe6fb610c6ad59a741a7170812611cf703) (cherry picked from commit 1d43003372f23275ceb7fcc463a34abedbeff9a7) |
||
|
|
376d835a4f |
Take no lock of a command buffer's fresh-texture log at a commit that logged nothing
What: FreshLog keeps a flag, set where FreshLog::add pushes an event. FreshUnwritten::commit returns before it takes the log's lock where the flag is clear, as it already did where no texture is noted. A commit that logged something takes the log as before. Why: host_ab percall's commit rows failed on gate/stack11: commit_one_dispatch 5 allocations a call (held to 4) and commit_no_copy_dispatch 10 (held to 9). e3b963bdc0 measured 4 and 9 on 9f56956ef3, before the pattern reads moved to the commit (95d7bdf6dc). Since then, while any noted texture is live in the process, every commit locks its command buffer's FreshLog mutex, in these rows for the first time: their dispatches bind only buffers and log nothing. On macOS a std Mutex makes its pthread mutex at its first lock, one allocation (Rust 1.98.1 on the M3: 4 allocations for the first locks of 4 new mutexes, 0 for the second locks). The trace put that allocation in FreshUnwritten::commit, the fifth of the commit's sites. The other four (Predication::end_unit, close_tail, the BatchSync list, gate::Hold::new) are the ones the rows were measured with. Verified: - host_ab --only percall --rounds 1, release, Apple M3 Max (MoltenVK 1.4.2), on 4f0a1043b1 with this branch's two commits before this one, the gate made to print: commit_one_dispatch 4 and commit_no_copy_dispatch 9 allocations a call (stack11 with those two commits: 5 and 10). No row of the gate fails in that run: end_render 24, end_compute 7, end_blit 7, heap_texture_256 17.25, the draws 0.0390625, dispatch 8.13. - The traced commit_one_dispatch lists Predication::end_unit, close_tail, the BatchSync list and gate::Hold::new, the four a trace of 9f56956ef3 lists, and no FreshUnwritten::commit. - tests::fresh_unwritten (8), tests::tracker and tests::heap pass under --cfg m2v_gpu on the M3 Max (93 of 93). - cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings, plain and under --cfg m2v_gpu: clean. The rows already hold the counts this restores, so the gate itself is the check: it fails without this change. No answer, announcement or submission changes (a log with no events gave the record nothing), so RUNTIME_VERSION stays; the runtime sources' pin moves with fresh_unwritten.rs. (cherry picked from commit b878f5b569662b4fcf45c23ef84e619e5e212ea6) (cherry picked from commit 6c70d5b7e01a874aa2cfde501b024cea394209d4) |
||
|
|
a977bbbe45 |
Pin the runtime sources after shared linked pipelines and the small encoder parts' stack order
(cherry picked from commit 873c932fa849d07da1d3d9186412d8044042c39c) |
||
|
|
e6f3c91973 |
Bump RUNTIME_VERSION to 1750: render variants of one link share its linked pipeline
A run of an unchanged artifact and plan on a device that links pipelines from libraries now takes the device's linked VkPipeline for a render variant whose four libraries and pipeline layout equal one already linked (a content-keyed map; WorkCounts::linked_pipelines_shared), where it linked a duplicate before; teardown drains the links before the libraries. Elsewhere nothing changes. Encoder ends order a small part's resources on the stack and a heap texture asks whether a shadow fits only where its images do not, which changes allocations alone. 1750 is 1749 (commits taken in) plus one. (cherry picked from commit 2d9d5868bce2b1ddc1b46bf15d0901f320e6ffd3) |
||
|
|
7c142e9a12 |
events: hold the post-commit scheduled-signal claim's command buffer behind an event
a_scheduled_signal_sets_its_value_as_the_command_buffer_is_scheduled encoded a scheduled signal right after committing a 64-byte fill and expected Ok(()); a call after the command buffer completed is refused (ScheduledSignalAfterCompletion, claimed just below), so where the fill completed before the call the claim failed. That happened once in stack13's lane under -j 6 load (10/10 alone). The command buffer now waits for an event the host signals only after the call, so the call always lands between its commit and its completion; the claims are unchanged. (cherry picked from commit d6771add4d5d8c009352d51543ca897f69fe94fd) |
||
|
|
e70d81dc6c |
made_at_creation: the second state of one link takes the first state's linked pipeline
What: runtime_lane::made_at_creation::states_of_one_fragment_and_pass_share_its_fragment_library now expects the second state (its attachment blending with factors one and zero, which makes no library: the four parts and the layout are the first state's) to link nothing and make no pipeline, and to take the first state's linked pipeline (WorkCounts::linked_pipelines_shared + 1), where it linked a pipeline of its own from the same four libraries before. Why: 22b2fd234e shares a linked VkPipeline between render variants of the same link; this lane held the old re-link. It is the shape the change is for: a state of its own whose whole key is the first state's. Verified: on the RTX 5080 (msi, no VM, under the GPU lock) the lane passed on d3e66f9415 and failed on 22b2fd234e with (0, 0, 0, 0) where it held (0, 1, 1, 0); the run of this commit is in the hand-over. (cherry picked from commit 9026d6e92c99425950099fd2387178d6021a03b1) (cherry picked from commit ac134c2420fe1151064ddba8221f032bafe38dc8) |
||
|
|
29550063fe |
Share one linked VkPipeline between render variants of the same link
What: where the device links its render pipelines from graphics pipeline libraries, the linked VkPipeline is now the device's, held in a content-keyed map (pipeline/libraries.rs) beside the four part libraries and found by exactly what its linking takes: the four parts' names and the pipeline layout it is linked with. A variant claims the link on the creating or drawing thread as it claims its libraries; the first caller links it (Library::made, as a library is made), and every later variant of the same link takes it with no driver call. The link holds its libraries and its layout share while it lives (Vulkan may read a pipeline's creation's objects as long as the pipeline lives); each variant's RawPipeline and each kept pipeline hold the link, and only the map destroys it, at a program's settle once nothing holds it or at the device's teardown, before the libraries. A pipeline made whole (no libraries, MoltenVK) is unchanged: the variant's own. New count WorkCounts::linked_pipelines_shared; a shared link counts in neither pipelines_linked nor variant_pipelines_made. The conformance cost half reports it as a FOUND count, never gated, in the translation region. api_signatures.tsv gains the field. Why: the consumer measured a client creating about 8,500 render states at login, each with a linked pipeline of its own. States alive together of one compiled pipeline already share their variant and its pipelines (memo.rs), and a released one's come back from kept.rs; but states that are compiled pipelines of their own whose stages come out as the same words linked the same pipeline again, each its own. Now a repeated link costs a lookup. Test: tests::linked_pipelines_shared makes 16 siblings of one pair that differ only in maxFragmentCallStackDepth (each a compiled pipeline and variant of its own; the fixture's fragment function recurses through no visible function, so the words are the first state's), draws with each and checks every pixel, and where the device links from libraries asserts the siblings linked nothing, made no library and no variant pipeline, and took at least 16 shared links. A descriptor differing only in a buffer's mutability is not such a sibling: it is the same compiled pipeline, whose live variant it shares whole. Verified: on MoltenVK 1.4.2 (M3 Max), which makes its pipelines whole, the new test and the touched suites (driver_pipeline_compile, render_sibling_work, kept, warm_record, uniform_bind_offsets, the libraries unit tests): all passed; the siblings there made 16 variant pipelines, 0 shared, so the siblings are variants of their own. cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings with --cfg m2v_gpu; public rustdoc clean, no new private intra-doc link diagnostic; the conformance cost tests (37 passed). The run on a device that links from libraries is in the hand-over. (cherry picked from commit 22b2fd234eb66bf71ebc2c6e6639c0488ff5149a) (cherry picked from commit a49b1f7d832c1beeae1e511a8f57b00b2e1640fd) |
||
|
|
2bf4e3b4cb |
Ask whether a shadow fits a heap texture only where its images do not, and hold it to 17.25
What: held_to_metal takes the question whether a shadow of the heap's bytes fits the image's planes as a closure (shadowable), asked only of a single-sample texture its images do not hold: past Metal's answer, or 4:2:2. HeapTextureShape loses its shadowable field. Device::heap_plan passes `|| shadowable(plan, metal.size)`. host_ab percall's heap_texture_256 row comes down to the measured 17.25 allocations a call from 20.25. Why: shadowable answers from heap_planes, which lays out the texture's planes (copy_units' list, heap_plane_layout's planes) and its copy regions (a BufferImageCopy list) only to compare the bytes they span. |
||
|
|
7e0d848a0c |
Order a small encoder part's resources on the stack at its end, and hold the end rows to 7 and 24
What: EncoderUses::finish_parts orders each part's resources by key through by_key. Up to 16
resources (ORDERED_INLINE) are sorted in an array on the stack, more in a vector of their own
as before. The summary is unchanged: resources in key order, each one's uses in the order
recorded. host_ab percall's HELD rows come down to the measured counts: end_compute and end_blit
8 -> 7, end_render 25 -> 24.
Why: a5a8ddf96f replaced the stable sort of a part's flattened uses, which allocates nothing for
a short slice, with a sort of the resources' keys, each once, through two vectors: the tracked
map collected, and the order. 1aaf95c79f dropped the first. The second was one allocation at
every encoder's end, the +1 c01e79adc1 raised end_compute and end_blit to 8 for with no cause
found. At
|
||
|
|
3d282e9a8d |
Pin the runtime sources after passes count the commits they take in
(cherry picked from commit 35431da6e694fb6e70edf2e2f132b78654deb13d) |
||
|
|
ce57c7dce4 |
Bump RUNTIME_VERSION to 1749: passes count the commits they take into the order
A run of an unchanged artifact and plan now also records WorkCounts::commits_taken_in, the commits a pass took into the scheduler's order, whichever thread made it, added as the pass ends after its submissions and groups. Nothing it submits or answers changes. 1749 is 1748 (shadow carries, withheld holds) plus one. (cherry picked from commit 968ab4aa38649203cf483b020e576441f32ccef6) |
||
|
|
25cb4367d8 |
Bless the API signatures for WorkCounts::commits_taken_in
scripts/api-signatures/signatures.py --bless on this tree: one signature added, the new WorkCounts field. Nothing else moved. (cherry picked from commit 9d121883145b5c63b7afce7561e0903375d88490) (cherry picked from commit 6cdc6575b6435f44dac9cdc755bdc4e6d3b82035) |
||
|
|
706855acfe |
grouped_submissions: wait for the commits taken in, not for a sleep
taken_in read WorkCounts::scheduler_sleeps after the last commit returned
and waited for it to move. Where the scheduler's thread had taken the commit
in and gone to sleep before that read, nothing moved it again: since idle
sleeps are untimed, an idle thread sleeps until woken. The behind-running-
work scenario commits each command buffer onto an otherwise idle order, so
a_command_buffer_with_a_submission_handler_and_check_is_held_behind_
running_work and the_exact_completion_keeps_no_group_behind_running_work
hung there and failed after 60 s on a loaded M3 ("the scheduler's thread
never slept"). The sleep read raced the commit; the runtime did not.
A new count: WorkCounts::commits_taken_in. It counts the commits a pass
took into the scheduler's order (the scheduler thread's, a waiting
thread's or a committing thread's), each as its pass ends, after the
submissions and groups it made. It is released then, and acquired as the
counts are read. Passes take commits in hand-off order, so once it
reaches commits_handed_off read after a commit returned, a pass has taken
that commit in and ended. That holds whether the pass ran before the read
or after, and whatever the thread does next. taken_in now waits for that.
It keeps its contract: every command buffer committed before the call is
in the order, and the counts read after it hold what that pass submitted
and kept. No sleep is involved.
The conformance cost lists classify the count as submission work and as
racy: a pass can end after its command buffer completed and the case read
the counts. A runtime change: RUNTIME_VERSION and the pin are left to the
lane.
(cherry picked from commit 0a0a7c1ff805af54ef7c7a1be786b513ef0b7c14)
(cherry picked from commit f2ec35ad576b115ad53442eb9ad05cb3ae514c18)
|
||
|
|
5553cb59bd |
Pin the runtime sources after shadow carries dropped where batches split and holds withheld behind waiting writers
(cherry picked from commit 01cd44dbdca5df118bf7e066b8a24c27d2f46482) |
||
|
|
b564a9a26e |
Bump RUNTIME_VERSION to 1748: shadow carries dropped where batches split, and holds withheld behind waiting writers
A shadowed texture's carry across one command buffer's encoders now lasts while they stay in one batch, dropped where its batches split (a wait, a host step, a resource state encoder, or a signal pending for the next encoder) and never at another command buffer's encoder end; and a command buffer that waits for an event or a semaphore and wrote logged host pages keeps every log of a shadow its writes meet from taking or giving a hold until it completes (WorkCounts::dirty_holds_withheld). Both change which copies a run of an unchanged artifact submits. 1748 is the lane's 1747 (residency joined where read, sampler prunes) plus one. (cherry picked from commit fe5d8c1b51dc29e5f9ff577e8f41be3b23b11f35) |
||
|
|
5c1b97e7e3 |
Keep a logged shadow from holding while a command buffer that waits and wrote its pages runs
What: a command buffer that waits for an event or a semaphore, and whose commands write logged
host pages (HostMemory::with_dirty_pages), now keeps its writes in the device's dirty shadows
(dirty_pages.rs, WaitingWrites) from its commit until it completes. While they are kept, no
log of a shadow they meet (the shadow's truth or the shadow) takes a hold or gives one. That
covers a log made after the commit too: a shadow's log is made at its first gated copy in.
Each hold left untaken is counted in the new WorkCounts::dirty_holds_withheld. A command buffer
whose writes went unnoted (nothing collected them as it encoded), or that wrote past WRITES,
counts as writing everything. Its completion lets the writes go, after it reports them again.
committed() now reports the host writes at its end (the order against the stamps is
unchanged), and the commit site passes `unnoted`.
Why: such a command buffer may run after work committed after it. Its writes reach the log at
its commit, before that later work's stamps. A later commit whose end leaves the shadow's image
holding the truth takes a hold as of its own stamp, and a copy in behind that hold then skips
pages the waiting writer fills after the image was copied. The first design kept the waiting
writer on each ShadowLog it met at the commit. It withheld nothing in the test below ("holds
withheld 0"), because the log did not exist yet at that commit: the first copy in came later.
So the writes are kept by the device, and each log asks them when it would hold.
Test: runtime_lane::cross_queue_shadows::
a_write_of_logged_pages_after_an_event_wait_reaches_a_copy_in_behind_a_later_hold, over one
anonymous guest page with a dirty log. Y (queue 2) waits for an event, fills row 3, then spins
(150 dispatches of about 10 ms). X (queue 1, committed after Y) reads the texture and signals
the event; its end holds the texture whole. Z (queue 1, after X) reads it. The test asserts
the copies in were gated, X's hold was withheld, X's read holds the initial bytes and Z's read
holds Y's fill.
Verified on the M3 Max (MoltenVK 1.4.2, macOS 27.0.1) under --cfg m2v_gpu:
- Without this change (the test alone, on the landing's first commit), the test failed: Z's
read lacked the fill (32 bytes of row 3 held the old texels), the gated copies in reading
[2 gated, 1 whole, 1 skipped, 512 bytes whole, 256 copied].
- With it, 93 of 93 passed: runtime_lane::cross_queue_shadows, parallel_encodes and
device_copies, and the runtime's tests::shadow, batches, fresh_unwritten, dirty_pages and
copied_log. This test read [2, 2, 0, 512, 512] and "holds withheld 2".
- cargo clippy -p metal2vulkan-runtime -p metal2vulkan-validation --all-targets --all-features
-D warnings, plain and under --cfg m2v_gpu: clean.
- metal2vulkan's api_signatures test passes with the new field's row.
(cherry picked from commit 5ef157a072f943ddcd71bb315cd4c1cb03f6097e)
(cherry picked from commit be09b8f937d221213a31230917680f1c848c4d7d)
|
||
|
|
d7e2436acb |
Drop a shadowed texture's carry where the command buffer's batches split, never on another's end
What: a command buffer's ShadowCarry (an earlier encoder left the shadow's image holding the
truth, so a later one takes no copy in) now lasts while its encoders stay in one batch.
State::shadows_to_carry clears it where the encoder opening next starts another batch:
- the batches split since the last ended encoder, at a wait, a host step or a resource state
encoder (State::carry_batches, set at end_encoder);
- or the current batch signals (Batches::signals_pending), so the next encoder starts the next.
ShadowCopies::touched and shadow::Touched are gone, with every field initialiser, Entry::met,
Carried::touched, ShadowCarry::queue and ShadowCarry::on. Another command buffer's encoder
ending in between, of this queue or another, drops nothing.
Why: the consumer's ruling. A later encoder that sees a CPU write made after its command
buffer's commit is a correctness bug on every device. On the GPU nothing runs between two
encoders of one batch but the command buffer's own commands. A queue's batches go in commit
order, and another queue's batch that conflicts with this one's uses of the texture runs
wholly before or after it: each copy in is a tracked write of the image. So the counted ends
dropped carries that held, and the later encoder then copied in at its own run, a CPU write made
after the commit among it. Another queue's work comes between only where the batches split.
There the carry used to survive a signal, and the encoder after it read the image as the
earlier encoder left it, missing another queue's write that ran in between.
shadow.rs's Copy in rule now records what Metal does with a CPU write made once the command
buffer's own signal was seen, measured by the new probe
metal2vulkan-conformance/probes/cpu_write_after_a_signal.m. On the M3 Max (macOS 27.0.1),
three runs of each case, every run alike:
- the read after the signal took the write, in the encoder after it (out2 64 of 64 NEW) and
in a later dispatch of that encoder (64 of 64);
- with no signal, a write while the command buffer ran reached no later encoder (64 of 64 OLD);
- a write before the commit reached both reads.
The GPU does not see a CPU store to a word while a kernel runs. Metal ended a spin waiting for
one ("Caused GPU Hang Error"), and also one dispatch of about 1.5 s, so the probe and the tests
spin in 150 dispatches of about 10 ms each, the cap timed first.
Tests:
- tests::batches::a_signal_is_pending_until_the_encoder_after_it_starts_a_batch (new).
- tests::shadow::a_carried_surface_is_dropped_by_anything_that_lets_another_writer_in: another
command buffer's encoder ending between, or while the encoder was open, now keeps the carry.
only_another_queue_s_encoder_drops_a_carried_surface is gone with Touched.
- runtime_lane::cross_queue_shadows (new), on the device the cfg selects:
- a_cpu_write_while_a_command_buffer_runs_reaches_none_of_its_encoders: X of queue 1 reads,
spins and reads; Y of queue 2 reads between X's reads; the CPU writes while X spins (X
Scheduled). Both of X's reads hold the bytes as of the commit, the second through the
carry (64 texels carried).
- an_encoder_after_a_signal_reads_what_another_queue_wrote_after_it: Y of queue 2 waits for
an event and fills a row; X of queue 1 reads, signals, reads. The second read holds the fill.
- a_cpu_write_once_a_signal_was_seen_reaches_the_reads_after_it: the probe's two signal
shapes through the runtime. The read after the signal holds the CPU's write.
Verified on the M3 Max (MoltenVK 1.4.2) under --cfg m2v_gpu, on f7abac8bbb plus the per-draw
log fix: those three, parallel_encodes, and the runtime's tests::shadow, tests::batches and
tests::fresh_unwritten pass. In that run the waiting-writer test that follows failed, as
expected without its fix. With this commit's runtime changes left out (95f22fb742, the same
validation tests), all three device tests fail on the M3 Max:
- the CPU-write test's second read held the write (0 texels carried);
- the signal test's second read missed the fill;
- the signal-seen test's read after the signal missed the write.
The checks at this landing's tip are in its last commit.
(cherry picked from commit 4cf86795b2430feb28062aa467333249dc62310e)
(cherry picked from commit 4b8b5eda8025d7abaaaacc929eacdfd1f1bcc968)
|
||
|
|
f9f498f9a5 |
Pin the runtime sources after ExtendedRange's public read and write models and the rgb10a2 sRGB bound
(cherry picked from commit a39b99678f7a121c5b81c105c885479c067f1eb2) |
||
|
|
d8d76438cd |
Hold the extended-range lanes to DevicePackConversion's bound, against Metal's answers
The eleven extended-range and padded lane tests compared the device's texels, reads and samples digest for digest with Metal's. A shader's conversion of such a texel is the device's own (no Vulkan format holds them), which PrecisionNote::DevicePackConversion records and the runtime announces. Its documented bound allows a code within one of Metal's (two for R10Unorm_X6_sRGB's and RGB10A2Unorm_sRGB's colour below 0.0031308), a linear read within one f32 ulp, an sRGB twin's decoded value within half a 2^-13 step of Metal's table (1.64 steps for those two formats) beyond the Pow's bound, a half within one half ulp, and a NaN's code the device's. So the digests did not match on the M3 Max (MoltenVK) or the RTX 5080, and these tests stayed red on both. Each test now checks every value within that bound of Metal's own answer, and each bit Metal does not read equal to Metal's. It asserts that the note was announced wherever a value moved, and it still pins Metal's answer by its digest: - xr_codes (new): the shared helpers. It splits a texel into codes and the bits Metal does not read, holds codes, reads, sRGB steps and halves to the bound, gives Metal's half rounding (ties away from zero), and loads Metal's M3 Max macOS 27.0.1 answer from a conformance recording. as_metal_reads replaces the device's lanes that are within the bound by Metal's values, so a digest of the rest can still be compared. - extended_range_targets: draws compared code by code, two-plane reads through the nearest code of Metal's read; clears' reads through the cleared codes. A CPU test holds the models to Metal's digests. - extended_range_planes: joined and split texels within a code. - extended_range_blends: one-zero blends against a model of Metal's blend, which clamps the source to its range, alpha to [0, 1] and a NaN to the low end. A CPU test holds the model to Metal's digests. - padded_loads: every drawn word within a code of a model of Metal's store (a float output rounded to half toward zero, then the write code), held to Metal's digests by a CPU test. - rgb10a2_srgb: reads, writes, nearest samples and stores compared with the rgb10a2-srgb-* recordings, whose digests are asserted equal to the test's constants. Linear samples run and are counted, their blend being the unbounded BicubicFilterArithmetic, which is asserted to be announced. - two_plane_samples: nearest cases against the xr-two-plane-samples-* recordings, a half case against the float recording. - extended_range_two_planes: plane reads and in-view buffer words within the bound, through as_metal_reads. No note set changes. Test code only; no version bump. Verified on the Apple M3 Max (MoltenVK 1.4.2, macOS 27.0.1): every test in the seven files passes (34 of 34), including the eleven that were red. In the run before the bound was corrected, both rgb10a2_srgb tests failed at exactly three words each, the shape the bound now states. Clippy (all targets, all features, --cfg m2v_gpu) is clean. (cherry picked from commit f097486e7a84a116c2c119114db4b665eb045600) (cherry picked from commit 4c972dab0c58ef908b7ac6c826afb8a5e07f1732) |
||
|
|
aa9b38e6fd |
State the padded sRGB twins' code and decode bounds as measured
DevicePackConversion's documented bound for the extended-range and padded conversions said "a code within one" of Metal's. For R10Unorm_X6_sRGB and RGB10A2Unorm_sRGB that is wrong. Metal's write of these formats rounds the value clamped to [0, 1] to 2^-13 (nearest even) and then looks it up in its encode table (R10X6_SRGB_ENCODE_FIRST). The device writes the MSL transfer by its own maths, times 1023, RoundEven. In the transfer's linear segment, one 2^-13 step spans 1.6 codes, so the two can land two codes apart. Measured: for each 2^-13 step over [0, 1], the f32s at and next to both edges, where Metal's code is constant within a step and the device's code rises with the value. The device's code (exact transfer) lies at most two from Metal's table. It reaches two only below 0.0031308: at 1.5/8192, just above 6.5/8192, and at 24.5/8192. Everywhere else it is within one, beyond the Pow's bound. Metal's recorded writes and stores of RGB10A2Unorm_sRGB on the M3 Max under macOS 27.0.1 (rgb10a2-srgb-writes, -stores-f, -stores-h) show exactly that: three words each, at k/16384 for k = 3 and 49, and at the 1.5/8192 special. Metal's decode of RGB10A2Unorm_sRGB's colour (the rgb10a2-srgb-reads recording, every code) lies up to 1.637 steps of 2^-13 from the exact transfer (code 952: Metal 0.84912109, exact 0.84932096). That is the 1.64 the docs gave for R10Unorm_X6_sRGB only. So artifact.rs's DevicePackConversion, the FAST-PATHS air.pack row and API.md's catalogue entry now give, for those two formats only: a colour code within two below 0.0031308, and a decoded colour within 1.64 steps. Doc text only: the device's conversion is unchanged (rule 1), and so is behaviour. No version bump. (cherry picked from commit 8bfaab43bd6c6368c41d58caa7e9c91fe64820d5) (cherry picked from commit e728f0fa394c46c528d2f99df89a33751f5691d7) |
||
|
|
24d2ada6af |
Answer Metal's extended-range read and write models publicly
The validation lanes that hold extended-range texels to Metal compare the device's conversion with Metal's answer within PrecisionNote::DevicePackConversion's bound (a code within one of Metal's, a read within its bound of Metal's). That needs Metal's code-to-value mapping and its write's rounding, which the runtime's clear model already holds as the private `code_value` and `code`. ExtendedRange gains two thin public wrappers: - `read_value(code, alpha) -> Option<f32>`: Metal's float read of a code of an extended-range form, or None for the padded and bfloat forms and a code past 1023. - `write_code(v, alpha) -> Option<u32>`: Metal's kernel write's code of a float of an extended-range or padded form, or None for the bfloat forms. Each doc comment states Metal's mapping and rounding, and says that a shader's conversion is the device's, bounded against this one. api_signatures.tsv gains the two method rows. The api_surface table lists items, not methods, and ExtendedRange's row is unchanged. No behaviour changes and no version bump. The pin needs recomputing, since metal/format/mod.rs is a hashed translator file. Verified: cargo nextest run -p metal2vulkan (api_signatures, api_surface and metal::format tests) 64 passed; clippy -D warnings plain and --cfg m2v_gpu; rustdoc -D warnings for metal2vulkan. (cherry picked from commit 753e6ac604e2f4be8150d787e50574ee880798a6) (cherry picked from commit 99e4bd12fd251ee97615d0ab535980089e5e0a71) |
||
|
|
e71efbe0e9 |
Pin the runtime sources after the joined residency, host import counts, spec_key lists and sampler prunes
(cherry picked from commit 4f0a1043b16311ccd498714627a2650ded1f2ece) |
||
|
|
1926a601ac |
Bump RUNTIME_VERSION to 1747: residency joined where read, host imports counted in place, sampler prunes amortised
A run of an unchanged artifact and plan now records and holds differently: - A command buffer joins its ended encoders' resources into its residency where its work first reads it, not as each encoder ends, and counts the joins in the new WorkCounts::resident_resources_joined; its encoders' shadowed textures are found where the next encoder opens. - A commit counts its buffers' host imports without making a list for the first sixteen (Buffer::distinct_host_imports). - The translator's spec_key makes its two lists once each, at the first constant given a value, and none for a key of no value. - A sampler state's creation prunes the device's map of live states only where it has grown to twice what the last prune left, so entries of states gone stay longer. The Vulkan commands, barriers, notices and refusals keep their meaning at the same calls. 1747 is the lane's 1746 (noted textures' pattern reads logged without an allocation per draw) plus one; it stands for the compute bind branch's 1744. (cherry picked from commit 6b4606e2e5d46f0aca873bf9f10f015f64c5f758) |
||
|
|
e94d068b3b |
State the queue sharing row's measured rates over the 5080's spread
What: docs/FAST-PATHS.md's queue sharing row now gives each shape's measured range with its run count, in place of the first three-run set's. Why: two more sets on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, release, one-draw command buffers, each thread its own queue) widened the ranges: - 2 threads with 3 in flight: Adaptive 27.0k to 46.5k a second in 13 runs after a hold's first. It fell within one hold, from 42.5k to 27.0k, while PerQueue stayed at 25.6k to 27.5k. Two more runs gave 15.4k and 17.7k; in both, one of the two queues was marked long as it began (gone long 2 or more, against 1 in every fast run). PerQueue: 25.2k to 27.7k in 14. - 2 threads with 1 in flight: 16.9k to 20.7k against 10.1k to 11.5k (5 each). - One thread over 16 queues in turn: 21.7k to 43.3k against 10.2k to 11.1k. Over 2,048: 20.0k to 39.2k against 10.2k to 11.2k (4 each). The 8-thread shapes keep their three-run ranges. One third of one hold, where both policies fell to 8.1k to 13.0k, is left out. Under PerQueue the pair of VkQueues made no difference: 2 x 3 with the second queue 1, 7 or 13 places after the first ran 25.6k to 27.5k. Verified: tests::fast_paths (19 passed). (cherry picked from commit adb362078504cca24358e8d9c331eb1b831a2b57) (cherry picked from commit 27999318cbb31bc8a46f24a28c40a6b80c7e2f4d) |
||
|
|
ec6fbca8f8 |
LiveSamplers' doc: the map's bound is twice the states live at its last prune
The previous commit's doc said the map holds at most about twice the live states. A prune sets the next bound from the states live then, so after states are dropped the map can hold up to twice that earlier count (or PRUNE_FROM entries) until its next prune: each a Weak of a state gone, holding its allocation alone. The doc now says so. No code changes. (cherry picked from commit 5e813b916ec5a5ca6b10714aced20d164f562aab) (cherry picked from commit cb79bc65d748f7877ffa57a950ebd963b9fe5cd3) |
||
|
|
26ead7a1b5 |
A sampler state's creation prunes the live states' map at a doubling bound, not every time
Each new state's creation ran live.retain over the device's whole map of live sampler states, so a creation cost time linear in the states live (reims measured about 1.1 ns a live state on an RTX 5080). The map is now sampler::LiveSamplers: a creation prunes the entries of the states gone only where the map has grown to twice what the last prune left, and at least to 64 entries (PRUNE_FROM), so each creation's share of the prunes is a few entries however many states live, and the map holds at most about twice the live states, plus 64. An equal request still gets the live state: the lookup upgrades the key's entry, so an entry whose state is gone answers none, and the creation's insert replaces it. A prune lets go of Weak entries alone, so no state is dropped under the map's lock, as before. The same Vulkan calls, notices and refusals at the same call; only when the map lets go of dead entries moved. Release numbers, M3 Max (reims's repro: N states live, a create of another descriptor and then the oldest dropped, mean of 2000 creates, µs; two interleaved runs each): live before after 1 0.46 0.35 0.44 0.72 64 0.58 0.58 0.43 0.90 1000 1.97 2.01 0.56 0.54 10000 16.75 16.93 0.48 0.49 Check that fails without it: tests/sampler_prunes.rs makes 4096 states and keeps them live; their creations' prunes must look at fewer than 8192 entries. With a prune at every creation they look at 8,386,560 and the test fails. It also checks an equal request gets the live state, and that 4096 more creations, each state dropped at once, leave the map at 65 entries or fewer. Verified: the runtime GPU suite on the M3 (1528 passed, 3 skipped); cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings, with and without --cfg m2v_gpu. (cherry picked from commit 61e1796535c6d07f384db2e4da7d31e8e4c2d5fb) (cherry picked from commit bf6578fd927e73f7d17ddc4b1a558dc347ff9cc6) |
||
|
|
4a5e49684c |
joined_residency test: compare against a slice of the texture, not a cloned array
cargo clippy --cfg m2v_gpu (cloned_ref_to_slice_refs) refused the shadowed-textures test's first assert, `[first.clone()]`, which the previous commit added after its clippy run: the assert now compares against std::slice::from_ref(&first). Nothing else changes. Verified: cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings with --cfg m2v_gpu and without. (cherry picked from commit 8e7a8f43523ecabb06c1d95e489e960d7b36ed12) (cherry picked from commit 942c58d90c028f36a0508bf3d106400fe16cacdc) |
||
|
|
b85685ae41 |
host_ab percall: re-bless the gate's stale rows to what the runtime does now
The percall gate (HELD) held calls to counts the runtime no longer makes, so it failed on every run for reasons that were not regressions, and a real one hid among them. Each row now holds what one percall round on the M3 measured (gate/stack6 with this landing): - draw_strip, draw_triangles, draw_indexed: the draw is recorded at the call (rt_draws_at_call 1, rt_recorded_cmd_draw_indexed_at_call 1), not at the commit. - end_render: its render pass is begun at the call (rt_render_passes_begun_at_call 1). - end_compute, end_blit: 8 allocations, held to 8 where they were 7. - dispatch: recorded at the call (rt_dispatches_at_call 1); 8.13 allocations, held to 8.2 where it was 19. - heap_texture_256: 20.25 allocations, held to 20.25. - buffer_texture_256: one image and one binding at the call, no memory of its own and no view (held to 0 images and 1 view before). - use_resources_read_256: 16 allocations, held to 16 where it was 277. Two rows keep their bounds and still fail: the draws' 1.055 allocations a draw (held to 0.2; 0.041 before this base) and end_render's 27 (held to 25). Neither has a cause found here, so neither is blessed. Verified: host_ab --only percall --rounds 1 on the M3, built with this table (its gate made to print rather than fail): the gate reports those four rows alone, and every row that holds a call to some work names a count its group moved. (cherry picked from commit c01e79adc1944a6f86ce63d13163c1b7f612b429) (cherry picked from commit 48e3b1e102411b6877258c1c91c142d5f014b0ca) |
||
|
|
2f9a3a3782 |
A command buffer joins its ended encoders' resources where its work reads them, not as each ends
Each compute or render encoder's end joined everything it made resident into its command buffer's
residency (Residency::join_encoder: a clone and a hash insert per resource), and each later
encoder's open walked every texture of that union for the shadowed ones. Most command buffers'
work never reads the union: only the commit's and host steps' recordings against every encoder's
resources (CommandBuffer::residency), the resident set of a GPU-alone recording, a texture made in
a heap since, and an encoder encoded again do.
- command_buffer/mod.rs: an encoder's end joins its heaps at once (join_encoder_heaps) and leaves
its resources in its record; State::joined_residency joins the records not joined yet, in the
order they ended, at the first read (CommandBuffer::residency, make_resident, fresh_ranges, a
splice of an encoder encoded again, before the textures its heaps made since). The union holds
what the eager join made, in the same token order: State::sync_heaps joins the records first
where a heap made textures, as each encoder's join came before them. The commit's sync of its
heaps and an encoder's open (State::inherited) read no resource list unless one did.
- residency.rs: each residency lists its shadowed textures' tokens (shadowed), found where an
open first asks for them (find_shadowed) and each texture looked at once, so making a texture
resident reads nothing of it, and an open starts with the shadowed textures of the joined union
and of the records not joined yet, in the order they were made resident, with the joined usage
and stages, at the cost of their count. The join's resource and heap halves and sync_heaps's
finding and joining halves are split out.
- WorkCounts::resident_resources_joined counts the joins (api_signatures.tsv blessed: one field).
The records hold what their encoders made resident until the command buffer completes, as before,
and the union goes with them, so nothing lives longer or shorter. The same resources, usages,
stages, tokens, shadows and heaps at every read.
Release numbers, M3 Max (host_ab --only encode, runtime side, median of 3 rounds, µs; before is
this landing without this commit, after with it, two or three interleaved runs each):
before (3 runs) after (3 runs)
resident_0 end_call 14.1 11.6 14.9 11.3 14.4 15.1
resident_256 end_call 34.7 25.6 37.3 11.1 13.3 15.4
resident_4096 end_call 230.3 152.3 244.3 11.4 14.1 15.5
resident_moving_4096 end_call 170.5 154.3 248.6 10.7 11.8 15.2
resident_textures_256 end_call 41.5 29.5 43.1 11.2 13.0 15.3
resident_textures_4096 end_call 287.8 193.5 294.6 11.5 12.9 15.8
resident_4096 use_call 346.1 379.3 335.1 326.1 297.3 342.0
resident_textures_256 use_call 38.0 37.0 36.9 35.1 35.1 37.2
resident_textures_4096 use_call 450.3 481.0 430.3 409.5 419.6 438.3
resident_4096 encode/dispatch 1.73 1.32 1.62 1.74 1.65 1.65
resident_textures_4096 encode 2.20 1.78 1.93 1.93 1.99 1.97
static encode/dispatch 1.75 1.74 1.61 1.62 1.64 1.60
The end call no longer grows with what the encoder made resident, and the useResources call does
not take the cost instead. A first form of this change looked for a texture's shadow as it was
made resident; that put about 80 µs into resident_textures_4096's use_call (260 to 317 against
188 to 200 before, four interleaved runs each), which is why the shadowed textures are found
where an open first asks for them. Percall's counts are the same with and without this commit;
the calls workload's end_compute allocates 5 a call where it allocated 8.5.
Checks that fail without it, in tests/joined_residency.rs:
- ended_encoders_join_their_command_buffer_s_residency_where_it_is_read: with the second
encoder's open joining the records (the eager join's timing), its first assert fails (16 joined
where 0).
- shadowed_textures_made_resident_reach_the_next_encoders_in_order: with find_shadowed looking
at none, its first assert fails (no shadowed texture inherited).
Verified: the runtime GPU suite on the M3 (1527 passed, 3 skipped); cargo clippy -p metal2vulkan
-p metal2vulkan-runtime --all-targets --all-features -D warnings, with and without --cfg m2v_gpu;
scripts/api-signatures/signatures.py --check.
(cherry picked from commit 18553c295c98dabe4c74fc226be6b45955c0c13a)
(cherry picked from commit ae56cfdfdd2e4cb1e9b189c7ce303d680fbc2b7f)
|
||
|
|
c6ff058263 |
host_ab encode: time each dispatch_resident variant's endEncoding call
The dispatch_resident variants timed the useResources call and the dispatches after it, but not the encoder's end, where a command buffer joined everything the encoder made resident into its residency: a cost that grows with the resident count and fell outside every row. Each variant now emits dispatch_resident_<name>_end_call, the end_compute call alone (before the commit), on Metal and on the runtime alike. Verified: host_ab --only encode on the M3 prints the new rows for every variant. (cherry picked from commit 87d8341d269d126b1edac5d3935485f0997b47be) (cherry picked from commit 400bf537e6efaaa15cdb1e6a8fcb1c7836de53f3) |
||
|
|
1d984c190e |
spec_key makes no list for a key of no value
The reserve that made spec_key's two lists at their whole size at once ran before any constant was given a value, so a key of none, which made no list before, made two empty ones of the layout's size. The reserve now runs at the first constant given a value, for it and every later one; a key of no value allocates nothing, and a key of values still makes each list once. Check that fails without it: bind::plan::compute::tests::specialization_lists_are_made_whole_at_once now also asserts a key of no value has no capacity in either list. Verified: with the reserve at the top the new assert fails (capacity (5, 17) for a key of no value); with this, the bind::plan::compute tests pass. (cherry picked from commit a52c75a9c1653ff26d98a20dfd748f85a1a752db) (cherry picked from commit ae8b8f95515085c586181f472534c0649c85d685) |
||
|
|
917fa5adf2 |
host_ab percall: the no-copy commit group's buffers live only in its windows
commit_no_copy_dispatch kept its two buffers over host pages alive in Objects for the whole run, so every other group's calls ran beside two live buffers over host pages and counted differently: use_resources_read_256 24 allocations a call where it makes 16 (16 before the group was added, 24 with it, 16 again with this; one percall round each on the M3). The group now makes its two buffers in each window's preparation, over the first two megabytes of the no-copy pages (Objects::pages, which buffer_no_copy_1m's windows use too), and lets them go with its drain. end_render's 27 allocations a call (25 before) is not this group's: it stays 27 with this change. (cherry picked from commit e2671b315330440b360abcd7a797ab414861068e) (cherry picked from commit fac1d2aeb20253c7593ce14a053d3a5c4506efce) |