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