summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c/pr39591-3.c
blob: a9aeea7c83ad488f46451dd0e9fbcee66336dbf1 (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
/* PR other/39591 */
/* { dg-do run } */
/* { dg-options "-O2" } */

extern void abort (void);

int err, a[40];

void __attribute__((noinline))
foo (int *array)
{
#pragma omp task
  {
    int j;
    for (j = 0; j < sizeof array / sizeof array[0]; j++)
      if (array[j] != 0x55555555)
#pragma omp atomic
	err++;
  }
}

int
main (void)
{
  int k;
  for (k = 0; k < sizeof a / sizeof a[0]; k++)
    a[k] = 0x55555555;

#pragma omp parallel
  {
    int i;

#pragma omp for schedule (dynamic)
    for (i = 0; i < 50; i++)
      foo (a);
  }
  if (err)
    abort ();
  return 0;
}