3feb4b3a55b50d52ee7782492018aa6df945a2eb
76
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6575c031f5 |
In place: 1- and 2-byte texels a shader writes, checked apart by the device's check
In every guest session reims measured (Iris Xe and Radeon 780M, macOS 26.7.2 guests), host_texture_shadows_store_width was 114, from 23 distinct R8Unorm, A8Unorm and R16 textures a shader writes (32x32 at 256-byte rows among them). They were shadows because the in-place check's write kernel stored only 4-, 8- and 16-byte texels (STORED_TEXEL_BYTES, ShadowCause::StoreWidth), so no check covered a driver's writes of narrower ones. What changes: - in_place.rs (from selfread's parked 0c587bcad5): Access gains NarrowWrites and NarrowBufferWrites, with 36 verdicts instead of 24. Access::written picks the writes check of a texel width and padding. STORED_TEXEL_BYTES holds 1, 2, 4, 8 and 16; NARROW_TEXEL_BYTES holds 1 and 2. in_place asks the written check in place of Writes. The report names "narrow writes" and "narrow buffer writes". CHECK_VERSION goes to 9 (development's dma-buf import fix took 8). - in_place_check.rs: NARROW_STORE_SHAPES, rounds of their own for the narrow accesses, through the copy-in kernel's R8_UINT and R16_UINT views (a801dac7d7). The shapes are packed R8 256x16 and R16 128x16 at 256; R8 61x37 and R16 45x29 at 256, whose rows end inside a word and whose heights are odd; the 16- and 64-byte tight pitches; and an R8 1024x1024. The source buffer holds a word per texel, the texel's bytes low and zeros above, since CopyIn takes 4*words() bytes a texel. A narrow round's change fails only the narrow verdicts, never a 4/8/16-byte texture's. A device whose kernel or image is not made (no shaderStorageImageExtendedFormats) leaves them unchecked. - in_place::storable: one helper for a render target's storage usage, used by route.rs and storage_form.rs. It asks Access::written(texel, Padding::Kept) instead of Writes, so a narrow render target never takes the 4-byte verdict. writes_reach (the storage usage an image that does not render takes beyond its usage) and fresh_pages_take ask the written check of the texels' width; InPlaceWatch carries the width. - InPlaceAccess::Writes covers the narrow accesses. Docs (in_place, the check, API.md, HOWTO, FAST-PATHS row, runtime README, WorkCounts, HostPageTexturePolicy, TextureShadowReason) say 1, 2, 4, 8 and 16 bytes, with narrow writes checked apart. The lane's VERDICTS goes to 36. Tests: - The decision test runs every width, 3 bytes for StoreWidth among them, against narrow answers that differ from their wide twins'. It also checks storable. - Shape tests cover the narrow set: tight pitches, row ends at 16/64/128/256, free padding. - New: each_check_of_storage_writes_stores_its_texels_width. A narrow tally case. - New device test narrow_writes_device: the guest's 32x32 R8Unorm and A8Unorm (and RG8Unorm and R16Unorm) at 256-byte rows over a no-copy buffer. Each takes its narrow verdict's path, its placement query agrees, a kernel's writes reach the bytes, and the padding and the bytes past the last row are kept. - in_place_storage adds an R8Unorm render target. Verified: not yet built; the build, clippy, unit and device runs follow as jobs. (cherry picked from commit dbb985df199b1c46bb783aafbd50efd40bcab187) |
||
|
|
b136c2531a |
Buffers: a declaration that the bytes between a texture's rows are unobserved
A consumer's cache buffer of the runtime's own memory (the 780M guest's 3662x2038 desktop
surface, more guest-page pieces than udmabuf takes) holds textures whose rows lie 14848 bytes
apart, 14648 bytes of texels each. linear_plan::holding shadows every such texture, since an image
at that pitch holds the bytes between rows and Vulkan lets its layout moves and a render pass's
load and store write them; the consumer's download copies each row's texels alone, so it never
reads those bytes, and the shadow's copies cost it about 1 G texels/s in a Finder drag.
BufferDescriptor::padding_unobserved (with_padding_unobserved) is the maker's declaration that
nothing reads the bytes between a texture's rows over the buffer (each row's bytes after its
texels to its pitch, the last row's included) nor between its slices. A runtime extension with
no Metal counterpart, only for the runtime's own memory: refused, Invalid
(PaddingUnobservedNoCopy), with NoCopy contents. The buffer keeps it (Buffer::padding_unobserved).
- The route (texture/route.rs) decides it for a buffer of the device's own memory:
Route::Device { holds } carries linear_plan::holding's answer, which with the declaration
holds rows and slices that lie apart (rows that share bytes stay refused). The making and the
placement query share it: the query answers NotHostPages where an image may hold the texels,
and the new TextureShadowReason::BytesBetweenRows where it may not (it answered NotHostPages
for both before).
- aliases takes the declaration: the image's subresources may then hold the padding
(linear_plan::within_padding: each subresource ends at its slice's last row's pitch or before,
slices at Metal's stride), never a byte past the last row's pitch, nor memory past the
buffer's. A byte of the image's memory past every subresource is reached by no operation on
it, the reading texels_alone already rests on, so no new check class is needed.
- WorkCounts::unobserved_padding_aliases counts the aliasing images that hold such bytes.
- A buffer the runtime lays in fresh pages (a long one where pointer imports cost submissions
nothing) keeps the in-place check's route: the declaration lets nothing more there (documented).
Docs: the field and builder, NotHostPages and BytesBetweenRows, HOWTO's paragraph on textures
over the runtime's own memory, API.md's shadow reasons and placement answers, the runtime
README; REFUSALS.md and api_signatures.tsv regenerated.
Tests: linear_plan's unit tests of the declared holding and aliasing (padding to the last row's
pitch held, past it or past the buffer refused, slices at Metal's stride alone, shared rows
refused); the route's placement test of both Route::Device answers; a device test
(tests/padding_unobserved.rs): a 101x48 BGRA8Unorm texture at 416, 448 and 512 bytes a row over
an undeclared buffer answers Shadow(BytesBetweenRows) and is a shadow, over a declared one answers
NotHostPages and is an aliasing image wherever the device lays one at the pitch (counted), at
least one pitch aliasing, its texels read back by a blit; and the declaration refused over the
caller's memory. The in-place lane's unobserved_padding_costs times a frame reading the
consumer's surface shape over a declared and an undeclared buffer.
Verified: pending (lavapipe and MoltenVK device tests, the 780M lane run next).
(cherry picked from commit 430523ce0e4dbd8433eb2b514f837d44ce1c5a9a)
|
||
|
|
95a5f1ad37 |
Point HOWTO's integrators at the texture placement query
docs/HOWTO.md's passage on textures over host pages told a program to start the in-place check early with Device::settle_in_place_checks; it now also says that a zero timeout later answers whether the verdicts are known, and that a program routing each surface to its pages or to a copy of its own asks Buffer::texture_placement (or texture_placement_with_iosurface_plane), whose answer is the making's own decision. Docs only. (cherry picked from commit 17bbae52a0330a75a5d1cd522407f2888dc7bcff) |
||
|
|
b6c025c12b |
Free a moved shadow's image once the command buffer that took the move completed
A texture over host pages made before its in-place verdict is a shadow, and moves in place at a
commit once its class's verdicts pass (`texture/storage_form.rs`). The shadow's image then stayed
with the texture until it went, so a long-lived surface kept an unused texel-sized image and its
merges' scratch buffers for the session.
The switch's last part now writes the shadow's image (a tracked transfer write of every level and
layer), so hazard tracking orders the committing command buffer after every use of the shadow
committed before it, on any queue, and that command buffer holds a ShadowAfterMove. Once it
completed, where the texture moved in and only the texture's storage and this hold the shadow's
image, the image's VkImage, views and memory go (`Image::let_go_unused`, the release a drop runs,
at most once), and its merges' kept scratch buffers. Nothing names the shadow by then: every later
command presents the image in place. A view of the texture made before the move, a shadow made
over the shadow's image (which holds it as its truth, `shadow::ImageTruth`), and an untracked
texture keep it until those and the texture go. The in-place counts are unchanged.
New WorkCounts field: host_texture_shadows_freed_after_move. FAST-PATHS (the in-place row) and
HOWTO say when the shadow goes.
Verified:
- runtime_lane::in_place_textures::a_texture_made_before_its_verdict_moves_in_place_once_it_passes
now requires as many shadows freed as moved (polled up to its wait): "moved 1, in place 1,
shadows freed 1" on lavapipe (gem10 m3-max-7070, at this base; msi m3-max-7019 at
|
||
|
|
2b7ebd8c38 |
ANV: blits through two imports of the same host pages are unordered by a barrier in one command buffer
On ms01's Iris Xe (Raptor Lake-P, Mesa 26.2.6) two host_ram_device tests failed (5425): a write through a buffer bound in a run's import and a read through one bound in the chunk's import of the same pages, in one blit encoder. A probe of each way (5482, scratch branch steelbrain/amdperf-iris-probe, two runs) showed the shape MoltenVK's AliasedImportBlitsUnordered names: in one command buffer, in one encoder or two, a fill through one import, a global memory barrier and a copy through the other read none of the fill (0 of 4096 bytes) in either direction, where two command buffers of one queue, a wait first, and two queues each read all of it, and every way through one import read all of it. Vulkan counts imports of the same pages as aliases of one memory, which a global barrier orders, so this is the driver's. ANV now has the defect in the Affected table, so an object over a chunk not yet imported binds in the chunk's import (waiting for it), never in an import of its own run, as on MoltenVK. The table test lists it for ANV; host_ram.rs, the host_ram_device tests' docs and HOWTO name ANV beside MoltenVK. Verified: cargo fmt only here; the Iris rerun of the 42 tests is a potluck job. (cherry picked from commit 589815be2cd36191673b6aae36e2f50a2afcd1cd) |
||
|
|
78e58c370f |
Guest RAM: listed chunks stop at 512 MiB, not 256
On a device whose held imports add to the cost of every submission (RADV), a guest RAM's chunks now run up to 512 MiB. reims's 16 GiB guest on the Radeon 780M (their job 5584, two boots of each setting) had less of QEMU's RAM resident with 512 MiB chunks than with 256 MiB ones: 0.45 GiB more than without the source at its desktop against 0.94 GiB, and 0.15 against 0.25 GiB at the end of its run, with at most 11 to 12 chunks live against 15 to 18. The probe's per-submission cost falls too: an 8 GiB RAM's submission median was 32 to 33 us in 32 chunks of 256 MiB and 24 us in 16 of 512 MiB (job 5411). LONGEST_LISTED_CHUNK, the module and use_host_ram docs, HOWTO, the FAST-PATHS row and the chunk-length probe (now up to 512 MiB) say 512 MiB. (cherry picked from commit 003382bdc921fa8e7901fa00c7896f29439d7907) |
||
|
|
f9bc470d7c |
Move a shadow made before its pages' in-place verdict in place once it passes
A texture over host pages made before its class's in-place verdicts were known is a shadow (CheckPending): an unknown, not a lack. Under the owner's 11-07 ruling a shadow is only for accesses that cannot be done in place, so such a shadow must not stay one for life because it was made early. Each such shadow now waits for its class's verdicts (StorageForms::moves). The check's thread, at each verdict, decides from facts stored with the wait (class, usage, texel bytes) and takes no handle of a program's texture. Where the verdicts take an image in place, the texture waits for the storage-form switch. At the commit of the device's only uncommitted command buffer, the switch makes the image in place exactly as the texture's making makes it: the declared plan, with feedback loop and storage usage where the device makes them so, and noted for a rebind and its first move. Where every encoder ran, the texture presents it from then on (TextureShared::moved; every storage read goes through Texture::storage). It is counted in host_textures_in_place and in the new WorkCounts::host_textures_moved_in_place, and its slots are written again. No texel is copied: between encoders the shadow holds nothing the buffer lacks, and the image in place is the buffer's bytes, whose uses hazard tracking orders after earlier copies back and merges. A view made before the move keeps the shadow. A shadow with a usage or render shadow, over detached or copied bytes, or whose image the device refuses stays a shadow. The shadow's image is kept with the texture until it goes. Test: runtime_lane::in_place_textures::a_texture_made_before_its_verdict_moves_in_place_once_it_passes (under the validation layer). Docs: storage_form.rs and in_place.rs module docs, FAST-PATHS in-place row, HOWTO, API.md. (cherry picked from commit 605d0444de1ad1a9b93e02649db7e1b2fda18e93) |
||
|
|
6aff9aaa3c |
Stop a listed guest RAM's chunks at 256 MiB: a chunk's import pins every page of it
Where each listed import costs every submission (RADV with a source of dma-bufs), a guest RAM was imported in chunks as long as the source's dma-bufs and the device's limits took: about 2.5 GiB on a consumer's 16 GiB guest on the Radeon 780M. A chunk's import pins every page of the chunk, and udmabuf allocates the pages of the memfd the guest never touched, which stay allocated once the chunk is freed. So each chunk an object lies in made all its bytes resident: the consumer measured QEMU's Pss_Shmem at 7.86 GiB without the source and 12.31 GiB with it. listed_chunk_bytes now stops at LONGEST_LISTED_CHUNK, 256 MiB, on every device and kernel. It is a structural bound, not tied to udmabuf's size_limit_mb, which stays an upper bound through HostRam::with_largest_dma_buf. The trade is speed against memory, with no accuracy change and so no switch. Each live chunk costs every submission about half a microsecond (an 8 GiB RAM on the 780M: 128 chunks of 64 MiB took a submission's median from 14 us to 60-88 us; 3 chunks of 2730 MiB, to 16 us). At 256 MiB, a 16 GiB RAM lists at most 64 chunks. The kept-chunk rule (releases_idle_chunks) is unchanged, so the first-gather win of kept chunks stays. The docs (the host_ram module, Device::use_host_ram, HOWTO section 6, and the FAST-PATHS "Idle dma-buf imports are released" entry, edited in place) say where the chunks stop and why. The lane probe submit_per_ram_chunk_length now measures only the lengths the plan can make (64, 128 and 256 MiB). Its run before the cap measured 64 MiB to 1 GiB. Verified: the unit test listed_chunks_are_as_long_as_every_limit_takes_in_whole_64_mib fails without the cap (a 2.5 GiB source gave 2560 MiB chunks) and passes with it (job ids in the tip). (cherry picked from commit 9a158941e94173b4e0dc53b89f3b15c9b59f60c2) |
||
|
|
442dcd08c9 |
Copied host memory: a copy that drops the GPU's writes takes its guest RAM's log, and a draw that only reads through loaded addresses leaves unnamed copies uncompared
A copy of memory of Metal's private option bit 24 (on a system that maps no read-only view of the pages) skipped the routing of its guest RAM runs, so it kept no log: every commit compared every byte of it, and every completion of a command buffer with a root table compared every copy. In consumer boots that is about 29.5 MiB per commit and per completion over 37-44 objects. - Commit (copy in): a no-copy buffer, heap or rebind whose GPU writes are dropped has its runs asked as a writable one's are (routes_runs), so its copy takes the RAM's log and copies in only the pages the log reports written. It is still never bound in the RAM's chunk: the in-chunk binding is filtered on drops_writes. macOS keeps its read-only view and asks no runs. - Completion (merge back): State::writes_unnamed narrows reaches_unnamed to commands whose functions may write memory. A draw's root table writes only where the vertex or fragment function may store or update memory (GraphicsState::vertex_writes_memory, fragment_writes_memory) or the pipeline has another stage; kernels, tile functions, replay tables and records resolved by host steps stay as they were (every copy compared). The compare itself stays: in a dropping copy it is what restores the dropped bytes, so later command buffers read the pages' bytes. Tests: host_ram_copy_device a_private_bit_copy_over_the_pages_copies_in_only_the_pages_the_log_reports (one page written: length - page bytes not compared, the GPU's fill dropped) and copied_device a_merge_back_skips_a_copy_when_a_draw_only_reads_through_loaded_addresses (root table noted, merge back compared 0). Docs: copied.rs, FAST-PATHS known gap, HOWTO section on copies. (cherry picked from commit 61a9a4f4603a4c080ba5a4f2e204668ae621cf41) |
||
|
|
78a98addc1 |
Guest RAM: a listed chunk stays imported where the whole RAM fits the memory its imports count against
On RADV the first kernel submission that lists a guest-RAM chunk just imported waits while amdgpu writes the chunk's page tables, one entry per host page, through SDMA jobs that wait for room in the IB suballocator (amdgpu_cs_ioctl > amdgpu_vm_bo_update > amdgpu_vm_sdma_update > drm_suballoc). It holds the VM's reservation lock throughout, so every other submission of the device waits too, and so did the guest-RAM thread's next PRIME_FD_TO_HANDLE (218 ms in amdgpu_gem_object_open). Seen with a root /proc stack sampler on the Radeon 780M (gem10 job 4750): 231 to 275 ms of a gather's submission per 3.94 GiB chunk imported again. Every re-import after the idle release paid it again. A listed chunk, once imported, now stays imported while the device uses the RAM, where the whole RAM fits in half the device's memory heaps with unified memory (RADV reports an APU's GTT and carve-out together, split across two heaps), else in three quarters of the heaps that are not device-local (a discrete GPU's GTT). Chunks kept past their objects must fit in the kernel's GTT: RADV lists every import in every submission, which fails once they pass it. Where the RAM does not fit, chunks are released while idle as before. Each kept chunk costs every submission about half a microsecond (3 chunks for 8 GiB: 16 us against 14 us). Plan::releases says which; Device::count_host_ram_imports_against is the device tests' seam (cfg(test)): the release test makes the RAM too long, and a new test sees chunks kept past their objects and the idle window, with the next objects bound in them and no import made. The lane probe's gathers say how many chunks are live and were released. FAST-PATHS and HOWTO say what is true now. (cherry picked from commit 75f17258ddd0dc03e2f89a85819091cfa22c345a) |
||
|
|
3312a0ad84 |
Make a texture over host pages before its verdict without waiting for the in-place check
A texture over host pages made while its class's in-place verdict was pending started the check
and waited for that verdict as it was made, up to in_place::VERDICT_WAIT (5 s). The check's
rounds take seconds on some devices and builds: on um870's Radeon 780M (RADV, Mesa 26.2.6), in a
debug build, the first of the consumer's odd-width surfaces (3662x16, rows of 14656 bytes,
ShaderRead | RenderTarget) took 1.75 s and 1.86 s to make (job m3-max-5168), past the ~2 s the
consumer's guest waits for the COMPLETE of its next message. reims-vgpu's
on_vulkan_a_presented_surface_at_an_odd_width_reads_row_for_row failed there ("a COMPLETE") from
the wait's landing on; every command buffer of the same shape completed in under 2 ms.
A texture made before its verdict is a shadow again (ShadowCause::CheckPending, counted in
host_texture_shadows_check_pending), and its making starts the check and waits for none of it.
A program that makes such textures as it starts, and wants them in place on a driver's first
run, starts the check earlier with Device::settle_in_place_checks and a zero timeout; a device
whose record holds the verdicts knows them as it is made, as before. VERDICT_WAIT,
InPlaceChecks::wait_for and WorkCounts::in_place_verdicts_waited go (api_signatures.tsv).
Test: tests::first_host_texture, the consumer's shape: six surfaces over no-copy buffers at widths
3662, 1831 and 1001 (rows padded to 64 bytes), ShaderRead | RenderTarget then ShaderRead, each
copied out by a blit and read at its own pixels by a draw. The first is a shadow made before its
verdict; before this change it waited and was counted 0 there (m3-max-5168), so the assertion
fails without the fix. fresh_pages's in-place test settles the check before its texture, as a
texture made before its verdict is a shadow now. The waiter's unit test goes with wait_for.
Docs: in_place.rs, docs/API.md, docs/HOWTO.md, the FAST-PATHS in-place row.
(cherry picked from commit eca12ad708a8f1ad53521c967d4340a9b2635a22)
|
||
|
|
6276d55b25 |
Textures a shader writes over host pages in place, where the device's check passes for their writes
A texture over host pages whose usage writes it through a shader (`ShaderWrite` or `ShaderAtomic`) was a shadow on every device: its texels copied in before each use and merged back after each write. The owner's ruling of 11-07 (confirmed for discrete GPUs) has CPU-visible memory worked on in place wherever the device can, slower or not, with a shadow only where in place is impossible, announced and counted. This takes such a texture in place on the same terms as one that renders, from the parked branch park/shaderwrite-in-place, onto the per-class, per-access check, with no device-type rule: a discrete GPU takes it in place too. - `in_place.rs`: a third access, `Access::Writes`, which a texture of `ShaderWrite` or `ShaderAtomic` usage takes; a texture is tried in place where its class's check passed for each access it takes (`Access::takes`: renders, writes, or reads where it does neither), asked in that order until one did not pass. A texture a shader writes of texels of 1 or 2 bytes, which the check's kernel stores none of, is a shadow (`ShadowCause::StoreWidth`); `ShadowCause:: ShaderWrite` is gone. Nine verdicts a record (CHECK_VERSION 3). - `in_place_check.rs`: the storage rounds, per class: a texture of `ShaderWrite` usage over the pattern, every texel stored by the crate-owned copy-in kernel through an unsigned-integer view (`Texture::store_in_place`, from a buffer outside the Metal address space), its first move first, while the writer writes the bytes between rows and after the image; every texel must read the kernel's bytes, every other byte the writer's or the pattern. `STORE_SHAPES`: 4, 8 and 16-byte texels, packed, padded at 512 bytes (widths no multiple of 4, odd heights) and at a tight 16-byte pitch, and 1920x1080. - `WorkCounts`: `host_textures_in_place_written` (of `host_textures_in_place`, those a shader writes) and `host_texture_shadows_store_width` are new; `host_texture_shadows_shader_write` is now the subtotal of the shadows a shader writes, as `host_texture_shadows_render_target` is of those that render. The rebind of a texture in fresh pages asks every access its image's usage takes. Tests: the decision test covers every usage, texel width and combination of the three accesses' verdicts, and the order in which they are asked; the cause words and the record of nine verdicts. Lanes: in_place_textures gains `written_textures_over_host_pages_take_the_path_their_checks_answered` (64x64 `RGBA16Float` at 1024 and 512 bytes, 61x64 at 496, signaling-NaN halves beside the texels: in place exactly where `Pointer writes` passed, a kernel's writes reaching the pages, every other byte kept), and `textures_that_render_or_write_take_the_path_their_checks_answered` replaces the test that counted every written texture a shadow; no_copy_textures and pitched_surfaces take a written texture in place where its texels are 4, 8 or 16 bytes. Docs: in_place.rs, in_place_check.rs, the policy's docs, API.md (the in-place paragraph, the shadow paragraph, the `shadowed-texture` notice), HOWTO.md, the runtime README and FAST-PATHS.md's in-place row and host-pages bullet. (cherry picked from commit c3ffb08376251b87e16b7b417b39f1458e271085) |
||
|
|
158f7220ff |
Pages the process maps read-only are a copy whose GPU writes are dropped, on every device
On Linux, a no-copy buffer, heap or rebind over pages the process maps read-only went to the caller's dma-buf source wherever it gave one, and so did pages an import alignment above the host page left with no pointer import (by_pointer false), which skip the gate. A dma-buf of the pages takes the GPU's writes, which Metal drops (an M3 Max under macOS 27.0.1: the CPU reads read-only pages as they were). The runtime announced that as read-only-pages-written. Without a source the pages were refused, where Metal makes the buffer. The owner's rule (10-23) is to drop such writes on every device, never refuse them. Such pages are now a copy whose GPU writes are dropped (copied.rs), with or without a source, which is never called for them. The gate is still asked first where the pointer would be imported, and its refusal is still counted as a refusal. Counted: WorkCounts::copied_unwritable_pages (new, public), announced as copied-host-pages with its own cause. Degradation::ReadOnlyPagesWritten is removed (public: api_signatures, docs/API.md's catalogue, the lane's notice registry), and so are HostWindow::unwritable and degrade_read_only_pages. Tests: the dma_buf_imports lane test is now read_only_pages_are_a_copy_whose_gpu_writes_are_ dropped. It fails at the base, where the sourced buffer's fill reaches the file's pages and the unsourced one is refused. The host_memory lane test a_read_only_page_is_a_copy_on_linux_and_ read_elsewhere replaces the refusal test. The runtime's copied_device tests cover a new buffer and a rebind over read-only pages whose gate admits them: a copy, the source unasked. The keep-alive order test uses writable memfd pages, which RADV imports as dma-bufs all the same. (cherry picked from commit 68805d8a5742590e157b089f336c17e8e1dc4ef4) |
||
|
|
23ffb2f64f |
Name the in-place check's record by the driver and the check alone; wait for the verdict
The record of the device's in-place check was named by RUNTIME_VERSION too, which moves at almost every pin: every reims boot after a pin move ran the check again, and the textures made before it answered (WindowServer's framebuffers, made at its start) were shadows for that boot's life. - in_place.rs: the record's name and body hold the check's tag, kind and version and the driver's identity (vendor, device, driver version, driver ID, name, info, device UUID), not the runtime version; the body loses its runtime field. CHECK_VERSION is the version of what decides the answer: the check, and the images over host pages it checks as the product makes them. Asked by main for the owner's 11-07 ruling. - A texture made while its class's verdict for its access is pending starts the check and waits for that verdict as it is made, up to in_place::VERDICT_WAIT (5 s), instead of taking a shadow for its life (InPlaceChecks::wait_for, woken by each verdict set and by the settle; counted WorkCounts::in_place_verdicts_waited). Past the wait it is a shadow, counted check_pending. - self_reads prints the check's time (SELF-READ-CHECK ... took). Tests: tests::in_place pins the record name to the identity and check alone (a hash computed in the test), drops the runtime field from the frame tests, and checks a waiter wakes on its own verdict and on the settle. Docs: in_place.rs, in_place_check.rs, docs/API.md, docs/HOWTO.md, docs/FAST-PATHS.md's row; api_signatures.tsv gains WorkCounts.in_place_verdicts_waited. Verified: build, clippy and the touched tests in the follow-up jobs named in the tip's report. (cherry picked from commit 841a92b0020f1d43e943c9bc04245cffb7fcf503) |
||
|
|
6a31655071 |
Guest RAM on a listed device: no making or copy waits for a long chunk's import
On a device where each listed import costs every submission (RADV with a dma-buf source), a guest RAM's chunks are a few long dma-bufs (2.7 GiB on the Radeon 780M and RX 7900 XTX), and the first object over a chunk not imported imported it on its own thread: 660 to 692 ms, at the first object over each chunk and again at a released chunk's next use. A copy over such a chunk (copy_from_host_ram, copy_to_host_ram) did the same on the encoding thread. Now the chunk's import is off the caller's path: - On a listed device the device's thread (listed_chunks, in place of release_idle) imports each chunk an object or copy asked for (ChunkSlot::asked, RamOnDevice::next_asked), and still releases idle chunks. The object, and every object over the chunk until the import is done, is bound in an import of its own run alone (RamOnDevice::run_alone), as on a device that imports ahead; those after lie in the chunk. - A buffer's (not a heap's) run import is releasable as a no-copy buffer's own import is (host_residency.rs, AgainFrom::RamRun): released while idle, its address never handed out, and at its next blit bound in the chunk's import where that is made and lays the bytes as the run's did, else in its run's own import again; never the chunk's import nor a wait for one. This holds on every device whose objects take run imports. - A copy over a chunk not imported imports each of its ranges of that chunk alone (ranges less than 2 MiB apart joined, at most copy::MOST_ALONE = 16), held by its command buffer, while the device's thread imports the chunk (RamOnDevice::for_copy); more ranges than that, or where an object's run would not be imported alone, the chunk as before. Tests: the listed device test now checks the first object's run import, the thread's import of the asked chunk, the holders in the chunk, the runs' release while idle and the rebind in the chunk at the next blit, the chunks' release, and a copy over a released chunk taking its run alone. The AHEAD copy window test expects the copy past the window to import its page alone. Unit tests: next_asked's choice, alone_ranges' joins. Docs: host_ram.rs, host_residency.rs, host_ram/copy.rs module docs, use_host_ram, HostMemory::with_runs, WorkCounts::run_imports_live, FAST-PATHS.md, HOWTO.md. (cherry picked from commit f80468eb4afac1e30f14fd99e1af06b67622a1a1) |
||
|
|
48ba1d9856 |
Guest RAM on a device that pays per listed import: few long chunks, none ahead, idle ones released
Where the device imports dma-bufs, the RAM has a source and the device's held imports add to the cost of every submission (RADV), each listed import costs every submission: an 8 GiB RAM as 128 dma-bufs of 64 MiB raised a submission's median from 14 us to 60-88 us on the 780M (probe submit_per_ram_dma_buf, job 3904), as 3 of 2730 MiB to 16 us. There (Plan::listed) a chunk is as long as one dma-buf of the source holds (HostRam::with_largest_dma_buf, new: udmabuf's size_limit_mb) and maxMemoryAllocationSize, maxBufferSize and maxStorageBufferRange take, in whole 64 MiB (listed_chunk_bytes). No thread imports ahead and no run is imported alone; the device's thread instead releases a chunk only its slot holds once it stayed so for its window (2 s, doubled per release up to 64 s, as a no-copy buffer's idle import), counted by the new WorkCounts::host_ram_chunks_released. Tests: listed_chunk_bytes and long chunk_spans unit tests; a device test (where_each_listed_import_costs_a_submission_...) of one long chunk, none ahead, kept while held, released once idle and imported again; the probe submit_per_ram_chunk (8 GiB memfd RAM, an object over each 64 MiB). Docs: host_ram.rs, with_runs, HOWTO section 6, FAST-PATHS idle-release row, api_signatures. Not built yet: the next commits fix forward what the build finds. (cherry picked from commit e313ddd4201e87a76490a36eb394281d6961dbc9) |
||
|
|
3eb84d76c6 |
Off macOS, drop the GPU's writes to bit-24 no-copy memory through a copy
Metal drops what a shader or the blit engine writes into no-copy memory made with its private option bit 24: the write completes with no error, a later command of the same command buffer may read it back, and neither a later command buffer nor the CPU sees it (probes/readonly_gpu_writes.m, an M3 Max under macOS 27.0.1; the owner's ruling of 10-23: drop, never refuse, on every driver). macOS imports the pages through a read-only view of them. Elsewhere the import was of the caller's own pages, so the GPU's writes reached the pages, the CPU and later command buffers (host-page-writes-kernel-store-read-only and host-page-writes-visibility-read-only diverged on llvmpipe and the RTX 5080), announced as private-resource-option. No import can keep the writes out there: Linux drivers pin imported pages for writing, and ANV lost the device and RADV failed every submission over read-only imported pages. So off macOS such a buffer, heap or rebind is made over a copy of the pages whose GPU writes are dropped, the mechanism copied.rs already has for pages the process maps read-only: each commit copies in what the CPU changed, later commands of the batch read the GPU's writes, and the batch's completion puts every byte the GPU changed back, writing nothing to the pages. The gate is not asked (nothing is imported), the copy joins no other buffer over the bytes, and a rebind whose bytes moved in their page is now a copy laid out at the old offset rather than refused. - buffer_descriptor.rs: buffer_over_host_memory makes the copy (CopiedFor::ReadOnly) where drops_writes and the system maps no read-only view; the rebind path copies the same way (read_only_copy); copied_buffer takes why it copies, and passes read_only to CopiedBuffers::add and drops_writes to the buffer's HostCell. no_copy_options moves here from degradation.rs and no longer announces private-resource-option off macOS (that notice stays for a heap of the runtime's memory and an indirect command buffer). - copied.rs: add() takes read_only, which drops the copy's GPU writes whatever the pages' protection. - buffer.rs: BufferParts carries drops_writes into host_lie. - New: CopiedBecause::ReadOnly, WorkCounts::copied_read_only_memory. - Docs: read_only_view.rs, copied.rs, capabilities.rs (the answer stays no off macOS), values.rs, host_backing.rs, interop.rs, host_aliases.rs, error.rs (RebindTextures is macOS-only now), degradation.rs, docs/API.md (private-resource-option, copied-host-pages), docs/HOWTO.md and the docs/FAST-PATHS.md known gap: off macOS a command buffer committed while the writer is in flight still reads its writes, and a render pass's store-out into the copy completes where Metal's faults. - Tests: degrade_notices' bit-24 lane tests assert the writes are dropped on every driver and count the copies (3 and 1 off macOS, 0 on it) and the kinds (copied-host-pages off macOS, none on it); copied_surfaces' dropping buffer is a copy of its own off macOS. - host-page-writes read-only rows declare copied-host-pages in place of private-resource-option; their 8 ledger rows are removed. - api_signatures.tsv blessed for the new field. Verified: see the replay and lane-test jobs named in the branch report (lavapipe, the RTX 5080 through b5080, MoltenVK on the M3). (cherry picked from commit 1f24b1f035d61f093ecf2c76fae4b9c2e4b541d9) |
||
|
|
924f46aac7 |
use_host_ram and HOWTO: the no-source case and the dma-buf route in one statement
flakes's landing (
|
||
|
|
718f6543b4 |
HostRam: chunks imported as dma-bufs where held pointer imports tax every submission
reims measured raw Vulkan on the Radeon 780M: each live host-pointer import adds about 0.75 us plus 0.33 us per MiB to every vkQueueSubmit (amdgpu gets every page of a userptr again in each CS), each dma-buf about 0.44 us with no per-page cost. A guest RAM imported in 64 MiB pointer chunks would cost RADV about 24 us per chunk per submission, and RADV refuses the pointer of any shared mapping (a memfd's) anyway, so the consumer imports 13-135 region blocks and its IOSurfaces one dma-buf each there. - `HostRam::with_dma_buf(source)` (new public method) gives the RAM a DmaBufSource. Each import of the RAM, a chunk or an object's run imported alone, is then one dma-buf of its pages where the device's submission checks found a held pointer import taxing every submission (the ImportTax verdict; the pointer where that import fails), and elsewhere the pointer first, the dma-buf where the pointer is refused. The decision reads the device's measured verdict or the driver's refusal, never its identity: NVIDIA, ANV and MoltenVK (untaxed) keep the pointer path unchanged. `use_host_ram` waits (at most 10 s) for the checks first when the RAM has a source. - A buffer bound in a dma-buf chunk is made for DMA_BUF_EXT memory (VUID-vkBindBufferMemory-memory-02985; `host_buffer` takes the handle type). Its placement lends the chunk's imports, so textures over it take the dma-buf image route (an image over a dma-buf of their own pages from the RAM's source), asked at the RAM's addresses (`Placement::dma_buf_address`: the caller's view may differ from the RAM's). A rebind into such a chunk makes the heap's and in-place images again as a rebind onto the caller's dma-bufs does. `host_backing` reports such a buffer InHostRam; its deallocator goes at once (it frees no memory of its own); the chunk's RAM keep-alive goes after the chunk's dma-buf import is freed. - Counted: WorkCounts::host_ram_dma_buf_imports (new field). Also in this commit, for the submission checks of 363fa41176: the docs that named the removed DriverFact rows (PointerImportsFollowTheirAddress, SubmissionsWithoutSignalsMerge) name the device checks (FAST-PATHS grouping row and known gaps, HOWTO, fresh_pages.rs, buffer.rs, buffer_descriptor.rs, host_memory.rs, work_counts.rs); fresh_pages.rs and FAST-PATHS give the measured reason for the tax gate (one 64 MiB fresh-page buffer: a commit's p50 10.7 -> 36.6 us on the 780M, 14.7 -> 164.7 us on the RX 550, submit_per_fresh_page_buffer at 27b9b13bcd); the checks' 10 s answer wait is one constant (submit_check::ANSWER_WAIT) shared with the in-place check; and the recall test's failure names the record, where it lies, the cache's rejected/failed reads and both identities (it failed on lavapipe, msi-laptop, m3-max-3160: no device recalled the record in 60 s; the cause is not known yet). Verified: cargo fmt only; compiled and tested in the following jobs. (cherry picked from commit fa8c27f1549fe09d769847ef63f8e34d51f2c6af) |
||
|
|
bc13149480 |
HostRam tests: fresh RAM a device imports; shared RAM a device refuses imports no chunk
On RADV (a Radeon 780M, Mesa 26.2.6) 8 of the 19 host_ram_device tests failed every run: every
test over fresh_ram, a memfd mapped shared as QEMU's memory-backend-memfd,share=on RAM is. RADV
imports a pointer through amdgpu's userptr, which takes private anonymous pages alone, so it
refuses those pages (Device::imports_shared_host_pointers answers false there): the device's
thread imported no chunk ("one chunk from the RAM's start", left 0), and a no-copy buffer over
the RAM was refused, Unsupported(HostMemory, NotRepresentable) (diagnosed on homelab-um870-1,
potluck jobs m3-max-2986, 3083 and 3119). The runtime's answer is the right one with no dma-buf
source; the tests asked RADV for RAM it cannot import.
fresh_ram now takes the device and maps the memory it imports: the memfd mapped shared where
imports_shared_host_pointers answers true (NVIDIA, lavapipe, MoltenVK), else private anonymous
memory, as QEMU's memory-backend-ram RAM is, both never touched and advised for huge pages.
ahead_device asks the probe once up front, so no test's counts or allocation limit meet its
one-page import. A new test pins the no-source case where the device refuses shared pointers:
a_ram_of_shared_memory_a_device_refuses_imports_no_chunk_and_refuses_its_objects makes the
memfd RAM, uses it, and expects the buffer over it refused (Unsupported, HostMemory), no chunk
imported or live, and the RAM's keep-alive dropped after the use; elsewhere it says so and
passes. use_host_ram's docs and HOWTO state that no-source case.
(cherry picked from commit 48202da5ba0c0cb7f49d0a630e59efd11c5918f7)
|
||
|
|
a2b99ee4f6 |
Report each write to a log of host pages in one batched call
The consumer measured DirtyCommit::report_host_writes at 77.7% of its present path on the RTX 5080: PagesLog::wrote_but called the source's hook once per run of the object's window in a guest RAM's log, about 9,000 calls a report for a 3840x2400 BGRA8 surface over scattered 4 KiB pages. PagesLog::wrote, wrote_as and a shadow's report did the same. DirtyPages gains wrote_runs(&[Range<u64>]) and wrote_runs_as(&[Range<u64>], writer), whose defaults call wrote or wrote_as once a run, in order, so existing sources keep working. Every write the runtime reports now comes to each log as one call carrying all its runs there: each range of a command buffer's writes in place (the bytes no shadow wrote, the gaps between the shadows' writes, in order), each shadow's write to the other logs, a copied host buffer's merge back (all its blocks, one call per log and copy, where it was one call per run of each block), a CPU write, and a shadow's copy back or merge (one run). For each source, the runs, their order and their writers are what the per-run calls carried. The runs gather in a thread-local buffer kept for the thread's next report, so a warm report allocates nothing (wrote_but also no longer builds a Vec per range to cut out the shadows' writes: one sorted list, swept). The internal DirtyHook calls the batched forms alone; its per-run methods went. The read side needs no batching: changed and changed_except already hand back every run of a query in one call. watch stays per run: a copied host buffer watches its runs once, at its making, not per report. Docs: the trait's contract for the runs (never empty, each non-empty, in the order of the object's bytes, apart in the object, not sorted by offset over scattered pages), its Batches paragraph, HostMemory::with_dirty_pages, the runtime README and HOWTO's guest RAM log; the api_signatures table blessed (two trait items). Tests: dirty_runs checks, over a memory log and a guest RAM log of 24 scattered pages, that a command buffer's report, a write with a shadow's merge inside it, a copy's merge back of three blocks and a CPU write each reach each log in one call per range carrying exactly the runs worked out from the window, and that a log keeping only wrote/wrote_as hears every run in the same order with the same writers. The bench gains a batched trivial log. (cherry picked from commit b69d6b70c49af0b0ab08db5fe2f8b78cd61ed2fe) |
||
|
|
d3f2bf185a |
HostRam: test a run-bound buffer against copies of its pages; copies' take wording
On gate/stack27b the HostRam copies (copy_from_host_ram, copy_to_host_ram) and the run imports compose: a copy reads and writes a chunk's pages through the chunk's import, and an object over a chunk not imported yet is bound in an import of its own run, two imports of the same pages ordered only by their host bytes (host_aliases.rs). New device test a_run_bound_buffer_and_a_copy_of_its_pages_order_by_their_host_bytes: four pages over a chunk not imported are bound in their run's import, and then, both ways: - a fill through the buffer before a gather of its second page; - a scatter into that page before a copy out of the buffer. Each way runs in one blit encoder (a barrier recorded between them), in two encoders of one command buffer, and across two queues in commit order (the writer behind 2 GiB of private fills). The six copies import nothing, and the run's import stays live. On a device with RuntimeDriverDefect::AliasedImportBlitsUnordered (MoltenVK) the test asserts the fallback: no run import, the buffer imports the chunk and lies in the copies' import. Docs: copy.rs's module docs and HOWTO said a copy takes a chunk "as an object does", importing it or waiting for its import; objects no longer wait, so both now say that a copy makes no run import of its own and waits. host_ram.rs and HOWTO add the copies to what a run-bound object's uses order against, and the test module's docs add the composition. Verification is pending in this commit: M3 and RTX 5080 device runs. (cherry picked from commit be6d43fbf2c0a5921a2468038740ef3604a2da9f) |
||
|
|
c074aa490e |
Document the HostRam window's direction, the runs' imports and their fallback
docs/HOWTO.md's "One run inside one chunk" bullet now says what the branch's runtime does: the window opens in the takes' direction, up or down the RAM; an object over a chunk not imported yet is bound in an import of its own run (run_bound_buffers_made, run_imports_live) and never waits for the chunk's fault-in; the price is up to one more allocation and pin per such object; and where the object falls back to the chunk's import (thread stopped, chunk failed or given back, allocations within the margin, a whole-chunk run, or RuntimeDriverDefect::AliasedImportBlitsUnordered on MoltenVK). It adds the measured result from tests/host_ram_window_bench.rs on the RTX 5080 laptop (NVIDIA 615.71.09), at 2b2419c67c: 256 2 MiB heaps upward, downward and scattered had no making of 5 ms or more (slowest 1.4, 1.5, 3.7 ms), against 2, 8 and 15 makings importing a chunk (slowest 8.2 to 8.7 ms) without the change; 128, about 76 and 20 heaps were bound in their own runs' imports. Docs only; verified by reading the text against host_ram.rs's for_object and after_take. (cherry picked from commit 25572e5af997da7009960fa31bf94c5d478e2370) |
||
|
|
a0bebe78f1 |
runtime: copy runs of a guest RAM to and from a buffer on the GPU, from the chunk imports
`BlitCommandEncoder::copy_from_host_ram(ram, runs, destination, destination_offset)` gathers runs
of a `HostRam` the device uses into consecutive bytes of a buffer, and
`copy_to_host_ram(source, source_offset, ram, runs)` scatters them back (a runtime extension:
Metal has none). A surface that is a scatter of guest pages is copied straight from the RAM's
64 MiB chunk imports, with no view mapped per surface (one mmap per run) and no import made per
surface.
How: adjacent ascending runs merge, descending neighbours stay apart; runs are cut at chunk ends;
the 4 KiB pages become a table in the command buffer's upload arena, and each chunk the runs touch
takes one dispatch of the new `bind::pages_copy_module` (more only past the storage-buffer range
or the workgroup count). A chunk not imported yet is imported, or its pending import waited for,
as an object over it does.
Ordering: each chunk a copy uses gets a resource key placed over the chunk's host bytes in the
host-alias placements, the way no-copy buffers and heaps are placed, so the copy's chunk uses
(joined to at most 16 ranges per chunk) order against other copies and against every no-copy
object over the RAM's own addresses, in one encoder and across encoders; the buffer side is
tracked like any blit. A scatter's writes reach the RAM's dirty log as the GPU's in place, so a
copied backing over those pages takes them in at its next commit. Objects made over another
mapping of the pages (a view resolved through `with_runs`) are not ordered against the copies.
Refused with `Problem::HostRam`: an empty run, one off 4 KiB, one outside the RAM, a RAM the
device does not use, buffer bytes off a 4-byte word; no host import is `Unsupported`; bytes past
the buffer are `RangeOutOfBounds`. Replayed at rebinds (`BlitCall::HostRamCopy`). New counters
`host_ram_copies`, `host_ram_copy_bytes`, `host_ram_copy_dispatches`. README, HOWTO, the
API signature rows and docs/REFUSALS.md updated.
Verified:
- On this M3 Max (MoltenVK), --cfg m2v_gpu under nextest: the five new device tests
(`tests::host_ram_copy_device`: round trips byte for byte over ascending, descending, adjacent,
repeated and chunk-crossing runs into Shared and Private buffers; CPU writes before the commit
gathered and a scatter's bytes in the pages after completion; the two hazard cases in one
encoder and across encoders; a copied backing over the pages taking a scatter at the next
commit; the refusals) and the ten `tests::host_ram_device` tests: 15 passed.
- Negative controls, each a saved build: merging descending neighbours fails
`adjacent_ascending_runs_merge_and_descending_ones_stay_apart` and
`a_gather_and_a_scatter_move_every_runs_bytes_in_order` ("the gathered bytes"); not placing the
chunk keys over the host bytes fails
`copies_are_ordered_against_a_no_copy_buffer_over_the_same_pages` ("a later reader sees the
scatter"). The first control found the test pattern repeating every 1 KiB, so a page swap
went unseen; the pattern now differs per page.
- The `host_ram::copy` unit tests (merge, refusals, chunk cuts, the plan, the joined uses) and
`consumer_auto_traits`; clippy --workspace --all-targets --all-features -D warnings, plain and
--cfg m2v_gpu; rustdoc -D warnings; `signatures.py --check` after the bless; the refusal
surface `--check`.
- The ignored release bench `tests::host_ram_copy_bench` on the M3, a 3840x2054 BGRA8 surface
(31,549,440 bytes, 31,551,488 in whole pages) scattered over 1 GiB of shared RAM: 7703 4 KiB
runs (5490 descending neighbours, 7279 runs after the merge) take 16 dispatches, 0.35 ms of CPU in the call, 0.59 ms of GPU and 0.64 ms from commit to completion
for a gather (scatter 0.37 / 0.58 / 0.64). The view path at the host's 16 KiB page (1926 runs:
a view mapped run by run, a buffer `with_runs`, a buffer-to-buffer copy, the release) takes
1.58 ms to map, 2.36 ms to make the buffer, 0.99 ms commit to completion and 0.78 ms to
release; the gather of the same 1926 runs takes 0.14 ms CPU and 0.60 ms commit to completion.
Ported onto gate/stack27, where the device's thread imports a window of chunks ahead of the
objects (paced, with the memory lock released, short of maxMemoryAllocationCount and giving back
what no object took). The conflict was `RamOnDevice`'s fields alone: the copies' `ChunkKeys` sit
beside the window and its wake, and the old cursor is gone. The copy still takes each chunk
through `RamOnDevice::chunk(.., By::Object)`, the objects' own path, which now moves the window
past it, wakes the thread and clears the chunk's untaken mark; there is no second import path. The
copy module docs and HOWTO say so. The ignored release bench waited for every chunk imported
ahead, which the window never does; its warm-up copy now imports the chunks the runs touch.
The verification above was on the old base; this tree's is in the commit that follows.
(cherry picked from commit 923718777c198bef526dd07f701fc71a71e07b00)
(cherry picked from commit fa00224f7b29ab0359c8305a47da9c9273fc5d37)
|
||
|
|
6c4b409fb0 |
Lay a no-copy buffer over a live copied host buffer's bytes in its copy
What: a copied host buffer (the caller's gate refused the import, or an admitted import failed) now joins its memory and is placed as an import is (`HostAliases::join` with `Kind::Copy`, `HostAliases::place`). A later no-copy buffer over exactly the same first byte and length, of either storage mode, finds it (`HostAliases::import`: an import of its class, else the live copy), lies in it through `Device::buffer_in_import`, is named to it (`copied_as`) and joins its key, with the gate not asked. A rebind onto such bytes lies in the copy too where its textures were planned at the copy's offset (its first byte) and no image in place rides on it; an import keeps the old `!moved` rule. A heap's own copy is placed but joins nothing; a buffer whose writes are dropped keeps its read-only view. New counter `WorkCounts::copied_host_buffers_shared`. Why: two copies of one memory agreed only through the pages (merge back at the writer's completion, copy in at the reader's commit). reims-vgpu measured on the M3 (MoltenVK) two textures over one 64x64 BGRA8 surface, each over its own refused no-copy buffer: a blit write then a blit read in one command buffer, and a reader committed first on a second queue waiting on the writer's event, both read all 16384 bytes stale, where Metal and the runtime in place read the write. The consumer also made a full copy of the surface per texture per present. The remaining GPU-to-GPU gap, between a copy and another copy or import of overlapping but different bytes, is recorded in copied.rs, docs/API.md, docs/HOWTO.md and docs/FAST-PATHS.md's known gaps. Verified: cargo check of the runtime with tests; the lane in the next commit, run on the M3 (see its message). (cherry picked from commit 69feb791dc6ec3bc2405dbf5b6ae5d0b27d936aa) |
||
|
|
968ccc4af0 |
host_ram: import a window of chunks ahead of the objects, not the whole RAM
What:
- The thread Device::use_host_ram starts now keeps a window of chunks past the one an object
last took imported (host_ram.rs, Window): one chunk after a take outside the window (and the
RAM's first chunk before any take), AHEAD_CHUNKS = 4 once a take lands inside it. It never
imports past the window, never goes back to the RAM's start, and so faults in at most 4
chunks (256 MiB) that no object took for one take, and at most 1 for a take that starts no
run. While its window is imported it waits (Wake: a mutex and a condition variable), woken
when an object takes another chunk or the use ends, holding the device and the RAM only
weakly, as between chunks before.
- Unchanged: the pacing (SCHED_BATCH, yields, MADV_POPULATE_WRITE in 2 MiB steps), imports with
the memory lock released, the stop a quarter short of maxMemoryAllocationCount and the
give-back of untaken chunks.
- Docs: host_ram.rs, Device::use_host_ram, WorkCounts::host_ram_chunks_imported(_ahead),
docs/HOWTO.md ("One run inside one chunk"), with the numbers below and the burst caveat.
Why: reims-vgpu's time to first present on the RTX 5080 laptop went from 11-12 s to 13.9-86.1 s
with the whole-RAM ahead import, worst at low MemFree, the normal state of a Linux desktop
whose page cache fills memory. Reproduced without a VM (release probe, public API: 16 GiB of
fresh memfd RAM under MADV_HUGEPAGE through use_host_ram, an mmap+munmap sampler, CPU-bound and
bandwidth-bound workers, a toucher faulting its own THP memory, vmstat and PSI):
- The whole-RAM import took 40.4 s at 35.4 GB free with only 21 free 2 MiB blocks, and 57.4 s
at 17.1 GB free: pgmigrate 4.1-9.1 M pages, PSI memory "full" 6.6-9.6 s, another thread's
mmap up to 0.96-1.19 s, another thread's 2 MiB faults up to 0.8 s at p99 0.48 s, a CPU-bound
worker up to 51% slower at p50 and a bandwidth-bound one up to 128%.
- 99% of it is the fault-in of fresh huge pages (direct compaction and reclaim, holding the
process's memory map lock): per chunk p50 39-123 ms, worst 1.46 s. The import itself (pin and
vkAllocateMemory) of a resident chunk took 1.7-3.2 ms at p50 (0.56 s for 248 chunks).
- So the thread now faults in only what the objects are about to reach.
Measured on the same laptop (NVIDIA 615.71.09, Linux 7.2), release, one run each, MemFree
1.7-3.0 GB with 82-88 GB of page cache. Pattern: 40 2 MiB heaps at use_host_ram, then 8 bursts
of 128 consecutive heaps (4 chunks) 1 s apart, 2.08 GiB in all, with a toucher writing 1024
2 MiB pages spread over the same RAM (the guest's own faults):
ahead own imports making max (after the first 40) PSI full
adaptive (this) 36 2 26.9 ms 0.97 s
fixed 4 36 2 6.6 / 171 ms (2 runs) 0.48 / 0.97 s
fixed 1 9 26 372 / 614 ms (2 runs) 2.1 / 2.9 s
none (no thread) 0 34 544 ms 1.14 s
whole RAM (cut at 40 s) 138 2 194 ms 14.6 s
The 2 own imports are heaps 0 and 32, made as use_host_ram starts. 16 heaps over scattered
chunks, 300 ms apart: chunks faulted ahead adaptive 16, fixed 1 16, fixed 4 38, fixed 16 46;
making p50 adaptive 99 ms, fixed 1 51-60 ms, fixed 4 61-135 ms, fixed 16 160 ms, none 28 ms
(states vary run to run). A window of 8 or 16 bought nothing more for consecutive heaps and
cost more (16: PSI full 1.5 s, guest-fault p99 134 ms). A burst that runs more than 4 chunks
past the last take waits at each chunk past the window, one fault-in each (45-70 ms at p50 in
that state, at worst 0.34 s).
No DevicePolicy switch: this trades speed for speed, and no measurement favoured the whole-RAM
form.
Tests:
- host_ram::tests::a_take_inside_the_window_opens_it_and_one_outside_gives_one_chunk (the rule)
and ::the_devices_thread_imports_the_window_past_the_last_take_and_no_more (the order: the
start's one chunk, the window past a take, a held chunk passed, nothing past the window or the
RAM's end, nothing back after a jump).
- tests::host_ram_device::the_window_ahead_moves_with_the_objects_and_imports_no_more: fresh
THP RAM of 16 chunks; the first chunk alone before any take; a full window once a heap takes
it; a run of heaps over the window imports nothing on its own thread; one chunk past a jump;
a full window again once the run goes on; nothing past the RAM's end; the skipped chunk never
imported. 14 chunks ahead, 1 by an object, over 259 heap makings, on both devices.
- chunks_are_imported_ahead_so_no_making_waits_for_one and
the_ahead_thread_leaves_the_allocation_limit_to_the_objects now open the window with a heap
over the first chunk; the limit test gives back the 3 chunks no object took.
Negative controls (a temporary build with one defect switched on at a time, M3, release,
--cfg m2v_gpu); each test failed as follows:
- whole-RAM order (next_ahead wrapping as before): the order unit test ("none past the start's
one chunk", Some(1)); the window device test ("the device's thread went on past the window",
16 chunks).
- a fixed window of 4 for every take: the rule unit test (Window { from: 10, chunks: 4 } after a
jump); the window device test (13 chunks ahead after the jump).
- the window one slot off: the window device test ("no chunk past it", 6 live).
- no wake when an object takes another chunk: the window device test ("a full window past the
take", 1).
- no thread: chunks_are_imported_ahead_so_no_making_waits_for_one ("the device's thread
imported the RAM's first chunk", 0).
- no give-back: the_ahead_thread_leaves_the_allocation_limit_to_the_objects ("the untaken
chunks went back", 0).
- with no switch, the same binary passes the window device test.
Verified:
- RTX 5080 laptop, release, --cfg m2v_gpu: the host_ram and allocations tests, 30 passed,
0 failed.
- M3 Max (MoltenVK 1.4.2, macOS 27.0.1), release, --cfg m2v_gpu, under maclock: 28 passed,
0 failed (the two dma-buf tests are Linux-only).
- cargo clippy --workspace --all-targets --all-features -D warnings, plain and with
--cfg m2v_gpu; cargo doc -p metal2vulkan-runtime with -D warnings.
(cherry picked from commit 6d72e50ebb7d52e195fea5062bfed989af2877d4)
|
||
|
|
cf7eae4420 |
Hold each device to maxMemoryAllocationCount; the ahead import stops short of it and gives back
What: - allocations.rs (new) counts each device's live VkDeviceMemory allocations, by its handle, at the runtime's two doors: - creation::allocate_memory, where every allocation goes; - release::object for vkFreeMemory, where every free goes. tests/exit_guard.rs already holds every allocation and free to those doors. So the count covers pooled and dedicated blocks, every host-pointer import (no-copy objects' own, guest RAM chunks, fresh pages) and every dma-buf import, with no caller passing it. A device is registered once its priming, which frees all it allocates, is done. Its registration goes with it. - At the limit, creation::allocate_memory refuses with ERROR_TOO_MANY_OBJECTS and does not call the driver. The refusal is counted in WorkCounts::memory_allocations_refused_at_limit. Callers handle it as they handle the driver's own refusal (memory.rs frees kept empty blocks and tries again). - The ahead-import thread stops where one more import would leave the device fewer than a quarter of its limit (Allocations::room_ahead). The remaining chunks are left to the objects over them, imported on demand as before. - Once an allocation leaves the device fewer than that quarter, a thread is spawned (Device::give_back_ahead_near_the_limit). It runs with no lock of the allocating caller held, and frees every chunk the ahead thread imported that no object took and only its slot holds. Counted in WorkCounts::host_ram_chunks_given_back. An object over such a chunk later imports it as it is made. - Scope: the ahead thread is started only in Device::use_host_ram (host_ram.rs, the one exit_guard::spawn of import_ahead). That call refuses a device without VK_EXT_external_memory_host, and its chunks are host-pointer imports (import_chunk -> memory::import_host). A no-copy object's own imports, by pointer or of the caller's dma-bufs (dma_buf.rs), never touch the RAM source and never start the thread. So RADV's per-object dma-buf imports are unchanged and never put all of RAM in GTT. That holds as long as the consumer calls use_host_ram only on devices that refuse dma-buf views, which reims-vgpu does: its os/linux/host_ram.rs hands the RAM only to devices that need imported pages mapped from their files. Why: - VUID-vkAllocateMemory-maxMemoryAllocationCount-04101: "There must be less than VkPhysicalDeviceLimits::maxMemoryAllocationCount device memory allocations currently allocated on the device". Nothing counted allocations before. - Importing ahead makes one allocation per 64 MiB of guest RAM whether or not an object ever uses the chunk. So the thread must leave the limit to the objects and never be the reason an allocation is refused. - The spec's minimum limit is 4096, so the margin is at least 1024 allocations. - The give-back runs on its own thread because the door may be called under the device's memory lock, which a chunk's free takes. A free of device-address memory can also wait for batches in flight (freed_memory.rs). Limits: - RTX 5080 laptop (NVIDIA 615.71.09): maxMemoryAllocationCount 4294967295, read by the device test. - M3 Max (MoltenVK 1.4.2, macOS 27.0.1): 1073741824, read by the same test. - At those limits, the margin and the refusal never come into play in practice. They hold for a device with a small limit. Verified on the RTX 5080 laptop, release, --cfg m2v_gpu: all 25 host_ram and allocations tests pass. Among them, the new device test the_ahead_thread_leaves_the_allocation_limit_to_the_objects: - It holds the device to a small limit (Allocations::limit_to, test-only). With 0 live, the limit is 5 and the margin 1. - The thread imports 4 chunks of a 12-chunk fresh RAM and stops. - An object over the 5th chunk imports it on demand. That allocation brings the device within the margin, and the 4 untaken chunks are given back (host_ram_chunks_given_back 4, host_ram_chunks_live +1). - Buffers of blocks of their own are then made until the device holds its limit. The next is refused at the door (Vulkan(VkResultCode(-10)), memory_allocations_refused_at_limit +1), with none of the thread's chunks live. On the M3 Max, release, --cfg m2v_gpu, the same test passes, the same way: limit 5, 4 chunks ahead, given back, then 2 buffers made and the next refused at the door. The runtime's whole host-side suite passes (1218 tests). The unit tests allocations::tests cover the refusal and room, the margin and the single give-back, and a registration's life. Not verified: a real device with a small limit (none of ours has one). The case where more than a quarter of the limit's allocations land before the give-back thread frees the chunks. That case is a race, bounded by the margin. (cherry picked from commit 15543aa261afa12b13bcda954fc5cb51063a6b0f) (cherry picked from commit 3766b1338e9b92367712cc4e9cf8f9a19dbe85e8) |
||
|
|
f739bea1eb |
host_ram: pace the ahead import, and import host pointers with the memory lock released
What:
- The thread that imports a used RAM's chunks ahead now runs as the system's batch work:
SCHED_BATCH on Linux, with its nice value kept, and the utility QoS class on Apple's systems.
- It yields between chunks.
- On Linux, before each chunk's import, it faults the chunk's pages in 2 MiB at a time with
MADV_POPULATE_WRITE, yielding between steps. That changes no byte. A kernel that refuses
the advice leaves the faults to the import, as before.
- memory::import_host (it was Memory::import_host) makes the vkAllocateMemory import with
the device's memory lock released, as import_own_pages and new blocks already do. It
re-locks only to record the block. Its callers are the chunk import (host_ram.rs) and a
no-copy object's own import (buffer_descriptor.rs).
- No CPU pinning, and no kernel, boot or module parameter.
Why: a reviewer accepted pinning all of guest RAM ahead on condition that the thread does
not stall the host while a VM starts.
- The pin of a 64 MiB chunk holds the VMM process's mmap lock while it faults in fresh pages.
Every mmap, munmap, and every page fault queued behind one, waits on that lock.
- The chunk import used to run under the device's memory lock, so every other placement on
the device waited for it too.
- A low-weight thread that holds those locks is worse, not better. On the RTX 5080 laptop
(24 threads, kernel 7.2), a thread faulting in 64 MiB pieces of a fresh THP memfd ran
against 24 or 48 spinning threads at nice 0. Another thread's mmap+munmap waited:
policy 24 busy: p99 / max 48 busy: p99 / max chunks faulted in 6 s
default 0.23 / 12.4 ms 3.6 / 26.9 ms 883 / 276
SCHED_BATCH 1.4 / 12.4 ms 11.2 / 13.9 ms 850 / 581
nice 19 131 / 511 ms 164 / 1012 ms 4 / 2
SCHED_IDLE 0.004 / 1039 ms 0.005 / 1419 ms 1 / 1
So the thread keeps the default weight (SCHED_BATCH only marks it as batch work) and paces
itself by yielding and by faulting in small steps.
Measured on the same laptop, release build, 16 GiB of fresh THP memfd RAM imported ahead
whole. "Unpaced" is the parent commit (df5beeecaa, in stack19 as 97a69f70ab). A sampler
thread timed mmap+munmap of one page every millisecond:
run time mmap p99 / max >10 ms compact_stall / fail / allocstall_normal
unpaced, idle, first run of a hold 5088 ms 57.8 / 98.8 ms 76 2411 / 183 / 67
paced, idle, right after it 8374 ms 7.5 / 45.9 ms 32 930 / 209 / 0
unpaced, idle, calm memory (x3) 1515-1824 ms 5.2-6.4 / 6.7-6.8 0 none
paced, idle, calm memory (x3) 1552-1600 ms 4.9-5.0 / 5.3-6.6 0 none
unpaced, 24 threads busy (x3) 2212-5649 ms 9.7-19.2 / 12.3-24.9 7-238 none
paced, 24 threads busy (x3) 3720-6693 ms 0.27-1.6 / 1.9-7.7 0 none
- The earlier unpaced measurement (batch at df5beeecaa) was 3.47 s, with compact_stall 1152
and allocstall_normal 54.
- Compaction follows the host's memory state, not the pace. Only the first run of each hold
met page cache to reclaim and fragmented free memory, and the hold that had it ran unpaced
first. So the compaction rows are not a like-for-like comparison.
- The pace costs time only when the CPUs are busy, where the thread now shares them. In
return, the process's other threads wait at most a few ms for the memory map lock.
- In calm memory, the remaining ~5 ms p99 is the import's pin of 64 MiB of resident pages.
Verified at the tip of this branch (this commit and the next), on the RTX 5080 laptop with
--cfg m2v_gpu, release: the host_ram device tests pass, including
chunks_are_imported_ahead_so_no_making_waits_for_one (4 chunks ahead in 31.6 ms, the slowest
of 40 heap makings 52 us). Clippy is clean with all targets and features, plain and with
--cfg m2v_gpu.
(cherry picked from commit aff66f6a5dc424d97854c0908dee022475e8dc01)
(cherry picked from commit 9bbe4518ceff598e5fa0172d5624f6af7a75b6a2)
|
||
|
|
9b60da4bee |
host_ram: import a used RAM's chunks ahead, on a thread of the device's
What: Device::use_host_ram now starts a thread ("m2v-host-ram", through exit_guard::spawn)
that imports the RAM's 64 MiB chunks one after another, ahead of the objects over them. It
goes on from the chunk past the one an object last took, then from the RAM's start. It
skips a chunk whose lock is held (an object is importing it) and one it failed to import
(left to the first object over it, as before). It stops once every chunk is imported, the
use ends, the device goes or is lost, or the process exits (each import inside an
exit_guard section). It holds the device and the RAM weakly between chunks. An object over
a chunk the thread has not reached imports it on its own thread, as before. One over the
chunk being imported waits for that one import. New counter:
WorkCounts::host_ram_chunks_imported_ahead.
Why: a consumer makes 2 MiB heaps over consecutive fresh guest RAM (memfd). Each 32nd heap
was the first object over a chunk. Its making waited for the chunk's import, which faults
in and pins 64 MiB of fresh pages. That took ~7.5 ms exclusive on the RTX 5080 laptop, and
0.4-4.0 s in a shared boot with compaction (compact_stall +10,889). Keeping chunks imported
for the RAM's life already held at the start of this branch (a chunk stays in its slot
while the use lasts). Measured here: a heap made again after every heap was dropped
imported 0 chunks.
The trade-off: the whole RAM is resident and pinned from soon after use_host_ram, not only
the chunks objects touch. 16 GiB of fresh THP memfd RAM took 3.47 s on the thread, with
compact_stall 1152, compact_fail 56, pgmigrate_success 935291 and allocstall_normal 54,
all off the making threads. No kernel, boot or module parameter is needed. Recorded in
docs/HOWTO.md ("One run inside one chunk").
Vulkan rules relied on (checked against the 1.4.366 spec): the import itself is
Device::import_chunk, unchanged, under VUID-VkImportMemoryHostPointerInfoEXT-pHostPointer-01749
"pHostPointer must be a pointer aligned to an integer multiple of
VkPhysicalDeviceExternalMemoryHostPropertiesEXT::minImportedHostPointerAlignment",
VUID-VkImportMemoryHostPointerInfoEXT-handleType-01750 "pHostPointer must be a pointer to
allocationSize number of bytes of host memory", VUID-VkMemoryAllocateInfo-allocationSize-01745
"allocationSize must be an integer multiple of ...minImportedHostPointerAlignment", and
VUID-VkMemoryAllocateInfo-memoryTypeIndex-01744 "the value of memoryTypeIndex must be one of
those returned by vkGetMemoryHostPointerPropertiesEXT". The spec's "Externally Synchronized
Parameters" list names no parameter of vkAllocateMemory, so the thread's imports may run
while other threads use the device. Each chunk's import is made once, under the chunk's own
lock. A chunk is freed only on the existing path (vkFreeMemory's memory parameter is
externally synchronized: one owner frees it).
Verified on the RTX 5080 laptop (NVIDIA 615.71.09), release, --cfg m2v_gpu:
- All 21 host_ram tests pass, among them the new device test
chunks_are_imported_ahead_so_no_making_waits_for_one. It covers 4 chunks of fresh memfd
RAM under MADV_HUGEPAGE, imported ahead in 32.5 ms. Then 40 heaps of 2 MiB over
consecutive runs: 0 chunk imports, 0 host-pointer imports and 40 chunk-bound buffers
during the makings, the slowest making 78 us. Heap 33 passes a CPU write -> GPU read ->
GPU write -> CPU read round trip. A heap made again after all were dropped imports
nothing. The other device tests hold the thread back (Device::hold_host_ram_imports,
test-only), so they still see each chunk imported by its first object.
- Negative control: with the spawn disabled, the new test fails ("the device's thread
imported 0 of 4 chunks").
- On the M3 Max (MoltenVK, macOS 27.0.1), release, --cfg m2v_gpu: all 19 host_ram tests
pass (the two dma-buf tests are Linux-only). In the new test, 4 chunks were imported ahead
in 7.2 ms; across the 40 makings the slowest took 35 us.
- Unit test the_devices_thread_goes_on_past_the_chunk_an_object_took_then_from_the_start
covers the order, the skip of a held or failed chunk, and the end.
Heap makings, 128 heaps of 2 MiB over fresh THP memfd RAM (wall time per
new_heap_with_bytes_no_copy):
case p50 p90 max makings > 5 ms
before, 1 GiB RAM 0.001 ms 0.002 ms 7.39 ms heaps 0, 32, 64, 96
after, made at once 0.001 ms 0.003 ms 7.54 ms heaps 0, 32, 64, 96
after, made once the thread is done (122 ms) 0.001 ms 0.002 ms 0.05 ms none
before, 16 GiB RAM 0.001 ms 0.002 ms 7.54 ms heaps 0, 32, 64, 96
after, 16 GiB, made once done (3468 ms) 0.001 ms 0.002 ms 0.03 ms none
Made at once, the makings outran the thread: 5 chunks were imported during them, 4 of
them by the thread. Once the thread is done, no making waits for an import.
(cherry picked from commit 7baa553a75515909f2ce9701c1e1bea4c408845a)
(cherry picked from commit 97a69f70ab96d37dcdf269192a6935f8c4126749)
|
||
|
|
d07650b362 |
Warm passes: judge the byte budget on every device, and say what pipeline_bytes counts
What: tests::warm::a_byte_budget_stops_the_pass no longer skips its 1-byte leg when the pass counted no driver bytes. That leg runs over a directory of its own, which holds none of the records' driver data, so it now asserts that the pass wrote records' data (driver_saves > 0), counted it (pipeline_bytes > 0), and stopped after the first record, on every device. A new test, a_pass_over_its_records_own_directory_counts_only_what_it_writes, warms records over the directory whose creations made them and asserts that the pass counts driver bytes exactly where its makings wrote data. Where it wrote none, it asserts that a 1-byte budget stopped nothing. WarmStatistics::pipeline_bytes, Device::warm, the runtime README and docs/HOWTO.md now say that a making whose data the directory holds already adds nothing. Over that directory the budget binds only where a making writes new data. Why: the consumer read pipeline_bytes 0 on every boot of the RTX 5080, though the warm pass made 248 pipelines, and asked whether the counter is broken there (a making's keep on a thread without the pass, or a path that never keeps). Measured with a scratch diagnostic at 1bb0b87a5a, not committed: - RTX 5080, a fresh directory: 23,800 bytes counted, 3 records' data written. - The 5080 over the records' own directory: 0 bytes, 0 written, 2 unchanged, 2 found. - M3 Max on MoltenVK 1.4.2: 13,362 bytes and 3 found respectively. So keep() runs on the pass's thread and counts on NVIDIA too, and the consumer's 0 is the true value. Their records come from the boot before, over the same directory, whose creations wrote every making's data. The old test's skip branch could have hidden a broken counter; now a pass that writes data and counts none fails. Verified: tests::warm on the M3 (MoltenVK 1.4.2), 6 passed. The 1-byte pass over a fresh directory counted 8,003 bytes with 1 record's data written; the pass over its own directory counted 0 bytes, wrote 0 and found 3. cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings with --cfg m2v_gpu; public rustdoc clean. The RTX 5080 run is in the hand-over. (cherry picked from commit 83cc2dbe6fb610c6ad59a741a7170812611cf703) (cherry picked from commit 1d43003372f23275ceb7fcc463a34abedbeff9a7) |
||
|
|
763965c854 |
Record a texture write's NaN encoding only where its stored NaN is not measured to be Metal's
reims-vgpu treats precision notes as fatal on Apple GPUs. A kernel's write of halves into a
32-bit float or RG11B10Float texture died with DeviceNanEncoding, and through NativeNanEncoding,
on the M3 Max where the stored bytes are Metal's; a write of a constant texel with no NaN died
the same way on every device.
What:
- A new DriverDeviation::MetalSmallFloatNans (VkProperty::MetalSmallFloatNans), taken by the
APPLE9 MoltenVK row alone: the device stores a float's or a half's NaN written to a
B10G11R11_UFLOAT_PACK32 storage image as Metal does.
- half_write_nans (a half texel's write) classifies the slot's storage choice: a 16-bit float
format takes MetalHalfTexelWrites as before, a 32-bit float one MetalNanMoves (the widened
half's bits are Metal's 0x7fc00000), the packed small float one MetalSmallFloatNans; a taken
deviation drops the note and requires its property. A slot declared without a format (every
float storage choice on MoltenVK and lavapipe) records the note under the bound format's class
(a SpecializedNote of BoundTexelFormat), one clause per class the profile does not cover, so
the runtime announces it only when such a texture is bound.
- half_storage_facts (a float texel's write) drops the small-float note the same way.
- A texture write of a constant texel none of whose lanes is a NaN records neither note.
- A new module side table, stored_texels, records each texture-family write's texel (kept
through edit.rs's retain and the roll pass's check). narrow::moves_unfolded no longer counts a
widened half's store as such a texel as an escape: the write's own DeviceNanEncoding accounts
for its stored NaN under the format it stores.
Verified on this M3 Max, byte for byte against plain Metal (an MSL probe): a float4 write of
33,792 words (16,446 NaNs) and a half4 write of all 65,536 halves (2,046 NaNs) into RG11B10Float,
RGBA32Float, RG32Float and R32Float store Metal's bytes; into R16Float and RGBA16Float a half
NaN's payload differs (the device stores 0x7e00), so those keep the note.
- runtime_lane::half_write_nans on MoltenVK: half writes into rgba32f, r32f and rg11b10f announce
nothing and 0 texels differ; rgba16f announces device-nan-encoding (2,045 NaNs differ). Without
note_stored_texel the lane fails ("write r32f: ... native-nan-encoding true").
- New core tests: a_half_texel_write_s_nan_into_wide_and_small_float_images_is_metal_s_where_
measured (declared and formatless choices on moltenvk-m3 with and without each deviation, and
lavapipe; the bound-class clauses evaluated per format) and a_constant_texel_without_a_nan_
records_no_nan_encoding (zero and 0x7e00 constants, every committed profile); the existing
device-nan-encoding and half-storage-notes tests follow the deviations. Each fails with its
change disabled (the NaN test forced true; the stored-texel exemption removed).
- Notes of every public fixture on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and
after: DeviceNanEncoding leaves 65 moltenvk-m3 rows and 6 rows on each other profile (constant
texels), 17 formatless rows per profile go from unconditional to specialized by bound format,
58 moltenvk-m3 rows lose their small-float clause, NativeNanEncoding leaves 11 moltenvk-m3 rows,
and no row gains a note. Consumer AIR on moltenvk-m3: DeviceNanEncoding 33 entries to 21,
NativeNanEncoding 9 to 5.
Docs: API.md (device-nan-encoding and native-nan-encoding exemptions), HOWTO.md, the
PrecisionNote, VkProperty and deviation rustdoc, the driver-facts measurement record.
api_signatures gains the two variants. The versions bumped in the previous commit cover this one.
(cherry picked from commit 05d96c61107989813c186961087ee70d573cf876)
|
||
|
|
217cc233f5 |
Carve MoltenVK on the M3 Max's identity out of NativeHalfConversion for measured conversions
reims-vgpu treats precision notes as fatal on Apple GPUs; NativeHalfConversion was its largest group of Mac-only failures (37 tests). The note says a half rounded through the device's conversion to 16 bits and back may differ from Metal's. On the M3 Max (MoltenVK 1.4.2, macOS 27.0.1), MoltenVK writes OpFConvert to 16 bits as MSL half(x), which is Metal's half(float), and Metal's compiler folds the conversion of an image instruction's float texel into the access. What: a new DriverDeviation::MetalHalfConversion (VkProperty::MetalHalfConversion), taken by the APPLE9 MoltenVK row alone. Where the profile takes it: - narrow::round_measured rounds a float the function holds (an AIR fptrunc or air.convert from float, through resize) by the conversion pair and records the pair's narrowing in a new module side table, measured_roundings (kept through edit.rs's retain and the roll pass's check); - narrow::rounds_unmeasured finds any other conversion pair: one neither recorded nor of a texel an image read, fetch, sample or gather hands back (directly, through a composite extract, or through a parameter every call passes such a texel); - the compile records NativeHalfConversion only where such an unmeasured pair exists, and otherwise requires the property. A half operation or function computed in float and rounded keeps the note: Metal's half tanh answers 7 of the 65,536 halves otherwise than the conversion of its float tanh. exp, sqrt and a reciprocal on half matched, but they are functions, not the conversion, so they stay noted. Verified on this M3 Max, word for word against plain Metal (an MSL probe, fast and safe math): - the conversion of a float loaded (425,216 words), of a sum, product and quotient (144,896 pairs each), of an fma (123,648) and of an integer's quotient (190,208): 0 words differ; - the half result of read, nearest sample at the centre, linear sample a quarter texel off and gather of every texel of ten formats (RGBA32Float, RGBA16Float, RGBA8Unorm and its sRGB twin, RGBA8Snorm, RGBA16Unorm, RGBA16Snorm, RGB10A2Unorm, RG11B10Float, RGB9E5Float): 0 differ. - New lane runtime_lane::half_conversions on MoltenVK: load, sum, product and fma kernels carry no note and 0 of 253,958 lanes per kernel differ from the half model; the half tanh kernel keeps the note. With measured_conversion forced false the lane fails. - New core test half_conversions_are_metals_where_measured: the four forms lose the note and require the property on moltenvk-m3 with the deviation, keep it without the deviation, and the half tanh keeps it on both; it fails with the carve disabled. - Notes of every public fixture on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and after: NativeHalfConversion leaves 58 moltenvk-m3 rows, and no row gains a note. Consumer AIR on moltenvk-m3: 23 entries noted before, 2 after (a heap texture's held half read). Docs: API.md (native-half-conversion exemption), HOWTO.md, the PrecisionNote, VkProperty and deviation rustdoc, the driver-facts measurement record. SEMANTICS_VERSION 1949 and ARTIFACT_FORMAT_VERSION 484 (new VkProperty variants in the codec); these bumps cover the rest of this branch. api_signatures gains the two variants. (cherry picked from commit 266f7cd26327e408d9cd1f0d6ea5ba33e49e10b3) |
||
|
|
3e28f68331 |
Carve MoltenVK on the M3 Max's identity out of NativeNanEncoding for NaN moves
reims-vgpu treats precision notes as fatal on Apple GPUs; NativeNanEncoding was its largest group of Mac-only failures. Measured on the M3 Max (MoltenVK 1.4.2, macOS 27.0.1), the device's widening of a half to float, its narrowing back, and float fneg/fabs and half fabs answer Metal's NaN bits, so the note was recorded where nothing differs. What: a new DriverDeviation::MetalNanMoves (VkProperty::MetalNanMoves), taken by the APPLE9 MoltenVK row alone. Where taken: - a float fneg or fabs records no NativeNanEncoding and the module requires the property (SPIRV-Cross writes -x and abs(x), Metal's own operators on the same operand); - a half's widening to float (fpext, air.convert) and a half fabs, and a module's reads and encodes of a half's bits, record no note and require the property, but only where the module moves its halves through the registers as measured. narrow::moves_unfolded keeps the note where a widened half is stored anywhere but a buffer, workgroup memory or a function's float variable, passes through a call, return, group, atomic or image operation, has its bits read (a bitcast that is not stored, frexp/modf/ldexp: the frexp routines stay noted), or where the module holds a float NaN constant other than 0x7fc00000. - A half fneg stays noted on every profile: the measured shapes matched only because the driver's compiler moved the negation onto the half. By construction: MoltenVK's MSL writes float(as_type<half>(x)) and half(f); Metal's compiler folds half(float(h)) across selects, phis and a function's local float variable, so moved halves keep their bits as Metal's do. Verified (all runs on this M3 Max): - Plain Metal running the lane's own AIR (8 kernels; every one of the 65,536 half patterns, 98,368 float words including 65,536 structured NaNs) matches the lane's model in every word. - runtime_lane::nan_moves on MoltenVK: the note is absent from every kernel but the half fneg, and 0 lanes differ from Metal in all 8 kernels. - Earlier MSL probe, fast and precise math: the same equalities over 262,144 float words. - New core tests: half_moves_are_metals_only_where_the_device_folds_them (a payload NaN constant keeps the note), the frexp negative control in engine_metal_routines, float_sign_operations and the class C/D NaN tests with a moves argument, and the driver-facts lists. - Core nextest (metal2vulkan, air, runtime, devtools, --all-features): 4,989 passed. Docs: API.md (native-nan-encoding exemption), HOWTO.md, the PrecisionNote and deviation rustdoc. SEMANTICS_VERSION 1946, ARTIFACT_FORMAT_VERSION 483 (a new VkProperty in the codec); these bumps cover the rest of this branch. api_signatures blessed (two variants); the moltenvk-m3 profile's golden hash re-blessed. (cherry picked from commit 93ae66b6ddb46b4d0d3db1944a4b043c40911592) (Note on the development copy: this message names SEMANTICS_VERSION 1946; the commit sets 1948, after a rebase.) |
||
|
|
8d75695ead |
Answer per buffer whether a no-copy buffer's bytes are imported in place or copied
A no-copy buffer whose import the caller's gate refuses, or whose admitted import fails, is made over a copy of its pages (copied.rs), announced once per device. A consumer that probes whether an import worked could only read a WorkCounts::copied_host_buffers_made delta, which races with buffers other threads make on the same device. A per-buffer answer cannot. What: - Buffer::host_backing(&self) -> Option<HostBacking>, a runtime extension (Metal has none: a no-copy buffer's bytes are always the caller's pages there). HostBacking is #[non_exhaustive]: ImportedByPointer, ImportedAsDmaBuf, InHostRam (bound in a guest RAM's chunk), Copied (the copied-host-pages degradation) and Detached. None for a buffer over no host memory of the caller's; a buffer placed in a no-copy heap answers its heap's. The answer is where the bytes lie now, so it changes only at a rebind (which may move between an import and a copy) or a detach. It reads the import's shape and its copy registration alone: no page read, no import exposed (unlike gpu_address). - buffer::Shape records whether the bytes are bound in a RAM chunk (Placement::over_ram_chunk, a 6-line accessor in memory.rs), so the answer needs no read of the import's objects. - Buffer::copied (crate-internal) now reads host_backing, so the runtime's own decisions and the public answer cannot disagree. - Docs: the runtime README's runtime extensions, HOWTO's copied host buffers section, the copied-host-pages declaration and its docs/API.md catalogue entry name the query. api_signatures.tsv re-blessed: 7 records added, none changed or removed. The metal2vulkan api_surface table does not cover the runtime, so it is unchanged. RUNTIME_VERSION unchanged: a pure query, nothing the runtime does with an artifact moved. Verified on this M3 Max (MoltenVK 1.4.2, macOS 27.0.1), --cfg m2v_gpu, under memcap and maclock: - copied_device: host_backing_answers_what_the_gpu_uses_for_a_buffer_s_bytes (own buffer and own heap's buffer None; pointer import ImportedByPointer; gate-refused Copied; a no-copy heap's buffer its heap's, then Copied after the heap's gate-refused rebind; Detached after a detach; ImportedByPointer after rebinding) and host_backing_follows_a_rebind_between_an_import_and_a_copy (import, gate-refused copy, import, failed-import copy, each read back on the GPU); every copied test's lies_in_a_copy asserts Copied; host_ram_device asserts InHostRam for chunk-bound buffers and rebinds, and Copied for a refused rebind onto two runs. - The host-memory filter (copied|rebind|host_import|in_place|heap|detach|host_ram|host_aliases| host_residency|stand_in|host_backing): 148 passed, 0 failed, no device skipped. - Negative controls: forcing Copied and InHostRam to answer ImportedByPointer (the internal copied kept right) failed 10 tests; forcing Detached to answer None failed the new test. - clippy -D warnings plain and --cfg m2v_gpu; rustdoc -D warnings for the runtime; the api_signatures, api_surface and degradation catalogue tests; refusal surface and Metal coverage checks current. Not run: ImportedAsDmaBuf on a device (the dma-buf import is a Linux path; nothing here ran it). One work packet, landed as 2 commits on archive/development-linear-2026-10-29: 31b81906af, then 27ba200e86 (the re-pin). |
||
|
|
6e88d181dd |
Record each pipeline state creation, and warm a device from an earlier process's records
DeviceOptions::pipeline_records (and RawDevice::pipeline_records) hands a
hook an opaque PipelineRecord once per pipeline state creation that made its
state. That covers compute, render, mesh and tile states, the
additional-binary-functions forms, and a render state's draw-time twins (the
one-sample and factor-scaling ones). A failed creation and a binary
archive's add make none. A record holds the descriptor field by field
("M2VPREC\0", RECORD_FORMAT 1, the library table by content hash, SHA-256),
read back and compared at its making. Its libraries are kept once in the
shader cache's content directory. to_bytes and from_bytes carry it between
processes.
Device::warm(records, byte_budget) stands in for Metal's own pipeline caches
across processes:
- One background thread per device (utility QoS on macOS, Urgency::Warm in
the making budget) runs each record's creation under the default options
and drops the state. Translations, creation records and driver
pipeline-cache data are then in place before the program asks.
- The guest sees nothing of it: no identifier, resource ID, sampler number,
neutral, room, stand-in copy, kept-variant traffic, live-variant sharing,
announcement or record.
- It stops at byte_budget of added driver data.
- An unread record is counted, and the device's first is announced as the
warning metal2vulkan-warm-record-unread; nothing fails.
- WarmStatistics and Device::warm_statistics report the pass.
Ports dev-perf 14df1fb5fe and 66fe0ada29 without per-entry stamps.
Development's build directory names the translator, and its creation records
name RUNTIME_VERSION, so no entry of another translator or runtime version
is ever found, and dev-perf's re-translate-and-compare check has nothing to
do. Adapted:
- the memo is asked but never hands a warm thread a live variant the
program holds;
- a warm thread's waits rank Urgency::Warm, not Program (making.rs), and the
pipewait creation bound still applies on warm threads;
- unread records are announced.
DeviceOptions' and RawDevice's Debug are hand-written. PipelineRecord is
among the consumer auto-trait checks. api_signatures re-blessed; runtime
README and HOWTO updated. RUNTIME_VERSION 1707.
Verified on the M3 Max (MoltenVK 1.4.2), on development 2e2e238346:
- 140 device tests and 500 plain tests pass.
- Five sabotages each fail their guard: an archive add making a record; a
pass answering Warmed without creating; no unread announcement; a warm
state taking an identifier; a warm thread taking a live variant.
- clippy plain and --cfg m2v_gpu, and rustdoc -D warnings, clean.
- Release, 5 runs of the cross-process test, three creations (render,
compute, indirect compute):
- after a warm pass: 3.11-3.42 ms, with 0 stages decoded, 0 translated, 0
directory lookups and 0 driver caches loaded;
- unwarmed over the same directory: 4.19-4.32 ms (6 lookups, 2 loads);
- cold: 4.98-5.10 ms.
Small shaders, and Metal's own cross-process compiler cache serves all
three legs.
Lane commits: ws/warmrec-lane (8d106f29ab hook, 30de4fc948 warm).
One work packet, landed as 2 commits on archive/development-linear-2026-10-29: 8c709f27a7, then e2f0f2a3d9 (the re-pin).
|
||
|
|
3fd1f6672b |
Cut copied host buffers' CPU sync: page-at-a-time compare, log-gated copy in, merge only what may be written
The consumer's 4K boot on the RTX 5080 at the stock vm.max_map_count was unusable past its import gate: about 680 MiB of live copies (2,934 made) were compared whole at every commit and every completion, costing about half a core on both sides. Until the GPU copy is wired, three exact cuts, plus the dirty-log reports change 1 needs (the consumer's audit, A to C). - Change 3, a page-at-a-time compare (copied.rs sync): each 4 KiB page is compared whole (slice equality, vectorized), and the byte-exact merge runs only inside a page that differs. Same bytes as before; unit-tested against the old routine on random data, both sides changed included. - A, the copies' merge-back is reported: each copy keeps its pages' DirtySource and a writer id. sync collects the runs it wrote, and merge_back reports them with wrote_as before the completion is visible. Bytes a read-only copy drops are not reported. - B, the runtime's own CPU writes into logged pages are reported: replaceRegion into a heap's shadow texture (texture/heap.rs), the argument encoder and copyParameterDataToBuffer, as buffer_texture.rs already did. - C, GPU writes into logged pages imported in place are reported: each command buffer's written uses over memory with a dirty source, as writer 0 (the consumer's own writes, which every copy counts). They are reported at commit, before signals in the completion turn, and at completion, minus the shadows' own copy-backs. Collection is on while copies or such imports are live. Past the use cap, each written import is reported whole. A texture's use is reported as its whole buffer or heap (correct, coarse). This also closes the texture-shadow gap for pages reached through two imports. - Change 1, the log gates the copy in: where a copy's pages have a log (HostRam::with_dirty_pages, or the object's HostMemory::with_dirty_pages), a commit compares only the pages the log reports written since the copy last agreed. It uses one stamp per log and commit for every copy, waited for as the shadows' gated copy-in waits (DirtyPages::wait). A false wait, a copy's first copy in, bytes no log covers, and a copy that merged back 1 MiB or more since its last copy in compare everything. The copy in now runs before the commit's second state-lock block, since it may wait up to the log's bound. - Change 2, merge-back skips copies no finished batch may have written. Its "may write" is the bindings' write answers plus unnamed reach: a command buffer with a function that reads addresses (a root table), or one that executes an indirect command buffer, counts every copy as written. WorkCounts (new): copied_copy_in_bytes_skipped, copied_merges_compared, copied_merges_skipped. RUNTIME_VERSION 1705. Docs: copied.rs (Cost, Coherence), dirty_pages.rs' trait doc (what the runtime reports), FAST-PATHS (copied-host-pages known gap; the shadow gap closed), HOWTO copied host buffers. Measured, release, 680 MiB of live copies (2,049), median of 7, copy in / merge back in ms: - RTX 5080 laptop host (Core Ultra 9 275HX): - nothing changed: 231.8 / 231.6 before; 0.16 / 0.00 with all three; - 1% of pages changed: 233.7 / 233.8 before; 3.43 / 33.0; - one copy redrawn: 254.6 / 261.6 before; 29.4 / 34.1. - M3 Max: - nothing changed: 314.5 / 314.0 before; 0.12 / 0.00; - 1% of pages changed: 321.4 / 321.4 before; 4.54 / 18.5; - one copy redrawn: 353.9 / 395.4 before; 39.4 / 54.9. The merge-back figures are with the batch naming what it writes. A real frame's skip rate was not measured; the new counters show it. Verified: - M3 Max, MoltenVK 1.4.2, --cfg m2v_gpu, under memcap and maclock: the runtime lib suite passes 1445, 2 skipped. - RTX 5080 Laptop, NVIDIA 615.71.09, one 42 s hold: copied|dirty_pages| host_ram|event 101 pass. - New tests: 6 plain gating and merge-skip tests; a contract test that a concurrent CPU write survives both ways, log on and off; 7 device tests of the B and C reports, the gated copy, a read-only batch skipped, and an unnamed write still merged back. - Negative controls, each shown failing then passing once restored: gate forced off; A's report removed; C's registration or completion reports removed; the shadows' copy-backs not subtracted; B's heap report removed; merge skip forced off; unnamed reach ignored. - clippy plain and --cfg m2v_gpu (Mac, and msi niced), rustdoc -D warnings, api_signatures, api_surface, fast_paths. Lane commits: ws/cpusync-lane (180fc103c1 .. 59d82299ad, 9 commits). One work packet, landed as 2 commits on archive/development-linear-2026-10-29: bb00ae47f6, then 2b8ad3ab58 (the re-pin). |
||
|
|
97116bb420 |
Keep pages the kernel cannot pin from NVIDIA's driver, and copy them as a failed import is copied
On NVIDIA's driver (615.71.09, RTX 5080 Laptop), a failed host-pointer
import of pages the kernel cannot pin breaks the process's later
host-visible allocations. The consumer's device-creation probe hit this, so
no guest RAM chunk imported afterwards. The runtime now asks the kernel
first on that driver, refuses such pages itself with the answer Vulkan
requires, and never hands them to the driver. The object then goes its
other ways: the dma-buf source, else a copy.
Cause, measured on msi's 5080 through runtime device tests that logged each
call's VkResult and errno, the fd table and the process's maps:
- The consumer's probe makes no dma-buf import on NVIDIA. Its 1025-page view
is past udmabuf's list_limit, so its source refuses. What fails is the
runtime's import of the view's pointer, a VM_PFNMAP mapping of a udmabuf:
vkGetMemoryHostPointerPropertiesEXT succeeds (types 2 and 3), then
vkAllocateMemory answers ERROR_OUT_OF_DEVICE_MEMORY on both.
- After that, vkAllocateMemory answers ERROR_OUT_OF_DEVICE_MEMORY to every
host-pointer import measured:
- memfd pages from 8 KiB to 8 MiB at any offset;
- anonymous pages;
- RAM 512 MiB away;
- 40 retries over 3 s;
- a second VkDevice.
It also fails a plain 64 KiB host-visible allocation. Device-local
allocations still work. The chunk import fails in vkAllocateMemory, not
in the properties query or the requirements check.
- Not the cause: a failed udmabuf import itself (the next 8 chunk imports
bind, and NVIDIA closes the handed clone: F_GETFD EBADF), the properties
query alone, mapping a udmabuf, address reuse, the fd table, VmPin/VmLck,
the kernel log.
Vulkan (vkspec 1.4.366, 11.2.6): such a restriction "must fail the memory
import operation with the error code VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR";
and (Return Codes) "VK_ERROR_OUT_OF_*_MEMORY errors do not modify any
currently existing Vulkan objects."
Fix:
- RuntimeDriverDefect::UnpinnablePagesBreakHostMemory (NVIDIA_PROPRIETARY,
no GPU probed clean, per the defect table's rule).
- On such a device, Device::refuse_unpinnable runs before a no-copy
object's, heap's or rebind's own import and before a guest RAM chunk's
import. It walks the mappings over the pages (PROCMAP_QUERY, or the maps
lines before Linux 6.11) and reads one byte of each through
process_vm_readv. The kernel refuses a whole VM_IO/VM_PFNMAP mapping, so
one read per mapping answers for all its pages.
- Pages it cannot pin get its own Unsupported/HostMemory refusal naming the
defect. That refusal sends the object to the dma-buf source; with none,
or where the source's import fails, the object is a copy, announced as
copied-host-pages and counted as a failed import. This holds for buffers,
heaps and rebinds. A RAM chunk over such pages is not imported, and the
objects over it end in the copy. Pages not mapped readable keep their
refusal. The new refusal reaches a caller only where pages remapped after
their first import are imported again (docs/REFUSALS.md regenerated).
- Counted: WorkCounts::host_imports_unpinnable.
- Every other driver, and every OS but Linux, asks nothing and keeps its
path.
- Docs: driver_defects.rs (the measurement), FAST-PATHS known gaps, HOWTO
section 6 and its copy causes, the runtime README, copied.rs,
CopiedHostPages and its API.md entry.
- RUNTIME_VERSION 1704.
Verified:
- RTX 5080 Laptop, NVIDIA 615.71.09, --cfg m2v_gpu: the runtime filter
host_ram_device|copied_device|rebind|dma_buf|host_residency|
driver_defects|host_memory|host_import|copied passes 97/97 on the
committed tree.
- New: a_chunk_is_imported_after_a_refused_import_of_a_dma_buf_mapping
failed without the fix ((0, 0) where (1, 2) is expected) and passes
with it.
- New: pages_refused_before_the_driver_with_no_source_are_copied: a
buffer, a heap and a rebind over a udmabuf mapping with no gate and no
source give 3 refusals before the driver and 3 copies. The GPU reads
the right bytes, and a chunk then imports with 2 buffers bound.
- The consumer's repro, with its device probe in front
(os::linux::host_ram::tests::a_buffer_over_one_run_of_the_ram_is_bound_in_its_chunk,
built from a read-only copy of their 2cb3c8f91): passes. It fails against
development 2e2e238346.
- M3 Max, MoltenVK 1.4.2: the same filter 83/83; runtime unit tests 1161;
API, refusal-surface and fast-paths tests 34; rustdoc -D warnings clean.
Clippy -D warnings is clean on the Mac (plain and --cfg m2v_gpu) and on
msi (plain and --cfg m2v_gpu).
Left: RADV and ANV refuse such pages themselves, so an object there with no
source is still refused (not run there). A failed chunk import is not kept,
so the kernel is asked again for each object over that chunk (cost not
measured).
Lane commits: ws/chunkfix-lane (a2420020ea, a56fa43f2b).
One work packet, landed as 2 commits on archive/development-linear-2026-10-29: a0a1ea79d4, then 22fa5003db (the re-pin).
|
||
|
|
44eaa09898 |
Copies of read-only pages drop the GPU's writes; the gate is asked before write permission
The consumer's 4K boot on the RTX 5080 (NVIDIA 615.71.09) died at a buffer rebind onto 12 KiB of
read-only pages (`replaceBackingWithRanges:readOnly:`) with `OutOfMemory(Device)`, its gate having
refused the pages.
Cause: on Linux the runtime asked the pages' write permission before the caller's gate. Read-only
pages with a dma-buf source were sent to the source (by_pointer cleared), and the gate, asked only
for pages imported by pointer, was skipped. NVIDIA 615's import of the source's dma-bufs fails with
VK_ERROR_OUT_OF_DEVICE_MEMORY, and that failure was answered as the call's error, where a failed
pointer import takes the copy. The copy path itself never ran. Reproduced on the 5080: a buffer's
rebind, a heap's rebind and a no-copy buffer over read-only pages under a refusing gate each
answered OutOfMemory(Device). On macOS the gate was asked and the copy made, and the copy's
merge-back then wrote the read-only pages: SIGBUS in all three.
Fix:
- The gate is asked before the write permission, at a no-copy buffer's or heap's making and at a
rebind. Pages it refuses, and bytes moved in their page, are a copy, their permission unasked;
only pages imported have it asked.
- An admitted import of the caller's dma-bufs that fails (out of memory, another Vulkan error)
takes the copy too, as the pointer's import did: the gate's documented contract.
- A copy of pages the process cannot write drops the GPU's writes (copied.rs), as Metal drops them
for read-only memory (read_only_view.rs). The copy asks the system as it is made
(`mapped_writable`: PROCMAP_QUERY on Linux, mach_vm_region on macOS). At each completion, every
byte the GPU changed in the copy takes back the byte the pages and the copy last agreed on, and
nothing is written to the pages. Later commands of the same batch read the write back; a later
command buffer reads the pages' bytes. CPU writes through another mapping are copied in at each
commit as before.
- The copied-host-pages detail says so; read-only-pages-written is not announced over a copy.
Changes beyond the consumer's case: gate-refused pages and moved-bytes copies no longer ask the
kernel for write permission (no host_mappings_queried for them). Read-only pages with no source
under a refusing gate are a copy instead of Unsupported.
WorkCounts::copied_dropped_bytes (new). RUNTIME_VERSION 1703. api_signatures.tsv blessed;
REFUSALS.md regenerated, unchanged. Docs: HOWTO (copied host buffers), API.md (copied-host-pages,
read-only-pages-written), FAST-PATHS (the read-only-memory known gap now excepts copies),
ImportGate, HostMemory::new, new_buffer_with_bytes_no_copy, Buffer::rebind_bytes_no_copy, the two
Degradation declarations, copied.rs module docs.
Tests:
- Device, copied_device:
- a no-copy buffer, a buffer's rebind and a heap's rebind over read-only pages under a refusing
gate, the consumer's form: a read-only shared mapping, a dma-buf source on Linux;
- checked in each: the gate asked once with the pages, the source never called, a copy that
reads the bytes and a CPU write through the writable mapping;
- a blit fill completes with the pages unchanged, nothing merged back, copied_dropped_bytes the
fill's changed bytes, and a later command buffer reading the pages' bytes;
- Linux: the rebind under an admitting gate whose dma-buf import fails is a degraded copy that
drops the writes.
- Unit: restore, merge_back of an unwritable copy, mapped_writable (Linux and macOS).
- Negative controls:
- the three refusing-gate tests on the unfixed runtime: RTX 5080 3/3 fail with
OutOfMemory(Device) at the call; M3 Max 3/3 die with SIGBUS;
- the admitted test with only the source-failure copy arm removed: the 5080 fails with
OutOfMemory(Device).
Verified:
- RTX 5080 Laptop, NVIDIA 615.71.09 (msi; four holds, each under a minute): runtime
copied_device|rebind|host_ram_device|tests::copied::|can_be_written 52/52 at the final tree. The
admitted test's copy path ran (its line printed).
- M3 Max, MoltenVK 1.4.2, --cfg m2v_gpu under maclock and memcap: the same filter 49/49 (the
admitted test is Linux-only).
- Mac: degradation_catalogue, copied and host_memory unit tests with api_surface and
published_crates 37/37; api_signatures and fast_paths 16/16; clippy --workspace --all-targets
--all-features, plain and --cfg m2v_gpu, clean; rustdoc -D warnings for the runtime clean.
- msi: clippy -p metal2vulkan-runtime --all-targets --all-features --cfg m2v_gpu clean.
- Not run: the validation suites. The runtime-sources pin is left for landing.
One work packet, landed as 2 commits on archive/development-linear-2026-10-29: 5012056c31, then 6385d650b9 (the re-pin).
|
||
|
|
c0617d796e |
Rebinds take the copy where the gate refuses: heaps, images in place, moved bytes, one-run chunks
The NVIDIA RAM route's rebind part, with RunResolver's doc saying a rebind asks it. One work packet, landed as 4 commits on archive/development-linear-2026-10-29, in order: * Rebinds take the copy where the gate refuses: heaps, images in place, moved bytes, one-run chunks (c0e37e8984) The NVIDIA RAM route's rebind part (consumer spec, part 4). A buffer's rebind with an image in place over it, and a heap's rebind, now take the copy of the new pages (copied_pages) where the caller's gate refuses their import or the admitted import fails, instead of refusing NotImplemented(RebindTextures) or failing the call. Heap rebinds ask the gate like any import. A buffer's rebind to bytes at another offset in their page, under a texture planned at the old offset, takes a copy laid out at the old offset (the gate unasked: nothing is imported) instead of refusing. - The copy's memory, where images will bind in it, holds the window's whole pages from a multiple of the import's unit. The heap's textures bound to its bytes and the images in place over the buffer are made again over the copy: in memory the device allocates, as linear images that start PREINITIALIZED, whose first move keeps the copy's bytes (Vulkan: "the transition away from this layout will preserve that data"). - Where images in place ride on the copy, it lies in fresh pages the runtime maps and imports by pointer (Device::fresh_page_buffer), and each image is made as over the caller's pages for host allocations, under the device's in-place check for fresh pages (PagesClass::Fresh, else RebindTextures). On the RTX 5080 the driver's own linear image does not lie at Metal's 256-byte pitch, so the first form still refused there. - The run resolver at rebind (ram1's route_runs and bind_in_chunk): asked once with the new window, on the calling thread with no runtime lock held, before the gate. One run inside one chunk binds in the chunk's import (no import, no gate); any other answer takes the gate, then the import or the copy. The runs are kept with the new pages, copies included; bytes moved in their page are never chunk-bound. - Metal's rebind order is unchanged: the pending check runs before the gate, and committed-not-submitted command buffers are encoded again over the copy. - RebindTextures stays, for a device that makes no image over the copy at the texels' pitch, memory type or alignment, and for drops-writes buffers (option bit 24) whose bytes moved. WorkCounts (new): copied_rebind_pages_moved (a third cause within copied_host_buffers_made) and copied_rebind_images_made. No new Error variant. heap_raw_image takes (memory, at) and a memory-type check. RUNTIME_VERSION 1702. Docs: HOWTO copied host buffers and guest RAM, API.md copied-host-pages, FAST-PATHS (the heap and in-place rebind exception removed from the known gap), the runtime README, ImportGate, HostMemory::with_runs and with_import_gate, rebind.rs, copied.rs module docs, RebindTextures; REFUSALS.md and api_signatures.tsv regenerated. Verified: - RTX 5080 Laptop, NVIDIA 615.71.09 (msi, one hold): runtime copied_device|host_ram_device|rebind|in_place 48/48; the image over the copy is made (copied_rebind_images_made asserted 1) in the gate-refused, moved and ordering tests. Validation rebinds|dma_buf_imports 28/30: the two failures (ycbcr planes over chunks "off the grid", dma-buf in place "one run") also fail at development 2cfd8d6ef9 on the same GPU. - M3 Max, MoltenVK 1.4.2, --cfg m2v_gpu under maclock: runtime host-memory filter 157/157; validation rebinds|dma_buf|copied|no_copy|host_memory 75/75; at the final tip copied_device|host_ram_device|rebind 40/40. Here textures over buffers are shadows, so only the heap image over the copy runs (1 per heap test). - 7 new device tests: gate-refused buffer rebind with a texture over it, moved bytes, heap rebind gate-refused and import-failed, ordering with a held and an uncommitted command buffer, resolver at rebind (one run binds in the chunk; two runs go gate then copy). - Focused non-device tests 76/76; clippy plain and --cfg m2v_gpu clean; rustdoc -D warnings clean for the runtime. - Not covered by one venue: both images over a copy at once. Lane commits: ws/ram3-lane (d3945d0d9d, 7a114b599e, b93a6c1eac, 8b9fa5fb46). * Re-pin the runtime sources at the landing tip (7f76090454) * Say that a rebind asks the run resolver, as c0e37e8984 made it (8dcba47435) RunResolver's doc still said a rebind to new pages does not ask it. Since c0e37e8984 a buffer's or heap's rebind asks it once with the new window, before the gate, except where the bytes moved in their page under a texture, which take a copy without asking (with_runs' and Buffer::rebind_bytes_no_copy's docs already say so). Doc only. * Re-pin the runtime sources at the landing tip (17896b4366) |
||
|
|
76d89d87a8 |
See an event signal behind a copied host buffer at its completion turn
An event signal behind a copied host buffer is seen at the batch's completion turn, and the
copied host pages' cost is announced as the catalogue states it.
One work packet, landed as 4 commits on archive/development-linear-2026-10-29, in order:
* See an event signal behind a copied host buffer at its completion turn (8fc9c56dcb)
A batch's event signal is its GPU signal of the event's timeline semaphore,
and the host read the semaphore's counter directly (`EventShared::value`),
while a copied host buffer's GPU writes reach the caller's pages only at the
batch's completion turn (`completion.rs`, merge then `reached`). So a CPU
that saw the value could read the pages before the GPU's writes, and a plain
event's wait chained on the VkQueue let another queue's work start before
them: Metal's writes before a signal are in the pages once its value is
seen (the documented gap in FAST-PATHS, now closed).
A signal kept while the device holds a live copy is marked behind the merge
(`EventTimeline::keep`). No counter read observes it or any signal after it,
and no wait is handed its index (the scheduler's own host wait included); a
plain event's wait for it is held as a shared event's is. The completion
turn, which merges first, observes it and wakes every host wait and held
batch. The signal stays the batch's GPU signal: no submission is added. The
cost per such signal: its value reaches readers one completion turn later
than the counter shows it, and a GPU wait for it is a host hold plus a
vkQueueSubmit at that turn. Counted: WorkCounts::event_signals_behind_merge.
The same mechanism will hold for the GPU-kept copies.
RUNTIME_VERSION 1699 (renumbered at landing).
Verified on the M3 Max (MoltenVK), --cfg m2v_gpu, under memcap and maclock:
57 copied, event, scheduler and fast-path tests pass, among them the new
a_shared_event_s_value_is_seen_once_the_copy_s_bytes_are_in_the_pages
(six rounds, spin reads and host waits, a 64 MiB copy beside to lengthen
the merge) and the timeline unit test
a_signal_behind_a_merge_is_seen_at_its_completion_turn_alone. Negative
control: with the mark off, the device test fails on the byte check
("the write is in the pages once the value is seen"). clippy (plain and
--cfg m2v_gpu) on metal2vulkan and metal2vulkan-runtime, api_signatures
re-blessed (the new field), api_surface pass.
RUNTIME_VERSION 1700.
* Re-pin the runtime sources at the landing tip (2cef515da6)
* Announce the copied host pages' cost as the catalogue states it; list what pack.rs reaches (e9ba27478b) (its crates/metal2vulkan-runtime/src/degradation.rs part)
The final gate on 3e20b58763 failed two tests.
- degradation_catalogue: the signal-behind-merge fix (8fc9c56dcb) closed the
shared-event gap and rewrote the API.md entry for copied-host-pages, but the
runtime still announced "(behind a shared event's value among them)". The
announced cost now drops it, so the catalogue's entry starts with it word
for word again.
- the_runtime_sources_are_the_committed_ones: pack.rs became a runtime input
(the mipmap kernel's sRGB transfers), and it also reaches
metal2vulkan-air's intrinsics, lower/arith/math.rs and lower/arith/narrow.rs
through its pack and unpack intrinsics, which only the compile emits. They
are listed as not runtime with that reason. The stale comment about
srgb.rs's encode, tables and steps (deleted by the mipmap and n7 packets)
now says only what is true.
Verified: the two tests on the landed tip (see the landing).
* Re-pin the runtime sources at the landing tip (538f3f1161)
|
||
|
|
f4394b8712 |
Copy a no-copy buffer's pages the kernel cannot pin where the process maps them readable
Cause: a copied host buffer (the caller's gate refused the import, or the admitted import
failed) read its first bytes only through the kernel: `process_vm_readv` of our own pid on
Linux. That read pins each page, and no page of a VM_PFNMAP or VM_IO mapping can be pinned, so
on a dma-buf's mapping (udmabuf's on Linux 7.2) it fails although the pages are mapped
readable. `CopiedBuffers::add` then answered `NotCopied::Unreadable`, and the buffer, heap or
rebind was refused as not importable (`Unsupported { HostMemory, NotRepresentable }`): the copy
never worked for dma-buf mappings, which is where a consumer's gate refuses imports on NVIDIA
at the kernel's default vm.max_map_count.
Fix: where the kernel's read fails, the copy asks the process's mappings whether every page of
the range is mapped with read permission and, if so, reads it with plain loads, the access the
copy's comparisons already make at every commit and completion (`copied::read_caller`). The
mapping check generalizes the import's write check: `PROCMAP_QUERY` tests
`PROCMAP_QUERY_VMA_READABLE` as it tested `..._WRITABLE`, and before Linux 6.11 the
/proc/self/maps lines' `r` as their `w` (`host_memory::Access`, `queried_permitted`,
`permitted`, `mapped_readable`). Pages not mapped, or mapped without read permission, are still
refused. All three users of `add` (buffers, heaps' own buffers, rebinds) take it. Off Linux
nothing changes (no mapping is asked; macOS's mach_vm_read path as before). RUNTIME_VERSION
1696 -> 1697 (renumbered at landing). Docs: API.md's copied-host-pages entry, HOWTO's copied
host buffers, the runtime README, and FAST-PATHS' known gap with the measured cost.
Evidence (verified):
- msi (Linux 7.2.8, RTX 5080): tests::copied + tests::host_memory 21/21; the udmabuf test
printed "the kernel cannot read this udmabuf mapping: copied with plain loads".
Under the GPU lock on NVIDIA: tests::copied_device + tests::copied 15/15, among them the new
copied_buffer_is_made_over_a_dma_buf_mapping_the_gate_refuses (gate refusal -> copy made,
announced, CPU writes copied in and a fill merged back over the udmabuf pages).
- Negative control on msi: with the fallback disabled the two new copied tests and the new
device test FAIL (the device test at the buffer's refusal); restored, PASS.
- macOS (M3 Max, MoltenVK, under maclock): copied, copied_device, host_memory 25/25; plus
degradation, catalogue and fast_paths 45/45.
- clippy -D warnings clean: macOS plain and --cfg m2v_gpu; Linux (msi) plain and
--cfg m2v_gpu, runtime crate, all targets, all features. rustdoc -D warnings clean (runtime).
- Cost, release, msi: one add of a 64 MiB udmabuf range 15 ms (the failing kernel read 6 us,
the mapping query 22 us); each comparison of a 64 MiB copy 22-41 ms on the CPU; on NVIDIA a
live 64 MiB copy makes each empty command buffer's commit and wait 45-68 ms (0.2 ms without).
- Not run: the Mac's Linux container exposes no /dev/udmabuf.
RUNTIME_VERSION 1698 at landing.
One work packet, landed as 2 commits on archive/development-linear-2026-10-29: 1612481fb3, then 95852120a3 (the re-pin).
|
||
|
|
442a9fd538 |
Bind no-copy objects over one run of guest RAM in the device's chunk import
The NVIDIA chunk route's API (HostRam, Device::use_host_ram, HostMemory::with_runs), the chunk
source and one-run route, and a chunk-bound buffer's out-of-bounds writes held to the device's
own containment (a device test and a known gap).
One work packet, landed as 7 commits on archive/development-linear-2026-10-29, in order:
* Add HostRam, Device::use_host_ram and HostMemory::with_runs (d3617f7e1d)
The API of the NVIDIA chunk route (guest RAM imported whole): the types the
chunk source, the GPU copy and the rebind lanes build on.
- HostRam (unsafe new(ranges, keep_alive)): the consumer's guest RAM ranges,
checked as non-empty, whole host pages, within the address space and apart;
a typed refusal otherwise (Invalid, Problem::HostRam). with_dirty_pages
takes one DirtyPages log for the whole RAM whose offsets are host addresses
(the log's pointer is 0), so one stamp per commit can serve every copy. The
keep-alive is dropped with the HostRam (forgotten while the process exits).
- Device::use_host_ram(&Arc<HostRam>) -> HostRamUse: a guard, since runtime
devices live for the process while a lease promises its RAM for one guest
device's life. Dropping the guard ends the use; a later RAM may be used
after. Several RAMs whose ranges are apart may be used at once; one whose
ranges meet a used RAM's (itself among them) is refused as misuse
(Invalid, Problem::HostRam). A device without VK_EXT_external_memory_host
is refused (Unsupported, naming it).
- HostMemory::with_runs(RunResolver): RunResolver is
Arc<dyn Fn(start, len) -> Option<Vec<Range<u64>>> + Send + Sync>, asked with
the import window, answering host addresses in the RAM's ranges. Stored
here; the routing that calls it comes in a later commit.
No Metal counterpart for any of it; the doc comments say so. The chunk import
itself (lazy 64 MiB chunks) and the routing in buffer_over_host_memory follow.
Verified: cargo clippy -p metal2vulkan-runtime --all-targets --all-features
-D warnings (Mac); host_ram unit tests 4/4 (range checks, refusals,
keep-alive drop); api_signatures and refusal_surface 7/7 after the re-bless
and regeneration; rustdoc -D warnings for the runtime crate.
* Re-pin the runtime sources at the landing tip (22c47609a9)
* Bind no-copy objects over one run of guest RAM in the device's chunk import (7f07d19b3d)
What: the chunk source and the one-run route (host_ram.rs).
- Chunk source: a device that uses a HostRam imports it by host pointer in
64 MiB chunks (CHUNK_BYTES), never across a range's end, lazily. Each chunk
is imported the first time an object over it is made, on that thread, once,
under a lock of its own (ChunkSlot). It goes through the existing
Memory::import_host: a coherent type, and the device-address flag where
bufferDeviceAddress is on. A whole-chunk VkBuffer is kept for the runtime's
own copies only, never named by a Metal buffer, root entry or binding.
- Chunk lifetime: chunks are never released while idle (they are no
HostImport, so host_residency never sees them). Once the HostRamUse is
dropped, a chunk is freed when nothing holds it: Placement gains ram_chunk,
so every buffer bound in a chunk holds it, and every command buffer that
used one does too. The RAM, and so its keep-alive, goes after the free
(release_then's after), dropped as the program's. Exiting leaves it all to
the process's end.
- Routing in buffer_over_host_memory: a buffer that lies in a live import of
the same bytes is unchanged. Otherwise, where the device uses a RAM and the
memory has a resolver, the resolver is asked once with the import window, on
the calling thread with no lock held, before the writability query and the
gate. Memory whose GPU writes bit 24 drops is never routed.
- One run inside one chunk: Device::bind_in_chunk makes the VkBuffer with
host_buffer against the object's own window, checks it with binds_in
against that window, and binds it at run offset + binds_in offset in the
chunk's memory. That offset must be a multiple of the buffer's alignment,
and the buffer must allow the chunk's memory type. Its placement
(Placement::ram_chunk) holds the chunk and maps the caller's pointer, so
contents stays the pointer. The buffer gets no import of its own, the gate
is not asked, and buffer_of keeps the import fixed (no Again).
- Several runs, a run crossing a chunk's end, a chunk that cannot be imported
or a buffer that cannot bind exactly: today's gate path (import, or copy
where the gate refuses).
- The RAM and runs are kept on HostPages (ram_runs) until rebind or release,
for the GPU copy lane.
- An answer that is not whole pages of one used RAM totalling the window is
refused: Invalid, Problem::HostRam.
- Heaps over host memory take the same routing (of_heap goes through
buffer_over_host_memory).
- rebind_host_pages only ignores the new HostParts.runs (`runs: _`). The
rebind lane asks the resolver there with Device::route_runs and
bind_in_chunk.
- New WorkCounts: host_ram_chunks_imported, host_ram_chunk_bytes,
host_ram_chunks_live (a gauge), chunk_bound_buffers_made.
- Docs: HOWTO "Guest RAM imported whole", the runtime README's extension list.
RUNTIME_VERSION 1697 -> 1698.
Why: the NVIDIA route (the consumer's spec). On a device that refuses
dma-buf views, each import of scattered guest pages takes a kernel mapping per
page, past vm.max_map_count at 4K. One-run objects bound in chunks take none.
How verified (this Mac, M3 Max, MoltenVK, under memcap + maclock):
- host_ram unit tests 8/8: chunk spans and lookup; one run in a chunk, a
chunk's last pages and a range's short last chunk; several runs and a run
crossing a chunk (gate path); broken answers refused.
- New device tests tests::host_ram_device 6/6. The path ran: the log prints
"chunks imported 1, chunk-bound buffers 2".
- One run binds in the chunk: 1 chunk import of 64 MiB, 0 pointer imports,
gate not asked, contents == pointer, the GPU reads the bytes, a fill
reaches them, a second buffer in the chunk imports nothing.
- Containment: a 1.5-page buffer's copy reach <= its 2-page window, and a
fill of all of it leaves the sentinel page before and the bytes after it
unchanged.
- A no-copy heap binds in the chunk.
- None, two runs and a crossing run ask the gate once and import; short and
outside answers are refused.
- A command buffer held behind an event keeps the chunk (live gauge, and
the keep-alive not dropped) after the buffer, the use and the RAM are let
go of; once it completes the chunk is freed and the keep-alive dropped.
- The same RAM twice and an overlapping RAM are refused, a RAM apart is
taken, and a new RAM over the same ranges is taken after the first use
and imports again.
- Regression on the same Mac: 249/249 for
host_|copied|dirty|rebind|heap|no_copy|dma_buf|in_place|detach|alias|
degradation|profile (copied_device, dirty_pages_device and the
host-import tests among them).
- clippy -D warnings plain and --cfg m2v_gpu (runtime, all targets, all
features); rustdoc -D warnings for the runtime; api_signatures 3/3 after
the re-bless.
Not run here: NVIDIA (msi 5080) and lavapipe; dma-buf devices' own tests
beyond the Mac's.
RUNTIME_VERSION 1699 at landing.
* Re-derive the generated documents at the landing tip (a9c042f142)
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.
Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
* Re-pin the runtime sources at the landing tip (2cfd8d6ef9)
* Hold a chunk-bound buffer's out-of-bounds kernel writes to the device's own containment (1b09d84fad)
What: a device test (tests::host_ram_device) whose kernel, the owned fixture's
scale_and_offset, writes three pages of words through a one-page buffer bound
in a chunk of guest RAM. It asserts that the page before the buffer and the
pages after it keep a sentinel, and that the kernel wrote the buffer itself.
The page-after assertion applies wherever the device keeps the same write,
through a one-page buffer of its own, out of the buffer made after it: the
chunk binding is held to the device's own containment, measured in the same
test. A known gap in docs/FAST-PATHS.md records the device that does not
contain such writes.
Why: containment (c) of the route. A chunk-bound VkBuffer ends at the
object's last page, but the chunk's memory goes on past it, so containment
rests on the device's buffer robustness or in-shader checks, not on the
import's end as a per-object import does.
Found and how verified:
- RTX 5080 laptop (NVIDIA 615.71.09), msi, one hold 06:00-06:02, strict form
(no device check): host_ram_device 7/7. The chunk's pages after the buffer
were untouched.
- lavapipe (linux-gate, slot lava, arm64), strict form: 7/7.
- M3 Max (MoltenVK 1.4.2), this form: 15/15 host_ram tests. It prints that
out-of-bounds writes changed 32720 bytes of the device's own next buffer and
32720 bytes of the chunk's next pages. A control run (not committed) showed
that a no-copy pointer import of one page changed 0 bytes past its page. So
MoltenVK's gap is within an allocation; it predates the route, which
inherits it.
- clippy --cfg m2v_gpu -D warnings (runtime, all targets).
Also: the RunResolver doc no longer says rebinds ask it; they do not until rebinds are routed (af9f1e057d).
* Re-pin the runtime sources at the landing tip (60c300198f)
|
||
|
|
bc1a6ebf8b |
Encode a half's bits by the device's narrowing, not an integer sequence
A half value whose bits are not known from a load (a store, a reinterpretation, a texel's or snapshot's bits) is encoded by the device: with shaderFloat16 one OpFConvert to 16 bits (NoContraction under the float controls), each lane read as a word beside a 16-bit zero; without it GLSL.std.450 PackHalf2x16. The exact integer sequence (rebias, NaN quieting, the 2^24 denormal scaling, the 0x7C00 cap under native rounding) is deleted. narrow::encodes_bits finds the narrowing; compile.rs records the widening's notes for it: NativeNanEncoding everywhere, NativeHalfConversion where neither the float controls nor MetalHalfArithmetic cover it. Bits known from a load, folded constants, an integer's half and bfloat stay exact. bits_words 136 -> 48 per lane. Tests pinning the old NaN bits accept the device's where the note is recorded; 40 known-gaps rows the Apple M3 Max no longer diverges at are dropped (29 attribute-format-fetches half-NaN sites, 3 each of half-texel-nans-r16f/ -rg16f/-rgba16f, 2 of math-frexp-ilogb-half: Metal's own NaN bits now). SEMANTICS_VERSION 1919. Verified: 347 translator tests (lower::arith::tests, the touched engine modules, every public fixture on every committed profile), clippy plain and --cfg m2v_gpu, rustdoc; a sabotaged encode form fails the new a_half_encode_is_the_devices_narrowing_in_every_form; on the M3 Max: conformance replay of 28 half cases exit 0 (every divergence a held ledger row), validation runtime_lane half tests 7/7, runtime nan_signs/vertex conversion notices/degradation sites 4/4. golden_hashes.tsv cells move, re-blessed on development. Not run: lavapipe, the full validation and conformance sets. One work packet, landed as 1 commit on archive/development-linear-2026-10-29: 0d7093d826. |
||
|
|
0a1851164d |
Copy a no-copy buffer, heap or rebind whose import the caller's gate refuses or that fails, announced
A new HostMemory::with_import_gate(ImportGate) asks the caller once,
holding no lock of the runtime's, just before a no-copy buffer, a
no-copy heap or a buffer rebind imports its pages, passing an
ImportRequest with the pages the import would map. If the gate answers
false, or an import the device and the gate admitted then fails
(OutOfMemory, another Vulkan error), the object is made over a copy of
the pages instead of failing. The default stays import-first. The copy
is host-visible memory owned by the runtime; `contents` stays the
caller's pointer. Each commit copies in the bytes the CPU changed since
the last sync, and each batch's completion merges back the bytes the GPU
changed (CPU wins where both wrote), byte by byte, before events,
waiters and handlers see it. Every copy is announced
(`copied-host-pages`) and counted. Pages the process cannot read are
never copied (the first copy reads through the kernel:
process_vm_readv / mach_vm_read_overwrite). A copied heap's buffers lie
in the copy and its textures are shadows. A rebind's copy is laid out as
its import would be. A rebind over an in-place image is refused
(NotImplemented(RebindTextures)) and a heap's rebind still imports
without asking. A caller's DirtyPages log stays attached to the copy as
to an import. The in-place check's pointer class skips copied buffers.
Ports dev-perf's fff961b7e5, 630d1b0174, 33d7aa5e98 and 9b4d4190f5 onto
a smaller coherence design: every live copy is compared in full at each
commit and completion, instead of dev-perf's log-driven,
encoder-collected copies (dev-perf's copied.rs, 79301a2515 and its
fixes, sat on a page log development has replaced). Also brings
789fa3d294's unreadable-page rule, 5190983470's lane site, and
1c7d49f788's copied-buffer skip. A driver that refuses the pointer
still fails the call (dev-perf copied there too; not taken). Known gaps
in FAST-PATHS: the compare costs O(size) per commit and completion, a
byte both sides wrote keeps the CPU's value, and a shared event's value
can be seen before the merge (c5db2d1b8a not ported). RUNTIME_VERSION
1690. Runtime-sources pin recomputed.
Public API: ImportGate, ImportRequest { start, length }
(#[non_exhaustive]), HostMemory::with_import_gate,
Degradation::CopiedHostPages, Device::fail_next_host_imports (test
hook), and the WorkCounts fields host_imports_refused_by_host,
copied_host_buffers_{made,refused,degraded}, copied_copy_in_bytes,
copied_merge_back_bytes, copied_rebind_pages_made, copied_heaps_made.
Verified on the M3 Max (MoltenVK, m2v_gpu): 11 new device tests
(tests::copied_device: buffer, rebind and heap, gate refusal and failed
admitted import, unreadable pages, a heap texture round trip) and 167
tests in the touched device filters pass; the counters move as
expected ([1,1,1,0,0] for a refusal, [0,1,0,1,0] for a failed import)
and the announcement is heard; on a 64 KiB copy 4079 bytes copied in and
4080 merged back for a 4 KiB CPU write and a 4 KiB fill, checked
exactly. Sabotage: ignoring the gate and removing the merge fails the 3
buffer tests; ignoring the rebind gate fails both rebind tests (no heap
sabotage). 249 host tests pass. Workspace clippy plain and
--cfg m2v_gpu, and rustdoc, clean; clippy re-run clean on the landing
merge. Not run on Linux.
|
||
|
|
8c09b7c2c0 |
Link a warm render creation from its recorded stages, and key the shader cache by its translator
A warm render state creation spent most of its own time in Device::render_variant_key, decoding and specializing every Function stage's AIR to learn its stages' compile keys, because the directory's variant record named only the pipeline's key and a sweep stores no pipeline artifact where the directory holds its stages. The record (v2: new tag and magic) now also names the stages' function compile keys (VariantStages); a creation that finds the record but not the pipeline finds the functions by those keys alone (Sources::found_function: memo, archives, disk, no translation) and links them (RenderVariant::link), decoding nothing. Every creation writes its record. The keys are valid exactly as long as the pipeline key beside them. (Ports dev-perf f4d864d160; development's lookup has no warm-pass Prior/Found and no fit_render_variant, and the bench it extended is gone.) The shader cache's build directory was named by the runtime's version, both artifact versions, the translator's SOURCE_DIGEST and the runtime's own source digest (its build.rs over every file under src/, tests included), so any runtime edit started the cache cold. Every translated entry is the translator's answer for the inputs its key and profile hash, so the runtime's digest goes (with build.rs, its sha2 build-dependency and the validation fingerprint's reference to it). The translator's SOURCE_DIGEST stays, as its doc promises: an unbumped translator change still starts afresh. The runtime's own creation records (linked-use answers, reflection, variant record) are runtime logic, so their names now hash RUNTIME_VERSION with their tag and key (creation.rs record_name): a runtime change that bumps it reads none of an earlier runtime's records. (Ports the idea of dev-perf db5f5baa73, narrowed: no per-entry stamp, no other_build_hits, no public API change.) Not ported from the same area: dev-perf's pipeline-record hook and Device::warm from an earlier process's records (14df1fb5fe, 66fe0ada29; ~3,200 lines on per-entry stamps this packet does not take). Verified on the M3 Max (MoltenVK): 84 device tests of the shader cache, creation, render-stage, sibling-work, archive and pipeline areas pass; the guard a_second_device_links_a_recorded_sweep_with_no_stage_decoded fails with the recorded-stage link disabled ((decoded, translated) = (2, 0)) and passes with it; a_creation_record_of_another_runtime_version _is_not_found passes. Release render-pipeline-split, integer-vertex-attributes, one run: warm processes decode 2 stages before and 0 after; cold counts identical; wall within run-to-run spread on this case's small shaders. Clippy (plain and --cfg m2v_gpu) and rustdoc -D warnings clean; 43 + 241 plain runtime/translator tests pass. No version bumps. Runtime-sources pin recomputed. |
||
|
|
04f6fb57b8 |
Read a half by UnpackHalf2x16 and narrow one by the bare quantize without float16
One work packet, landed as 4 commits (91d9e38f75..80ca8d6abd on archive/development-linear-2026-10-28), in order:
* Read a half by UnpackHalf2x16 and narrow one by the bare quantize without float16
On a device with 16-bit storage but no shaderFloat16 (QuantizeForm::Device: Pascal, the
lunarg-2023 baseline, vk12-floor, SwiftShader), the GPU's native arithmetic is the contract
(AGENTS.md rule 1), so neither the read nor the narrowing of a `half` emulates Metal's bits any
more:
- A `half` read from its bits (a load, a reinterpretation, a texel's or snapshot's bits, a
vertex fetch) is GLSL.std.450 UnpackHalf2x16 of the bits as the low half of a 32-bit word
(component 0), or of both halves for a pair (`narrow::from_bits`, `from_word_halves`). The
exact integer decode (`half_bits_to_f32_bits`) is deleted: UnpackHalf2x16 is core and needs no
capability, so no device lacks a native form. The module records NativeNanEncoding (a NaN's
bits) and NativeHalfConversion (the widening is neither under DenormPreserve 16 nor measured,
so a denormal may flush), by the rules 860ad1489f set for the float16 widening;
`narrow::widens_bits` counts the unpack.
- Every narrowing to `half` through `narrow::round` (fptrunc, every `half` operation, function,
sum, multiply-add, mix step, division, square root, dot, simd and matrix reductions, stage I/O,
color and fetch narrowing, texel rounding through `round_texel`) is the bare OpQuantizeToF16,
recorded NativeHalfQuantize on every such device, measured or not. The denormal arm (quantize,
compare, RoundEven of x * 2^24, select) and `device_round`, `scaled` and
`flushes_below_normal` are deleted; `native_rounding(form)` now depends on the form alone, so
`native_half` holds on every Device-form module. `round_integer` stays exact: it is the
workaround for NVIDIA 615.71.09 keeping an integer conversion unrounded under the quantize.
- No module requires VkProperty::MetalHalfQuantize any more (compile.rs drops the requirement);
DriverDeviation::MetalHalfQuantize and the property are kept and documented as measuring only.
Devices with shaderFloat16 are unchanged.
Integer roundings to `half` that never took `narrow::round` are unchanged: the extended-range
blend's `half_of` (every form but the controlled one), the extended-range color encodes, the
sampler's level and the bicubic routines (Metal's directed roundings among them), and the texture
routine's grid families, which round an integer code's ratio.
Docs: PrecisionNote's NativeHalfConversion, NativeHalfQuantize and NativeNanEncoding, the
runtime's declarations of the three, docs/API.md section 9 and docs/HOWTO.md state the new reach;
`fetch.rs`'s `half()` no longer says "exactly". SEMANTICS_VERSION 1886 -> 1887. The runtime
sources change in doc comments only, so RUNTIME_VERSION stays; the runtime-sources pin moves.
Tests (the arith interpreter harness now builds in QuantizeForm::Controlled unless a body sets a
form, so routine references stay Metal's; a half NaN through the device's widening is accepted as
a NaN, the interpreter's widening being canonical):
- `narrow::device_half_rounding_is_the_quantize_alone`, `engine_native_half::
a_half_below_the_smallest_normal_takes_the_devices_quantize` and `engine_arith::
a_half_rounding_without_float16_is_the_quantize_alone`: no RoundEven or compare after the
quantize, NativeHalfQuantize on every Device profile, sums and narrowings below 2^-14 answer
the signed zero on the interpreter. Negative control (the denormal arm restored in `round`):
all three fail, and `half_rounding_follows_the_operation`.
- `narrow::a_half_decode_is_the_devices_widening_in_every_form` and `engine_native_half::
a_half_read_from_memory_is_the_devices_widening_on_every_profile` and the loop decode test: one
UnpackHalf2x16 per word, no 16-bit type, no integer decode, NaN and conversion notes. Negative
control (the integer decode restored in `from_bits` and `from_word_halves`): all three fail.
- The texel tests accept the quantize's signed zero for a half denormal in the Device form; the
16-bit grid comparison runs the Device form under native rounding only (its one production
setting); the wide tests validate on vk12-floor in its own form.
Verified on this Mac (no GPU): cargo nextest -p metal2vulkan -p metal2vulkan-runtime
-p metal2vulkan-air -p metal2vulkan-devtools --all-features: 5014 run, 5013 passed, the one
failure golden_hashes_match_the_table (hashes moved; not re-blessed here). cargo clippy
--workspace --all-targets --all-features -D warnings, plain and with --cfg m2v_gpu; cargo doc
-D warnings for metal2vulkan and metal2vulkan-runtime. Every fixture below translated with
spirv-val (vulkan1.2, vulkan1.4) passing.
Words (instructions), the CLI on the public engine fixtures, before -> after:
hfb_filter_bank (fragment) Pascal 198141 -> 147460 (38283 -> 28981)
lunarg-2023 176378 -> 124545 (34510 -> 24920), same on
swiftshader and vk12-floor
unm_contract_chain Pascal 46258 -> 34491 (9333 -> 6952)
lunarg-2023 48303 -> 36536 (9699 -> 7318)
swiftshader, vk12-floor 48364 -> 36597 (9928 -> 7547)
fmx2_contract_fast Pascal 24177 -> 18912; lunarg-2023 25107 -> 19842
a1_half_denormals Pascal 4230 -> 3071; lunarg-2023 4353 -> 3194
hwd_half_reads Pascal 2647 -> 2194; lunarg-2023 2688 -> 2235
dsm_half_live_built Pascal 6782 -> 5988; lunarg-2023 6799 -> 6005
sum_regroup unchanged (Pascal 1047, the others 879)
* Hold the native half lanes to each rounding's bound, and bound the quantize's flush by its input
On SwiftShader (no shaderFloat16, so every half narrowing is the bare OpQuantizeToF16) two
native_maths lanes broke the note they check:
- half_rounding_answers_within_its_recorded_bound held half(a) + half(b) to one ulp of Metal's
sum, but the note bounds each rounding: SwiftShader's quantize rounds toward zero, so two
roundings land two ulps off (thread 30: -45.0625 for Metal's -45.125; failing on development
too), and a flushed denormal operand moves the sum by itself. The sum is now held to the bound
of the sum of operands each rounded within it (half_within_sum).
- native_maths_answers_within_its_recorded_bounds held a half fma below 2^-14 to one ulp; where
the stage records NativeHalfQuantize or NativeHalfConversion, the zero of its sign is the
note's bound.
The quantize tests the value it rounds, not the rounded result: SwiftShader answers -0 for
-6.1005354e-5, which Metal rounds to -2^-14. PrecisionNote::NativeHalfQuantize, the runtime's
declaration, docs/API.md (its section 9 entry and the device-answers paragraph, which still said
the widening was the device's only with shaderFloat16) and docs/HOWTO.md now bound a value below
2^-14, not a result, and the lane tests the input.
Verified: scripts/linux-gate --icd swiftshader, runtime_lane::(driver_deviations|half_|
native_maths|sum_regroup|math_routines): 26 run, 22 passed. The four failures fail identically
on development 60fe70fb12 without this branch (sum_regroup 3863 of 4096 pixels, RG11B10 small
floats 2005 of 71505 fields, the slice NaN lane's 17 stored halves, 86 and 484 float NaN words),
so they are SwiftShader's, not this change's; development there fails six, among them
half_loads_the_device_widens_answer_as_metal, which passes here. The same lanes on lavapipe:
26 of 26. clippy -p metal2vulkan-validation --all-targets --all-features --cfg m2v_gpu
-D warnings; the runtime's degradation catalogue tests.
* Number SEMANTICS_VERSION 1889, after development's 1888
The half read and narrowing change (91d9e38f75) bumped SEMANTICS_VERSION, and each rebase onto
development took development's own bump for it (1887 for the MoltenVK vertex fetch, 1888 for the
blend sweep's one compile), so this change shared a number with another. 1889 keys its modules
apart: Device-form modules read a half by UnpackHalf2x16 and narrow one by the bare
OpQuantizeToF16, with their precision notes.
Verified on the rebased tree: the core suites, clippy plain and --cfg m2v_gpu (see the change).
* Re-pin the runtime sources at the landing tip
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.
|
||
|
|
a3c550ca33 |
Read a half from memory by the device's widening, and sum one by its quantize
One work packet, landed as 3 commits (860ad1489f..46ec3ad81f on archive/development-linear-2026-10-28), in order: * Read a half from memory by the device's widening, and sum one by its quantize The owner's ruling on native half arithmetic, applied to the reads and sums that still emulated Metal's bits. A half read from memory or from its bits is the device's widening wherever the module holds 16-bit floats (every QuantizeForm but Device, i.e. every profile with shaderFloat16): the bits read as f16 (an OpBitcast of the word or words, a 16-bit storage unit read as a half itself) and one OpFConvert, with no use analysis. The module records NativeNanEncoding (the widening's NaN bits are the device's; a half stored unchanged keeps its bits through the noted bits). Its denormals are kept under the 16-bit float controls (ANV, RADV: DenormPreserve), read as Metal's by the measured MetalHalfArithmetic on MoltenVK (the module then requires the property), and elsewhere (NVIDIA, lavapipe) may flush, recorded as NativeHalfConversion. Without shaderFloat16 the integer decode stays: no 16-bit float type exists to read the bits as. The use analysis (lower/arith/widening.rs), ModuleBuilder::set_widens_halves, the loop-free offers it fed and the UnpackHalf2x16 decode are deleted. A half sum or difference (and the mix, muladd, fract and sqrt results that round the same way) takes the device's rounding alone (narrow::device_round): on a device without shaderFloat16 the bare OpQuantizeToF16, whose result below the smallest normal half may be a zero, noted NativeHalfQuantize whether or not the quantize is measured (narrow::flushes_below_normal). round_exact_below_normal is deleted. An integer's half stays exact (round_integer), documented as the workaround for NVIDIA 615.71.09 keeping an integer conversion unrounded under OpQuantizeToF16. SEMANTICS_VERSION 1883 -> 1884. The runtime-sources pin moves for doc comments only (device/driver_facts.rs, device/requirements.rs), so RUNTIME_VERSION stays. The golden hash table moves (2704 cells) and is re-blessed on development, not here. API signatures and REFUSALS.md are unchanged. Words (instructions) of the release command line's output, before -> after: hfb_filter_bank NVIDIA 5080 159876 -> 147962 (31488 -> 29438), lavapipe 160444 -> 148530, MoltenVK 153283 -> 148284, ANV 164906 -> 159903; unm_contract_chain NVIDIA 34516 -> 33048 (6985 -> 6769), MoltenVK 35366 -> 33666; fmx2_contract_fast NVIDIA 18983 -> 18272; sum_regroup pascal 3356 -> 3286, vk12-floor 2506 -> 2436. Every module passes spirv-val. Verified: the core suites (metal2vulkan, -air, -runtime, -devtools): 5056 of 5057 pass, golden_hashes_match_the_table the one failure (moved hashes, as above); a touched-test pass of 318 in metal2vulkan and the validation crate, the runtime pin included; clippy -D warnings with all features, plain and with --cfg m2v_gpu. New tests fail without the change (checked for the 16-bit unit read by disabling its note). Device lanes on lavapipe follow. * Re-pin the runtime sources at the landing tip 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. * Re-bless the golden table after the half reads' native widening 860ad1489f reads a half by the device's widening on every shaderFloat16 profile and sums one by the bare quantize elsewhere, so 288 rows' cells moved. bless_engine_inventory, bless_golden_hashes and bless_engine_goldens at 9ac9892868; public_fixtures_engine, air_input and golden_hashes: 28 passed. |
||
|
|
e87d6e558f |
Drop the exact read of a 16-bit float texel's own bits
One work packet, landed as 6 commits (b07aaeec71..ffa0751e77 on archive/development-linear-2026-10-28), in order:
* Drop the exact read of a 16-bit float texel's own bits
The owner's ruling of 2026-10-27 ("just promise the GPU's native
arithmetics, no more 'exact' emulation") makes the device's decode of a
16-bit float texel the only answer a `half` or `float` read gives. So
`DevicePolicy::half_texel_bits` and `HalfTexelBitsPolicy` go, with
everything only its `Exact` value reached:
- the slot's second binding of the texture's unsigned-integer alias
(`RuntimeFact::HalfBitsTexture`, `metal::format::half_bits_read_view`,
`DeviceProfile::reads_half_texel_bits`), its declaration, the read's
branch on the bound class and its integer widening;
- the snapshot copy's alias arm and the read's codes beside the value;
`snapshot_copies_alone` now expects the copy's one fetch a slot;
- the binder's alias view and its in-shader swizzle for it, and the
runtime's alias view format on a sampled image;
- the fit's `half_texel_bits` field of `ExactFormsOverCompilerLimit`
and the runtime's name for it.
The read keeps the device's decode and its `DeviceNanEncoding` note.
The `StorageImageClass::HalfBits` storage path is untouched. Tests of
the deleted form go (`engine_half_texel_bits`, the snapshot alias and
swizzle tests, the golden check of the copy's arm); the ledger row goes,
and the conformance gap rows' reasons no longer cite the switch.
SEMANTICS_VERSION 1872, ARTIFACT_FORMAT_VERSION 455 (a RuntimeFact
variant and a field gone), RUNTIME_VERSION 1653.
Verified: cargo clippy --workspace --all-targets --all-features
-D warnings clean; nextest over fast_paths, catalogue, degradation,
profile, mechanism, compile::fit, engine_snapshot_exact,
engine_srgb_raw, engine_swizzled_storage, snapshot_codes, codec and
image_plan (276 tests) passed. api_signatures is re-blessed at the
lane's end.
* Drop the shader's exact 16-bit float blend of a half output
The owner's ruling is to promise the GPU's native arithmetic, so the
`half_blend` switch (`HalfBlendPolicy`) goes. Under its exact value the
pipeline named a blended 16-bit float attachment of a `half` output, and a
32-bit float one of a four-lane output under fast math, for the interlocked
storage form alone (`FramebufferFetchInputs::half_blends`), so the shader
computed Metal's blend where the device would otherwise blend. That path
is gone: `compile::blended_in_shader`, the `half_blends` set and its
"optional" handling in the fetch lowering, `fetch::blends_half_in_shader`,
`half_output` and `half_blend_attachment`, the policy field, the profile
field and the fit's `half_blend` flag in
`RuntimeFact::ExactFormsOverCompilerLimit`.
Kept: a fetched attachment's blend (the function reads it, so no Vulkan
blend applies) and an attachment a draw moves into the storage form
(`VariantKey::interlocked_colors`), both capability. `HalfOutputPrecision`
still describes the device's blend and is recorded as before; with no
switch it is no fast-default row, so the ledger test classes it with the
notes docs/API.md section 9 states. The ledger's `half_blend` row goes,
and the device-gap rows no longer cite it.
Tests of the exact form go (`engine_fetch_float32_reach`, two
`engine_stage_io` tests); the validation lane `half_output_blends` runs
under the device's blend alone, and `corpus-draw-ab --policy` no longer
takes `half_blend`.
Verified: cargo clippy --workspace --all-targets --all-features -D
warnings clean; nextest of engine_stage_io, compile::fit, fast_paths,
device::tests, pipeline::api_tests, lower::fragment, catalogue,
degradation, fitted_variant_notice, api_surface and link render tests
(246 passed), and of every fetch, blend, interlock and half_output test
(199 passed). Golden tables not run (re-blessed on development).
* Round half by the device's own conversion or quantize
The owner's ruling is that the GPU's native arithmetic is promised, with
no exact emulation. This deletes the half_rounding switch
(HalfRoundingPolicy, ProfileFields::half_rounding, HalfRoundingRoute)
and everything that only its Metal value reached:
- QuantizeForm::Integer: Metal's rounding to half by integer arithmetic,
its texel routine arms (grid16_by_integers), round_texel_plain and
texel_round's f32_to_half_by.
- The NoContraction barrier on the conversion pair, and the
MetalHalfConversion requirement it carried.
A half now rounds by the device's form:
- Controlled: the float-controls route (ANV, RADV), unchanged.
- Converted: the device's conversion pair, wherever the profile has
shaderFloat16. It records NativeHalfConversion, MoltenVK included.
- Device: OpQuantizeToF16 with its denormal arm, which becomes the
QuantizeForm default. It records NativeHalfQuantize unless the driver
is measured as Metal's (MetalHalfQuantize).
A Converted module reads a half from its bits by the device's widening,
MoltenVK now included. The tests that held a NaN's bits there now accept
any NaN where the module records NativeHalfConversion: engine_access,
engine_half_moves, engine_typed_threadgroup and engine_texel_nans.
The integer conversion of an int to half, and the integer decode inside
loops and on profiles without shaderFloat16, stay: they have no native
form with a recorded bound.
Docs:
- FAST-PATHS.md: the three half_rounding rows are deleted.
- API.md: the degrade catalogue entries are rewritten without the
switch.
- HOWTO.md: the half paragraph is rewritten.
Tests: deleted the integer-form tests, and rewrote the engine_native_half
and engine_arith half-rounding tests to the device's forms.
SEMANTICS, ARTIFACT_FORMAT and RUNTIME versions were already bumped to
this lane's reserved numbers.
Verified:
- cargo clippy --workspace --all-targets --all-features -D warnings,
plain and with --cfg m2v_gpu: clean.
- cargo nextest over half, narrow, texel_round, lower::arith,
engine_arith, engine_sampler, engine_link, fast_paths, device::tests,
compile::fit, catalogue, degradation, fitted_variant_notice,
api_surface, engine_texture, lower::texture and engine_snapshot
(939 tests): the 11 failures were fixed, and the 161 tests they touch
re-run green.
* Take the device's float Fma for a half fused multiply-add
The owner's ruling is that the GPU's native arithmetic is promised, with
no exact emulation. Where neither MetalHalfFma (the device's 16-bit Fma
measured as Metal's) nor a 16-bit OpFmaKHR under the float controls is
offered, a half fused multiply-add used to call Route::HalfOdd. That is
the translation's round-to-odd routine of Metal's once-rounded answer;
off MoltenVK it was taken only under FloatMathsPolicy::Exact. It now
takes Route::Native under every policy: the device's float Fma, its
result rounded to half, noted NativeFma.
Removed: Route::HalfOdd, its census name (arith.fma.half), its define,
emit, words and routine arms, and half_form. Routine::words,
Routine::words_among and complete no longer take the quantize form, now
that no routine holds a half rounding. half_sum stays, since the
extended-range blend uses it.
Docs: the fma module docs, the narrow docs, NativeFma's and
DeviceSignedZeroInfNan's docs, their API.md catalogue entries, the
runtime NativeFma declaration, and the FAST-PATHS float-maths row's
mention of the half routine.
Tests:
- The HalfOdd rounding test becomes a test of the two 16-bit routes.
- The mix and dot half tests run through F16Khr.
- The route, words and lane-count tests drop HalfOdd.
- The engine_arith fma, zero-sign, chain and denormal-rounding tests
expect the inline device Fma, and NativeFma within one half ulp.
Verified:
- cargo clippy --workspace --all-targets --all-features -D warnings,
plain and with --cfg m2v_gpu: clean.
- RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features
--no-deps: clean.
- cargo nextest over lower::arith, engine_arith, engine_simd, engine_agx,
lower::sampler::face, fast_paths, catalogue, degradation, api_surface,
engine_native_half, engine_extended_range, fused and fma (938 tests):
935 passed. The three engine_arith failures were fixed, and
engine_arith re-ran 43 of 43 green.
* Bless the public signatures after the half switches' removal
These are the public items lane C's commits removed:
- HalfRoundingPolicy, HalfBlendPolicy and HalfTexelBitsPolicy, and
their variants;
- FramebufferFetchInputs::half_blends;
- metal::format::half_bits_read_view;
- DeviceProfile::reads_half_texel_bits;
- RuntimeFact::HalfBitsTexture.
RuntimeFact::ExactFormsOverCompilerLimit also loses its half_rounding,
half_blend and half_texel_bits flags.
docs/REFUSALS.md re-derives unchanged: no refusal changed.
Verified:
- signatures.py --check: clean.
- cargo nextest of api_signatures, api_surface, fast_paths, catalogue,
degradation, device::tests, compile::fit, fitted_variant_notice and
published_crates: 171 of 171 passed.
- scripts/api-docs: clean.
* Re-pin the runtime sources at the landing tip
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.
|
||
|
|
675a3ee122 |
Take sampled textures over host pages in place where the device's check passes
One work packet, landed as 2 commits (86ec320bae..8485bc6865 on archive/development-linear-2026-10-28), in order:
* Take sampled textures over host pages in place where the device's check passes
A 2D texture (or array) over host pages is now a linear image aliasing those pages, with no shadow,
when all of these hold:
- its declared usage only samples or reads it (no RenderTarget, ShaderWrite or ShaderAtomic);
- the pages are a no-copy buffer's, imported by their pointer or as dma-bufs, or a buffer the
runtime placed in fresh pages;
- a startup check shows that, on this device, the image's first move keeps every byte while the
CPU writes beside it.
Vulkan makes such an image start UNDEFINED (VUID-VkImageCreateInfo-pNext-01443) and lets the move
read and write every byte bound to it. Relying on the driver here, once checked, is the owner's
ruling ("In place, trusting the driver"): a deliberate, scoped exception, recorded in FAST-PATHS.
The switch is DevicePolicy::host_page_textures:
- HostPageTexturePolicy::InPlace is the default.
- HostPageTexturePolicy::Shadow is the exact form, which exact_answers() selects. Under it every
such texture stays a shadow and no check runs.
The check (in_place_check.rs):
- It runs on a thread of its own, started by the first texture that asks, per class of pages:
pointer imports, fresh pages and dma-buf imports. On a Unix target the dma-buf class uses an
exported allocation of the device's own.
- Each class tries 11 shapes, 3 rounds each, through the product's own Buffer::new_texture:
- packed rows of 1, 2, 4, 8 and 16-byte texels;
- rows with bytes between them, for the same texel sizes;
- one 3840x2160 surface.
A shape the device makes no image of is skipped, as the product makes none either.
- A writer thread writes the pattern's complement through texels, the bytes between rows and the
bytes after the image while the move runs. Every byte is then compared.
- The pattern is a 4099-byte prime period, so it lines up with no row, page or texel. The window
is filled by copies and compared written bytes first, then a period at a time. That makes the
33 MB surface cost about 11 ms a round in release.
The verdicts are kept as one record in the shader cache's content store:
- The record is named by vendor, device, driver ID, version, name and info, the UUID, the check's
kind and version, and RUNTIME_VERSION.
- It is checksummed. A bad, partial or other-version record counts as none: the check reruns and
overwrites it.
- With no cache directory, the check runs once per process.
- A forced failure (DeviceOptions::fail_in_place_check, a hidden test hook) keeps nothing.
Every texture that still takes a shadow announces why (shadowed-texture) and is counted by cause:
- the policy;
- usage that renders or writes;
- check pending, failed or unchecked;
- refused: rows, detached, image, pitch, placement, the dma-buf source, other dma-buf reasons.
WorkCounts also counts the in-place textures by class and pitched images, and the check's runs and
verdicts.
How an image in place is made, used and visible:
- Pointer and fresh pages take a linear image made for host allocations at Metal's pitch, or a
DRM_FORMAT_MOD_LINEAR image at an explicit pitch over the host allocation where the driver makes
one. Dma-buf pages take the modifier image over a dma-buf of the texture's own pages.
- A rebind remakes these images like the others.
- A write or pass beyond the declared usage goes through the existing usage shadow and attachment
stand-in.
- A CPU write reaches the image's commands as it reaches the buffer's (Host Write Ordering
Guarantees).
RUNTIME_VERSION 1643 -> 1644. The runtime-sources pin is left for the landing.
Check duration, Apple M3 Max on MoltenVK 1.4.2:
- 75-78 ms in release: Pointer and Fresh passed; DmaBuf unchecked, as there are no dma-bufs on
macOS.
- 1.76 s in a debug build.
- The first version took 4.1-4.2 s in debug, almost all of it the 3840x2160 shape's per-byte
hashed fill (240 ms) and compare (461 ms) per round, times 3 rounds and 2 classes; the GPU move
itself took 0.15-3 ms.
- Nothing was dropped from the check. The 64x64/256 shape became 64x16/256, and packed shapes of
each texel size were added, because MoltenVK takes no padded pitch: the first version made only
4-byte images there.
Verified on the M3 Max (debug lanes, --cfg m2v_gpu):
- in_place_textures, all five tests:
- the path follows the check, and an event-held CPU write after the commit is read;
- a kernel write and a pass beyond the usage go through their shadows and keep the image;
- a forced failure keeps the shadow and no record; the next device runs the check, and the one
after recalls three verdicts and checks nothing;
- the costs.
- first_use_writes under both settings: 1920x1080/7680 in place, 0 of 542 writes undone.
- no_copy_textures read/write under both settings: ShaderRead-only textures in place at packed
rows, the rest shadows.
- pitched_surfaces, including the new _in_place variants of the only-reads and read-only-pages
tests.
- The runtime and translator suites passed (4971 tests), with clippy plain and under --cfg m2v_gpu.
Cost on the M3 Max, release, median GPU time per command buffer, in place against shadow:
- 3840x2160, one pass reading a 32-row strip: 492 against 553 us.
- 1920x1080 strip: 457 against 452 us.
- 1920x1080 whole: 393 against 466 us.
- 1920x1080, three whole passes: 566 against 545 us.
Untested here: RADV, lavapipe and the dma-buf class, which follow; ANV and NVIDIA have no venue
now.
* Re-pin the runtime sources at the landing tip
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.
|
||
|
|
a73af4db0b |
Keep one driver pipeline cache per record, named by what converts a stage
The steps this packet landed as, in order: - Read the records lane's files only once the device that wrote them is gone Content: the tree of `development` at fdf4232b79, unchanged. |