Update concepts branch to revision 131834
[official-gcc.git] / libgomp / testsuite / libgomp.c / reduction-2.c
blob52b3faff787e3a3d160cd15c3c37dbda88d91852
1 #include <omp.h>
2 #include <stdlib.h>
4 int
5 main (void)
7 int i = 0, j = 0, k = ~0, l;
8 double d = 1.0;
9 #pragma omp parallel num_threads(4)
11 #pragma omp single
13 i = 16;
14 k ^= (1 << 16);
15 d += 32.0;
18 #pragma omp for reduction(+:i) reduction(*:d) reduction(&:k)
19 for (l = 0; l < 4; l++)
21 if (omp_get_num_threads () == 4 && (i != 0 || d != 1.0 || k != ~0))
22 #pragma omp atomic
23 j |= 1;
25 if (l == omp_get_thread_num ())
27 i = omp_get_thread_num ();
28 d = i + 1;
29 k = ~(1 << (2 * i));
33 if (omp_get_num_threads () == 4)
35 if (i != (16 + 0 + 1 + 2 + 3))
36 #pragma omp atomic
37 j |= 2;
38 if (d != (33.0 * 1.0 * 2.0 * 3.0 * 4.0))
39 #pragma omp atomic
40 j |= 4;
41 if (k != (~0 ^ 0x55 ^ (1 << 16)))
42 #pragma omp atomic
43 j |= 8;
47 if (j)
48 abort ();
49 return 0;