xref: /llvm-project/offload/test/offloading/bug51982.c (revision dcc27ea41ebc7244a10f15114f60f5e8d6b93b34)
1 // RUN: %libomptarget-compile-generic -O2 && %libomptarget-run-generic
2 // -O2 to run openmp-opt
3 // RUN: %libomptarget-compileopt-generic -O2 && %libomptarget-run-generic
4 
5 int main(void) {
6   long int aa = 0;
7 
8   int ng = 12;
9   int nxyz = 5;
10 
11   const long exp = ng * nxyz;
12 
13 #pragma omp target map(tofrom : aa)
14   for (int gid = 0; gid < nxyz; gid++) {
15 #pragma omp parallel for
16     for (unsigned int g = 0; g < ng; g++) {
17 #pragma omp atomic
18       aa += 1;
19     }
20   }
21   if (aa != exp) {
22     return 1;
23   }
24   return 0;
25 }
26