Files
metal2vulkan/docs
Anees Iqbal 9f3dc79994 A Managed buffer's named range is copied in by the GPU as the submission runs, by default
What: DevicePolicy gains managed_copy_in (ManagedCopyInPolicy, a runtime
choice no profile carries). Under the default, AtSubmission, a commit that
takes a did_modify_range's range has the GPU copy it from the host copy (the
import of the caller's pages, or the runtime's own host-cached memory) into the
device copy as the submission runs (Buffer::upload), with no CPU copy and no
staging. Pages no import maps are still staged by the CPU at the commit. Under
AtCommit, which exact_answers() selects, the commit copies the range on the
CPU as the host copy holds it then (the RV2145 snapshot, Buffer::upload_now,
now upload_at_commit). Staging buffers of both directions are now Shared in
the default CPU cache mode, host-cached system memory, never the device-local
(BAR) memory a write-combined buffer prefers without unified memory, and of
power-of-two lengths (64 KiB at least), so a like-sized later copy takes a
buffer the recycler parked rather than new memory.

The ledger gets its row (the bound: a CPU write after the commit, before the
GPU runs the command buffer, may be read), and managed.rs, managed_copy.rs,
API.md's accepted difference, the runtime README, FAST-PATHS' costs bullet and
the conformance crate's Policy::Exact say so. tests::fast_paths names the
choice and checks it keys no profile and that exact_answers() takes AtCommit.
The named-rounds race tests take the policy: by default each round reads, in
each byte, its own byte or one the CPU wrote to its buffer after its commit
(0xee, a later round's), never an earlier round's; under AtCommit only its
own; three AtCommit tests join the three default ones. The lane test's step 4
reads either oracle's answer by default and the 5300M's under AtCommit
(exact_answers_take_a_did_modify_range_at_the_commit).

Why: a compute benchmark's commits spent most of their time in this copy on a
discrete GPU (a CPU memcpy into write-combined staging in BAR across an eGPU
link, fresh 32 MiB chunks each time). The oracles differ on the bytes after
the commit (5300M A,B,B,A,B; UHD 630 A,B,B,B,B), so the cheaper answer is the
default and the snapshot stays behind the switch (AGENTS.md rule 1).

Verified: jobs in the report (lint both cfgs, the translator's fast_paths, the
runtime suite on lavapipe, managed_copy_device and the lane test on the RTX
3090 and the RX 7900 XTX, and the copy-in bench there before and after).
2026-11-12 23:57:16 -08:00
..