1 | // RUN: %libomptarget-compile-run-and-check-generic |
---|---|
2 | |
3 | #include <omp.h> |
4 | #include <ompx.h> |
5 | #include <stdio.h> |
6 | |
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 |
13 | { |
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(1); |
21 | } |
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_acq_rel(); |
28 | if (tid == 0 && bid == 0) |
29 | X++; |
30 | ompx_sync_block(ompx_release); |
31 | if (tid == 0 && bid == 0) |
32 | X++; |
33 | } |
34 | // CHECK: X: 46 |
35 | // CHECK: X: 46 |
36 | printf(format: "X: %i\n", X); |
37 | } |
38 | |
39 | int main() { |
40 | foo(device: omp_get_default_device()); |
41 | foo(device: omp_get_initial_device()); |
42 | } |
43 |