ac7dffa3fdbf940c149d1539697265cfb3604e2a
1430
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ac7dffa3fd |
RUNTIME 2488: A spliced shadow's staged heads and tails go back as row copies too, one dispatch each where faster
A spliced copy back out of a staging buffer copied its rows' edges into the arena region (each row's head before its first line boundary and its tail after its last, which the host step then copies into the pages) as one vkCmdCopyBuffer region per edge: 2N regions per copy back. On ANV, which splices every such copy back, and on the RTX 5080 Laptop (DriverFact::RowCopiesDispatchFaster), the driver records each region as an operation of its own. That is the cost row_copies.rs removes. shadow_splice::staged now puts a cut's heads (in `edges`) and its tails (in `tails`) in separate lists. Each takes the region in the same order as before (a row's head, then its tail), so the region's layout, the pieces and the host step are unchanged. For rows of one shape the heads are equal-sized and equally spaced in both buffers, and so are the tails. SplicePlan::place makes each list a RowCopies from the staging buffer into the region (the arena's chunks carry storage usage), beside the whole lines' RowCopies into the truth. record_spliced records all three; the encoder takes their stages and uses (ShadowCopy::spliced_stages and spliced_uses: a texture buffer's shadow is read by every dispatched copy) and retains every set. Tests: - tests::shadow_splice::a_staged_cut_of_equal_rows_is_three_copies_of_rows_of_one_shape_each checks that the cut of the validation test's shape, at three phases, gives whole lines, heads and tails of one dispatchable shape each. - The staged cut's byte test also reads the tails. - runtime_lane::row_copies::a_spliced_shadow_s_lines_heads_and_tails_go_back_as_one_dispatch_each (renamed from ..._whole_lines_go_back_as_one_dispatch) asserts 3 row copies of 96 regions, 3 dispatched where the fact holds. Before this change it was 1 copy of 32. - The unforced test expects 3 copies where its copy back was spliced, else 1. The three row copies live in Splice.rows (clippy's large_enum_variant refused a 600-byte variant of SpliceCopies::Staged; nothing boxed). RUNTIME_VERSION 2488 (2487 is the early pin branch's). Verified: msi m3-max-38042 at 777d9a3412, lavapipe, --cfg m2v_cpu_icd: clippy -p runtime -p validation --all-targets --all-features -D warnings 0; validation 43/43 (a_spliced_shadow_s_lines_heads_and_tails_ go_back_as_one_dispatch_each: spliced 1, row copies 3, regions 96, 3 dispatched where the fact holds; the same scenario measured 1 copy at 869519d69f, m3-max-38028); runtime shadow, splice and row-copy tests 118/118 (a_staged_cut_of_equal_rows_is_three_copies_of_rows_of_one_shape_each: each copy meets RowsDispatch::new's conditions, so ANV and the 5080 dispatch them: expected, not run). Plain and --cfg m2v_gpu clippy and rustdoc in m3-max-38043. |
||
|
|
566f2da4f9 |
RUNTIME 2486: A spliced shadow's staged whole lines go back as row copies, one dispatch where faster
RUNTIME 2431 splices a shadow's copy back into host pages where the device's check of those pages failed or has not answered. Its staged form (a copy back out of a staging buffer: a 2D texture whose texels start off their alignment, or a texture buffer) recorded its rows' whole lines as one vkCmdCopyBuffer region a row, bypassing row_copies.rs, which every other copy back out of a staging buffer goes through. So on ANV and the RTX 5080 Laptop (DriverFact::RowCopiesDispatchFaster), and the Iris Xe splices every such copy back, the rows went as N regions again instead of one dispatch, and WorkCounts::row_copies counted none. runtime_lane::row_copies::a_shadow_s_staged_rows_go_back_as_one_dispatch caught it on lavapipe: its device has no record of the check's verdicts, so the copy back is spliced, and the row copies since were (0, 0) where (0, 1) was wanted. SplicePlan::place now makes a staged splice's whole lines a RowCopies from the staging buffer into the truth (counted, one dispatch where the device runs it faster); record_spliced records it; the encoder's splice records it with the copy's stages and uses as that dispatch's (ShadowCopy::spliced_uses: a texture buffer's shadow read by both the dispatch and the edges' copy), retains its set, and notes the host step's write as before. The validation test is split: its clear over the pages is a helper; the original test keeps its contract, and a_spliced_shadow_s_whole_lines_go_back_as_one_dispatch runs it on a device whose check fails (DeviceOptions::fail_in_place_check), asserting the copy back spliced and its whole lines one row copy, dispatched where faster. Cause: shadow_splice.rs `splices` splices a copy back into host pages while the in-place check is failed or pending (RUNTIME 2431, |
||
|
|
45ebbdaa5e |
RUNTIME 2484: Copies between a texture's region and a surface's runs of guest RAM
A consumer that keeps an IOSurface's GPU copy as one optimal texture, on a host whose surface path copies by runs of guest RAM (copies_guest_ram: no view of the pages is made), needs the texture forms of the run copies, or its fill, upload and download go back through a view per block or a staging buffer. What: BlitCommandEncoder::copy_texture_from_host_ram(ram, runs, offset, bytes_per_row, size, texture, slice, level, origin) and copy_texture_to_host_ram(texture, slice, level, origin, size, ram, runs, offset, bytes_per_row), runtime extensions (Metal has none). `runs` is the surface's bytes in order (the shape the consumer's run copies pass today); offset and bytes_per_row are Metal's copyFromBuffer layout over those bytes. Each row's texels within a run and a chunk are one vkCmdCopyBufferToImage / vkCmdCopyImageToBuffer region straight on the chunk's import (bufferRowLength and bufferImageHeight 0; bufferOffset a multiple of the texel, VUID-vkCmdCopyImageToBuffer-srcImage-07975; the subresource bounds 07971/07972), with no staging buffer. A first-touch or CPU-only chunk goes through the existing StagedGather / StagedScatter, which now take a buffer or an image target. Hazard tracking, dirty-page reports, imports held to completion and the bytes outside the texels are as the buffer forms keep them. Refused as the buffer forms are, and with Invalid / Problem::HostRam for the texture's own cases (its doc extended); no new RuntimeGap, Degradation kind or WorkCounts field: the direct form shows in host_ram_copy_regions with no staged copy. replay.rs logs the call (HostRamTextureCopy); blit_texture.rs and blit_plan.rs helpers are shared (pub(super)). Runtime README and HOWTO document it; the signature table blessed (+2 methods); REFUSALS regenerated. RUNTIME_VERSION 2484. Verified: msi job m3-max-37991 (lavapipe, --cfg m2v_cpu_icd): clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0; nextest host_ram_texture_device + host_ram_copy_device 39 passed. m3-max-37997: "HOST-RAM-TEXTURE llvmpipe: fill regions 250, dispatches 0, staged 0" (a 300x200 BGRA8 Private texture, rows at 1280 bytes from byte 48, one row across a chunk end); the staged test saw exactly one staged gather and one staged scatter. Plain and --cfg m2v_gpu clippy, rustdoc and the 780M and Iris runs follow on development. |
||
|
|
3619e37540 |
RUNTIME 2482: Texture::view_placement answers what a view would be, by the decision its making takes
The consumer will make an IOSurface plane's device cache one optimal Private texture, every texture over the plane a view of it, and needs to know before it makes a view whether the runtime would make it a Vulkan view of the image or a view shadow (which it sends to its own fallback instead). What: `Texture::view_placement(pixel_format)` answers `ViewPlacement` (`Image`, `ImageThroughSwizzle`, `Shadow(ViewShadowReason)`, `OverBytes`), or the error `new_texture_view` would refuse the view with. The decision is factored, not copied: `Texture::checked_view` holds the checks `view_as` ran inline (Metal's rules, rotation, X32, buffer slices, decoded twins), `Texture::view_hold` decides the storage (shared, through a swizzle, the viewed image, a shadow and why, storage over the bytes), and `Device::view_shadow_plan` / `shadow_plan` hold the shadow's refusals `image_shadow` checked while making. `view_as` and the query call the same three. `image_plan::views_missed` replaces `takes_views_of` and names why an image takes no view (another compatibility class, or not in its list); `Device::view_apart` replaces `image_takes_view` and puts the device's missing reinterpretation first; the `shadowed-texture-view` notice's reason now follows that reason (it chose by the texture's PixelFormatView usage before). Tests: `view_placement_device` (runtime, device cfgs) sweeps 10 texture formats x 5 usages x 24 view formats, checks the query moves no count and matches the view made (by `view_shadows`, `views_through_swizzle` and the handed-out image), and names the consumer's cases. `plane_device_cache` (validation lane): a 300x200 BGRA8Unorm Private texture round-trips between no-copy buffers at offset 48 and pitch 1232 with every other byte kept; a clear through its sRGB view then a copy through its own-format view in the next encoder, tracked and untracked with a fence, read the clear with no hazard under synchronization validation, and the unordered control is reported as a read after write. Documented in the runtime README; the signature table blessed (10 rows); REFUSALS regenerated. RUNTIME_VERSION 2482. Verified: msi job m3-max-37961 at c2f0c96d3c: clippy -p metal2vulkan-runtime -p metal2vulkan-validation --all-targets --all-features --cfg m2v_cpu_icd -D warnings 0; the lavapipe tests, plain and --cfg m2v_gpu clippy and rustdoc follow on development. The hazard tracker keys a view's uses on its image (texture.rs view_as shares the Arc<Image>; bound_use/image_use key on image.identity.key), so the order across views needed no fix. |
||
|
|
d8b39b12d1 |
SEMANTICS 2141 / RUNTIME 2481: Read short constant windows through uniform texel buffers on the Iris Xe
What: on a device whose profile takes the new cost fact DriverWorkaround::ExternalUniformReadsSkipACache (ANV on the Iris Xe of RPL-P alone), a buffer slot's uniform view whose window the translation bounded to at most TEXEL_WINDOW_BYTES (4 KiB) is declared as a uniform texel buffer (UniformConstant image, Dim Buffer, Sampled 1, u32 texels) and read with OpImageFetch; the plan's form is DescriptorView::UniformTexel, its descriptor UNIFORM_TEXEL_BUFFER, its use class Sampled, its range the uniform view's own under minTexelBufferOffsetAlignment and maxTexelBufferElements. Every other uniform view stays a uniform buffer exactly as before. The runtime makes an R32G32B32A32_UINT view of the planned range for each write, with no cache, holds it until the command buffer completed (State::retain_own, which also keeps an indirect chunk that made one from being kept), and binds whole a draw rebound or carried at such a slot. The zero buffer takes the uniform texel usage, and upload regions align to the texel offset alignment too. ARTIFACT_FORMAT_VERSION 525 (DescriptorView gains a variant); SEMANTICS_VERSION 2141, RUNTIME_VERSION 2481. WorkCounts: uniform_texels_bound; uniform_buffers_bound_to_16k (a bound buffer's uniform view written as a uniform buffer, window at most 16 KiB: on the Iris the 4-16 KiB ones); uniform_buffers_bound_past_16k (longer, or not bounded). Why: ANV gives external memory MOCS 61 on Gen12.0, which loses the HDC L1 that uniform buffer reads go through; the sampler path keeps its cache. On the Iris, a UBO over imported memory ran 2.0-2.5x (and 5.2-5.5x for a divergent index) the time of device memory, a uniform texel buffer 0.98-1.04x (jobs m3-max-37703, 37729). The window sweep (37753, 37780) set B: at 1 and 4 KiB texel-set was no slower than ubo-set on device memory in every pattern; at 16 KiB one row was 3.1% slower; from 32 KiB per-lane patterns 2.8-4.2x. B = 4 KiB covers the consumer's binds only where the kernel's window (its struct size or accessed hull) is at most 4 KiB. The counting walk counted buffer sizes, not windows, so the new counter will tell. The cost of a view per write: vkCreateBufferView+vkDestroyBufferView 0.082 us on the Iris (mean of 4000), vkUpdateDescriptorSets 0.007 us against a uniform buffer's 0.024. A set 0 naming a fresh view is found again by no later command, so such commands lose set-0 reuse. Tests: engine_access (the texel form's module, its interpretation at residuals 0, 4, 16 and 256, the window bound, the slot's plan), the profile fact's carriers, and a lavapipe test whose compile device takes the Iris's identity (cfg(test) DeviceOptions::compile_as): offsets 0, 4, 16, 256, 260, set*Bytes data, bytes written before encoding, after it and by a blit, and a 4100-byte window kept as a uniform buffer, with the counts as evidence. Also: the fixture uniform_texel_windows's AIR companions (job m3-max-37901); a texel form's loop-invariant fetches move out of their loops as a uniform block's loads do (spirv::hoist, with its test); the texel form documented (ARCHITECTURE, FAST-PATHS, view docs, runtime README); the API signatures blessed. Verified: msi job m3-max-37946 at 00121399e7: fmt check 0, clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd; --all-targets --all-features -D warnings) 0, rustdoc -D warnings 0. Touched suites running in the same job. Golden table and engine fixture inventory re-bless on development. |
||
|
|
8bcaf69f1d |
RUNTIME 2475: Compute dispatches instantiate over the commands their bind state kept
What: BindingPlan::instantiate_dispatch_into writes a dispatch's commands over a kept DispatchCommands, every field set as instantiate_dispatch sets it, the vectors keeping their storage: each region's specialization (spec_key_into, region_specialization_into) and push write's bytes, the argument table's bytes, the ranges, extents, holes and uses. instantiate_dispatch is that method over no commands. The regions a dispatch plans take no list of each axis's pieces (`Pieces`, numbers alone). In the runtime, compute::Instantiated keeps its commands as storage when a value they may read moves, and a direct dispatch that instantiates writes over them where nothing else holds them (the memo entry they were taken into is replaced first: a dispatch that instantiates settled anew); builds with debug assertions instantiate afresh and compare. WorkCounts::dispatches_instantiated_in_place counts them. Why: a guest's compute encoders bind their buffers at moving offsets, one dispatch an encoder, so their kept commands never serve again (reims's Iris walk: 96.6% of dispatches instantiated anew). Profile (msi lavapipe, dispatch_chain --host 400 --only encoders --dispatches 5 --groups 64 --states 3 --binds tex-moved, calling thread): instantiate_dispatch 5.6% of its CPU, about 600 ns a dispatch, of it translator instantiate 3.4%, regions 1.6%, region_specialization 1.1%; about fifteen allocations each instantiation. The commands read the buffer bindings that move, so no memo of them is exact for this shape: the cut is the work of making them. Verified: tests::bind::dispatch's instantiating_over_kept_commands_gives_a_fresh_instantiation (more regions, fewer, none, another state, the key's storage kept); compute_instantiated's encoders_of_moving_offsets_instantiate_over_the_kept_commands (five encoders of one command buffer: 5 instantiated, 4 in place, each writing at its own offset), on lavapipe. Checks at the lane tip d52118ce95 (msi): clippy -D warnings --all-targets --all-features for metal2vulkan and the runtime, plain (m3-max-37686), m2v_cpu_icd (37688) and m2v_gpu (37689), all 0; rustdoc -D warnings 0 (37689); the translator bind::dispatch, plan::compute and graphics tests 42/42 (37686); the runtime compute, dispatch and encoder tests on lavapipe in a debug build, so every in-place instantiation was compared with a fresh one, 244/244 (37688). gem10 lavapipe m3-max-37685: dispatches_instantiated_in_place 0.80 a dispatch on the tex-moved row, every instantiation; that run's timing was unusable (rows the change does not touch moved more than the cut); one interleaved timing run follows. With: dispatch_chain: an encoder's dispatch binds as its command buffer's dispatch index says (aac8651f23): at development the encoders shape never moved offsets or swapped textures. |
||
|
|
3a3d31c374 |
RUNTIME 2470: Rebinds: a rebind before the submission of an encoder no rebind encodes again is refused
A rebind between a command buffer's commit and the submission of its last event group, of a buffer an encoder of it named that keeps no log (a compute encoder its unit of command predication reaches past, a loop's laying, a render encoder opened while no buffer over host pages existed), failed that submission EncodedUseRebound: the commit let go of its holds, and nothing encodes the encoder again. The consumer's answer table ends the VM on that kind. Now the rebind is refused instead (EncodedUses), and the command buffer runs over the pages it was encoded over. - State::keep_replays also answers whether an encoder that keeps no log (not one its commit fails, which runs nothing) named a buffer over host pages, by its own commands or by work it left for later not recorded on the GPU alone (State::unlogged_names_a_pin). - Where so, the commit keeps the command buffer's holds (State::held_to_submission) instead of letting them go: Holds::hold_to_submission moves each from Entry::pending to a new Entry::unsubmitted under one lock of `buffers`, so no rebind falls between. They go as the last event group's first batch is submitted (State::first_submission, State::later_group), or at completion; a rebind after that keeps the old pages for the submitted work, as before. - replace and the rebind's first check refuse while `unsubmitted > 0`, counted as their own reason: WorkCounts::rebinds_refused_unsubmitted. - Cost: nothing new for a command buffer whose encoders a rebind encodes again (one pass over its ended encoders' flags at the commit, inside keep_replays). A host-step command buffer keeps holding to completion (steps_hold), unchanged. Deadlock audit, by lock: - Commit: hold_to_submission takes `buffers` under the command buffer's `state` lock: state -> buffers, the order encode_moved's Submitting and the commit's own clear of its holds already take. - Submission: the holds go under the scheduler's lock and `state`, after the `Submitting` guard (`buffers`) was dropped; each Holds' drop takes `buffers` alone: scheduler -> state -> buffers, the order the submission's judging already takes. Never under `buffers` itself. - Completion: moved out of `state` and dropped after its lock, with the submitted holds. - Nothing waits on them: a rebind finds `unsubmitted` and is refused; no wait is added anywhere, so no cycle can form. Tests (lavapipe): rebind_races gains a control (the predicated family committed behind an unsignaled shared-event wait, rebound before the signal: refused, completes over the old page, refused-unsubmitted 1), and the threaded run asserts no command buffer fails EncodedUseRebound. Tests that asserted the old outcome of such a rebind now assert the refusal and a completion over the old pages: pending_rebind, rebind_loop_check's rebind before the laying's submission, tile_rebind_making_wait's unlogged tile pass, and validation's rebind_reach test of a unit's encoder that laid its first step. The validation lane no longer has a test that announces encoded-use-rebound (degrade_notices says so). Docs: rebind.rs module docs (ordering rule, a predicated loop's laying), Buffer::rebind_bytes_no_copy, RebindProblem::EncodedUses, the encoded-use-rebound catalogue entry and its declaration, runtime README; api_signatures blessed. Follow-ups in the same landing: Rebinds: a state's reset takes held_to_submission fresh too; Rebinds: clippy (append, take) in the hold-to-submission moves. Checks (lane rebindsafe2): clippy plain (runtime, validation) 0 at 5bfab2beaa in m3-max-37364; lavapipe runtime tests 356/356 at a0fc57f283 (m3-max-37354: rebind, detach, host_page, host_step, indirect, predication, pending, holds, encoder_fold, deferred_calls), the new control refused with refused-unsubmitted 1 and the threaded run asserting 0 EncodedUseRebound. Validation lavapipe (m3-max-37365), rustdoc and the cfg clippy runs follow on development. |
||
|
|
5acd27cd0d |
RUNTIME 2468: Rebinds: a call of an encoder the runtime cannot encode again never races a rebind
After RUNTIME 2465 a rebind racing an encoder call on another thread is detected and the encoder encoded again; one the runtime cannot encode again (a compute encoder its predication unit reaches past, one that left a GPU-written indirect dispatch to its host step, a render encoder that keeps no log) failed EncodedUseRebound at submission instead, which a consumer's answer table treats as fatal. The protocol: those encoders' calls are gated, so no publish overlaps one. - Rebinds gains `calls` (gated calls under way). A gated call begins (`Holds::begin_call` -> `CallGate::enter`): calls += 1, then reads `open`; where a publish is open it backs off and waits for it to close (`wait_published`), before it reads anything of a buffer over host pages. - A rebind's publish now opens before its replace (`Rebinds::quiet_calls`): open += 1, then reads `calls`; where a call is under way it waits for the calls to end (`drain`/`drained`), up to CALLS_DRAIN (2 ms), and is refused past it (EncodedUses, Unreplaced::Calls), never failing the encoder later. The four accesses are SeqCst (a store-buffering handshake: of a rebind and a call that meet, at least one reads the other's rise), so each gated call reads the buffer wholly before the publish (holding it, which refuses a rebind until its commit) or wholly after its close. Chosen over the registry lock: the call side costs two atomics and takes no lock. - Which encoders: every compute encoder, and a render encoder that opened with no log. A compute encoder can become unreplayable mid-encoding (the call that records predication, a loop's record, an unbalanced record that leaves work out, a later encoder of its unit that lays a loop, a dispatch left to its host step), after earlier calls ran: a gate that started at that transition would leave those earlier calls racing. So the gate covers a compute encoder from its open. Blit encoders always log, and render encoders with a log, stay re-encodable and pay nothing new. A device with no buffer over host pages pays one Relaxed load per gated call (`any`). - Nesting: a thread-local depth, so a call an encoder's call makes of its own public calls (a blit's unlogged calls, a loop's copies) never waits. - WorkCounts: rebinds_refused_calls_in_flight (the retry rate), encoder_calls_held_by_rebind, and encoders_raced_unreplayable (raced encoders committed with no log: each fails EncodedUseRebound; zero now). Deadlock audit, extending 2465's, by lock: - `drain`: taken by a rebind waiting for the calls (no other runtime lock held: rebind_host_pages holds no lock across replace) and by a gated call's end, which holds none of the runtime's at its end. Nothing is taken under it. - `buffers`: `unopen` takes it alone to lower `open` and notify `closed` (so a waiter between its check and its wait cannot miss it); a gated call's back-off waits on `closed` under it, holding at most its render deferral's `lowerer` lock (lowerer -> buffers is the order holds already take). No publish step takes `lowerer`; the rebind's `lower_all` runs before the publish opens. - The rebind's wait for calls is bounded (2 ms), so a gated call under way that waits on a thread held at a gated begin (a render end waiting for its lowering) ends in a refusal, not a deadlock. A gated call waits only as it begins, never under way, and the publish waits for nothing an encoder holds (2465's audit), so every begin's wait ends when the open publishes close. Docs: the Safety text of Buffer::rebind_bytes_no_copy and Heap::rebind_bytes_no_copy, the rebind.rs **Other threads** bullet and RebindProblem::EncodedUses state the new outcome: refused, never failed later, for the gated kinds. api_signatures.tsv gains the three fields. Tests (src/tests/rebind_races.rs): a pause-point control (a predicated dispatch, Unlogged::Predicated, held at its hold while the main thread rebinds: the rebind refused, the command buffer completes over the old page, refused-for-calls 1); the threaded run gains a predicated family and a host-step family (an indirect stage-in region, Unlogged::Segments), and asserts encoders_raced_unreplayable == 0. Follow-up in the same landing (cc0b4592a3): Rebinds: the refusal reason carries no pages (clippy: field never read). Unreplaced::Held and Unreplaced::Calls no longer give the new pages back: replace drops them once the registry's lock went (unopen drops the guard first), as the caller's map_err dropped them before. Also the docs of the encoded-use-rebound notice (degradation.rs, docs/API.md) and the runtime README say which encoders still fail it after a race (a blit or logged render encoder whose commit failed it, or whose encoding again a call that answers otherwise refused) and that gated calls never race. Verified: m3-max-37298 (msi) clippy at ec3cbb49c7 failed on exactly these two fields; the next job checks this commit. Checks (lane rebindsafe2): clippy plain (runtime, all targets, all features) 0 at cc0b4592a3 in m3-max-37302; lavapipe rebind/detach/host-page/host-step/indirect/predication/pending/holds suites with the gated control and the six-family threaded run in m3-max-37299 (ec3cbb49c7, same library code), the gate-off negative control, clippy GPU/CPU-ICD cfgs and rustdoc follow on development. |
||
|
|
2bafb6537a |
SEMANTICS 2138: Fragment simdgroup lane: run it on Cluster32 tiers, refuse it only below 32 lanes
What: a fragment function that reads [[thread_index_in_simdgroup]] on a profile
without DriverDeviation::MetalFragmentSimdgroups was refused Unsupported{SimdWidth}
on every tier but Direct. It is now refused only on Tier::PartialFragment (fragment
subgroups narrower than 32). On Tier::Cluster32 (a 64- or 128-lane fragment stage,
e.g. RADV on Polaris, wave64 only) the lane is the subgroup lane's low five bits.
Why: the guest is told an Apple GPU's width, 32 (threadExecutionWidth 32,
[[threads_per_simdgroup]] the constant 32), and its shaders are built for 32-lane
simdgroups. On Cluster32 each aligned 32 lanes of the device's subgroup is one
simdgroup. The function's simdgroup operations already ran there, and the emitter
already gave the lane as L & 31 (group::Lane::metal), the same cluster the shuffles
and ballot words use. So the device lacked nothing; the refusal was ours. The lane
is the device's grouping, which Metal allows, and records the existing
PrecisionNote::FragmentSimdgroupGrouping as before.
Tests: engine_simd's fragment-lane test also runs on wave64() (the committed RDNA3
description narrowed to 64 lanes) and requires every lane form to compile there on
Cluster32 with the note, the low-bits mask and L3. Without the fix it is refused and
the test panics. Device test fragment_simdgroup_lanes_are_metal_s accepts the
SimdWidth refusal only where the fragment stage's sizes are all below 32, so on a
wave64-only device it fails without the fix; it also prints the stage's sizes.
Docs: the note's text in docs/API.md and PrecisionNote, the doc comments in
lower::simd. SEMANTICS_VERSION 2137 -> 2138. REFUSALS.md regenerated, unchanged.
Checks (lane simd64): msi m3-max-37237 clippy plain 0, tests 88/88 (engine_simd, public_fixtures_engine, fast_paths, device::tests::subgroup); m3-max-37255 clippy GPU and CPU-ICD cfgs 0, rustdoc 0. The RX 550 run (m3-max-37259) follows on development.
|
||
|
|
35ac917d6f |
RUNTIME 2466: GPU start: written before the batch's first work, and at the top of the pipe on every driver
What: a timed command buffer's first batch with first work (new resources' first moves and zero fills, Managed copies in, staged copies) writes its start timestamp in that work's command buffer, after an execution barrier from every command before and before the work; and every start is written at the top of the pipe, where batches ordered by their ends wrote it at the bottom. Why: GPUStartTime must say when the GPU began the command buffer's work. In a traced Geekbench-like compute pass on an RX 7900 XTX (RADV, Mesa 26.2.6), the gfx ring's drm_sched jobs placed on the trace's clock (the job trace drifts 39.8 ppm against it, fitted per pass) showed command buffers whose start lay in the last tenth of their own job: spans of 1 us on jobs of 4.5 to 36.5 ms. Two causes. (a) The first work is inserted ahead of the start, and the start, at the bottom of the pipe under by-ends ordering, waited for it: managed copies in of the guest's did_modify_range ranges were 0.25 to 6.98 GB per workload. (b) With no first work too (prefixed starts, 237 first-work batches of 7486), about 1700 command buffers read their bottom-of-pipe start late; a Radeon 780M showed the same. That GPU time counted as "submitted, GPU not started" in the consumer's split: 4.06 s of its 5.90 s on the XTX. Ordering (every driver path): the first work's start follows an execution barrier ALL_COMMANDS -> ALL_COMMANDS, whose "first synchronization scope includes all commands that occur earlier in submission order" and "second synchronization scope includes all commands that occur later in submission order" (vkCmdPipelineBarrier), the timestamp write among them. A start at the top of the pipe where batches are ordered by their ends is held by the earlier batch's end barrier, Barrier::to_all (src ALL_COMMANDS, dst ALL_COMMANDS and HOST), by the same clause. Where batches are not ordered by their ends the starts were at the top already and are unchanged; a start after a barrier planned before the first encoder stays at the bottom, after that barrier. Whether Metal's span holds a Managed copy in on a Mac with a discrete GPU is not measured (the 5300M oracle can say). Verified: compile and device runs pending (tests/start_stamp.rs). Also folded: the test of a command buffer's GPU start against its own long work and its batch's first work (e86e9d356e). |
||
|
|
372cf95641 |
RUNTIME 2465: Rebinds: an encoder call that races a rebind on another thread is encoded again
rebind_bytes_no_copy (Buffer and Heap) may now run while other threads encode and
commit command buffers that use the buffer or heap. Before, the Safety contract
excluded that; this lifts it.
The windows found:
- W1: an encoder call reads a buffer's pages before it holds the buffer. A
dispatch builds its bind state, a draw its tables, and a blit reads the
VkBuffer for a copy run that records in a later call. A rebind can land
between that read and the hold. The hold then pins the new pages while the
commands name the old ones.
- W2: what lies over the bytes (aliasing images and their views, texel views,
the heap sets' elements) is made over the new pages only after `replace` has
let go of the registry's lock. A hold in that gap pins the new pages over
half-made state.
- W3: the render lowering thread does the same reads, later.
- W4: an encoding again (`replay.rs`) can run under a concurrent rebind of
another thread. This one is a live defect under today's contract: a commit's
rate-map or split re-encode, and one rebind's turn racing another buffer's
rebind.
- W5: a texture made over the bytes during the call stays excluded.
The change: detect, then encode again. Nothing waits on the encode path.
- Each rebind's publish runs from `Rebinds::replace` to a new
`Rebinds::published`. `published` is the close, after `renew_over`. It is
tracked by a per-device count of closed publishes (`published`), a count of
open ones (`open`), and `Entry::publishing` / `Entry::published`.
- Every encoder call loads that count as it begins (`Holds::begin_call`: one
Acquire load of an AtomicU64). The sites: compute and blit `logged`,
`end_encoding`, the five predication calls, render `Lowering::logged`, the
deferral's `at_call_unit`, the replay dispatcher and `open_render`, which
reads the count before it reads the attachments.
- A hold or pin finds the call raced when the entry's publish is open, or
closed after the call began. A raced Taken counts as rebound
(`Submitting::rebound`), so the commit encodes its encoders again before the
first submission (`State::raced_again`), as for a rate-map reset.
- `reencode` loops: when an encoding again itself raced, it waits until no
publish is open (`Rebinds::wait_published`, a condvar on `buffers`) and
encodes again.
- The close marks again the command buffers committed while the publish was
open, so their raced encoders are encoded again over finished state.
- An encoder the runtime cannot encode again whose call raced fails
EncodedUseRebound at its submission. These are the existing list: a compute
encoder its predication unit reaches past, one that left a GPU-written
indirect dispatch to its host step, a blit or render encoder opened while no
buffer over host pages existed, one whose commit fails it, and one with a
call that answers otherwise. A rebind that no encode overlaps changes
nothing for them.
- New WorkCounts::encoders_raced_rebind counts the encoders marked stale this
way.
- `blit_at` holds the buffer before it reads its VkBuffer, because a copy run
records in a later call.
- `replace` refuses a second rebind of a key whose publish is open
(EncodedUses).
What the publish window covers:
- Inside it: `live_buffers.rebound`, the alias leave/hold/place, the image
swaps and parking, the texel views, `forget_stale` and `renew_over`.
- Moved after the close: dropping the read twins (`drop(twins)`), dropping
the old pages (`drop(old)`, which reaches vkDestroyBuffer/vkFreeMemory and
the deallocator), `release_held_back`, `heap_sets::retire` and the
encodings again.
- What a later pin judges against: the old pages' twins and the stand-ins.
- Not covered: the import of the new pages and the images made again over
them before `replace`. These are the rebind's own and are invisible to
other threads until `replace`.
Deadlock audit, by lock:
- `rebinds.buffers`:
- `hold` and `pin` take `buffers`, then the cell's `pages` (`lying`), and
hold nothing across them.
- `replace` takes `buffers` -> `waiting` (`mark_waiting`) and `buffers` ->
`pages` (`cell.replace`).
- `published` takes `buffers` -> `waiting`. `mark_reencode` is an atomic.
- No thread holds `waiting` or `pages` and then takes `buffers`.
- The existing `state` -> `buffers` order (`encode_moved`'s `submitting`)
is unchanged. Neither publish step takes a command buffer's state lock.
- `wait_published`: its callers hold only the command buffer's `reencoding`
turn. These are the commit (after its state and slot locks are gone) and a
rebind's or commit's `reencode`. No publish step takes a `reencoding` lock
or waits for one. A publish waits for nothing: these take no lock an
encoder holds across a hold:
- `live_buffers.inner`;
- `aliases`;
- the image swap and view locks (`Image::swap_in`);
- HostPages `parked`;
- `rebinds.stale`;
- the texel views;
- `heap_sets`: `passing_hold` and `heaps`, whose writes are deferred while
`heaps.holds > 0`, with no wait.
So every wait ends as soon as the open publishes close.
- The test pause points (`rebind::pause`, cfg test) stop at the hold, with
no runtime lock held, and in the publish after `replace` has let go of
`buffers`.
Docs:
- The Safety text of Buffer::rebind_bytes_no_copy and
Heap::rebind_bytes_no_copy states the new contract and outcomes. Still
excluded: another rebind or a detach of the same buffer or heap, a texture
made over its bytes, and a resource placed in the heap, during the call.
- The rebind.rs module docs gain an **Other threads** bullet.
- Also updated: the EncodedUseRebound declaration and its docs/API.md
catalogue entry (the cost text is unchanged), the `renew_over` doc and the
runtime README.
- api_signatures.tsv gains the new field.
Tests (src/tests/rebind_races.rs, device tests):
- A pause-point control at the hold: a dispatch that read the bound buffer
before its hold, with a second buffer keeping the old import. Expected: the
new page's output and one raced encoder.
- A pause-point control in the publish: a dispatch reading a texture over the
buffer.
- A threaded run: four families (a dispatch of a texture over K, a draw with
K as a vertex buffer, a blit copy from K, and a dispatch bound a call
before) against a rebinding thread. Each output must be wholly one page of
those K lay in meanwhile, or EncodedUseRebound.
Hot path: one Acquire load per encoder call (begin_call) plus one compare
under the lock the hold already takes. Per-call numbers follow in the bench
commit or report.
Also folded: the threaded run reports the pages its outputs read and each wrong output's reason
(060e8219f0); and a publish's close counts as a move (buffer::host_cells_settled), so a binding read
during the publish (a texel view for one) is not kept under the post-replace count and reused
by a later encoder that did not race; debug checks (check_reading, compute check_whole,
KeptSpaces::of) hold off where a call may have raced (rebind::call_may_have_raced, debug only)
(0c7a7a5c98).
Verified (lavapipe, msi): m3-max-37154 at 0c7a7a5c98: clippy plain and --cfg m2v_cpu_icd 0;
rebind*, pending_rebind, degradation*, argument_table, live_bind 41 passed; the hold and publish
controls raced 1 and completed; the threaded run (4 threads x 25 command buffers: a dispatch over
a texture over the buffer, a draw with it as vertex buffer 1, a blit from it, a dispatch bound a
call before) read every output wholly from one page, 0 EncodedUseRebound, 63 rebinds made, 1,537
refused (EncodedUses), 5 encoders raced, 11 encoded again. Negative control m3-max-37156 with
Entry::raced forced false: the hold control fails (the dispatch read the pages the buffer left).
|
||
|
|
49b25c189c |
RUNTIME 2464: Parked dma-buf images released at the next pass where held imports tax submissions; each whole guest RAM import said with its time
A parked image (an in-place image over a no-copy buffer's dma-buf pages, kept for the next texture over the same pages) is one more imported memory on every kernel submission's list on RADV and ANV on i915. On the Radeon 780M that costs about 0.46 us a submission (m3-max-36970: 167 against 6 listed memories, 86.8 against 13.7 us a submission), 0.53 ms a second at the 1,150 submissions a second of a guest's desktop. Held 2 s (released by the first pass at least 2 s after the park, passes every 0.5 s), an untaken park cost 1.06 to 1.32 ms of vkQueueSubmit time, while a take saves its texture's making: on the 780M 0.13 ms (7.9 MiB) to 2.6 ms (84 MiB) over 2 MiB pages, 0.73 to 24.3 ms over 4 KiB pages (texture_shadow_bench, m3-max-37048, medians). In a guest's desktop walk on the 780M, 443 of 2,098 parks were taken; at 2 s the parks cost about 2.0 to 2.5 s of submit time, which pays only where a take saves 4.5 ms or more on average. Where Device::pointer_imports_tax_submissions holds, the residency thread now releases a parked image at its first pass after the park (held 0 to 0.5 s, 0.25 s on average); elsewhere, where a held import costs no submission, the 2 s window stays. The cap of 64 parked images stays. Expected, not measured: takes come soon after their park (a guest wrapping the same surface again a frame or two later), so most still hit; an untaken park then costs about 0.13 ms instead of 1.2 ms, and a desktop walk at the cap holds about 10 parked images instead of 64. The proof is a guest's desktop walk on the 780M before and after: dma_buf_images_taken against dma_buf_images_missed, dma_buf_images_parked_released, and batch_submit_nanos per submission. Tests: dma_buf_parked_images now forces the import tax: with Fails, a pass right after the park keeps the image; with Holds, the next pass releases it (fails without the change: the 2 s window keeps it). texture_shadow_bench's in-place arm parks its image in a warm-up within its own cycle, outside its times and counts, so its texture still takes one: the other arms between two of its cycles run longer than a pass. Documented in host_residency.rs, dma_buf/parked.rs and docs/HOWTO.md. No new Degradation kind; not an accuracy choice, so no FAST-PATHS row. Also folded: Guest RAM: say each whole import, with its time; bench it at 2, 4 and 8 GiB and across a recovery A device that imports a resident guest RAM whole as its use begins now says so once on its message sink (id name metal2vulkan-host-ram, Info): the bytes and chunks imported, those left to the copies, the imports' time and the first listing's (the submission of no work it waits for). A consumer then sees the one-time wait at setup in its log, and at each recovery of the device, whose carry makes the use again on the new device before it serves, so the new device imports the RAM whole in turn on the recovering thread. Tests (host_ram_whole.rs): the resident RAM says the line once, naming its bytes and its one chunk; the RAM with a hole says nothing; a recovery imports the resident RAM whole again before recover_for_test returns, and says so again. The ignored whole_ram_bench runs 2, 4 and 8 GiB RAMs, each on a device of its own, each with a hole and then resident, the resident one recovered, printing the device's lines. Documented in host_ram.rs (the module docs and use_host_ram) and docs/HOWTO.md. Guest RAM recovery test: read the chunks of the generation that serves a_recovery_imports_a_resident_ram_whole_again_before_the_new_device_serves read the RAMs through the root handle, whose own generation the recovery lost, so it found none and passed without asserting (m3-max-37099: "the new device does not import the RAM whole ([])", while the same run counted one chunk imported ahead in the recovery and heard the second line). It reads them through Device::current now, the generation that serves. The docs give the 780M's measured whole-import times at 2, 4 and 8 GiB (m3-max-37099): the imports 0.05, 0.08 and 0.1 s, the first listing 0.43, 0.63 and 0.51 s. And: whole_ram_bench times the first commit after the chunks' imports apart (dbc707372d); one doc line rewrapped (0d19c052f8). Verified: at ae6ae7876a clippy x3 (m3-max-37116 CLIPPY_GPU=0; m3-max-37117 CLIPPY=0, CLIPPY_CPU=0, DOC=0, 20 host_ram unit tests, lavapipe host_ram_whole/dma_buf_parked_images/host_residency 13 passed: the parked check kept with the tax forced Fails, released with Holds). PHOENIX (m3-max-37099, at c894bbdb13): whole import 2/4/8 GiB: imports 56/77/102 ms, first listing 441/633/511 ms, use_host_ram 532/759/690 ms; recoveries 507/768/716 ms; the lazy first commit today 429/639/510 ms. |
||
|
|
df87983bb7 |
RUNTIME 2463: Render draws: the restarted list and the error and notice makers out of line, cold
What: draw_resident's restarted-list arm (the index rewrite and gather requests, 205 source lines) is its own #[cold] #[inline(never)] method, restarted_list; Device::degrade, degrade_copied_pages, degrade_host_step, degrade_where and tell, and error.rs's vulkan, invalid, nil and internal are #[cold]. Same commands, barriers and answers; only where the code lies changes (draw_resident 130.7 -> 127.4 KB of machine code). Also folded: draw_costs gains a guest shape of a few render encoders with set_bytes and each thread's CPU a draw (17126bfe04), the encoding thread's own CPU apart from unnamed threads (afa24f4074), and --calls counting each call's cycles and cache misses (7249f6930b). Why: on a Zen 4 host a one-draw render pass ran at IPC 0.79 against 1.7 inside a long pass, the same on RADV and lavapipe (gem10, m3-max-36911/36975). The misses are instruction fetches: per pass about 8.3k L2 instruction misses against 1.2k data, over 806 distinct 4 KiB code pages (more than the L2 iTLB's 512), no function above 7.5% of them (m3-max-37017, -37041). This change is measured neutral (m3-max-37061, lavapipe, release: pass1 instructions 112,257 -> 112,123, L2 misses 10,590 -> 10,577; cycles within the node's noise) and kept as correct and neutral; the lever left is the layout of the path's code across pages, a build setting of the program. Verified: see the landing's check jobs. |
||
|
|
0da1b0a342 |
RUNTIME 2462: Guest RAM: a resident, kept RAM takes chunks past 512 MiB, all imported as its use begins
On a device whose every held import costs each kernel submission (RADV, ANV on i915), a listed guest RAM's chunks stopped at LONGEST_LISTED_CHUNK (512 MiB), our own constant: an 8 GiB guest listed up to 16 chunk imports in every submission (the consumer's Iris Xe desktop: 15 live, about 4.7 ms/s at 0.35 us each and 1114 submissions/s). The cap bounds memory alone: a chunk's import pins every page of it, and udmabuf allocates the pages of the guest's memfd that the guest never touched. A RAM the VMM preallocated has every page allocated already, so there the cap bounds nothing. ram_plan now asks listed_chunks_of: where the cap would cut a range into more chunks than the source's and the device's limits do, the chunks are kept (releases_idle_chunks false), and every page of the RAM is resident as the use begins (every_page_resident: mincore over the ranges, a chunk at a time, stopping at the first page missing), the chunks run to those limits (4032 MiB on RADV and on ANV, whose maxStorageBufferRange is 4 GiB less one byte: an 8 GiB RAM in 3 chunks) and the plan is whole. A whole plan's chunks are all imported on the calling thread before Device::use_host_ram returns (Device::import_whole, counted as chunks imported ahead), then one internal submission of no work is made and waited for: the first kernel submission that lists a chunk just imported waits while the kernel writes its page tables, and every other submission of the device waits with it (the VM's page-table lock), so that wait falls in the use's start, before the guest's work, never inside a later submission. Vulkan used: the chunk import as before (vkAllocateMemory with VkImportMemoryFdInfoKHR) and vkQueueSubmit with a fence, waited for. A RAM with a hole, or one too long to keep, keeps the cap and its lazy imports as before. listed_chunk_bytes now gives the limits' length alone; the cap moved into listed_chunks_of. The module docs, use_host_ram's, Plan's, the imported-ahead count's, HOWTO section 6 and the FAST-PATHS "Idle dma-buf imports are released" row say so. Tests: listed_chunks_are_as_long_as_every_limit_takes_in_whole_64_mib (the limits' length); a_resident_kept_ram_takes_chunks_past_the_cap_imported_whole (the rule, residency asked only where the cap cuts the RAM; fails without the change, which answered the cap); and a_ram_is_resident_once_every_page_of_its_file_is (mincore, a memfd with a hole then written). The device tests tests::host_ram_whole (a 640 MiB resident RAM: one chunk imported as the use began; one with a hole: 512 + 128 MiB, none imported) and the ignored whole_ram_bench (a consumer's 8 GiB RAM in 16 chunks of 512 MiB each imported against 3 imported whole: the use's time and a submission's vkQueueSubmit time). Also folded: the probe tests::listed_memories with the test-only census Memory::blocks_by_kind (7120ba7212), and the unit tests' clippy fix (9efafb7742). Verified: clippy x3 at 9efafb7742 (m3-max-37010 CLIPPY_GPU=0, m3-max-37011 CLIPPY=0 + 20 host_ram unit tests, m3-max-37012 CLIPPY_CPU=0); rustdoc m3-max-36994 DOC=0; lavapipe host_ram 120 passed (m3-max-36995). PHOENIX (m3-max-37009): a touched 640 MiB memfd took one 640 MiB chunk imported ahead (use 126.2 ms); with a one-page hole [512, 128] MiB, none ahead. 8 GiB bench: 16 chunks listed -> 3, vkQueueSubmit 11.6 us a submission resident against 971.7 us averaged over 300 with the lazy chunks (first-listing stall included); use_host_ram 459.7 ms (89.0 ms imports). |
||
|
|
ba311896eb |
SEMANTICS 2137: Iris: a loop-uniform read-only slot stays a storage view (undo SEMANTICS 2136)
What: reverts |
||
|
|
3de483d86f |
RUNTIME 2459: Joined completions: a command buffer marked to join the next groups under Exact
CommandBuffer::set_completion_joins_next marks a command buffer, before its commit, as one whose completion may be seen with the next one's. Under CompletionPolicy::Exact, on a device whose merge check holds and whose queues are not relayed, a marked command buffer's batches wait in the scheduler's group as every batch does under Grouped. The first batch of the VkQueue behind them that is not marked goes last in that group, which then goes at once (GroupEnd::Closed, WorkCounts::group_ends_closed), so it is seen complete at its own end and never held back. Its submission check runs with the marked ones' (check_heads), so they are found ready together. No group is kept past its pass under Exact (Alone::Unkept, WorkCounts::batches_held_alone_unkept): a kept group can reach the GPU after the work ahead of it ended, which would delay the unmarked one behind it. Everywhere else (Grouped, no merge, relayed queues, the encoder trail, batches that never group) the mark changes nothing. Why: on the Iris Xe, ANV on i915 lists every VkDeviceMemory in each execbuffer, about 170-190 us of driver time a vkQueueSubmit at the consumer's import count, and the consumer cuts each guest command buffer into about 12 parts committed under Exact, one kernel submission each. In its walk the GPU sat idle about 1.5 ms per waited guest buffer between parts already committed, behind a backlog of those calls. The consumer will mark every part but the last of a cut whose completion nothing observes. Grouped-completion's notice, docs/API.md's catalogue, FAST-PATHS row 38, the runtime README, CompletionPolicy::Exact's doc, api_signatures and REFUSALS say so. Tests: runtime_lane::joined_completions (marked parts group and a group is closed by the last; checked parts too; a no-op where the device's own check finds no merge; unmarked parts go alone; an unmarked command buffer is seen complete while the long one behind it still runs, the marked one before it complete by then), on lavapipe with the merge assumed. Joined completions: the cost table's length, and the order test's first work done before The conformance cost table's SHARED list holds 36 rows with batches_held_alone_unkept. In the order test the marked command buffer took the new buffers' first work, which no batch in a group takes, so it went alone and nothing grouped: the buffers' first work now runs before it. Verified: clippy and lavapipe lane job m3-max-36769 showed the failure (grouped 0 with grouping true); the rerun is the next job. Verified at 8e6c37c263: m3-max-36784 (msi) clippy --workspace --all-targets --all-features 0; m3-max-36785 (msi, lavapipe, --cfg m2v_cpu_icd) joined_completions + grouped_submissions + alone_batches 21/21 (marked parts under Exact with the merge: 7 command buffers in 2 submissions; unmarked: 7 submissions, 0 grouped; lavapipe's own merge check, not Holds: 0 grouped; an unmarked buffer is seen complete at its own end). The Iris merge check answers Holds (m3-max-36725: 9.6 us in one call of 4 against 26.4 us apart). Release-mode lavapipe, clippy --cfg m2v_gpu and m2v_cpu_icd and rustdoc run after the merge. |
||
|
|
a552a55d1f |
SEMANTICS 2136: Iris: a kernel's loop-uniform read-only slot is a uniform view
What: a new cost fact, DriverWorkaround::UniformAddressStorageReadsSlow, derived for ANV on the Iris Xe RPL-P alone. On a profile that takes it, with robust descriptors: - the memory plan finds a kernel's read-only slots read in a loop at a per-instance uniform offset (SlotPlan::uniform_loop_reads); the loop forest and the per-instance uniformity run only there (memory::plan::marks_uniform_loop_reads), nowhere else; - lowering (lower::access::loop_uniform_views) reads such a slot through a uniform view in place of its storage view when the slot is also one unwritten_slots admits: an argument the AIR declares unaliased (air-buffer-no-alias) that no store, atomic, volatile or coherent access reaches, so no write of the dispatch lands on it and the view reads the bytes the storage view would. No aliasing fact, no bind-time check, no runtime change; - the view is sized as Profile F's fallback sizes its views (fallback_view): its window's range, or maxUniformBufferRange where the window does not bound it. Then the slot states RuntimeFact::UniformViewRange as Viewed and no BufferRangeLimit, so a plan whose shape binds a buffer whose length class does not fit asks for the existing storage_view_slots variant, whose compile keeps the slot a storage view and states it Kept (a fixed point). That variant is made only for such a shape. Every other profile and stage is unchanged. Why: Iris job m3-max-36137 measured a convolution's weights, read in its tap loop at the loop counter, at 316.3 us per tap through the storage view and 249.0 us per tap through a uniform view of the same bytes (4896.8 and 4042.4 us a dispatch at 15 taps, 10589.8 and 8523.5 at 33). The uniform view is the one form A's walk and that arm measured fast; ftreg's twin removal ( |
||
|
|
8933378831 |
SEMANTICS 2135 / RUNTIME 2458: No storage twins: a kernel's constant buffer on the Iris reads its uniform view alone
What: the Iris Xe RPL-P profile (DriverWorkaround::PushReadsLengthenThreadPayload) declares no storage twin. A kernel's constant slot keeps its plain uniform view, read at its residual as on every device without ConstantOffsetUniformReadsPreloaded; its set-0 layout binds the uniform view alone. Deleted with it, everything only the twin used: - translator: DescriptorView::UniformWithStorageTwin, BufferForm::storage_twin, ResourceKind::StorageTwin, BindingSource::StorageTwin, AccessPlan/Declared twins and the census's twin count, storage_twins, views::declare_twin/twin_symbol, emit's TwinMem, the twin's NonWritable statement (unwritten_buffer keeps its unaliased-argument use), PlannedBuffer::twin, the second DescriptorRange, buffer_uses back to buffer_use, range_at_bind_offset's unbound twin arm, planned_range's twin exclusion, rebinds_into's twin arm, the interpreter's twin binding, the codec's variants, and BindingPlan::read_only_buffer (its only reason was the twin); - runtime: uniform_residual_form_of and reads_other_words (keyed_regions takes no flat_grid), the neutral zero buffer's STORAGE_BUFFER usage and plan-based read-only check (back to the descriptor type alone, binding::read_only_buffer); - validation: out_of_bounds's twin arms; - docs: API.md section 5's twin bullet, the workaround's profile doc, residual.rs, views.rs, ModuleBuilder::unwritten_buffer, non_writable.rs, neutral.rs, neutral_zeros_shared's docs; api_signatures.tsv drops the five items. Kept: storage views' RangeAtBindOffset at offset 0 on that profile and its creation of both forms (RUNTIME 2410), set-0 counting tests, the dispatch_chain example's arms. Why: the twins are the confirmed cause of the Iris regression. Walk A (the tip with no twins) took 137.4 s of GPU time against 145.8 to 150.2 s for three walks with twins; Face Tracking 13.50 s against 18.1 to 21.1, Super Resolution 25.78 against 28.2 to 28.4, Background Blur 4.93 against 5.7 to 6.4; Horizon Detection gives up about 1.3 s (17.78 against 16.2 to 16.8). No structural rule separates where a twin pays (ftreg's report to main). SEMANTICS and RUNTIME are bumped at landing; golden tables and the compile census are re-blessed on development. Test: engine_access::a_kernel_constant_slot_binds_its_uniform_view_alone. On intel-irisxe-rplp-anv, with and without uniformBufferStandardLayout, buffer_end_byte_load_constant's slot 0 is UniformWords/UniformVec4, its RangeAtBindOffset key is read, and set 0 links exactly slot 0 at (0,0) and slot 1 at (0,1). A plan of nothing bound writes those two alone in set 0 (UNIFORM_BUFFER, STORAGE_BUFFER), and only them on four other profiles. At development the slot is UniformWithStorageTwin and set 0 holds a third binding, so it fails. ARTIFACT_FORMAT_VERSION 524: the codec drops the twin variants. Verified: m3-max-36704 (msi) at 2b88dec3f1 clippy --all-targets --all-features 0; m3-max-36706 clippy --cfg m2v_gpu 0. Rustdoc, the translator suites, clippy --cfg m2v_cpu_icd with the lavapipe runtime tests, and the negative control (the new test at development fails) run after the merge; golden tables and the compile census are re-blessed on development. |
||
|
|
e10f3529c2 |
FAST-PATHS: the Iris Xe reads imported host memory at about 2.2 times device memory's GPU time
A known gap, the device's: under ANV (Mesa 26.2.6, i915) a compute kernel's reads of constants over imported host pages cost per read, by host pointer or udmabuf dma-buf alike. Measured on the Iris Xe (reads_k probe, one pass, rings of 64): 256 threadgroups with 1,024 uint4 reads per thread took 325 us per dispatch from device memory against 714-740 us from a pointer import or a dma-buf import (jobs m3-max-36557, m3-max-36652). 4 KiB and 64 KiB rings cost the same, uniform and storage views cost the same, and no recorded command count differed between placements. The dma-buf route ran (dma_buf_imports 4, no pointer imports). The only lever would copy guest constants into device memory, which zero copy excludes. |
||
|
|
83b3b67f30 |
RUNTIME 2457: Predicated loops: a rebind while a loop without work apart runs again is taken
A predicated loop's check (Deferred::Loop) answered false in Deferred::resolved_at_its_calls, so the commit's steps_hold kept the pages of every buffer over host pages its command buffer used until it completed, and a rebind of one meanwhile was refused Invalid(Rebind(EncodedUses)) for as long as the loop ran on, which Metal does without bound. The check's host step reads only its unit's halt word, in the command buffer's upload arena. Each run again submits the laying's VkCommandBuffers again as they were encoded (Piece::Raw), the predicate word's VkBuffer or address and the body's sets taken at encoding, over the pages the laying's event group took at its first submission, which Submitting::submit keeps in State::retained until the command buffer completes; the batch the check holds keeps it from completing before the loop ends. Only the work the laying left apart is recorded again at each run: a host step's resolves the buffers its encoder named then, and work on the GPU alone records over the buffers as they lie then. So a loop's check is now resolved at its calls where its laying left no work apart (LoopCheck::leaves_work_apart). A rebind after the laying's submission is taken and every run again keeps the old pages, as Metal's loop reads the pages its submission found. A rebind before that submission is taken too, and the laying's encoders, which keep no log to be encoded again from, fail their submission EncodedUseRebound (announced), as every other compute encoder that predication reaches past does. A laying that left work apart keeps holding as before. The docs say so: deferred.rs, rerun.rs, rebind.rs (the module doc, RebindProblem::EncodedUses, Buffer::rebind_bytes_no_copy), the commit's steps_hold comment, the runtime README, and FAST-PATHS's two known gaps (the refusal now names a loop whose laying left work apart; the rebind between submissions names a loop's laying rebound before its submission). docs/REFUSALS.md does not move. The test is tests/rebind_loop_check.rs: a no-copy buffer holds a DoWhile's word and its body's input. A rebind while the loop runs again is taken, the loop runs again after it, ends on the old page's word alone, and its body wrote the old page's input; a rebind before the laying's submission fails the command buffer EncodedUseRebound, announced, its output unwritten. Verified: m3-max-36621 (msi, lavapipe, --cfg m2v_cpu_icd) at 30a7bfaa4e: rebind_loop_check 2/2 (running: rebind Ok, loop ends on the old page's word, old input; before submission: rebind Ok, EncodedUseRebound announced); rebind_*|pending_rebind|host_step_*|rerun_*|predicat* 29/29; control (development's Loop arm) fails both with Err(Invalid(Rebind(EncodedUses))); m3-max-36628 clippy --all-targets --all-features 0. clippy --cfg m2v_gpu / m2v_cpu_icd, rustdoc and the validation lanes run after the merge. |
||
|
|
9dc0a6a6ef |
Docs: name no workload of a consumer's benchmark
docs/FAST-PATHS.md's unshared-isolation row and a spares test's doc named two workloads of a guest compute benchmark; they now say 'one workload' and 'a guest's compute workload'. The repository names no consumer app, benchmark or workload. No behaviour change. Verified: git grep for the benchmark's and its workloads' names finds none after the change. |
||
|
|
e63ecb9405 |
RUNTIME 2453: Host pages: a buffer inside a no-copy buffer's own dma-buf import dedicated to nothing is bound in it
What: Device::bind_in_import now binds a no-copy buffer whose pages a live import of dma-bufs holds all of inside that import, as it does inside an import of the pointer, where the import is one VkDeviceMemory dedicated to nothing (a no-copy buffer's own dma-buf of one chunk, a piece of a shared file's import, a guest RAM chunk's). The new VkBuffer is made for the import's handle type (VkExternalMemoryBufferCreateInfo DMA_BUF, from bound_memory), its alignment and memory type checked as before, and the holding import is kept imported for good (HostImport::pages(ReadApart::Inside), as for a pointer import). Still refused: an import the driver took only dedicated to its buffer (DmaBufPages::dedicated_to_buffer, NVIDIA 615's retry) and several chunks bound to a sparse buffer (no memory); those pages stay a copy, or an import of their own beside dma-bufs. Before, every dma-buf import but a guest RAM chunk's refused, so such a buffer was a copy (copied_over_live_imports) whenever it came with no dma-buf source, or a second import beside it. The Vulkan rules: VUID-vkBindBufferMemory-memory-02985 (a buffer bound to imported memory names the import's handle type in VkExternalMemoryBufferCreateInfo::handleTypes, which host_buffer does from bound_memory's External(DMA_BUF)); VUID-vkBindBufferMemory-memory-01508 binds only the dedicated buffer where VkMemoryDedicatedAllocateInfo::buffer was not VK_NULL_HANDLE, which holds only for the dedicated retry, still refused; VUID-vkBindBufferMemory-None-10739 (offset a multiple of the alignment) and -memory-01035 (memory type) as checked before. Why: on the Iris, with a platform mapping a view of guest pages through one dma-buf, a guest heap's region takes a 2 MiB no-copy buffer imported through that dma-buf, and the 256 KiB buffers placed in the heap's pages, handed over by their pointer alone, became copies of the pages over the live import: 582 copy ins compared a second, each the copy's whole 64 pages (155 MB/s), 10.7 MB/s copied in, commit_nanos 43.7 -> 120.5 ms/s. With the views mapped from their files the same buffers were bound inside the pointer import (buffers_bound_in_import), with no copy. dma_buf_buffer_imports_dedicated was 0 there: every such import was dedicated to nothing. Docs: bind_in_import's doc no longer says a buffer's own dma-bufs' memory is that buffer's alone; dma_buf.rs's module docs, import_from_source's and chunks_buffer's `sole` contract and DmaBufPages::dedicated_to_buffer say a buffer over part of the pages binds inside an import dedicated to nothing and in none dedicated to its buffer; FAST-PATHS's NVIDIA dma-buf gap says the same. Test: tests/dma_buf_beside.rs's without_pointer_imports_a_buffer_inside_a_live_dma_buf_import_is_bound_in_it, on a device made without VK_EXT_external_memory_host: a first no-copy buffer over 4 pages of a memfd with a dma-buf source, then inside it a second with no source and a third with one, each bound inside ([0, 0, 0, 0, 1] of copied over live, beside, inside live, pointer imports, bound inside) where the first's import is dedicated to nothing (else a copy, and beside or a copy); the GPU reads the CPU's bytes through each, a CPU write before the commit reaches a copy through the second, a fill through one and a copy through the other in one encoder are ordered either way, and after the first's release the second's fill reaches the file's pages and reads through the third. Verified: m3-max-36423 at e377c24dce, clippy -D warnings (runtime and translator, all targets and features) 0 and rustdoc -D warnings 0. Lavapipe tests, the negative control, the cfg clippy and PHOENIX run after the merge. |
||
|
|
aa272cd706 |
Rebind: record the refusal while a dispatch's host step is left as a known gap
A compute encoder can leave a dispatch to its host step (Deferred::Dispatch, indirect_dispatch.rs): an indirect dispatch off the GPU's own path, or any dispatch while an indirect stage-in region is set. The host step reads the arguments once the work before it completed, and resolves the buffers its encoder named as it records. Deferred::resolved_at_its_calls is false for it, so the commit keeps the pages of every buffer over host pages the command buffer used until it completes. A rebind of one meanwhile is refused with Invalid(Rebind(EncodedUses)), where Metal's replace before the submission reaches the new pages. Encoding the encoder again (the reverted 947c110e49) would not reach this path: the rebind is refused before any encoding again. So the behaviour stays, and is now recorded: - rebind.rs's module doc lists the dispatch among the commands that keep a committed command buffer counting as uncommitted until it completes, with the refusal; - the doc comments of RebindProblem::EncodedUses and of Buffer's and Heap's rebind_bytes_no_copy name the committed case; - Deferred::resolved_at_its_calls names its false arm (an execution, a dispatch left to its host step, a loop's check); - the runtime README's rebind sentence names the committed case; - docs/FAST-PATHS.md has a known-gaps entry. HOWTO does not state the rebind's refusal, so it is unchanged. The test is host_step_reads.rs's a_rebind_while_an_indirect_dispatch_s_host_step_is_left_is_refused_until_completion. On a device without device addresses (shaderInt64 withheld), it dispatches [4, 1, 1] threadgroups from a no-copy page behind a shared-event gate, and rebinds the page before the signal over one holding [2, 1, 1]. It asserts: - the rebind is refused with Invalid(Rebind(EncodedUses)); - the command buffer completed with no error; - the host step ran; - the dispatch ran the encoded page's 256 threads; - a rebind is taken once the command buffer completed. Degradation kinds added or removed: none. |
||
|
|
dcac15a5c6 |
RUNTIME 2449: Host RAM: a rebind encodes the encoder of a gather staged past the imports again
An encoder that left a gather from a guest RAM staged through the CPU kept no log (Unlogged::Segments) where an encoding again could not copy the gather through the imports in its place: over a chunk that takes no import while it runs (Staging::cpu_only: a chunk the device refuses, or one an object's own import of its pages holds back), or in a part of its own after the GPU completed the work before it (Staging::after_the_gpu: a copy into those chunks was recorded, or a buffer over host pages lies over the bytes), which a copy through the imports would not start. A rebind, before the command buffer's first submission, of a buffer over host pages that encoder used then failed the command buffer with EncodedUseRebound, where Metal runs it over the new pages. Now such a gather is staged again as its first encoding staged it, as RUNTIME 2448 does for a staged scatter: HostRamCall::staged_again answers the first encoding's Staging for a gather that is not Staging::through_imports (StagedGather::encoded_again_through_imports), and Deferred::left_again_by_an_encoding_again answers for such a GatherStage, so the encoder keeps its log, its place takes the encoding again, and finish_replay leaves the step for its host step. Every other staged gather is copied through the imports by an encoding again, as before (Deferred::recorded_by_an_encoding_again). Unlogged::Segments now names a GPU-written indirect dispatch's host step, a scrub, and a shadow's copy in left to its batch's submission (shadow::GatedCopyIn, which no Segment::records_again test holds either; the doc did not name it). Docs: host_ram/copy.rs (First touch, the gather; Staging; StagedGather), deferred.rs, encoder.rs, reencode.rs, rebound_use.rs, and docs/HOWTO.md's two sentences on a gather's rebind. Test: host_ram_copy_device's a_rebind_before_the_first_submission_encodes_a_gather_staged_after_the_gpu_again, on the shape of a_first_gather_over_chunks_a_scatter_wrote_waits_for_no_import (each chunk import held in flight 300 ms by making_pause): one encoder scatters into scattered pages, gathers them back (staged after the GPU, the scatter having written the chunks) and fills a no-copy buffer, behind a shared event; the buffer is detached and rebound before the signal. Asserts the command buffer completes with no error, the first encoding staged both copies, the rebind encoded the encoder once and staged both again, the fill is in the new pages alone, the RAM's runs hold the scatter's bytes, and the gather's buffer holds them too. At RUNTIME 2448's files it is expected to fail on the error (EncodedUseRebound): the gather's step keeps the encoder from keeping its log. Degradation kinds added or removed: none. Verified: m3-max-36303 at 75b7873bc2 (same tree), clippy -D warnings of the runtime (all targets and features) 0 and rustdoc -D warnings 0. The cfg clippy, the lavapipe control at the old files, the staged rebind tests and the touched suites run after the merge. |
||
|
|
ce22739364 |
RUNTIME 2448: Host RAM: a rebind encodes a staged scatter's encoder again, staging it again
An encoder that left a scatter into a guest RAM staged through the CPU (Deferred::ScatterStage and ScatterDrain, host_ram/copy.rs) kept no log (Unlogged::Segments): no Segment::records_again test held for those steps. A rebind, before the command buffer's first submission, of a buffer over host pages that encoder used then failed the command buffer with EncodedUseRebound, where Metal resolves the use at the submission and runs it over the new pages. Keeping the log alone would not do: an encoding again took no chunk (takes() is empty there, and so is the kept plan's) and copied the scatter through the imports, which starts no part, while the staged scatter's CPU copy goes in a part of its own; splice_fits refuses an encoding again with fewer parts. And a scatter staged because a chunk takes no import while it runs (CopyTake::CpuOnly) cannot go through the imports at all. Now the call records how its first encoding staged it (HostRamCall::staged, set where the staging is decided), and an encoding again stages a scatter so marked again (HostRamCall::staged_again): no kept plan, no imports, record_staged_scatter from where the buffer lies then, its two steps and its part as the first's. It is the first encoding's own decision made again. Deferred::left_again_by_an_encoding_again answers for ScatterStage and ScatterDrain too, so such an encoder keeps its log (Segment::records_again), its place takes the encoding again (reencode.rs's splice_fits), and finish_replay leaves the two steps for their host steps as the commit left the first's. The first encoding's steps are retained unrun, as a replaced splice's are; the stage takes its arena region only at its step, so the unrun one takes none. Every other copy in an encoding again goes through the imports as before. Unlogged::Segments now names a GPU-written indirect dispatch's host step, a staged gather over a chunk that takes no import or in a part of its own, and a scrub. Docs: host_ram/copy.rs (First touch, the scatter; takes), deferred.rs, encoder.rs, reencode.rs, rebound_use.rs, and docs/HOWTO.md's sentence that such a rebind failed EncodedUseRebound. Test: host_ram_copy_device's a_rebind_before_the_first_submission_encodes_a_staged_scatter_s_encoder_again, on the shape of the staged gather's: a blit encoder scatters into scattered pages (a page named twice) and fills a no-copy buffer, behind a shared event; the buffer is detached and rebound before the signal. Asserts the command buffer completes with no error, the first encoding staged the scatter, the rebind encoded the encoder once and staged the scatter again, the fill is in the new pages alone, the RAM's runs hold the scatter's bytes (the later's for the page named twice), and the page beside them is unchanged. At development's files it fails on the error (EncodedUseRebound). Degradation kinds added or removed: none (EncodedUseRebound stays, for fewer encoders). Verified: m3-max-36269 at ebf9c7563f, clippy -D warnings of the runtime (all targets and features) 0. Rustdoc, the cfg clippy, the lavapipe control at the old files, the new test and the touched suites run after the merge. |
||
|
|
8562b28fe4 |
RUNTIME 2446: Shadows: a split merge on the host copies no piece; its kernel skips their columns
A merge on the host past shadow_merge::HOST_WHOLE_BYTES split: its host step stored the pieces of each row in lines beside the texels, and its kernel the rest. To keep the kernel off those lines, the GPU copied the pieces' kept bytes into an arena region and their changed bytes over them in the kept part: two vkCmdCopyBuffer calls of one region per piece. On the Iris Xe (ANV) that work cost about 7 to 9 us a region, growing with the rows, not the bytes: about 0.6 ms for 34 rows (m3-max-35898) and about 15 ms for 1024 (m3-max-36118: a BGRA8 1023x1024 render target over host pages drew in 17.57 ms a command buffer as a shadow against 1.26 ms in place, its host step 0.28 ms of it). Now the kernel takes a column window (bind::ShadowMergeModule: two more push words, PUSH_BYTES 24; shape_within, shape the whole row): a word outside the columns is neither read nor written in either store form, and counts as unchanged in its block. A split merge pushes the words between each row's pieces where every row's pieces lie at the same places in it (shadow_merge::columns: whole words, the same head and tail each row; rows whose pitch is no multiple of the line differ, and those merges go on the host whole). It records the changed copy and its dispatches alone, with no save, no mask, two fewer barriers and no arena region; the host step reads each piece's kept and changed bytes in the scratch's two parts, which nothing writes after the changed copy. Removed: HostMerge::saved, ShadowMerge::saves, ShadowCopy::merge_saves, the merge's region in EncoderCore::merge_on_host, MergeDrain::_region, and the split's copy uses of the kept part. The bound stays 1 MiB; its doc comment states the measured costs. Linear merges push the whole row. Tests: - bind::shadow_merge's a_region_merged_within_columns_leaves_the_words_outside_them: 70 rows of 6 words, columns 1 to 4, every word changed; words outside the columns keep the current buffer's, in both store forms, and a window of every column equals shape. - shadow_runs' merges_on_the_host_go_whole_up_to_the_bound_and_split_past_it also asserts shadow_merge_words_examined: every word of the whole merge's rows; for the split, the words between each row's pieces alone (height * (row bytes - line) / 4). - shadow_write_lines' cost test gains a 4K shape: 3839 RGBA16Float texels a row, 2160 rows 30720 bytes apart. The merge module is under no golden table (golden_hashes covers the fixtures' translations). api_signatures: PUSH_BYTES, shape, and the new shape_within. Degradation kinds added: none. Landing note: msi m3-max-36189 at 4b09425f2d (same tree): clippy metal2vulkan + runtime, all targets and features, CLIPPY=0. The API tables, the module tests, rustdoc, clippy m2v_gpu / m2v_cpu_icd, the lavapipe control (development's whole-row kernel fails the split test's words-examined count) and the touched suites, PHOENIX and the Iris re-time follow on development. |
||
|
|
7fa39e82e5 |
RUNTIME 2445: Scheduler: a committing pass that ended at its own handlers wakes the scheduler's thread before running them
What: where a commit_and_submit pass ends right after its own command buffer's last batch with
batches left, it marks the state for the thread's pass (State::dirty) under the lock. Right after
the lock is free, before the completion turn it owes and before its handlers, the committing
thread wakes the scheduler's thread (wake_thread, Woken::Host). That pass reports no left_over,
so the end of submit_at_commit does not wake the thread again; passed_over() is still checked.
The thread passes while the committing thread runs its handlers; the batches it submits take
later Turns tickets, so their handlers still run after the committing command buffer's.
Why: in PHOENIX m3-max-36098 (the guest-shaped SubmissionHandlers leg after RUNTIME 2442), the
time from an early end to the next kernel submission made by the scheduler's thread was
p50 27 / p90 278 / p99 986 / max 1273 us (212 samples). The left batches waited for the
committing thread's handlers and the wake after them. The usual wake (wake_for, inbox.nudge)
skips the wake while the committing thread is still counted as the passer, and pass_once_then
never looks again. The scheduler's thread is never gated by a counted passer: it waits only for
the lock.
Tests: submission_turns' a_committing_pass_ends_at_its_own_submission_handlers_{exact,grouped}
now let the scheduler's thread go once the committing command buffer's handler has started. That
handler waits, up to two seconds, for the three later command buffers' submissions
(CommandBuffer::submit_returned_time), and all three are made before it ends (none without the
wake). The handler-order assertion stays. The test's messages lose the runs of spaces an edit
left in them.
The check also requires no sleep-slice rescue (WorkCounts::scheduler_slice_rescues moves by 0): the first control with the wake removed (ctl/complat2f 86baad51c4, lavapipe m3-max-36134) passed the timed check, because a 100 ms WAIT_SLICE let the left batches go within the handler's two-second bound.
Verified: msi m3-max-36132 at 46c7eedd4a (product code as landed): build, runtime clippy plain and --cfg m2v_gpu, unit, sigs EXIT=0. The tightened check at the tip and its control (m3-max-36157), the suites, clippy x3, rustdoc and the PHOENIX legs (m3-max-36158) follow on development.
Degradation kinds added: none.
|
||
|
|
c602b94223 |
RUNTIME 2444: Host pages: remove the lend of free padding to the copies; such render targets are shadows
What: a texture that renders over host pages whose rows end inside a line, with
free padding, whose renders failed, no longer takes its image in place when the
class's copies failed too. Removed: in_place::lent_to_copies and lends, the lend
branch in in_place() (it now asks each access's own verdict and nothing else),
unlent_words and the shadowed-texture notice words it added,
degrade_line_write_back and line_write_back_reason, the storage form move's lend
count and notice, Degradation::LineWriteBack ("line-write-back") with its
docs/API.md catalogue entry, the device test lent_dma_buf_targets, and the
validation lane's LINE_WRITE_BACK list. copies_verdict stays: through
InPlaceChecks::decided it now decides only whether a shadow's copies back and
merges into such pages are spliced (shadow_splice::splices). FAST-PATHS's
host-pages row and the Iris known gap are edited in place.
Why: the lend loses CPU writes Metal keeps. Both Macs kept render padding over
buffer rows (m3-max-35486 and 35487: clear-and-store and draw changed 0 bytes;
only the UHD 630's kernel changed any), and the lend's render passes write the
rows' last lines back whole on the Iris. Its stated reason was that the shadow
lost the same bytes. That no longer holds: the shadow splices its copies back
and merges on the host on such devices, and on the Iris (m3-max-35898) its
clears and draws put back 0 bytes against the copy control's 5,941 in 300
rounds. Under the user's contract rule a form that loses writes Metal keeps is
deleted, not kept behind a switch.
Guest cost, bounded by counts: the guest's Iris Forward+ boot (reims run 35408
at
|
||
|
|
61b3749144 |
RUNTIME 2443: WorkCounts::dma_buf_sparse_binds; DmaBufRequest and HOWTO state what several chunks cost
What: a new WorkCounts field, dma_buf_sparse_binds, counts each
VkSparseMemoryBind the dma-buf chunks bind a sparse buffer with (one a
chunk, counted in dma_buf.rs's chunks_buffer once the binding is made).
DmaBufRequest's rustdoc and docs/HOWTO.md now say what an answer of
several chunks costs: each chunk is one sparse bind, which RADV makes a
GPU virtual-address operation of its own, updating the GPU's page tables
as the buffer is bound and again as it is released, where one chunk binds
a plain buffer in its import with no such update. The advice: answer a
request whose pages lie in several runs with one dma-buf of those runs
where the source can (udmabuf's UDMABUF_CREATE_LIST, up to list_limit),
and with several chunks only where one dma-buf cannot hold them. The
host_ab example lists the count.
Why: a consumer's guest compute walk on the RX 7900 XTX (RADV, Mesa
26.2.6) rose 0.4 s in its heaviest workload once its source answered
guest buffers with many pieces of its RAM's region files: 81 sparse
buffers over about 5,000 pieces in one second of setup, followed by
15,732 of amdgpu's page-table range jobs (377 ms of kernel SDMA jobs in
that second, against about 45 ms before), and 4,930 more as 240 buffers
were destroyed with one memory freed. Across the workloads the page-table
jobs tracked the pieces at about 3.5 a piece; the guest's own GPU job
time fell. No count said how many binds a sparse buffer took, and the
docs gave sources no cost for splitting.
Test: tests::dma_buf_shared_files's two-piece buffer now asserts two
sparse binds for its one sparse buffer (none where the device binds one
piece) and prints the count.
Verified: in the job that reports this tip (clippy of the runtime, the
dma_buf_shared_files tests on lavapipe). api_signatures blessed (one
field). No new Degradation kind.
Verified: msi m3-max-36087 at 9c5829c1ac: clippy -p metal2vulkan-runtime --all-targets --all-features CLIPPY=0; lavapipe (m2v_cpu_icd) tests::dma_buf_shared_files 10/10 ("two pieces of one file: ... sparse buffers 1, sparse binds 2", asserted). Clippy m2v_gpu / m2v_cpu_icd and rustdoc follow on development.
Degradation kinds added: none.
|
||
|
|
3348b469c2 |
RUNTIME 2442: Scheduler: a committing pass ends right after its own command buffer's last batch where that one has submission handlers
What: where a commit_and_submit pass submits its own command buffer's last batch and that command
buffer has submission handlers, the pass ends there. It takes no check, and leaves whatever else
is ready to the scheduler's thread, which the committing thread wakes as before (left_over ->
Woken::Host). The committing thread then runs its own handlers once the lock is free, before any
later batch's submission. New WorkCounts::scheduler_passes_at_commit_ended_early counts the
passes that so ended with batches left. A test-only hold point, trace::Point::AtCommitPass, comes
before a committing thread's pass.
Why: PHOENIX m3-max-35993 (the guest-shaped submit-cost leg, a trace of Turns waits by the
holder of the ticket waited behind) found one kind of wait. A segment that a committing pass
handed off waited behind that pass's own ticket: 0.12 a frame, p50 3449 us, max 4586 us. The
handler runs only after the pass's later submissions, which are costly in that leg. Every
segment after it in the one hand-off context waited too: submission return to own handler
p99 3410 us on the handler threads. The scheduler's handed segments never waited in Turns, and
committing threads never waited behind handed segments.
Tests: submission_turns' a_committing_pass_ends_at_its_own_submission_handlers_{exact,grouped}.
The scheduler's thread is held after a pass. A commit_and_submit is held before its pass while
three ready command buffers are committed after it: one on another queue, one behind it on its
own, one behind the first on the other. Its handler runs inside its call with one kernel
submission made (without this change, after all four). The pass submitted one batch and counted
one early end. The handlers run in submission order, each queue's in commit order.
Verified: msi m3-max-36060 at 0c131eff3a: build, runtime clippy plain and --cfg m2v_gpu, unit, sigs EXIT=0 (api_signatures: WorkCounts::scheduler_passes_at_commit_ended_early). Control m3-max-36061 (early return removed, lavapipe): both checks FAIL under Exact and Grouped ("submitted 4 batches, ended early 0; handlers ... [ours 4, ...]"); the other 12 submission_turns tests pass. Lavapipe suites, clippy x3, rustdoc and the PHOENIX submit-cost leg (36069) follow on development.
Degradation kinds added: none.
|
||
|
|
c2aedcd64c |
Diagnostics: encoder times count draws again; the pass log watches states by label hash
METAL2VULKAN_ENCODER_TIMES counted a render encoder's draws only where a draw took every step: a draw drawn again as before (render/draw_again.rs) or rebound (render/draw_again/rebound.rs) bumped the encoder's draw calls but not its timed work, so a row named a fraction of its draws (a measured guest run: rows of about 2300 draws/s against about 36k indexed Vulkan draws/s). Both paths now count as the program's draws, as every step's do. METAL2VULKAN_LOG_PASSES watched only textures by format and size, and its 256-line bound was spent before the pass of interest ran: in that run every 2768x1570 pass before the measured step printed (256 lines distinct even with object IDs left out, 171 by attachments and states alone), so the pass the encoder times ranked first never printed. A `state:HASH` entry now watches a render pipeline state by the label hash the encoder times name their rows by (encoder_trail::label_hash), so a run can name exactly the pass it needs; each state in a line carries its hash, so a line maps encoder-time rows to states. The hashes are worked out only where the log watches a state or prints a line. The bound and the once-per-pass rule are as before. Both are default-off diagnostics and change no work while off. Tests: tests::encoder_times::an_encoder_s_draws_again_count_among_its_draws (draws again as before and rebound, each counted, in a line of all its draws; fails without the fix: the line names only the draws that took every step); tests::pass_log state-entry parsing, refusals and matching. |
||
|
|
f3390be7f0 |
RUNTIME 2441: Scheduler: a committing thread's pass keeps only its own command buffer's submission handlers; gated completions post with one look
What: commit_and_submit's own pass (and the pass the lowering thread makes for one left for a
render encoder's end) keeps inline only its own command buffer's submission handlers, which run
on the committing thread inside the call, in their turn, as before. Every other command buffer's
handlers whose last batch the pass submits go to the device's handler threads right after that
submission, as one segment with its Turns ticket; the committing command buffer's ticket is taken
as its batch goes, so submission order holds. Both of submit_plain_ready's places that take
handlers (a submitted last batch and one held in the group) go through keep_or_hand_off.
A transition to Completed or Error whose transition to Scheduled is still owed is posted behind a
gate only where its submission handlers have not run (gate_for_handlers); otherwise plainly. The
gated post pushes the item behind the gate and opens the poster's closing under one lock with one
look for a thread (Contexts::post_gated), where post_behind and open made one each. FAST-PATHS
records the hand-off's own cost (19.1 wakes a frame).
Why: on PHOENIX, in the guest-shaped submit-cost leg after the scheduler-pass hand-off
(RUNTIME 2437), a submission's return to its own handler was p50 991 / p99 5231 us where a
committing thread ran it (978 handlers), against p99 380 on handler threads: a committing pass's
handlers waited for the rest of that pass's submissions. The gated post's second look for a thread
cost 4.4 wakes a frame.
Tests (submission_turns): a_committing_pass_keeps_only_its_own_submission_handlers_{exact,grouped}
(fails at control C2 m3-max-35888, the hand-off reverted: the earlier command buffer's handler ran
on the test thread); a_gated_completion_is_posted_with_one_look_for_a_thread_{exact,grouped} (fails
at control D m3-max-35877, post_behind + open: [(true,2)] against [(true,1)]). The check takes the
device's queue plan.
Verified: msi m3-max-36014 at bd810397db: build, runtime clippy plain and --cfg m2v_gpu, unit
44/44, sigs, lavapipe suites 126/126 (encoder_holds TextureWrite passes). Workspace clippy x3,
rustdoc and lvpval 30/30 at the pre-rebase tip 2d09ed2392 (m3-max-35927). PHOENIX m3-max-35923
(suites at df21628b0f): handler-thread wakes per frame 50.2 -> 48.37 (post_behind + open 8.9 ->
post_gated 6.72); seen to seen-handler p50 11, p99 3658 us.
Degradation kinds added: none.
|
||
|
|
528379dad5 |
RUNTIME 2439: Merge on the host whole up to 1 MiB of rows; count host steps
On the Iris Xe (RPL-P, ANV) the split merge's own GPU work (two buffer copies of the pieces beside the texels, three barriers and the kernel's dispatch) cost about 0.6 ms a command buffer for the guest's 34x34 RGBA16Float target (m3-max-35898: draw minus clear 0.69 ms, against 0.10 ms when the merge went on the host whole), while the host step's word loop costs about 0.30 ns a byte (4.97 ms for a 1920x1080 target's 16.6 MB, half its texels changed). So the split pays only past about 2 MB of rows. A merge on the host whose cut rows hold at most HOST_WHOLE_BYTES (1 MiB, half the break-even) now goes on the host whole again; larger ones split. A merge none of whose rows' lines holds a byte beside its texels still goes by its kernel alone, as on any device. The whole merge is also the exact form for the unmeasured case (a CPU write to a texel the commands left in a line whose other bytes they changed), so the known gap now applies only where the kernel stores: past the bound, and where no row's line holds a byte beside the texels. Both forms keep the measured padding contract, so there is no switch and no FAST-PATHS row. WorkCounts::shadow_host_steps counts the host steps that ran for encoders' copies back spliced and merges on the host: against command_buffers_submitted, the GPU-to-CPU round trips a command buffer pays, for a walk to read before any deferral of them. Tests: - shadow_runs::merges_on_the_host_go_whole_up_to_the_bound_and_split_past_it: over pages 16 bytes into a page, a 512x512 BGRA8Unorm target (1 MiB of rows) compares every byte of its rows on the host, and a 512x513 one each row's first and last lines alone; each one host step. - shadow_write_lines: the contract test's draw merges now compare every byte of their rows; the cost test alternates its verdict arms round by round, so clock drift and order weigh on both alike (the 1080p gap 35898 showed, equal in Clear and Draw, with the same work recorded in both arms by every count); a new test prints, for a render target whose rows end a texel short of a 4096-byte page (1023x256 and 1023x1024 BGRA8Unorm), under the device's own check and default policy, over pages imported by pointer and as dma-bufs: every host-page class's renders and copies verdicts for those row ends and its memory flags, the form the texture takes with its notices, and the median per command buffer of a clear-and-store and of a draw. Degradation kinds added: none. Verified: msi m3-max-35933 at f763e15338 (same tree): CLIPPY=0, CLIPPY_GPU=0, API=0 (15/15), release archive built. PHOENIX, lavapipe and the Iris run follow on development. |
||
|
|
438fdd4eee |
RUNTIME 2438: Merge on the host only the lines beside a texture's texels
A shadow's merge in place into host pages, on a device whose stores write back the lines they end in (the Iris Xe under ANV) or whose check has not answered, went on the host whole: the host step compared and stored every byte of the merge's rows. On the Iris that cost 12.7 ms a merge for a 1920x1080 RGBA16Float draw (17.7 ms a command buffer against 3.7 ms by the GPU kernel), and the guest's scene has about 73 such shadows. The merge now splits as the splice of a copy back does: - Its kernel stores the changed words of each row's bytes in the lines that hold the texture's texels alone (ShadowMergeStores::Words, never whole blocks). - The host step merges only each row's bytes in the lines that also hold a byte of no row of the texture's: the bytes between the rows and around them (shadow_splice::beside_texels; at most a row's first and last line). - Before the kernel the GPU copies those pieces' kept bytes into a region of the command buffer's arena, then their changed bytes over them in the kept part, so the kernel finds them unchanged and stores none of them; the host step compares the region's bytes with the changed part's. - The host step compares 4-byte words and stores a changed word with one AtomicU32 store (the changed word where all four bytes differ, else the word as it holds it with those bytes changed, as the kernel's Words form does); bytes outside whole words go one by one. - A merge none of whose rows' lines holds such a byte (rows that start and end on lines, as the 1920x1080 plane's 15360-byte rows do) goes by its kernel alone, with its fetch view and kept image where it has them. A merge not cut to its texels' rows stays on the host whole. The measured contract is the padding: row_padding_writes found the M3 Max, the 5300M and the UHD 630 keeping CPU writes to the bytes between and around a texture's rows under clears, stores and draws, and over IOSurfaces under kernels. No probe measured a CPU write to a texel the commands left inside a line whose other bytes they changed, while the command buffer runs; the kernel now stores into such lines, so that write may be put back on the Iris. FAST-PATHS's known gaps record it, beside the measured contract. WorkCounts::shadow_merge_bytes_on_host counts the bytes the host steps compared. Buffer::own_pages_flags gives a buffer's memory type flags, which the cost test prints for a buffer made as the host scratch is, beside the host loop's time over plain heap memory and over that memory (1920x1080, half the texels' red and blue changed). Tests: - tests::shadow_splice (pure): the pieces equal the rows' bytes in lines beside the texels, found byte by byte, over 9 shapes and 6 page phases (wrapping among them); the host loop stores the differing bytes alone at every alignment. - tests::shadow_write_lines: each draw merge's host step compares 16 bytes a row (the row's last texels, in its padding's line); the cost test's 1920x1080 draw no longer merges on the host. - tests::shadow_runs: the rebind test of host merges puts its pages 16 bytes into a page, so every row's first and last lines hold bytes beside its texels, and asserts the bytes compared (a line a row). Degradation kinds added: none. Also (65db6f5b40): the old device-local query, left with no callers, is gone; the probe prints the scratch's memory flags by name. Verified (fplend): msi m3-max-35872 at a5289d8132 (same tree as 65db6f5b40): clippy 0, clippy --cfg m2v_gpu 0, api_signatures + api_surface 15/15, debug and release archives built; 35850: tests::shadow_splice 5/5 (host pieces against a byte-by-byte answer over 9 shapes x 6 page offsets; the CPU word loop at every alignment). PHOENIX, lavapipe, rustdoc and the Iris run follow. |
||
|
|
2feb4e70f1 |
RUNTIME 2437: Scheduler: hand a pass's submission handlers to the device's handler threads as it goes on
What: the scheduler thread's passes no longer run the submission handlers of the command
buffers they submit (or hold in a group, or make Scheduled behind a host step) at the end of
the pass. Each time the pass is about to look for its next batch, it hands the handlers taken
so far, as one segment with its Turns ticket, to the device's handler pool (one context of the
"metal2vulkan-handlers" threads, made at the first hand-off), and goes on submitting. The
segment runs there in its turn, so submission order holds across passes and with
commit_and_submit's own pass, which still runs its handlers inside the call on the committing
thread. A pass that settled a switch of storage forms keeps the handlers it took from then on
and runs them itself after the switch ended, as before, since the switch must end before those
command buffers are Scheduled.
The blocking wait in run_scheduled (a Finished that found Scheduled owed waited on a pool
thread for the submission handlers) is gone: such a Finished is posted behind a context gate
(finish_after_handlers), its place kept, holding no thread, and the thread that ran the
handlers opens the gate; the Finished then runs the owed Scheduled first. So no handler thread
waits for a submission handler, and the pool's cap cannot be exhausted by such waits.
A held group is cut short for another queue's submission handlers (Alone::Handlers) only where
the pass keeps them (a settled switch): handed-off handlers hold back no pass.
Why: in the guest-shaped submit-cost leg on PHOENIX, a command buffer's submission handlers
started 1683/5299/5776 us (p50/p99/max) after its own vkQueueSubmit returned, behind the rest
of the pass; 4561 of 5280 command buffers were seen complete before their own submission
handler ran, and seen -> seen handler was 1.4 ms p50 / 5 ms p99 against Metal's 0.28 ms p99.
Tests: submission_turns gains a_pass_s_submission_handlers_run_while_it_goes_on_{exact,grouped}
(a handler of an earlier submission starts before the pass's later submission returns plus the
pause) and completions_before_their_submission_handlers_hold_no_handler_thread_{exact,grouped}
(6 queues with owed Scheduled on a pool of 2 threads, all complete within a bound; test hook
contexts::TEST_LIMIT). waiter_submits::Held now holds the scheduler thread with a test hook
after the pass that handed off its command buffer's handler (trace::hold_after_hand_off,
Point::HandedOff), since a submission handler no longer runs there. Tests and lanes that held
the scheduler thread in a submission handler hold it in a submission check instead
(unsubmitted, host_memory's deallocator lane); queue_order's take-up probe notes from the
check, which still runs on the scheduler thread; commit_and_submit's held-check test asserts
the orders that hold (A's handler before B's, B's check before B's handler) instead of one
interleaving; the submission_handlers lane expects the handler threads; grouped_submissions'
cross-queue handler lane counts X and Y's one submission once all completed.
Docs: add_submission_handler names the threads (inside commit_and_submit: the committing
thread; otherwise the device's handler threads), README, RUNTIME-PORTING, FAST-PATHS (the
grouped-completion row's handler rule, the commit cost entry), scheduler, inbox, group,
submit, contexts.
Also: the completion_latency guest-shaped leg times each submission handler from its own
submission's return; the unsubmitted check and the deallocator lane hold the scheduler thread
where an empty opener runs no submission check.
Verified (complat): msi m3-max-35809 at 0e0c55e4e8: build, clippy -D warnings (runtime, plain and
--cfg m2v_gpu), unit 44/44, signatures, lavapipe suites 122/122, all 0; gem10 35797 at 4aa9c2ac29:
workspace clippy x3 and rustdoc 0. Negative controls (msi 35811, lavapipe): with the blocking wait
back, completions_before_their_submission_handlers_hold_no_handler_thread fails under Exact and
Grouped (5 of 6 never completed with 2 handler threads); with no hand-off,
a_pass_s_submission_handlers_run_while_it_goes_on fails under both. PHOENIX suites and the
submit-cost leg before/after follow.
|
||
|
|
be720853a5 |
Name no consumer benchmark in comments, tests or docs
Eight comments and docs (dispatch_chain, compute_instantiated, spares_compute, unshared_hold and its tests, FAST-PATHS) named the guest compute benchmark a workload came from, and two named a consumer's job labels. AGENTS.md keeps consumer apps and benchmarks out of the tree; the shapes and numbers stay, described by what they are (a guest compute benchmark's super-resolution workload, its fluid simulation). Verified: git grep finds no such name; cargo fmt. Comments and docs only. |
||
|
|
2824464479 |
Storage twin docs: NonWritable states read-only memory, nothing more
What: views::declare_twin, DriverWorkaround::PushReadsLengthenThreadPayload and docs/API.md section 5 no longer say that the twin's NonWritable decoration lets ANV fold or merge its loads, or that the twin without it read more than the uniform view. They keep the fact: the twin binds the uniform view's own range of a constant buffer, which the dispatch only reads, so its views are decorated NonWritable. The decoration and its test stay. Why: |
||
|
|
518d6d8443 |
RUNTIME 2432: Shadows: merge on the host over host pages on devices that write lines back
What: a shadow's merge in place into a no-copy buffer's host pages, on a device whose check of those pages failed, or has not answered, the copies or the shader writes of texels whose rows end inside a line (the same rule as the copy back's splice), now goes on the host. Its keep and the copy of the texels the commands left go into two parts of a Shared scratch (ScratchKind::ShadowHost; the fetch view is not used, so the changed texels are always copied). The encoder records only that copy, and a host step of a batch of its own (Deferred::ShadowSplice, now carrying HostWrite::Splice or ::Merge) compares the parts eight bytes at a time and stores each byte that differs into the pages with atomic byte stores. Such a texture joins no run of passes (render.rs), so each pass merges as its encoder ends. Devices where both checks passed keep the kernel merge. Why: the Iris probe (m3-max-35510) showed the merge kernel's stores losing CPU writes to padding bytes in the line that holds each row's last texels, as the copy back did. A CPU store changes only the bytes it stores, so the bytes the commands left, and every byte the CPU writes meanwhile, stay. Metal keeps those bytes (conformance probe row_padding_writes.m). Where the merge stays on the GPU (FAST-PATHS known gaps): merges recorded between a pass's instances, before a tile dispatch, into a held command buffer, at a segment's end, merges through a copy, and the runtime's own Shared memory. New WorkCounts fields: shadow_merges_on_host, shadow_merge_host_nanos. Tests: shadow_write_lines now asserts the Draw rounds (keep + merge) put back no byte and go on the host under unanswered verdicts, and follow the measured verdicts in the second test. A new test, costs_of_a_write_back_spliced_or_not, prints the median command-buffer time of a copy back and a merge for 34x34 and 1920x1080 RGBA16Float, with verdicts unanswered and passed. Degradation kinds added: none. Verified (fplend): msi m3-max-35675 at bdb1e2cbae clippy (runtime, all targets/features, -D warnings) 0, touched unit tests 3/3, api_signatures + fast_paths 34/34; msi 35689 clippy --cfg m2v_gpu 0. PHOENIX suites (35711), lavapipe, rustdoc and the Iris cost run follow. |
||
|
|
9ea0a9c1f6 |
RUNTIME 2431: Shadows: splice a copy back into host pages on devices that write lines back
What: a shadow's copy back (Step::Back) of a 2D texture's image, or of a texture buffer's staging buffer, into a no-copy buffer's host pages is spliced where the device's check of those pages (DmaBuf or Pointer) failed, or has not answered, the copies or shader writes of texels whose rows end inside a line (Access::Copies or Access::Writes of RowEnds::InLines, Failed or Pending). The GPU copies only the columns that fill whole lines of memory (nonCoherentAtomSize): one region a slice where its rows are a multiple of a line apart, else one a row. Each row's head and tail columns go by the GPU into a line-aligned region of the command buffer's arena, and a host step of a batch of its own (Deferred::ShadowSplice, after the work before it completed) copies them into the pages a byte at a time, as the CPU's stores go. The encoder notes the truth's writes after the step. A copy whose texels fill whole lines alone copies back as before; a device where both verdicts passed copies back as before. New count WorkCounts::shadow_copies_back_spliced. Why: on the Iris Xe (ANV) a copy of texels into a buffer's rows writes back the 64-byte line holding each row's last texels whole, putting back older values over the CPU's writes beside them. The lane's probe (m3-max-35510) lost 3,539 to 14,319 bytes a kind in 300 command buffers through a shadow's copy back and merge, where Metal keeps every such byte (row_padding_writes.m). This breaks Metal's contract on the guest's bytes; the merge is the next change. Where the copy stays (docs/FAST-PATHS.md, known gaps): a copy back between a render pass's instances or before its tile dispatch, into a held pass's command buffer, at a segment's end recorded at a commit or a host step, of rotated, two-plane, tiled or heap depth/stencil textures, and into the runtime's own memory. Tests: tests::shadow_splice (the cut run as GPU and CPU over a map of host bytes: every texel once, no GPU byte in a shared line, every shape of texel, width, pitch and phase); tests::shadow_write_lines (the probe made a device test: the guest's 34x34 RGBA16Float target over dma-buf pages, buffer and plane forms, a clear's copies back put back no byte the CPU wrote beside them and are spliced; and a copy back spliced exactly as the device's measured verdicts say). Degradation kinds added: none. Verified (fplend): msi m3-max-35614 clippy 0, tests 0, signatures 0; 35623 clippy m2v_gpu 0; lavapipe 35625 clippy m2v_cpu_icd 0, 216 passed, rustdoc 0; PHOENIX 35632 (um790) in-place + shadow suites 287/287, shadow_write_lines 2/2: under the measured verdicts (Copies and Writes Passed) 0 spliced; under HostPageTexturePolicy::Shadow (no check, verdicts Pending) every copy back splices (+300 in 300 rounds, 0 bytes put back). The Iris run follows. |
||
|
|
a585a74686 |
SEMANTICS 2134 / RUNTIME 2427: A uniform view's storage twin is decorated NonWritable
What: memory::views::declare_twin states the twin's binding unwritten (ModuleBuilder::unwritten_buffer). The serializer then decorates the twin's variables NonWritable, its word view and its uvec4 view, where its own walk finds no store reaching them. No store goes through a twin: TwinMem's write, write_bits, write_unit and write_vec all refuse. Why: on the Iris profile (DriverWorkaround::PushReadsLengthenThreadPayload, ANV, Mesa 26.2.6) RUNTIME 2413 reads a kernel's constant slot through its storage twin where the slot's RangeAtBindOffset holds. The twin was not decorated NonWritable, because serialize::non_writable only takes the bindings the lowering states unwritten. ANV runs nir_opt_access (anv_shader_compile.c), which marks a storage buffer's loads reorderable only where the variable is NonWritable or the shader writes no buffer. A kernel that writes its output therefore kept every twin load apart, wherever it stood: no CSE, no hoisting, no merging. The uniform view's loads, a uniform buffer's, are always reorderable, and the driver folded them. Metal's compiler leaves a constant buffer's repeated loads for its own backend to fold. One guest depthwise convolution kernel loads its params.srcSize (<4 x i32>) four times in every iteration of its tap loop and its dstSize about ten times, and every inlined sample reads its ndArrayParams again. Read through the twin, each of those loads ran per thread. A benchmark's Iris walk rose from 754 to 1120 us a dispatch on that workload between pins |
||
|
|
8b70cf1ca7 |
FAST-PATHS: what listing a render target's sibling formats costs its compression
The view bullet now states the measured cost of cdcd787fb8's listing of
a render target's channel-order sibling formats (BGRA8Unorm and
BGRA8Unorm_sRGB of an RGBA8Unorm texture) in its image's format list,
which lets a pass render into such a view of the image in place.
Measured with tests::reordered_list_compression (ignored probe, carried
archive of
|
||
|
|
b034129644 |
RUNTIME 2426: Grouped: count each batch that went alone by why, and unshared queues' batches
Under CompletionPolicy::Grouped a batch refused a place in a group while no group
was held went alone and was counted nowhere: group_ends_* count only groups that
held a batch. So the consumer's steady Launchpad walks (batches_grouped 0,
group_ends_drained 1 a window) could not say why nothing grouped.
Each batch on a VkQueue whose batches group that goes in a kernel submission of
its own now counts once, by the first reason in group::Alone's order
(WorkCounts::batches_alone_* and batches_held_alone_*): an unshared queue's
batch, a binary wait or signal (a completion sync file), a sparse update, pieced
work, a fence, an unknown or too long expected run, first work or a wrapped image
with no group held, a committing thread's submission; or, held in a group that
went holding it alone, what sent that group (at most one earlier submission in
flight, an unshared queue's hold on the VkQueue, a head waiting for the GPU,
another queue's handlers, a waiter, kept with none joining, a batch that could
not join, or other). Group::keeps answers why it does not keep. And
batches_of_unshared_queues counts unshared queues' batches on every device, so a
walk under either policy gives their share.
The validation lane's alone_batches checks one batch per reason it can make
deterministic (unknown run, at commit, one pending, a completion sync file, an
unshared queue, beside an unshared queue) on a device that groups, and none
counted elsewhere; steady_presents (ignored, a measurement) runs a steady
present shape with an unshared compositor queue and prints the spread.
Conformance classes the counts that follow what the host had seen complete as
not the case's own. API signatures blessed.
Also 4d71df7f28 (a type alias for clippy) and 5e04b74b48: FAST-PATHS: grouped submissions' measured lateness, the unshared exclusions and the alone counts
Row 38 edited in place, docs only. It now states:
- the measured cost of the fast form in the consumer's guest walks on RADV at
|
||
|
|
59fc85ea83 |
SEMANTICS 2133 / RUNTIME 2425: OpenCL mode: a 1D image bound to a real 1D texture reads it, through a variant
An OpenCL-mode kernel declares each image1d_t / image1d_array_t slot as the 2D texture of
height 1 Apple's OpenCL binds (canon::opencl::entry, canon::opencl_1d). A real 1D or 1D array
texture is a VK_IMAGE_TYPE_1D image, which takes only 1D views (Table 18,
VUID-VkImageViewCreateInfo-subResourceRange-01021), and a 1D view cannot sit in the slot's
Dim 2D descriptor (VUID-vkCmdDispatch-viewType-07752). So the binder wrote the declared 2D
type's neutral (PlanDiagnostic::IncompatibleBinding) and every read answered zero, outside
both measured answers (Radeon Pro 5300M: the 1D values; UHD 630: layer 0 of the array).
Now a per-slot variant keyed by the bound texture's type:
- air: Entry::open_cl_1d_images records the texture indices of an OpenCL-mode kernel's 1D
images; SpecRequest::open_cl_lines names those a 1D texture is bound for, whose parameter
keeps its texture1d type (opencl::entry) and whose operations stay 1D (opencl_1d::expand
skips a call whose texture operand is that parameter).
- The kernel states RuntimeFact::OpenClLineTexture { slot } (Mechanism::Variant) per 1D image,
in the base and the variant alike; nothing else states it.
- The compute plan puts such a slot in VariantKey::open_cl_lines where the shape binds a
Type1D (Type1DArray) texture at a 1D (array) image read by the kernel
(bind::plan::slots::open_cl_line_variant). VariantKey::lowering_inputs carries it to
LoweringInputs::open_cl_lines, the specialized-entry cache key and SpecRequest. The variant's
interface states the slot Type1D / Type1DArray, so its plan binds the 1D view and states the
same key. The answer is the 5300M's.
With the set empty (Apple's 2D bindings) canon, the SPIR-V and the VariantKey are as before;
the base artifact gains only the OpenClLineTexture facts. The reflection still states the 2D
types. No runtime source changes.
Tests: canon::tests::opencl::opencl_1d_images_bound_to_1d_textures_keep_their_1d_operations,
engine_opencl_mode::an_opencl_mode_kernel_reads_real_1d_textures_through_its_variant and
a_plain_2d_texture_slot_given_a_1d_texture_binds_the_neutral; the runtime's
opencl_mode_1d_images_read_real_1d_textures (the repro).
SEMANTICS_VERSION 2133. api_signatures blessed (5 records); REFUSALS unchanged; docs/API.md's
OpenCL images paragraph.
Also e1aba1ad67 (the repro test), 9f3b309b65 and 8f2677c0ae (compile fixes: an Idx import; every SpecRequest literal names open_cl_lines).
Verified in the lane at 8f2677c0ae: lavapipe (m3-max-35393) OpenCL-mode runtime tests 19/19, the
new opencl_mode_1d_images_read_real_1d_textures among them (it failed at e1aba1ad67, m3-max-35348:
[0,0,0,0] for [10,11,12,13]); the 2D height-1 read and write tests pass at both. air OpenCL tests
9/9 (m3-max-35386). Still running when landed: the translator's engine_opencl_mode and api tests,
clippy x3, rustdoc, executor parity (runtime_lane::executions, runtime_run), the probe comparing
the guest 2D path's SPIR-V, facts and plan at base and tip, the PHOENIX run.
RUNTIME 2425 because the runtime's variant choice moves (bind::plan::slots); no runtime source
changed. New Degradation kinds: none.
|
||
|
|
662460fe5e |
RUNTIME 2424: Storage twins take 0 where their kernel reads any other word the binder writes for it
What: the runtime's uniform_residual_form sets every twin's RangeAtBindOffset to 0, as it does beside a residual read, also where the twin's stage reads under the key another word the binder writes for it (residual::reads_other_words, from the interface's PushPlacements): a field placed in its push range or its ArgumentTable, but a slot's SlotBindOffset residual where the key sets its RangeAtBindOffset, and the DispatchRegion words where the key leaves the stage's MultiRegion 0 on a variant that does not run a flat grid (a flat grid's one region reads them whatever MultiRegion says). A root table's or execution status's address, a replay's region record, a slot's guest base, a texture's levels and every other placed field count wherever placed. keyed_regions passes the variant's flat_grid; the render callers pass false (render stages have no twins). Why: RUNTIME 2419 kept a twin's key wherever no other RangeAtBindOffset of the key was 0, so a kernel with a twinned constant view that also reads a root table's address (a pointer through an argument buffer, dispatch_chain --binds ptr), or a multi-region region (dispatchThreads' edge regions and group-count splits, tile and partial-threadgroup plans), or a flat grid's region kept reading the twin at its bind offset while its thread payload stays long: the 2419 mechanism (ANV, Mesa 26.2.6, Iris Xe RPL-P: moved arm 154.0 us through the twin against 143.1 us through the uniform view, job m3-max-34864), whose cost is the stage's push reads (job m3-max-34063). dispatch_chain --binds 4 reads thread_position_in_grid but dispatches threadgroups with MultiRegion 0, so its measured twin gain (102.1 against 142.8 us) is kept. Runtime only: no translation output, plan or artifact moves (the executor and the execution record's plan check compare plans and artifacts, which the runtime's region keys are not), and no creation key. Only dispatch keys of a kernel with a twin and such a word move, on the Iris profile alone. Docs: residual.rs's module docs and functions, keyed_regions, the workaround's profile doc and docs/API.md section 5. Tests: general_form's a_twin_takes_0_where_its_stage_reads_another_word (the twin zeroed where its kernel reads another word, kept where it reads none, another stage's word ignored) and a_stage_reads_its_region_under_multi_region_and_every_other_word_it_places (reads_other_words' cases: MultiRegion 0 and 1, a flat grid, a residual held or not, an unkeyed residual, a root table's address, another stage's field). Verified in the lane (m3-max-35286, msi, at def6a68f94; each step's own exit code): clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0; tests::general_form 6/6; lavapipe runtime_lane::executions + candidate::engine::runtime_run 34/34 (executor parity). Still running when landed: clippy m2v_gpu and m2v_cpu_icd, rustdoc, the Iris A/B (a twinned constant view beside a root table address / multi-region region, --binds 4 as control). New Degradation kinds: none. |
||
|
|
92a77c7025 |
RUNTIME 2421: Continued passes on a device that splits at aliases, where no buffer write meets their images
What: on a device whose driver has DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer (NVIDIA's 620.70.06 on the RTX 3090), an inline pass's last instance may now stay open, and the next render encoder may continue it, as on every other device. Before it continues, EncoderCore::continue_pass checks the group's byte writes (FoldOrder::byte_writes, the leader's summary or the group's order) against every image the continuing pass uses: its draws' images (AliasWrites' images noted apart), its attachments, and the uses of the copies and steps before its later instances (render/inline_splits.rs, waiting_uses), all of which record into the tail after what the group wrote there. Where one meets, the pass begins its own instance in its own VkCommandBuffer, the measured form, counted in WorkCounts::command_buffers_split_at_aliases. Where none meets, it continues and takes the group's writes as its own (AliasWrites::continues), so what it records into the tail after its pass is checked as a joining encoder's is. Why: continuation cut the glass-panel frame's GPU time 11-26% on the 780M and Iris but was off on the 3090. The open instance itself never holds a buffer write: its draws touch only attachments, and anything else that records into the tail ends it first. The tail before it can hold one, though (the leader's earlier inline instances and what records between them), so the check is what the fact needs. Also: render_fold's Lane::continuing (622368ab37) goes, since its lanes continue on every device now. A test-only DeviceShared::aliases_split_forced lets lavapipe take the 3090's path. New tests: tests::alias_split's continues unit test; tests::alias_split_device's count case, a copy out of a texture after a continuation, a later instance of one pass reading an earlier one's buffer write, and a texture over another buffer of the same host pages (the last two are byte cases for two possible gaps on the 3090). Also e818e7b442: Continued passes: a pass's uses of bytes count in the alias check, as an aliasing texture's are. What: AliasWrites notes the bytes of buffers that the commands noted apart use (bytes_apart). AliasWrites::continues now refuses a continuation where those bytes, or a Bytes use among the pass's other uses, meet the group's byte writes, besides its images. Why: a texture whose linear image aliases a buffer's bytes (Storage::Alias) names them as the buffer's bytes (Texture::image_use), not as an image range. The lavapipe run with the split forced (m3-max-35002) showed a pass sampling such a texture over bytes the leader had just written continuing anyway: (1, 1, 1, 2, 0) where (2, 1, 0, 3, 1) was expected. A continuation is refused rather than guessed at: a draw that reads, through a buffer, bytes the group wrote also begins its own instance on such a device. Tests: the count case now reads the written bytes through a texture over a buffer and And dae7c2cad8: alias_split_device: the counted and copy-after cases read a texture over a buffer alone. Verified in the lane (m3-max-35085, msi, at dae7c2cad8): clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings exit 0; lavapipe (m2v_cpu_icd) alias_split and render_fold 36/36; the count test forced: written read (2,1,0,3,1), quiet read (1,1,1,2,0), unforced (1,1,1,2,0), texels right. Still running when landed: the 3090 correctness job (alias_split, render_fold; F1-F3 byte cases), PHOENIX render suites, clippy m2v_gpu and m2v_cpu_icd, rustdoc, the 3090 glass A/B. New Degradation kinds: none. |
||
|
|
cceefacfa7 |
RUNTIME 2420: A storage twin's neutral shares the device's zero buffer: the plan says which buffer writes are read-only
What: a new public BindingPlan::read_only_buffer(&DescriptorWrite): true for a uniform buffer and for a uniform view's storage twin (DescriptorView::UniformWithStorageTwin, PlannedBuffer::twin), which no function stores through. The runtime asks it where it used to read the descriptor type alone (binding::descriptor's neutral arm, make_neutrals, binds_own_zeros), and makes the device's zero buffer a storage buffer too, so a twin bound to nothing binds it. Why: on the Iris Xe RPL-P profile (DriverWorkaround::PushReadsLengthenThreadPayload) RUNTIME 2413 gave a kernel's constant slot a storage twin. Left unbound, the plan writes the twin from the ZeroBuffer neutral at a STORAGE_BUFFER binding, which the runtime took for a writable binding: every dispatch took a fresh 64 KiB upload region, a dedicated VkBuffer allocated and zeroed, held until its command buffer completed. Round 5974320352's Iris leg: neutral_zeros_shared::dispatches_share_the_devices_one_zero_buffer, 8 dispatches made 8 VkBuffers and 16 made 16. Translation output and plans are unchanged (no SEMANTICS bump); the API addition is blessed in api_signatures.tsv, and docs/API.md section 5 says it. Test: engine_access::an_unbound_constant_slot_s_storage_twin_is_a_read_only_write plans buffer_end_byte_load_constant with nothing bound on intel-irisxe-rplp-anv (the twin's STORAGE_BUFFER write read-only, the written slot's not) and, as the negative control, on four other profiles (no twin; read-only exactly at uniform buffers). The device check is the neutral test itself on the Iris, which fails at the base. Also, test premises on the Iris profile (round 5974320352's iris:runtime reds): - a20c0a26d8: the compute creation test counts the forms its profile makes (1 + keyed storage views since RUNTIME 2410) and holds the pool only where completion is bounded (under Exact the second form runs on the pool). - 88b8d31a32: set 0 at offsets counts the pipeline binds (draws past offset 0 take the residual form) and the push after each where the driver forgets pushed descriptors after a pipeline bind. Verified in the lane (msi): m3-max-35051 clippy -D warnings -p metal2vulkan -p metal2vulkan-runtime --all-targets --all-features exit 0, translator tests 71/71 (api_signatures 3/3); m3-max-35053 lavapipe (cpuicd) deferred_calls, neutral_zeros_shared, set_zero_at_offsets, uniform_bind_offsets 43/43. Still to run: clippy gpucfg and cpuicd, rustdoc, ONE Iris run of the three tests. New Degradation kinds: none. |
||
|
|
da08882991 |
RUNTIME 2419: Storage twins keep their key only where no other view reads its residual
On ANV (Mesa 26.2.6, Iris Xe RPL-P) a kernel's uniform view with a storage twin read the twin at
its bind offset wherever its own key held, also beside a storage view bound past offset 0, which
keeps reading its pushed residual word. There the thread payload stays long, and the twin's
per-lane storage read cost more than the uniform view's block read at its residual:
dispatch_chain --binds moved ran in 153.96 us a dispatch against base's 143.14 (job
m3-max-34864, 7 interleaved rounds, medians; ref's branch-free storage module 154.01), while
--binds 4, fixed and tex gained 28 to 38 %.
The runtime's uniform_residual_form now sets every twin's RangeAtBindOffset to 0 too where
another RangeAtBindOffset constant of the key is 0 (uniform_residual_form_of): a storage view
bound past offset 0, a twin at an offset no alignment divides, or a uniform view of no twin. The
kernel then reads its uniform views at their residuals, as base does. Where every view holds its
key, nothing changes.
Runtime only: no translation output moves, and no creation key (a creation's prediction binds
nothing, so its storage views and twins all hold). Only dispatch keys of a kernel with a twin and
a view off its bind offset move, on the Iris profile alone.
Docs: residual.rs, keyed_regions, the workaround's profile doc and docs/API.md section 5.
Test: general_form's a_twin_keeps_its_key_only_where_no_other_view_reads_its_residual (fails
with the cut sabotaged, the negative control in the check job).
Verified in the lane at 6d68983cc6: release build of the runtime and its dispatch_chain (m3-max-34932,
BUILD=0). Still running when landed: clippy plain, m2v_gpu and m2v_cpu_icd, rustdoc, the touched
runtime tests and the negative control (34931, 34933), the runtime suite on lavapipe, and ONE Iris
A/B of the arms and native code (base
|
||
|
|
c053f814b1 |
RUNTIME 2418: The in-import dma-buf class takes the dma-buf class's copies verdicts
The check's DmaBufInImport class makes its pages exactly as DmaBuf's
(dma_buf_pages, plus the gate that its buffer lies in one import dedicated
to nothing), and a copies round puts no image over the pages: its copies
rounds repeat DmaBuf's over pages made alike. At its copies turn it now
takes DmaBuf's copies verdicts for both row ends, and runs no rounds of its
own, where DmaBuf's were measured this run or known before (passed or
failed) and both classes' noted memory flags are known and equal, the
same-memory-type rule of RUNTIME 2417's crossing; otherwise its own rounds
run as before. The note names the source verdicts and the flags
("DmaBufInImport copies: DmaBuf's verdicts, Failed and Passed for rows on
lines, its pages made as DmaBuf's in memory of property flags 0x..: no
rounds of its own"). A shared failure is a proof for pages made alike; a
shared pass is one draw of the rounds' race fewer, which errs to the shadow.
CHECK_VERSION 22: a record of 21 may hold the in-import class's own copies.
Tests: tests::in_place's unit test of shared_copies (shared where measured
and memory alike; the control: coherent against cached either way, either
memory unknown, a row end unchecked or pending, every other class: none);
tests::in_place_check's device count (the shared note once and no rounds of
its own where the rule holds, the dma-buf class's verdicts taken; printed
with both classes' memory and the check's wall time).
Also 00ba762437 (test only): the lent targets' test prints every host class's memory on a device made
with VK_EXT_external_memory_host too (LENT-TARGETS-POINTER lines).
Verified in the lane (m3-max-34930, msi, at 937274ec72): runtime clippy --all-targets --all-features
-D warnings plain, m2v_cpu_icd and m2v_gpu exit 0; touched tests 39/39; gpucfg archive built.
On the Iris Xe (RPL-P, m3-max-34910 at 00ba762437): lent_dma_buf_targets passed; Pointer, Fresh,
DmaBuf and DmaBufInImport check pages all lie in memory of flags 0xf. Still to run: the PHOENIX
check wall time base against tip, and the Iris count test with the in-place suite.
New Degradation kinds: none. CHECK_VERSION 21 -> 22: every device runs one fresh in-place check.
|
||
|
|
b63bfbfac7 |
RUNTIME 2417: A render target's lend takes copies' failures through memory of one type
On the Iris Xe walk, a game engine's renderer made 73 RGBA16Float render targets with free rows' padding over a no-copy buffer's dma-buf pages, and each was a shadow: their renders failed for rows that end inside a line, and the dma-buf classes' copies' verdict they lend that padding by (`in_place::lent_to_copies`) was not failed in the recorded check, while fresh checks fail it. A class's rounds catch a copy's line write-back only as often as the CPU's writes race it, so the verdict hangs on a race. The lend's copies verdict (`in_place::copies_verdict`, through `InPlaceChecks::decided` at every decision site) now takes another host class's copies failure, its reads passed, where the class's own kept every byte or was unchecked, but only where the check's pages of both lay in memory of a type of the same VkMemoryPropertyFlags as the driver reports them: a write-back measured through memory of other flags says nothing of this memory. Each class's memory flags are noted by the check and kept in its record (CHECK_VERSION 21, eight words more). A shadow that renders with free padding over host pages names the copies verdict it took in its shadowed-texture notice. The line-write-back reason and docs (FAST-PATHS host-pages row and the Iris known gap, API.md section 1 and the catalogue, the kind's rustdoc) say so. Tests: the unit test of the rule on the exact shape (same memory in place, coherent against cached apart in both directions a shadow, unknown memory, reads not passed, own-memory classes, own failed or pending kept, the record's memory words); and a device test over a no-copy dma-buf buffer (tests::lent_dma_buf_targets) whose control notes the pointer class in memory of other flags and keeps the shadow. Also 6e1f7b369d: the lend's memory flags are compared and printed as raw bits (ash's MemoryPropertyFlags has no Debug impl here; clippy's chunks_exact_to_as_chunks). Verified in the lane (m3-max-34875, msi, at 6e1f7b369d): runtime clippy --all-targets --all-features -D warnings plain and --cfg m2v_cpu_icd exit 0; tests::in_place, tests::degradation*, tests::texture_placement 38/38. Still to run: the device test on the Iris, PHOENIX and lavapipe in-place suites, a sabotaged-build negative control, clippy m2v_gpu, rustdoc. New Degradation kinds: none. CHECK_VERSION 20 -> 21: every device runs one fresh in-place check. |
||
|
|
45296d9b50 |
RUNTIME 2416: DmaBufRequest names the alignment of a one-chunk answer apart
A no-copy buffer's, heap's or rebind's request longer than the device's sparse granule asked every chunk at a multiple of the granule (64 KiB on RADV of Mesa 26.2.4), one chunk included. That rule was ours: one chunk is bound to a plain buffer, which vkBindBufferMemory takes at any multiple of the buffer's memory alignment (VUID-vkBindBufferMemory- None-10739). The granule binds only an answer of several chunks, as a sparse buffer is bound at multiples of its alignment in both the buffer and the memory (VUID-VkSparseMemoryBind-resourceOffset-09491). So a consumer whose guest buffers lie in a 64 MiB region's dma-buf at page offsets off 64 KiB (15 of 16 such starts) answered them with dma-bufs of their own, each one more import on every RADV kernel submission's list. Expected effect on the consumer (reims's diagnosis of 1910 refused asks on the 780M, m3-max-34841): only the 212 asks that are one run of pages inside one region (30 of them 2 MiB heaps) were refused for this rule alone; about 33 of their objects are live at a time, about 7% of the ~450 imports on each submission's list, and the walk's dma-buf imports fall about 4092 -> 3900. The other 1698 asks are scattered 4 KiB guest pages (runs per ask p50 6, 1317 crossing region ends): no piece of a region holds them (a plain buffer is one range of one memory) and no split does (the 64 KiB granule needs 64 KiB-aligned runs), so they stay dma-bufs of their own. DmaBufRequest gains one_chunk_alignment (the host page, or the plain dma-buf buffer's memory alignment where larger; it divides alignment and equals it where the granule is the length); a lone chunk is checked against it, several against alignment, as before. Answers valid before stay valid. The rustdoc and HOWTO say how a source picks between them. How it is verified: tests::dma_buf_shared_files::one_piece_off_the_ granule_binds_a_plain_buffer_at_its_offset (the previous commit's, refused Invalid without this one) and two_pieces_off_the_granule_are_ refused (its control, refused before and after) on a device whose granule is coarser than the page (PHOENIX, RADV); tests::one_piece_bench, a release bench of submission cost with 128 buffers over one region answered by each rule. The evidence is in the lane's report. Also: 51768bf6ab (tests: one piece off a device's sparse granule is taken; two such pieces stay refused), and an ignored release bench, tests::one_piece_bench. Verified in the lane (m3-max-34863, msi, same tree as 832c48ad2c): api_signatures 3/3; lavapipe -E 'test(/dma_buf/) | test(/host_memory::a_source/)' 76/76 (lavapipe's granule is a page, so the two new tests print "shows nothing" there); clippy m2v_cpu_icd --all-targets -D warnings. Still running when landed: PHOENIX (64 KiB granule) base refusal, tip suite and bench; clippy plain and m2v_gpu. API: adds the field DmaBufRequest::one_chunk_alignment (additive; a source that checks alignment alone still answers validly). |