Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / offloading / ompx_bare_ballot_sync.c
blob101d1255f0d67077f71643fb69579d893980299e
1 // RUN: %libomptarget-compilexx-run-and-check-generic
2 //
3 // REQUIRES: gpu
5 #include <assert.h>
6 #include <ompx.h>
7 #include <stdint.h>
8 #include <stdio.h>
9 #include <stdlib.h>
11 int main(int argc, char *argv[]) {
12 const int num_blocks = 1;
13 const int block_size = 256;
14 const int N = num_blocks * block_size;
15 int *res = (int *)malloc(N * sizeof(int));
17 #pragma omp target teams ompx_bare num_teams(num_blocks) thread_limit(block_size) \
18 map(from: res[0:N])
20 int tid = ompx_thread_id_x();
21 uint64_t mask = ompx_ballot_sync(~0LU, tid & 0x1);
22 #if defined __AMDGCN_WAVEFRONT_SIZE && __AMDGCN_WAVEFRONT_SIZE == 64
23 res[tid] = mask == 0xaaaaaaaaaaaaaaaa;
24 #else
25 res[tid] = mask == 0xaaaaaaaa;
26 #endif
29 for (int i = 0; i < N; ++i)
30 assert(res[i]);
32 // CHECK: PASS
33 printf("PASS\n");
35 free(res);
37 return 0;