|
| 1 | +// language: metal1.0 |
| 2 | +#include <metal_stdlib> |
| 3 | +#include <simd/simd.h> |
| 4 | + |
| 5 | +using metal::uint; |
| 6 | + |
| 7 | + |
| 8 | +struct test_atomic_workgroup_uniform_loadInput { |
| 9 | +}; |
| 10 | +kernel void test_atomic_workgroup_uniform_load( |
| 11 | + metal::uint3 workgroup_id [[threadgroup_position_in_grid]] |
| 12 | +, metal::uint3 local_id [[thread_position_in_threadgroup]] |
| 13 | +, threadgroup metal::atomic_uint& wg_scalar |
| 14 | +, threadgroup metal::atomic_int& wg_signed |
| 15 | +) { |
| 16 | + if (metal::all(local_id == metal::uint3(0u))) { |
| 17 | + metal::atomic_store_explicit(&wg_scalar, 0, metal::memory_order_relaxed); |
| 18 | + metal::atomic_store_explicit(&wg_signed, 0, metal::memory_order_relaxed); |
| 19 | + } |
| 20 | + metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup); |
| 21 | + bool local = {}; |
| 22 | + uint active_tile_index = workgroup_id.x + (workgroup_id.y * 32768u); |
| 23 | + uint _e11 = metal::atomic_fetch_or_explicit(&wg_scalar, static_cast<uint>(active_tile_index >= 64u), metal::memory_order_relaxed); |
| 24 | + int _e14 = metal::atomic_fetch_add_explicit(&wg_signed, 1, metal::memory_order_relaxed); |
| 25 | + metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup); |
| 26 | + metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup); |
| 27 | + uint unnamed = metal::atomic_load_explicit(&wg_scalar, metal::memory_order_relaxed); |
| 28 | + metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup); |
| 29 | + metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup); |
| 30 | + int unnamed_1 = metal::atomic_load_explicit(&wg_signed, metal::memory_order_relaxed); |
| 31 | + metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup); |
| 32 | + if (unnamed == 0u) { |
| 33 | + local = unnamed_1 > 0; |
| 34 | + } else { |
| 35 | + local = false; |
| 36 | + } |
| 37 | + bool _e26 = local; |
| 38 | + if (_e26) { |
| 39 | + return; |
| 40 | + } else { |
| 41 | + return; |
| 42 | + } |
| 43 | +} |
0 commit comments