Merge from mainline
[official-gcc.git] / libgomp / testsuite / libgomp.c / reduction-1.c
blob665163af09f9181a7a35f33090968497c6f3f94e
1 #include <omp.h>
2 #include <stdlib.h>
4 int
5 main (void)
7 int i = 0, j = 0, k = ~0;
8 double d = 1.0;
9 #pragma omp parallel num_threads(4) reduction(+:i) reduction(*:d) reduction(&:k)
11 if (i != 0 || d != 1.0 || k != ~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 d = i + 1;
21 k = ~(1 << (2 * i));
24 if (j & 1)
25 abort ();
26 if ((j & 2) == 0)
28 if (i != (0 + 1 + 2 + 3))
29 abort ();
30 if (d != (1.0 * 2.0 * 3.0 * 4.0))
31 abort ();
32 if (k != (~0 ^ 0x55))
33 abort ();
35 return 0;