Translator tests: an OpenCL-mode simdgroup barrier keeps Metal's flags
The OpenCL-mode reading of barrier flags (canon::opencl::barriers) takes air.wg.barrier alone. Of the canonicalization passes that run before it, only async_copy writes a barrier, and that barrier is air.simdgroup.barrier with Metal's mem_threadgroup: its simdgroup_barrier writes one name only, NAME = "air.simdgroup.barrier" (async_copy.rs, at line 295). No canon pass writes air.wg.barrier, none expands wait_group_events or async_work_group_copy, and the OpenCL work-item, image and hidden-buffer rewrites write loads, arithmetic, selects and texture calls. The lockstep pass writes air.wg.barrier (lower/simd/lockstep.rs, at line 1149), but it is lowering's and runs after specialization. This test pins the half of that the pass decides: a kernel's air.simdgroup.barrier(mem_threadgroup) orders threadgroup memory alone (WorkgroupMemory) in OpenCL mode and without it, on the 780M's profile under the runtime's policy. If the pass took simdgroup barriers, OpenCL mode would read 2 as CLK_GLOBAL_MEM_FENCE and the test would see UniformMemory.
This commit is contained in:
1 parent
e6f2606842
commit
578f8c9df5
1 file changed
+30
@@ -1008,3 +1008,33 @@ fn an_opencl_mode_barrier_of_a_flag_opencl_does_not_name_is_refused() {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// In OpenCL mode an `air.simdgroup.barrier` keeps Metal's flags: Apple's `cl_kernel.h` declares no
|
||||
/// barrier of a simdgroup on `cl_mem_fence_flags`, and the simdgroup barrier canonicalization
|
||||
/// writes itself (an asynchronous copy's wait, `mem_threadgroup`) is Metal's. `mem_threadgroup`
|
||||
/// (2) orders threadgroup memory (`WorkgroupMemory`) alone in both modes, on the 780M's profile
|
||||
/// under the runtime's policy.
|
||||
#[test]
|
||||
fn an_opencl_mode_simdgroup_barrier_keeps_metals_flags() {
|
||||
let b = Budget::standard();
|
||||
let (_, dev) = (runtime_devices().into_iter())
|
||||
.find(|(stem, _)| stem == "amd-780m-radv")
|
||||
.expect("the 780M's profile");
|
||||
let calls = " tail call void @air.simdgroup.barrier(i32 2, i32 4) #5\n";
|
||||
let defs = "declare void @air.simdgroup.barrier(i32, i32) #5\n";
|
||||
let Some(k) = function(&barrier_kernel(calls, defs), "__entry_b") else {
|
||||
return;
|
||||
};
|
||||
for open_cl_mode in [true, false] {
|
||||
let p = dev
|
||||
.compile_compute_pipeline(
|
||||
&descriptor(StageSource::Function(k.clone()), open_cl_mode),
|
||||
&b,
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("OpenCL mode {open_cl_mode}: {e}"));
|
||||
let storage: Vec<u32> = (control_barriers(&p.stage.spirv).into_iter())
|
||||
.map(|(_, _, storage, _)| storage)
|
||||
.collect();
|
||||
assert_eq!(storage, [0x100], "OpenCL mode {open_cl_mode}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user