| 1 |
#include <gpuintrin.h> |
| 2 |
#include <stdint.h> |
| 3 |
|
| 4 |
extern "C" { |
| 5 |
|
| 6 |
uint32_t global[64]; |
| 7 |
|
| 8 |
[[gnu::constructor(202)]] void ctorc() { |
| 9 |
for (unsigned I = 0; I < 64; I++) |
| 10 |
global[I] += 20; |
| 11 |
} |
| 12 |
|
| 13 |
[[gnu::constructor(200)]] void ctora() { |
| 14 |
for (unsigned I = 0; I < 64; I++) |
| 15 |
global[I] = 40; |
| 16 |
} |
| 17 |
|
| 18 |
[[gnu::constructor(201)]] void ctorb() { |
| 19 |
for (unsigned I = 0; I < 64; I++) |
| 20 |
global[I] *= 2; |
| 21 |
} |
| 22 |
|
| 23 |
__gpu_kernel void global_ctor(uint32_t *out) { |
| 24 |
global[__gpu_thread_id(0)] += __gpu_thread_id(0); |
| 25 |
out[__gpu_thread_id(0) + (__gpu_num_threads(0) * __gpu_block_id(0))] = |
| 26 |
global[__gpu_thread_id(0)]; |
| 27 |
} |
| 28 |
} // extern "C" |