1 // RUN: %libomptarget-compilexx-run-and-check-generic 2 3 #include <omp.h> 4 #include <ompx.h> 5 #include <stdio.h> 6 foo(int device)7void 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(); 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(); 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("X: %i\n", X); 37 } 38 main()39int main() { 40 foo(omp_get_default_device()); 41 foo(omp_get_initial_device()); 42 } 43