summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c/omp-nested-1.c
blob: 655ef26fa8c8cc2767d2b4afb347e11fadea27e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// { dg-do run }

extern void abort(void);
#define N 1000

int foo()
{
  int i = 0, j;

  #pragma omp parallel for num_threads(2) shared (i)
  for (j = 0; j < N; ++j)
    {
      #pragma omp parallel num_threads(1) shared (i)
      {
	#pragma omp atomic
	i++;
      }
    }

  return i;
}

int main()
{
  if (foo() != N)
    abort ();
  return 0;
}