summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/nested-1.C
blob: 8d0e397bd2e628526575b6bd322b4b0a5fc7b1b7 (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 "C" 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;
}