0
|
1 /* { dg-do run } */
|
|
2
|
|
3 #include <omp.h>
|
|
4 #include <stdlib.h>
|
|
5
|
|
6 int
|
|
7 main (void)
|
|
8 {
|
|
9 int a = 1, b = 2, c = 3;
|
|
10 void
|
|
11 foo (void)
|
|
12 {
|
|
13 int l = 0;
|
|
14 #pragma omp parallel shared (a) private (b) firstprivate (c) \
|
|
15 num_threads (2) reduction (||:l)
|
|
16 {
|
|
17 if (a != 1 || c != 3) l = 1;
|
|
18 #pragma omp barrier
|
|
19 if (omp_get_thread_num () == 0)
|
|
20 {
|
|
21 a = 4;
|
|
22 b = 5;
|
|
23 c = 6;
|
|
24 }
|
|
25 #pragma omp barrier
|
|
26 if (omp_get_thread_num () == 1)
|
|
27 {
|
|
28 if (a != 4 || c != 3) l = 1;
|
|
29 a = 7;
|
|
30 b = 8;
|
|
31 c = 9;
|
|
32 }
|
|
33 else if (omp_get_num_threads () == 1)
|
|
34 a = 7;
|
|
35 #pragma omp barrier
|
|
36 if (omp_get_thread_num () == 0)
|
|
37 if (a != 7 || b != 5 || c != 6) l = 1;
|
|
38 #pragma omp barrier
|
|
39 if (omp_get_thread_num () == 1)
|
|
40 if (a != 7 || b != 8 || c != 9) l = 1;
|
|
41 }
|
|
42 if (l)
|
|
43 abort ();
|
|
44 }
|
|
45 foo ();
|
|
46 if (a != 7)
|
|
47 abort ();
|
|
48 return 0;
|
|
49 }
|