1 // RUN: %libomptarget-compilexx-generic && \ 2 // RUN: env LIBOMPTARGET_STACK_SIZE=2048 %libomptarget-run-generic 3 // RUN: %libomptarget-compileoptxx-generic && \ 4 // RUN: env LIBOMPTARGET_STACK_SIZE=2048 %libomptarget-run-generic 5 6 // We need malloc/global_alloc support 7 // UNSUPPORTED: amdgcn-amd-amdhsa 8 9 #include <cassert> 10 #include <iostream> 11 work(int * C)12void work(int *C) { 13 #pragma omp atomic 14 ++(*C); 15 } 16 use(int * C)17void use(int *C) { 18 #pragma omp parallel num_threads(2) 19 work(C); 20 } 21 main()22int main() { 23 int C = 0; 24 #pragma omp target map(C) 25 { 26 use(&C); 27 #pragma omp parallel num_threads(2) 28 use(&C); 29 } 30 31 assert(C >= 2 && C <= 6); 32 33 std::cout << "PASS\n"; 34 35 return 0; 36 } 37 38 // CHECK: PASS 39