Debian Codegraph @

libgomp/testsuite/libgomp.c/copyin-3.c

raw
1 /* { dg-do run } */
2 /* { dg-require-effective-target tls_runtime } */
3
4 #include <omp.h>
5 #include <stdlib.h>
6
7 int thr;
8 #pragma omp threadprivate (thr)
9
10 int
11 test (int l)
12 {
13 return l || (thr != omp_get_thread_num () * 2);
14 }
15
16 int
17 main (void)
18 {
19 int l = 0;
20
21 omp_set_dynamic (0);
22 omp_set_num_threads (6);
23
24 thr = 8;
25 /* Broadcast the value to all threads. */
26 #pragma omp parallel copyin (thr)
27 ;
28
29 #pragma omp parallel reduction (||:l)
30 {
31 /* Now test if the broadcast succeeded. */
32 l = thr != 8;
33 thr = omp_get_thread_num () * 2;
34 #pragma omp barrier
35 l = test (l);
36 }
37
38 if (l)
39 abort ();
40 return 0;
41 }