Merge from mainline
[official-gcc.git] / libgomp / testsuite / libgomp.c / copyin-3.c
blob86b0d691f3a8f8223eaf451bfb122153af469a86
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3 /* { dg-require-effective-target tls_runtime } */
5 #include <omp.h>
6 #include <stdlib.h>
8 int thr;
9 #pragma omp threadprivate (thr)
11 int
12 test (int l)
14 return l || (thr != omp_get_thread_num () * 2);
17 int
18 main (void)
20 int l = 0;
22 omp_set_dynamic (0);
23 omp_set_num_threads (6);
25 thr = 8;
26 /* Broadcast the value to all threads. */
27 #pragma omp parallel copyin (thr)
30 #pragma omp parallel reduction (||:l)
32 /* Now test if the broadcast succeeded. */
33 l = thr != 8;
34 thr = omp_get_thread_num () * 2;
35 #pragma omp barrier
36 l = test (l);
39 if (l)
40 abort ();
41 return 0;