From 30732306642b842337d4ca62d20b02d66d1cff4e Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Mon, 23 Nov 2026 20:41:18 -0800 Subject: [PATCH] Tests: the flat-grid guard's arms store to a buffer of their own The guard's kernel stored its arms' values at b0[p + 4096] and the shuffle's result at b0[p]. With that store the kernel observes its threadgroup partition, so its flat variant of the call's threadgroups is refused on every committed and derived profile (Unsupported{GpuEncodedIndirectCommands, NotRepresentable}, the partition gate in pipeline/compile.rs; m3-max-72860 listed all 45). No flat module reached the comparison, so the guard failed its final count at the fix and at the parent alike (m3-max-72826). The arms now store to b1[p], a second buffer parameter, which the lockstep analysis takes as an object apart from b0. The shuffle still follows the merge of the parity selection. Verified: cargo fmt only; the diagnostic and the check job follow. --- .../src/tests/engine_variant_reconvergence.rs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/crates/metal2vulkan/src/tests/engine_variant_reconvergence.rs b/crates/metal2vulkan/src/tests/engine_variant_reconvergence.rs index 13bc9ab25..f1deca8ed 100644 --- a/crates/metal2vulkan/src/tests/engine_variant_reconvergence.rs +++ b/crates/metal2vulkan/src/tests/engine_variant_reconvergence.rs @@ -34,18 +34,20 @@ use crate::pipeline::testing::{ }; use crate::spirv::testing::{committed_descriptions, committed_profiles, spirv_dis}; -/// `k(b0, p, l)`: each thread stores 1 or 2 at `b0[p + 4096]` by its parity, then, past the merge -/// of that selection, the shuffle of the stored value from lane 0 plus its lane `l` at `b0[p]`; -/// `p` is its position in the grid, `l` its index in its simdgroup. The shuffle stands in a block -/// every thread runs together. -const AFTER_MERGE: &str = r#"define void @k(ptr addrspace(1) noundef "air-buffer-no-alias" %b0, i32 noundef %p, i32 noundef %l) { +/// `k(b0, b1, p, l)`: each thread stores 1 or 2 at `b1[p]` by its parity, then, past the merge of +/// that selection, the shuffle of the stored value from lane 0 plus its lane `l` at `b0[p]`; `p` +/// is its position in the grid, `l` its index in its simdgroup. The shuffle stands in a block +/// every thread runs together. The arms store to a buffer of their own, an object apart from `b0` +/// for the lockstep analysis (`lower::simd::lockstep`): with their store at `b0[p + 4096]` the +/// kernel observes its threadgroup partition, and its flat variant is +/// `Unsupported{GpuEncodedIndirectCommands, NotRepresentable}` on every committed profile. +const AFTER_MERGE: &str = r#"define void @k(ptr addrspace(1) noundef "air-buffer-no-alias" %b0, ptr addrspace(1) noundef "air-buffer-no-alias" %b1, i32 noundef %p, i32 noundef %l) { entry: %odd = and i32 %p, 1 %d = icmp eq i32 %odd, 0 %i = zext i32 %p to i64 %o = getelementptr inbounds i32, ptr addrspace(1) %b0, i64 %i - %j = add i64 %i, 4096 - %q = getelementptr inbounds i32, ptr addrspace(1) %b0, i64 %j + %q = getelementptr inbounds i32, ptr addrspace(1) %b1, i64 %i br i1 %d, label %a, label %b a: @@ -71,10 +73,11 @@ declare i32 @air.simd_shuffle.u.i32(i32, i16) !air.language_version = !{!21} !0 = !{ptr @k, !1, !2} !1 = !{} -!2 = !{!3, !4, !5} +!2 = !{!3, !6, !4, !5} !3 = !{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"b0"} -!4 = !{i32 1, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"p"} -!5 = !{i32 2, !"air.thread_index_in_simdgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"l"} +!6 = !{i32 1, !"air.buffer", !"air.location_index", i32 1, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"b1"} +!4 = !{i32 2, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"p"} +!5 = !{i32 3, !"air.thread_index_in_simdgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"l"} !20 = !{i32 2, i32 8, i32 0} !21 = !{!"Metal", i32 4, i32 0, i32 0} "#;