Daily bump.
[official-gcc.git] / libgomp / testsuite / libgomp.c / reduction-15.c
blob50f7e2422cad74e9a0839dfaa13ba332cc07a446
1 extern void abort (void);
2 int a[16], b[16], c[16], d[5][2];
4 __attribute__((noinline, noclone)) void
5 foo (int x, int y)
7 int i;
8 #pragma omp for schedule (static, 1) reduction (+:a[:3])
9 for (i = 0; i < 64; i++)
11 a[0] += i;
12 a[1] += 2 * i;
13 a[2] += 3 * i;
15 #pragma omp for schedule (guided) reduction (+:b[4:3])
16 for (i = 0; i < 64; i++)
18 b[4] += i;
19 b[5] += 2 * i;
20 b[6] += 3 * i;
22 #pragma omp for schedule (static) reduction (+:c[x:4])
23 for (i = 0; i < 64; i++)
25 c[9] += i;
26 c[10] += 2 * i;
27 c[11] += 3 * i;
28 c[12] += 4 * i;
30 #pragma omp for reduction (+:d[x - 8:2][y:])
31 for (i = 0; i < 64; i++)
33 d[1][0] += i;
34 d[1][1] += 2 * i;
35 d[2][0] += 3 * i;
36 d[2][1] += 4 * i;
40 int
41 main ()
43 int i;
44 #pragma omp parallel
45 foo (9, 0);
46 for (i = 0; i < 16; i++)
47 if (a[i] != (i < 3 ? 64 * 63 / 2 * (i + 1) : 0)
48 || b[i] != ((i >= 4 && i < 7) ? 64 * 63 / 2 * (i - 3) : 0)
49 || c[i] != ((i >= 9 && i < 13) ? 64 * 63 / 2 * (i - 8) : 0))
50 abort ();
51 for (i = 0; i < 5; i++)
52 if (d[i][0] != ((i && i <= 2) ? 64 * 63 / 2 * (2 * i - 1) : 0)
53 || d[i][1] != ((i && i <= 2) ? 64 * 63 / 2 * (2 * i) : 0))
54 abort ();
55 return 0;