From efd7dbcd4db02a867e97ee1020855b2509c56a58 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 25 Nov 2026 14:23:50 -0800 Subject: [PATCH] AGENTS.md: rule 2's eleventh form, Shared memory's host coherence, with its known gap The owner chose this form, Telegram 2963, verbatim: "Correction, a-narrow sorry". That answers the planner's question whose A-narrow option named the eleventh form; it replaces 2961. This commit lands with the form's code (the commits before it), so development never holds the form without its rule. AGENTS.md, rule 2 only: "for ten only" becomes "for eleven only", the list's final "and" moves before the new entry, and the entry names the query (the host-coherent flag of the memory type Shared takes), the second form (on the cached type without coherence, what is flushed before the GPU reads it and what is flushed then invalidated before the host reads it), and its known gap (no device the tests run on shows a missed range; the flush's cost grows with the Shared bytes a submission reaches). The planner accepted the wording with two changes, both applied. Nothing else in AGENTS.md changes. crates/metal2vulkan-runtime/README.md, the known gaps of memory blocks: a submission's flush names every Shared range its command buffers reach, written or not, merged, so its cost grows with the Shared bytes a submission reaches, not with what its commands wrote. The cost on devices whose Shared type is host-coherent, as measured at 890f6580ac against development 8f74582eb3, three alternated passes, each job alone on its node: 74045, Radeon RX 7900 XTX: every row passes, +43.1 user-space instructions per command buffer on burst_2000; 74046, Radeon 780M: burst_2000 1.0062 (+152.1 per command buffer) and frame_5cb 1.0115, a loss by the planner's reading rule; +2 instructions per draw, 0 per dispatch, on both. The form lands on the owner's word with those figures before him. Checks: cargo fmt. The prose matches the code (coherence.rs, submit.rs, texture.rs, fill.rs, command.rs, complete.rs, event.rs). docs/REFUSALS.md and error/basis.rs are unchanged under refusal_surface.py. The quick and suites checks run at the rebased tip. --- AGENTS.md | 16 +++++++++++++--- crates/metal2vulkan-runtime/README.md | 22 ++++++++++++---------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a9c39c629..42022167f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -58,7 +58,7 @@ order, and a lower one never overrides a higher one. limit and memory-type queries. Product code holds no vendor, device or driver ID, and no runtime policy switch. A test enforces this for `metal2vulkan-runtime`. One form means one form per Vulkan capability: where the floor cannot require a feature, that feature's query may choose a - second form, for ten only: 16-bit floats, storage-image reads without a format, 64-bit + second form, for eleven only: 16-bit floats, storage-image reads without a format, 64-bit atomics, 64-bit floats, SIMD groups (the subgroup size range with its stages and operations, and maximal reconvergence), unified memory (decided by Vulkan's physical device type alone: one copy of a Managed buffer on an integrated or CPU @@ -69,14 +69,24 @@ order, and a lower one never overrides a higher one. that branch's compile time is recorded as a known gap), the push window (the device's push-constant limit sizes it, up to 256 bytes; on a device below 256 the fields past the window come from the stage's parameter block, and an indirect command carries fewer vertex slots, - recorded as a known gap), and fragment stencil output (a device with + recorded as a known gap), fragment stencil output (a device with VK_EXT_shader_stencil_export writes a fragment function's [[stencil]] as the fragment's stencil reference; a device without it draws each draw of such a pipeline once with a stencil reference of 0, which clears the stencil bits its depth-stencil state can replace and runs its other stencil operations, then once for each of those bits, and, where the draw writes depth under a depth compare other than always or never, once more for the depth; those draws, and the note that fragments of one draw that overlap leave the OR of their values, are recorded as a known - gap). A second form chosen by anything else is not allowed. + gap), and Shared memory's host coherence (decided by the host-coherent flag of the memory type + Shared takes, the first host-visible, host-cached type a buffer can use, a host-coherent one + first: a device whose type has it makes no flush or invalidate call; on a device whose type is + the cached type without coherence, the Shared memory a submission's command buffers and Managed + copy-ins reach, and the runtime's own writes to Shared memory, are flushed before the GPU reads + them, and the Shared memory a command buffer may write, and the bytes a copy stages for the + host, are flushed then invalidated before the host reads them, at the command buffer's + completion and before a shared event's value that a GPU signal raised is seen; that no device + the tests run on shows a missed range, since each has a host-coherent cached type, and that the + flush's cost grows with the Shared bytes a submission reaches, are recorded as a known gap). A + second form chosen by anything else is not allowed. 3. **Native-like speed.** Structure decides speed: driver-owned memory, optimal images in real layouts, direct addresses, nothing copied that Metal would not copy. Optimal images have two exceptions. A texture over a Shared buffer: a linear image on that buffer's memory, in the diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index a1045281e..89b097c86 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -1034,16 +1034,18 @@ the Direct3D 11 texture's payload until it is freed. ### Known gaps of memory blocks -- On a device whose Shared type is not host-coherent (Shared memory's coherence), the flushes - and invalidates are that device's cost: before each submission over what its command buffers - reach, and at each completion and each shared event's GPU-raised value seen over what they may - write, on the submit and completion threads and in the calls that read an event's value. Every - device of ours has a host-visible, host-coherent, host-cached type, which Shared takes, so none - makes these calls, and none can show a flush the runtime missed: only a device whose Shared - type is cached and not coherent can. The device tests run the calls on our devices through a - view that reads their cached types as not coherent (`--cfg m2v_shared_view`, - docs/VALIDATION.md), on memory that is coherent in fact; neither the calls' time nor their - effect has been measured on a device whose memory is not. +- On a device whose Shared type is not host-coherent (Shared memory's coherence), the flushes and + invalidates are that device's cost: before each submission over what its command buffers reach, + and at each completion and each shared event's GPU-raised value seen over what they may write, on + the submit and completion threads and in the calls that read an event's value. A submission's + flush names every Shared range its command buffers reach, written or not, merged, so its cost + grows with the Shared bytes a submission reaches, not with what its commands wrote. Every device + of ours has a host-visible, host-coherent, host-cached type, which Shared takes, so none makes + these calls, and none can show a flush the runtime missed: only a device whose Shared type is + cached and not coherent can. The device tests run the calls on our devices through a view that + reads their cached types as not coherent (`--cfg m2v_shared_view`, docs/VALIDATION.md), on memory + that is coherent in fact; neither the calls' time nor their effect has been measured on a device + whose memory is not. - On such a device, a host write to a range a command buffer may write, made while the command buffer runs, may be lost, and so may the GPU's writes to the same atoms. The runtime flushes each such range just before it invalidates it, and Vulkan states: "If a range of non-coherent