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 
7 #include <cassert>
8 #include <iostream>
9 
10 void work(int *C) {
11 #pragma omp atomic
12   ++(*C);
13 }
14 
15 void use(int *C) {
16 #pragma omp parallel num_threads(2)
17   work(C);
18 }
19 
20 int main() {
21   int C = 0;
22 #pragma omp target map(C)
23   {
24     use(&C);
25 #pragma omp parallel num_threads(2)
26     use(&C);
27   }
28 
29   assert(C >= 2 && C <= 6);
30 
31   std::cout << "PASS\n";
32 
33   return 0;
34 }
35 
36 // CHECK: PASS
37