Merge from mainline
[official-gcc.git] / libgomp / testsuite / libgomp.c / reduction-4.c
blob23e9d6d5bda819eb98887070257112fbf54116f7
1 #include <omp.h>
2 #include <stdlib.h>
4 int
5 main (void)
7 int i = 0, j = 0, k = 0, l = 0;
8 #pragma omp parallel num_threads(4) reduction(-:i) reduction(|:k) \
9 reduction(^:l)
11 if (i != 0 || k != 0 || l != 0)
12 #pragma omp atomic
13 j |= 1;
15 if (omp_get_num_threads () != 4)
16 #pragma omp atomic
17 j |= 2;
19 i = omp_get_thread_num ();
20 k = 1 << (2 * i);
21 l = 0xea << (3 * i);
24 if (j & 1)
25 abort ();
26 if ((j & 2) == 0)
28 if (i != (0 + 1 + 2 + 3))
29 abort ();
30 if (k != 0x55)
31 abort ();
32 if (l != 0x1e93a)
33 abort ();
35 return 0;