1 // RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu
2 // RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu
3 // RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu
4 // RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu
5 // RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
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