| 1 |
#pragma clang diagnostic ignored "-Wmissing-prototypes" |
| 2 |
|
| 3 |
#include <metal_stdlib> |
| 4 |
#include <simd/simd.h> |
| 5 |
|
| 6 |
using namespace metal; |
| 7 |
|
| 8 |
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); |
| 9 |
|
| 10 |
static inline __attribute__((always_inline)) |
| 11 |
void set_f(thread int& f) |
| 12 |
{ |
| 13 |
f = 40; |
| 14 |
} |
| 15 |
|
| 16 |
static inline __attribute__((always_inline)) |
| 17 |
void set_shared_u(threadgroup int& u) |
| 18 |
{ |
| 19 |
u = 50; |
| 20 |
} |
| 21 |
|
| 22 |
kernel void main0(uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) |
| 23 |
{ |
| 24 |
threadgroup int u; |
| 25 |
int f; |
| 26 |
set_f(f); |
| 27 |
set_shared_u(u); |
| 28 |
if (gl_LocalInvocationIndex == 0u) |
| 29 |
{ |
| 30 |
f = 10; |
| 31 |
} |
| 32 |
else |
| 33 |
{ |
| 34 |
f = 30; |
| 35 |
u = 20; |
| 36 |
} |
| 37 |
} |
| 38 |
|