The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
A compute pipeline state kept what its latest direct dispatches planned
(Planned: the variant, its plan and its regions' made VkPipelines) keyed
by the exact dispatch, so a guest's fix-up stream of dispatchThreads:
calls of a thread per element, one width after another, planned every
dispatch again: settle_direct, settle_flat and Variant::plan's LRU hash
and compare of the bind shape two or three times, a new Planned whose
regions' pipelines were looked up again, and plans of other shapes
pushed out of the four kept, so the shape was made again too. In the
consumer's profile of its GL fix-index encoder on an RX 7900 XTX that
was plan_now 17.8% of dispatch_threads, region lookups about 6%, and
BindState::shape 5.3% beside position_of_shape 2.3%.
A grid's class (pipeline::GridClass) is its dispatch form, its
threadgroup size, and whether it is a whole number of threadgroups and
one row in threadgroups of one row: what settle_direct chooses its
branch by (flat_direct and partial_direct now read those from the
class). Where every region a plan plans has the call's threadgroup size
(a flat variant's one region, a partial-threadgroups variant's
threadgroups, a whole grid's chunks), every variant key the branch makes
is a function of the plan and that local size, and the grid's size
reaches it only through the device's limits. So a Planned of the bound
form on a flat or partial-threadgroups variant, or of a whole grid,
serves the other grids of its class, after its plan names its very
variant for the new grid (BindingPlan::dispatch_variant, which checks
the grid against those limits each time); otherwise the dispatch plans
as any and meets the same refusal. A ragged grid's exact split keeps
the exact key. The call's own grid is what record instantiates; the
dispatch memo and the kept commands (Instantiated) keep their dispatch,
since their commands are the grid's.
New count: WorkCounts::dispatches_planned_across_grids, those of
dispatches_planned_as_before of another grid of the class.
Verified: not yet built; the next job builds and tests it.
Verified (msi, lavapipe, m3-max-32955 at ccfcc384b3): clippy plain 0;
api_signatures and api_surface 15/15; compute, dispatch, grid, region
widths, partial threadgroups and flat simdgroups 90/90; grid_classes reads
every dispatch back against Metal's answer and counts 20 cross-grid plans
a kernel; an over-limit grid of a planned class is refused as before.
Negative controls: reuse with the check skipped fails both tests.
Clippy (--cfg m2v_gpu and --cfg m2v_cpu_icd, -D warnings) refused the manual
modulo in Memfd::shared_source (clippy::manual_is_multiple_of), red in
m3-max-32936 for development b1c6b40570. Same check, its method form.
Verified: cargo fmt; clippy of metal2vulkan-validation in all three
configurations in the msi job that follows.
A third held-for-good kind: the n buffers' source answers each request with
a piece of one udmabuf of their whole memfd (DmaBufRequest::shared_files, as
a consumer's group of views is), so the device imports the file once and
binds each buffer at its piece (Memfd::shared_source). Against the own
dma-buf rows it shows whether a shared file costs RADV's submissions one
listed entry, whatever its pieces; the lines now print the pieces joined and
the shared files live, the evidence the join path ran.
Verified: cargo fmt; run on gem10's PHOENIX in the probe job that follows.
The dma-buf phases held at most 64 imports live (136 for 1000): their
buffers are read by blits alone, so the residency released those past the
most it keeps on a device whose held imports cost every submission. A
guest's imports are bound and stay (the HawkPoint Launchpad walk held 363
buffer dma-bufs and 163 image ones). Each kind now runs again with every
buffer's Metal address read (Buffer::gpu_address), which keeps each import
held for good, so a phase holds all n live and its line gives the per-entry
cost at the walk's counts.
Verified: cargo fmt; run on gem10's PHOENIX in the probe job that follows.
The SUBMIT-PER-IMPORT lines now carry the VkSubmitInfos a phase submitted and
WorkCounts::batch_submit_nanos over them: the driver's time per submission
beside the kernelStart-to-kernelEnd percentiles, so a phase's per-import cost
reads in the same unit as a walk's WorkCounts (perdraw8: the HawkPoint walk's
scheduler spent 390 us per VkSubmitInfo in RADV's vkQueueSubmit).
Verified: cargo fmt; built and run in the gem10 PHOENIX probe job.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
What: a head on a queue made for copies (Device::new_command_queue_for_copies) no longer
goes before an earlier-committed batch of another queue it conflicts with because that
batch gives way. The order's comparator (scheduler/mod.rs is_behind) treats a held batch
that gives way as one that keeps its place when the head's queue keeps commit order
(Standing::commit_order, from CommandBufferShared::keeps_commit_order: the queue's kind,
set by the copy queue's constructor). Such a head waits behind it in the scheduler when
tracker::ordered says the two conflict, whether the held batch waits for its pipelines'
making, a host step or its checks. Once the held batch is submitted, the tracker orders the
copy after it on the GPU: the copy engine's VkQueue waits for the other VkQueue's timeline,
or a barrier where they share one. There is no wait on the host. A copy that shares nothing
with the held batch still goes. Unchanged:
- plain queues keep the give-way exactly as before (order.rs, Held batches give way), so the
Iris Xe compositor case is untouched;
- a held batch ON a copy queue stands to a later plain queue's commit as any held batch does
(the rule is the head's);
- a batch held for an event value or a binary semaphore's signal the program has not given
holds back no copy (Stops).
Why: the copy queue's documented promise is that a copy reading what another queue's
command buffer committed before it wrote waits for that command buffer on the GPU. A
command buffer of a blit and a new pipeline's first dispatch, held for the pipeline's
making, gave way to a copy committed right after it on the copy queue. The copy ran first
and read the bytes from before the blit: the consumer's copy queue on an RTX 2080, and a
plain second queue on MoltenVK, round 0 only, always the new pipeline's first dispatch. The
give-way rule (b46459080d) stays for plain queues, where real Macs disagree; the copy queue
is a runtime extension whose contract is ours.
Docs: order.rs (But not to a queue made for copies, No deadlock), the scheduler's Tracking
paragraph and is_behind, new_command_queue_for_copies (what holds exactly, the reverse
direction, and that on a device that answers None a plain queue used instead gives way, so a
caller orders such a copy with an event), the runtime README's copy-queue and pipeline-wait
passages, docs/API.md's pipeline-wait passage, pending_dispatch.rs,
WorkCounts::heads_held_for_earlier_commits, and the hold_sites module docs.
Verified: lavapipe before (the previous commit's copy-queue leg) and after, reported with
the tip.
Verified (lavapipe, the copy queue on the round robin VkQueue): at
87ab2111b0 (m3-max-32839) the copy-queue leg fails, reading the bytes
from before the blit; at 404352e262 (m3-max-32840) hold_sites,
dispatch_pending, pipeline_wait_order, held_step_order and copy_queue
16/16, clippy m2v_cpu_icd 0.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
On a repeated copy by a kept plan, a third of the encode was the call's own work on its
runs before the plan was even looked up: runs.to_vec, merged into a second vector, boxed,
in_words, then compared with the plan's at the recording (probe m3-max-32752, msi: 66.8 of
97.1 us at 1 chunk, 51.2 of 233.0 at 128 chunks).
The four calls (copy_from_host_ram, copy_to_host_ram, copy_runs_from_host_ram,
copy_runs_to_host_ram) now give HostRamCall::new their runs as given (Given: laid one after
another from an offset, or each at its own byte). It looks for a plan of the same direction,
form and buffer key (RamCopies::kept_for) and compares the given runs with the plan's while
it merges them (merges_to): each run checked as merged checks it, joined as merged joins
it, each joined run compared with the plan's next, a run laid past u64 refused as
one_after_another refuses it. Merged runs, checked and in_words are functions of the given
runs alone, and a plan exists only for checked runs copied by words, so a match is exact.
On a match the call shares the plan's runs (HostRamCall.runs and KeptPlan.runs are now
Arc<[Run]>) and names the plan (HostRamCall::kept); else it builds its runs as before, and
a plan kept of it shares them instead of cloning them.
The recording takes a named plan only while the RAM keeps that very plan
(RamCopies::keeps, by Arc identity): one the LRU bound or anything else let go of before
the copy records (an encoding again at a rebind, say) takes the copy to the full path
over the call's shared runs. A call that named none looks one up as before. Every dynamic
check of record_kept is unchanged.
Second, takes() no longer joins every chunk's ranges for copy_take: copy_take's signature
is unchanged in its types (device, importer, slot, ranges: &[Range<u64>]) but ranges are
now the chunk's ranges as touched_ranges gives them, and copy_take joins them
(copy::alone_ranges) itself, only past its made() check, where it reads them. Same
answers: the joined ranges were read only on that branch. (probe: 9.2 us a call at 1
chunk, whose ~4100 ranges were joined though the chunk was made; 40.3 at 128.)
chunk(), take(), took() and after_take are untouched.
Tests: unit, runs_merged_as_they_are_compared_match_the_kept_runs_exactly_as_merged_gives_them
(random runs of both forms with joins, empty and off-word runs, runs laid past u64,
against their merge, one run more, the last fewer, the merge of the runs less their last,
each run changed); device, the repeated-copy test gains runs at their own bytes, and
a_named_plan_the_ram_let_go_of_before_the_recording_is_not_taken (eight copies' plans
push the named one out, a rebind encodes the encoder again: no reuse, the bytes right).
Verified at 96e281ba59 (msi, m3-max-32802): host_ram tests on lavapipe
106/106, clippy plain, m2v_gpu and m2v_cpu_icd 0, rustdoc 0; the named
plan let go of before recording is not taken (negative control fails).
Release medians (m3-max-32803, lavapipe, interleaved, 200 of 200 copies
by a kept plan): layer in 1 chunk 99.1/94.0 -> 59.7/58.1 us, over 128
chunks 248.9/282.6 -> 176.9/197.0 us.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
With no caller directory and no home (USERPROFILE on Windows, HOME elsewhere),
default_directory answered Err and CacheSetup::of turned it, and any failure to
open the default path, into Error::ShaderCache, so every device creation and
adoption failed. Metal never fails device creation over its shader cache, and
the default is the runtime's choice, not the caller's (owner rule 2).
- The Windows default is %LOCALAPPDATA%\metal2vulkan (the local application
data folder, read from the environment; no new dependency). XDG_CACHE_HOME and
USERPROFILE are no longer read there.
- default_directory takes its environment as a closure (CacheSetup::of_in), so
a test feeds its own without touching the process's.
- Where the caller names no directory and the default does not exist or cannot
be made or written, the device keeps its cache in memory alone: the Store has
no directory, every lookup is absent, every write is refused with no
filesystem call, the scans do nothing, and writers ask has_directory first so
nothing is encoded for it (a translated function still is: its encoded length
weighs it in the memo). The device says so once as it is made, as the existing
degrade notice ShaderCacheEntryNotWritten naming why; each entry it does not
write counts in write_failures. The driver's pipeline cache data is not read
back, and the device checks' verdicts are not encoded.
- A directory the caller names that cannot be used is still Error::ShaderCache.
- Device::shader_cache_directory answers Option<&Path>: None for such a device.
Docs: the shader_cache module docs, ShaderCacheOptions::directory,
write_failures, Error::ShaderCache, the degradation's declaration and its
docs/API.md entry, the runtime README (Windows default, error table), HOWTO,
create.rs's list of environment variables. api_signatures re-blessed;
docs/REFUSALS.md regenerated (a refusal's site function renamed).
Tests: tests::shader_cache's default-directory and no-directory-store unit
tests (plain gate), and the lavapipe/GPU device test
shader_cache_no_directory: a device made with an empty environment and no
caller directory is made, has no directory, makes four render states with two
functions translated once, writes nothing, and its notice is heard once.
Verified (msi): m3-max-32796 clippy plain 0, 67/67 shader_cache and
degradation tests, api_signatures 0, clippy x86_64-pc-windows-gnullvm 0;
m3-max-32797 (lavapipe) clippy m2v_cpu_icd 0, 61/61 shader_cache and
in_place_check, including the no-directory device test.
Its three faulting passes each take a queue of their own, and the earlier
queues stay live to the test's end, past the runtime tests' default limit
of two (lavapipe, job m3-max-32737: the device's panic names the limit).
plan_device, as the resolve tests use.
A Stencil8 texture on a device without S8_UINT is held in a combined
depth/stencil image; these tests run the shapes the consumer's tests died
at on Intel's UHD 630 under Windows, and a plain draw into such a target.
- store_out_device: a Stencil8 texture at the start of a placement no-copy
heap of bit 24 stored at Store (descriptor's and encoder's) faults its
command buffer; at DontCare and a late CustomSampleDepthStore it
completes. A 4-sample Stencil8 attachment resolving into it at
MultisampleResolve (descriptor's and encoder's) and
StoreAndMultisampleResolve faults; attached unresolved it completes. The
pages keep their bytes. Each prints the format its image is held in.
- stencil_target: a Stencil8 target cleared to 0x5a, drawn into over its
left half with a Replace of reference 0xa5, and stored reads 0xa5 and
0x5a by halves through a copy; a later pass that loads and stores it
keeps every byte, so the hidden depth aspect's DONT_CARE disturbs no
stencil byte. Prints the image's format.
Verified: compiled and run in the jobs named in the lane's report (the
UHD 630 under Windows and lavapipe).
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
A Stencil8 texture on a device without S8_UINT (Intel's UHD 630 under its
Windows driver 101.2145, and the roadmap-2022, vk12-floor and
lunarg-desktop-baseline-2023 profiles) is held in D32_SFLOAT_S8_UINT or
D24_UNORM_S8_UINT (FormatEmulation::StencilInCombined), which the format
table admits for DepthStencilAttachment and documents as exact. plan_held
kept the attachment mapping only where its format was the direct one
(S8_UINT), so the image took no DEPTH_STENCIL_ATTACHMENT usage, RenderTarget
went unavailable, and the render pass refused the texture as needing
D32_SFLOAT_S8_UINT as a depth/stencil attachment, which the device has.
The consumer's store and resolve of a Stencil8 attachment died there.
The attachment filter now also admits the combined-aspect emulations
(DepthInCombined, StencilInCombined); the RenderTarget branch compares the
image's format with the attachment mapping's rather than the direct
format, and a memoryless plan takes the mapping's format. Colour formats
and direct depth/stencil formats plan as before (their attachment format
is the direct one). render_target.rs already renders such an attachment:
the hidden depth aspect is DONT_CARE both ways.
Test: tests/image_plan.rs
a_depth_or_stencil_format_held_combined_is_an_attachment_of_its_combined_image
feeds the planner the UHD 630's formats (no S8_UINT, no D16_UNORM_S8_UINT;
the combined formats render, sample and copy optimally, with no BLIT_DST
and no linear features) over the uhd770 profile: Stencil8 and Depth32Float
without D32_SFLOAT, 1 and 4 samples and memoryless, are D32_SFLOAT_S8_UINT
depth/stencil attachments with nothing unavailable.
Verified (m3-max-32701, msi): clippy plain 0; the runtime unit suite
1593 passed; with image_plan.rs restored to its parent, the new test
fails (Stencil8 planned D32_SFLOAT_S8_UINT with TRANSFER_SRC|TRANSFER_DST
only, RenderTarget unavailable).
the_replay_modules_test_overflow_by_a_products_high_word counted every
OpUMulExtended (8 in the flat dispatch, 11 in the preprocess). Since
the builder makes each 64-bit extended product from four 32-bit ones,
the five u64 products count four each: 23 and 26, every one 32-bit.
The test now counts them by width and wants no 64-bit form, so a
64-bit OpUMulExtended coming back into either module fails it.
Found red by the msi run of the metal2vulkan suite at 71ec267314
(job m3-max-32642: 3617 passed, this one failed with 26 where it
wanted 11 on the preprocess). Verified by the follow-up job named in
the report.
Step 2 (a1175662e7) gives a runtime buffer of 16 KiB or more Metal's allocation,
its length rounded up to 16 KiB, and the host clears all of it so that a texture
over the buffer reads zero past the length. Two fresh_pages expectations still
counted the length rounded to 16: the recycled buffer in
a_long_buffer_made_right_after_a_filled_one_reads_zero (red on lavapipe, partition
2: 33570816 cleared, 33558544 expected) and the cleared class in
a_long_new_buffer_reads_zero_with_nothing_written (the RADV leg, where no class
takes fresh pages). Both now expect the length rounded up to METAL_PAGE.
Test-only: the runtime-sources pin skips tests, so it is unchanged.
Every 64-bit OpUMulExtended and OpSMulExtended the builder would emit
is now built from four 32-bit OpUMulExtended of the operands' halves,
summed in 64-bit adds and shifts; signed, the high word subtracts
each operand where the other is negative. The struct result is the
same, so every caller (mul_hi, the flat indirect-dispatch derivation's
checked multiply, the replay preprocess) keeps its shape.
Why: Intel's Windows driver 101.2145 on the UHD Graphics 630 answers
garbage high words for both 64-bit forms, different from run to run,
while its 32-bit forms and its 64-bit UDiv and UMod are exact
(measured by the runtime's host_step_reads device test in job
m3-max-32600). The flat indirect-dispatch derivation's overflow check
read those garbage high words as overflow, zeroed the command and
reported ReplayFaults::GROUP_COUNT, so indirect dispatches and ICB
executions ran nothing on that device. The leaf is unconditional:
both forms are exact everywhere, and a per-driver key would leave
any missed construction site broken.
SEMANTICS_VERSION 2123 -> 2124: modules with a 64-bit mul_hi or a
flat dispatch derivation change their words.
Verified: the CPU interpreter test
sixty_four_bit_extended_products_are_exact_from_halves (both signs,
scalar and two-lane vectors, 121 operand pairs including 0, 1, -1,
i64::MIN, i64::MAX and u64::MAX, against i128/u128 products, and only
four 32-bit MulExtended in the module) is dispatched with this
commit; the device run on the mini follows.
The wide-math device test also stores `mul i64 x, y` for large
operands, to show whether the 64-bit OpIMul is exact on the device
whose 64-bit OpUMulExtended and OpSMulExtended high words are wrong.
Not yet run; the next mini run measures it.
On the UHD 630 (m3-max-32592) the unsigned 64-bit mul_hi answers garbage high
words while 64-bit division and remainder are exact, and the flat dispatch
reports ReplayFaults::GROUP_COUNT. The fix's encoding depends on which widths
and signs the driver multiplies right; this measures them.
Verified: m3-max-32592 (UHD 630).
The device-pointer run passed on the UHD 630 (m3-max-32574): the translated
kernel's own loads and stores by device address work there. The flat path's
derivation (bind::replay flat_dispatch) computes in 64 bits through
OpUMulExtended, OpUDiv and OpUMod; this checks those in a translated kernel
and prints the flat dispatch's execution report (a GROUP_COUNT replay fault
would say the derivation found the grid too large).
Verified: not yet run.
On the UHD 630 (Windows, 101.2145) the indirect dispatch on the flat path, from
Shared, Private and unimported memory alike, and the GPU replay of copied
commands run nothing, while the host step with no device addresses
(shaderInt64 withheld) runs. This separates the translated kernel's own reads
and writes by device address (direct dispatches) from the indirect machinery.
Verified: m3-max-32562 (UHD 630) ran the earlier five: 4 failed, the host step passed.
The consumer's correction: their failing indirect dispatch takes the GPU (flat)
path, not the host step. The test now runs the dispatch from a Shared buffer the
CPU wrote on the default device and on one that imports no host pointer
(VK_EXT_external_memory_host withheld), from a Private buffer a blit filled, and
through the host step; each prints its page-buffer and import counts.
Verified: not yet run.
A device test of what a host step reads: an indirect dispatch on a device
without device addresses (shaderInt64 withheld) runs the arguments the CPU
wrote and those a blit copied before it; the same dispatch on the device as
made; and an execution of a dispatch a blit copied into the executed buffer.
Each prints the notices and the host steps recorded. Reproduces the consumer's
Windows report (UHD 630: host-step dispatches and executions run nothing).
Verified: not yet run (first build on the Windows mini).
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
A copy by dispatches spent most of its encode on work that depends only on its runs, its
buffer and the imports it reads through: cutting the runs into pieces, the chunks' ranges,
the pieces' places in the imports, the table and the dispatches. A consumer repeats the same
copy (a surface's same runs) every frame.
Such a copy's plan is now kept per RAM per device (RamCopies, which ChunkKeys becomes):
direction, runs' form, buffer key (object id, device generation, length), the runs, the
blit_at VkBuffer and byte, the device's figures (window, alignment, workgroups, array), the
span and total, the chunk ranges and joined ranges, the import serials in order with the
chunk-to-imports map, the table and the dispatches. The next copy with the same key (runs
compared element by element, no hash trusted) takes the table and dispatches where:
- blit_at gives the same VkBuffer and byte (a rebind or a new VkBuffer plans anew);
- the device's figures are the same;
- every chunk takes at once (copy_take Now for all; else the full path stages it);
- copy_imports gives the same imports, by serial number, in the same order, with the same
map. RamChunk now carries a serial from a process-wide counter, never reused, so a chunk
released, given back or imported again has a new one. Plans keep numbers, not Arcs.
Every step a copy takes each time still runs: blit_at, copy_wrote, the takes, copy_imports,
the upload, the binds, the uses and the counts. Where the plan does not hold, what it took
(blit, takes, imports) goes to the full path, which takes none twice: a chunk released
between the takes and the imports plans over the imports it got.
Bounds: 8 plans and 4 MiB per RAM per device, the one taken longest ago dropped first; a
plan over 4 MiB is not kept. Counter: WorkCounts::host_ram_copy_plans_reused.
stages() is split into takes() and Takes::staging() so both paths share the takes;
record_dispatches() is the dispatch tail both paths record through.
Tests: unit, the bounds; device (lavapipe): a repeated copy takes its plan and a run
changed, the other direction, another buffer offset, another buffer, a rebound no-copy
buffer each plan anew; a chunk let go of (idle, given back) makes the next copy plan anew
and the one after take the new plan; a new use of the RAM plans anew; a kept plan's copy
is ordered after a fill of its buffer and after a scatter into its pages in the same
command buffer.
The plan also holds the buffer's host pages weakly and compares them by
identity: lavapipe gave a rebound buffer's new VkBuffer the destroyed
one's handle value (m3-max-32579), so a handle match alone cannot see a
rebind. The plan names no VkBuffer; the binds take the live one on every
call. The pages copy's kernel is looked up only where a copy goes by
dispatches, as before. The layer bench says how many copies a kept plan
recorded.
Measured (release, msi lavapipe, m3-max-32581, before d0ef5e0145 and
after, one job, median us a call over 8100 single-page runs): layer in 1
chunk 373.9 -> 139.1, over 128 chunks 859.8 -> 323.4; at 0bae61504a
(m3-max-32615) 200 of 200 copies by a kept plan.
Verified at 0bae61504a (m3-max-32610): host_ram tests on lavapipe
103/103, clippy plain, m2v_gpu and m2v_cpu_icd 0, rustdoc 0. Negative
control (m3-max-32579): with the serial compare removed, the let-go test
fails (a reuse happened).
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
Intel's driver for the UHD 630 on Windows (101.2145) rounds a small
linear image's VkMemoryRequirements size up to its 4096-byte alignment:
BGRA8 73x8 at a pitch of 320 has a 2560-byte subresource and a 4096-byte
image, 16x16 1024 -> 4096, RGBA16F 88x8 6144 -> 8192. The in-place check
(linear_plan::aliases) bounded the image's size by the buffer's VkBuffer
bytes from the texture's first, so a texture over a padding-unobserved
Private buffer of exactly its rows was a shadow, and a buffer placed on
256 bytes failed the image's 4096 start too.
The room an image over a buffer's texels may take is now the buffer's
own placement from its byte 0 (Buffer::memory_room: bytes no other
resource is placed in), in texture.rs's two aliasing checks and the
two-plane YCbCr check. A buffer whose maker declares its padding
unobserved is placed on the device's linear images' memory alignment
(Device::linear_image_alignment: one probe image's alignment, a 64x8
R8G8B8A8_UNORM linear image, kept for the device), its start and size
whole units of it; the recycler's BufferMaking keys on that alignment,
and a device recovery's carry places such a buffer so again. Where the
alignment is 256 or less (RADV, lavapipe, MoltenVK), every placement met
it already and nothing changes. Cost: at most alignment - 1 bytes more
for each such buffer on the UHD 630, plus the start's padding.
Still a shadow: an image the driver sizes past its alignment's rounding,
R8 4096x1 over 4096 bytes taking 16384 on the UHD 630 (FAST-PATHS known
gaps), and on that driver textures over buffers that do not declare
their padding unobserved where the image is larger than the placement or
starts off 4096.
Tests: padding_unobserved's a_texture_whose_rows_fill_an_unobserved_buffer_is_in_place
makes a 73x8 BGRA8Unorm texture at the device's own linear pitch over a
Private padding-unobserved buffer of its rows alone and asserts the
placement lies on the alignment, the texture is the image over the
buffer, and no shadow is counted.
Docs: BufferDescriptor::padding_unobserved, the runtime README entry,
FAST-PATHS known gaps.
Checks: on the UHD 630 (Windows, m3-max-32630, at the same diff before
its rebase), padding_unobserved's new test passed: 73x8 at a pitch of 320
over 2560 bytes, 4096 of room on 4096, an image over the buffer, 0
shadowed. At cb7660c625: clippy plain, m2v_gpu and rustdoc 0
(m3-max-32602); lavapipe touched set 153/153 and m2v_cpu_icd clippy 0
(m3-max-32603).
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
What: RamOnDevice::chunk cleared a chunk's `untaken` mark for an object's call
before it looked at the chunk's state. An object that found the device's thread
importing the chunk (Import::Making, By::Ahead) cleared it, then waited; the
thread, ending its import, set Made and then marked the chunk untaken under the
chunk's lock, after the object's clear. The object then took the chunk, which
stayed marked untaken. A give-back near the allocation limit skipped it while
the object's buffer held it, but freed it once that buffer went, setting `tried`,
so the thread never imported it ahead again and the next object over it
imported it itself.
How: the object clears the mark in the Import::Made arm, once it holds the
chunk, under the same lock the thread marks it under, so the clear comes after
the thread's mark whether the object found the chunk made or waited for it.
Test: at_the_margin takes when its first object takes the RAM's first chunk
(Opens::Made, as before, or Opens::InFlight: the thread's import held in flight
by making_pause, the object's call past taking_pause and still blocked on it).
a_chunk_an_object_waited_for_the_thread_s_import_of_is_not_given_back drops
that object, brings the device within the margin with an object past the
thread's chunks, and asserts AHEAD-1 chunks went back and 2 stay live (the first
chunk and the new object's); with the mark left set, AHEAD go back and 1 stays.
Verified on lavapipe: m3-max-32606 ran the 99 host_ram tests and clippy
(m2v_cpu_icd); m3-max-32614 ran clippy plain and with m2v_gpu. In the
same job, the host_ram.rs hunk reversed (negative control) fails the new
test: 4 chunks given back, 1 live.
A 16385-byte buffer's VkBuffer requires 32768 bytes where 16400 did, on
RADV PHOENIX and lavapipe (m3-max-32595, m3-max-32558). On the Radeon
780M, release, exclusive, the base (d2ee5bca5b) and this tree run twice
each in one job (m3-max-32595): 1000 buffers of 16 KiB + 1 to 4 MiB
required 763.3 MB against 754.8 MB and took one more 64 MiB block in
their second round; making them took the same time within the runs'
spread, Shared ones cleared on the host and Private ones' first fills
alike.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
A texture over a buffer whose texels run past the length was always a
copy: a shadow image or a staged texture buffer whose bytes past the
length lay in a tail of its own. Metal's texels there are the
allocation's: a buffer of 16 KiB or more holds its length rounded up to
16 KiB (allocatedSize), zero when made, and a heap's buffer reaches its
heap's end, whose bytes are the heap's.
Now a buffer the device makes in the Metal address space with a length
of 16 KiB or more takes that allocation (buffer.rs's metal_allocation):
its VkBuffer and placement are its length rounded up to 16 KiB, which
its first fill clears with the rest (Buffer::clear_first: the host's
clear of a Shared or Managed buffer, the device's fill of a Private
one), with no command of its own. A texture keeps in place the bytes the
buffer's memory holds for it (Buffer::texel_reach: the allocation, a
heap's buffer's heap to its end, a no-copy buffer's length), so such a
texture is made as one inside the length is: an image over the buffer's
memory where the device makes one, a texture buffer viewed in place. The
shader-visible ranges, robustness, copy reach (a blit past the length is
still refused) and exported sizes stay at the length. Heap, no-copy,
wrapped and exportable buffers, and every buffer under 16 KiB, take
their length; past what the memory holds a texture keeps its tail, as
before. The runtime has no buffer allocatedSize; a heap's size and a heap
texture's allocated_size are unchanged.
The tails conformance cases now lie in place: their comments say so,
and the texture buffer case drops its staged-texture-buffer allowance,
which no device can fire there any more (its view starts at 16384).
Tests: buffer_tail_device's last-texel case lies as over a buffer that
holds it inside its length, with no tail; a new case over a 20000-byte
buffer (64x128 packed, ending at 32768) reads zero in the padding as
made, lies as inside the length, lands a kernel's writes past the length
in the buffer's memory, takes no copy where it is an image over the
buffer, and refuses a blit past the length; the heap case lies in the
heap, its kernel writes landing in the heap's other buffer; a new case
over a heap's second buffer keeps its texels past the heap's end in a
tail; the no-copy and 4096-byte cases keep their tails.
Docs: buffer_texture.rs's Tails, linear_plan.rs's Length, docs/API.md's
accepted difference and StagedTextureBuffer entry, and a FAST-PATHS
cost-of-matching-Metal entry for the padding.
Checks: the jobs that compiled and ran this commit are named in the
lane's report.
Evidence (lane jobs): m3-max-32551 (msi): clippy runtime+conformance -D warnings 0; 2632/2632 runtime+conformance; fast_paths +
api_surface 34/34. m3-max-32578 (lavapipe) at the tip: touched 56/56 (buffer_tail_device incl. the allocation, heap and
heap-end cases, texture_placement_device, linear_plan, buffer_texture, degradation_catalogue); runtime+validation partition
1/4 1572/1572. VkMemoryRequirements on lavapipe for a 16385-byte buffer: 32768 (alignment 64). The padding is cleared by the
buffer's existing first fill (no new command). allocatedSize: no buffer API; heap sizes unchanged. The PHOENIX run, the
release creation bench and lavapipe partitions 2-4 follow in the lane. Conformance: buffer-tails cases now in place; the M3
venue's cost records for buffer-tails-* re-bless on development.
Lane commits: d2ee5bca5b (bench), a8f3796f59, ee54952340 (heap cases in a placement heap).
The untracked lane (a kernel's write of an untracked heap's buffer, bound
or through the address its argument buffer holds with the buffer resident,
then a read of a texture over the same bytes in one encoder) asserted only
that the run as a whole split some command buffer at aliases where the
driver fact holds and a texture lay in place. On the RTX 3090 at
25119268da both forms split 1 command buffer over the Shared and the
Private heap, each texture in place, so the counts did not say which heap's
read split, nor that the resident write splits where the bound one does.
Each HEAPTEX untracked line now prints the command buffers split at aliases
while its heap ran (from before its texture was made to after its compute
command buffer completed). Test-only; nothing asserted changes.
Verified: cargo fmt. The lavapipe build and run follow.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
A copy's encode cost grew with the chunks its runs touch: a binary search over the
chunks for each run that left the last run's chunk, a bitmap allocated for each chunk
touched, its runs read into a vector and copied into another, and each chunk's ranges
cloned, sorted and merged again before joining, though touched_ranges already gives
them sorted and apart.
- ChunkSpans (host_ram.rs): the chunks' spans and each RAM range's first chunk; of()
finds an address's chunk as the range's first plus the chunks before it, the span
span_of finds. pieces() takes it and still tries the last piece's chunk first.
- touched_ranges keeps every touched chunk's bitmap in one vector, reads the pages
back with MarkedRuns (lazily, runs across words as one) and builds each chunk's
ranges once, with as much room as its pieces.
- joined takes a chunk's ranges as touched_ranges gives them and borrows them where
there are no more than the bound; chunk_ranges sorts and merges before it.
Same ranges, same overlap answer, same uses as before (the touched_ranges
equivalence test is unchanged). New unit tests: a chunk found by arithmetic is the
span that holds the address; MarkedRuns reads the runs the bits one by one give.
Evidence (lane jobs, msi lavapipe): m3-max-32538 at the lane tip: clippy plain / m2v_gpu / m2v_cpu_icd -D warnings 0;
host_ram 98/98; rustdoc 0. m3-max-32486: a_chunk_found_by_arithmetic_is_the_span_that_holds_the_address and
marked_runs_are_the_runs_of_the_bits_one_by_one; the touched_ranges equivalence test unchanged. Release medians, one job
m3-max-32485, 8100 single-page runs: 1 chunk 309.6 -> 298.9 us, 128 chunks 811.7 -> 733.4 us.
Lane commit: b13c097e6d.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
Plain clippy of the runtime's lib test failed on development (a4ea017d9e): the
accessor was cfg(test), but its only caller, tests/host_ram_copy_device.rs,
compiles only under m2v_gpu or m2v_cpu_icd, so it was dead code there. It now
takes the caller's cfg, as step_aside.rs's device-test hooks do.
RamOnDevice::wakes stays cfg(test): the host_ram unit tests call it.
clippy -D warnings under --cfg m2v_cpu_icd (m3-max-32505, msi) refused 02a27ea50f's
(answer == 0).then(|| ...) as unnecessary_lazy_evaluations: the value is two field reads.
Verified: the clippy job follows.
The printout's time on a CPU came from /proc/thread-self/schedstat's first field, which stands
as of the thread's last scheduler event and leaves out the slice it is running: at the 5 runs
alone on the Radeon 780M (m3-max-32473) it printed 1.99 ms on a CPU for a 1.19 ms call. It now
comes from clock_gettime(CLOCK_THREAD_CPUTIME_ID) on unix, which counts the running slice too;
the run-queue wait stays schedstat's second field (Linux), which accrues only while the thread
waits and is whole by the time it runs.
The COMMIT doc and the nextest override's comment said the suite stretched the commit's work 8
to 60 times its CPU time, a ratio of tick-granular rusage numbers. They now give the measured
times themselves: a release build's later calls 5.8 and 7.0 ms under the suite's load (4.7 and
7.3 ms on a CPU, by rusage) against 0.10 to 0.26 ms alone; the test build's 10.7 and 16.3 ms
(8.2 and 10.4 ms on a CPU) against 1.1 to 1.2 ms alone.
Test printout and comments only; every assertion is unchanged.
tests::held_step_order::command_buffers_behind_a_waiting_step_read_scheduled failed on the Radeon
780M (PHOENIX) in the development rounds a88823f8f4 and cc68beb2af, inside the device suite's
runtime partition: the long command buffer's commit call, bounded by a frame's 16 ms in one of
its 3 runs at least (COMMIT), took 394.2 / 21.7 / 30.7 ms and 166.9 / 38.3 / 16.9 ms.
The split of that call (WorkCounts' commit phases, and the thread's /proc schedstat and rusage
over the call; gem10's 780M, RADV PHOENIX, Ryzen 7 7840HS) puts all of it in Recording, the
host-step pass's Deferred::prepare on the program's thread: no pipeline wait, no wait for the
scheduler's lock, no pass or submission time (each 0.00 ms), 0 to 1 voluntary switches in the
later calls. First call / later calls, in ms:
- test build, the GPU to itself (m3-max-32424, 2 x 3 runs): 27.1-29.8 / 1.12-1.23, nearly all
of it on a CPU, at most 0.05 on a run queue;
- test build inside the runtime partition 2/2 (m3-max-32429, 1355 tests, load average 14 on 16
threads): 367.6 (274 on a CPU, 85 on a run queue) / 10.7 and 16.3 (on a CPU 10.4 and 8.2, on a
run queue 1.5 and 10.3);
- release build alone (m3-max-32453): 3.58-4.21 / 0.10-0.26;
- release build inside the partition (m3-max-32457): 39.1 (28.6 on a CPU, 6.6 on a run queue) /
5.8 and 7.0 (on a CPU 4.7 and 7.3).
So the call is the same work, which the suite's 15 other GPU test processes stretch to 8 to 60
times its CPU time (the APU's CPU shares its power, caches and memory with the GPU they keep busy)
plus waits for a CPU. There is no wait for the product to remove. The bound is the fastest run's,
a later call: 1.2 ms in the test build alone, 13 times under it; 5.8 ms in a release build under
the suite's load; 10.7 to 38 ms in the test build under it.
The test now runs alone (.config/nextest.toml, threads-required = num-test-threads), as the
teardown test's 16 ms wait and the queue-sharing latency tests do. COMMIT stays 16 ms, by the
call's own clock, on the fastest of the runs; its doc and the override's comment carry the
split. Test and nextest configuration only; no product change.
Verified: the numbers above are those jobs' printouts. The 5 runs alone at this tip and the
negative control (20 ms slept in the commit's recording phase) follow in the lane's report.
The long command buffer's commit call is asserted within a frame (COMMIT) in one of the runs at
least. Its failure printed the call's whole time alone, which cannot tell the call's own work
from a host whose other processes held the CPU. The printout now splits the call by its phases
(WorkCounts' commit times: lowering, recording, pipeline waits, the scheduler's lock, its pass,
submissions) and, where the host reports them (Linux's /proc/thread-self/schedstat), the
calling thread's time on a CPU and on a run queue over the call.
Test printout only; every assertion is unchanged.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
copy_imports' for_copy moved the import thread's window for each chunk a copy touches and woke
the parked thread each time it moved, which, the chunks coming in order each next to the last,
was every chunk: 127 futex wakes for a copy over 128 chunks, a few microseconds each on the
encoding thread (kernel time a user-space profile misses; the per-chunk part of a consumer's
download encode, ~7 us a chunk). The staged first-touch paths did the same with a take and an
ask a chunk, up to two wakes a chunk.
RamOnDevice::take_for_copies(slots, ask) applies a take of each chunk in turn to the window
under one lock, so the thread finds the window a take of each would leave, asks for those not
imported where ask (a staged copy), and wakes the thread once after them all, or not at all
where the window moved nowhere and nothing was asked. copy_imports calls it once before
for_copy, which takes nothing itself now; the staged gather and scatter call it with ask. An
object's take is unchanged.
Tests: host_ram::tests::a_copy_s_takes_move_the_window_as_each_take_would_and_wake_the_thread_once
(the same window as a take of each, one wake, none where nothing changes, asks in the same
wake), and host_ram_copy_device::a_copy_over_several_chunks_wakes_the_device_s_thread_once (a
staged scatter over three new chunks and the scatter through their imports after it each wake
the thread once; a test-only count of wakes). Timings: see the lane's report.
Evidence (lane jobs, msi lavapipe): m3-max-32403/32436: a_copy_over_several_chunks_wakes_the_device_s_thread_once (staged
copy 1 wake, copy through the imports 1 wake); negative control (one take a chunk) fails with 3 wakes; the window unit test
(the same final window as a take of each chunk; no wake when nothing moved); clippy cpuicd clean; host_ram 95/95.
Timing (m3-max-32404, one job): no measurable change (1 chunk 354 -> 359 us, 128 chunks 938 -> 972 us, within the jobs'
~15% spread): the per-chunk cost is not the wakes (a phase probe names the per-run passes). Kept as a correct, built,
neutral change.
Lane commits: 754e50319e, c3dbc7c309.
recordings_dir() (recording.rs) and the coverage census's read_source and runtime_src
(coverage.rs) joined env!("CARGO_MANIFEST_DIR"), the directory the binary was built in, so a
conformance binary carried to another machine read the build machine's paths: no recording, no
source. The replay lane had to symlink the build path on the GPU node to run a carried binary
(11-15). All three now go through metal2vulkan_devtools::workspace_dir(), which takes the
checkout the runner names (a remapped archive's or cargo's CARGO_MANIFEST_DIR at run time) where
it holds the validation fixtures, else the build checkout, as the validation and runtime test
trees have since 39bff0de2a. No other env!("CARGO_MANIFEST_DIR") is left in the conformance
crate's src/.
Verification: the next development round's conformance suite (1043 tests), the lavapipe replay
and the XTX/PHOENIX replays, which read every recording through recordings_dir.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
RamOnDevice::chunk moved the device's thread's window to an object's chunk
(take + notify) before the object marked the chunk's import in flight. The
window's first slot is the chunk just taken, so the woken thread could find it
not imported and import it By::Ahead in the object's place: counted as imported
ahead and marked untaken, with the object waiting for that import at the
thread's pace (SCHED_BATCH on Linux, utility QoS on Apple). Off Linux the thread
does no fault-in before an import, so it reaches the claims lock at once; that
is the failure seen once on the Windows mini under nextest -j 4:
a_chunk_bound_buffer_and_a_copy_of_its_pages_order_by_their_host_bytes saw ahead
imports 3 where 2 were expected (chunks 0 and 2 by the thread, then 3 within
settled()'s 300 ms).
Now the window moves (RamOnDevice::took) once the object holds the chunk: found
made, marked in flight by it, or held back. The thread, woken by the move,
finds the chunk in flight or made and imports the ones past it.
Test: an_object_holds_its_chunk_before_the_window_moves_to_it holds the
object's call 300 ms before it holds the chunk (RamSource::taking_pause, a new
cfg(test) pause beside making_pause) and checks the object imported its chunk
and the thread one past it alone.
Evidence (lane jobs, msi): m3-max-32427: clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0;
lavapipe 78/78 (host_ram_device, host_ram_copy_device, host_ram:: units) incl. the new
an_object_holds_its_chunk_before_the_window_moves_to_it and the original a_chunk_bound_buffer_and_a_copy_of_its_pages_...
Negative control m3-max-32428 (the take back at the top of chunk()): the focused test fails, "the object imported its
chunk, the thread not in its place: left 0, right 1". The Windows mini runs follow in the lane.
Lane commit: 10dfe36dce.