Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / api / ompx_sync.cpp
blobc6e17103459d08b5af224210efa39fac3ab0c536
1 // RUN: %libomptarget-compilexx-run-and-check-generic
3 #include <omp.h>
4 #include <ompx.h>
5 #include <stdio.h>
7 void foo(int device) {
8 int X;
9 // clang-format off
10 #pragma omp target teams map(from: X) device(device) thread_limit(2) num_teams(1)
11 #pragma omp parallel
12 // clang-format on
14 int tid = ompx::thread_id_x();
15 int bid = ompx::block_id_x();
16 if (tid == 1 && bid == 0) {
17 X = 42;
18 ompx::sync_block_divergent(3);
19 } else {
20 ompx::sync_block_divergent();
22 if (tid == 0 && bid == 0)
23 X++;
24 ompx::sync_block(ompx::seq_cst);
25 if (tid == 1 && bid == 0)
26 X++;
27 ompx::sync_block();
28 if (tid == 0 && bid == 0)
29 X++;
30 ompx_sync_block(ompx_release);
31 if (tid == 0 && bid == 0)
32 X++;
34 // CHECK: X: 46
35 // CHECK: X: 46
36 printf("X: %i\n", X);
39 int main() {
40 foo(omp_get_default_device());
41 foo(omp_get_initial_device());