From 01ed021d532e0136c2ebd453fbff8616bf3cd30f Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 2 Dec 2026 03:19:08 -0800 Subject: [PATCH] Translator tests: a direct access's instruction bounds are PR 22's carry form's measured cost engine_access_size::a_device_access_of_whole_words_is_one_access held a direct access to the old form's cost: a 64-bit add of the slot's base and the zero-extended biased offset. PR 22 replaced that add with an OpIAddCarry on the low word and a carry into the high word, because AMD's Windows driver folded the biased offset's 2^31 into a sign-extended 64-bit immediate and read 4 GiB below the buffer. The structural pass (e2e76d8879) made the base and the slot's address once per slot; the per-access remainder is the carry. The bounds move to the measured cost, never rounded up: float4 load at a uint offset 16 -> 19 float4 store at a uint offset 16 -> 19 float4 load at a float4 offset 16 -> 18 pointer chase 24 -> 22 (the pass took it below the old form) The loss, as measured: - On a device that takes compute buffers by address (lavapipe, a states-only play of 25,942 states, refused 0 in both forms; m3-max-77799, a b a b): SPIR-V +7.0% (largest entry +6.2%), driver compile +5.1% (same-arm spread 1.1% and 2.6%), translation +0.7%, pipeline-make time +1.6%, play wall +0.8%. - One translation by the compile worker's counting allocator (corpus-pipeline --compile-only, lavapipe; m3-max-77820, m3-max-77825): the corpus's largest row by allocator peak, 184,135,107 bytes in both forms (PR 22 does not reach it); its largest by SPIR-V output, 62,572 -> 62,894 words and 2,905,472 -> 2,921,373 bytes (+0.5%), 11 ms in both. - Runtime GPU time of the frames (a b a b, one job per card): XTX +0.09% (m3-max-77764). RTX 3090 (gem10, in a Thunderbolt enclosure): m3-max-77854 not resolved, its arms at unequal clocks (one b play 81 samples at P8 210 MHz against 50 and 51, wall 144.4 s against 133.7-137.9 s); m3-max-77895, both pairs counted (P8 samples 109/109 and 108/103), +1.90% and -2.72%, means -0.44%: inside. The +0.21% at 2f5f35ca47 on that card was before it moved hosts and is not a before-run. Iris Xe: no loss shown, 3% not resolved by this measure there (pair spread 7.8% and 11.3%). The carry form is unverified in the lab on the driver it fixes: no lab device runs AMD's Windows driver; only the contributor's run (RX 6950 XT and an integrated Radeon, driver 26.11.2, offsets 0 and 256) covers it. A cheaper form for constant offsets was not taken for that reason; the cost is a no-lane row that reopens on a venue running that driver or a pipeline-make cost of 5% or more on a real device that takes buffers by address. Verified: the measured values are m3-max-77757's size table at e2e76d8879 (no translator change since); this commit's test runs in the merge check next. --- crates/metal2vulkan/src/tests/engine_access_size.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/metal2vulkan/src/tests/engine_access_size.rs b/crates/metal2vulkan/src/tests/engine_access_size.rs index be6f653fb..f8ab3d929 100644 --- a/crates/metal2vulkan/src/tests/engine_access_size.rs +++ b/crates/metal2vulkan/src/tests/engine_access_size.rs @@ -105,7 +105,7 @@ const SHAPES: &[Shape] = &[ }, value: Some(("float", "fadd")), accesses: 2, - bound: 24, + bound: 22, }, Shape { name: "float4 load at a uint offset", @@ -117,7 +117,7 @@ const SHAPES: &[Shape] = &[ }, value: Some(("<4 x float>", "fadd")), accesses: 1, - bound: 16, + bound: 19, }, Shape { name: "float4 store at a uint offset", @@ -129,7 +129,7 @@ const SHAPES: &[Shape] = &[ }, value: None, accesses: 1, - bound: 16, + bound: 19, }, Shape { name: "float4 load at a float4 offset", @@ -141,7 +141,7 @@ const SHAPES: &[Shape] = &[ }, value: Some(("<4 x float>", "fadd")), accesses: 1, - bound: 16, + bound: 18, }, ];