summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c/pr36802-2.c
blob: 06e792f0f14da3ec63ba37d91338f9cc8bc80d62 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* PR middle-end/36802 */

extern void abort (void);

int q;

int
foo (int k)
{
  int i = 6, n = 0;
  omp_set_dynamic (0);
  omp_set_nested (1);
#pragma omp parallel shared (i) num_threads (3)
  {
    int l;

    if (omp_get_num_threads () != 3)
    #pragma omp atomic
      n += 1;
    else
    #pragma omp for
      for (l = 0; l < 3; l++)
	if (k)
	#pragma omp atomic
	  q += i;
	else
	#pragma omp parallel shared (i) num_threads (4)
	  {
	    if (omp_get_num_threads () != 4)
	    #pragma omp atomic
	      n += 1;
	    #pragma omp critical
	      i += 1;
	  }
  }
  if (n == 0 && i != 6 + 3 * 4)
    abort ();
  return 0;
}

int
main (void)
{
  foo (0);
  return 0;
}