1 #include <stdlib.h>
2
3 int x;
4 long long y;
5 int r, s, t;
6
7 void
8 foo (const char *a)
9 {
10 #pragma omp parallel sections lastprivate (conditional: x, y)
11 {
12 if (a[0])
13 x = a[0];
14 #pragma omp section
15 {
16 if (a[1])
17 x = a[1];
18 if (a[2])
19 y = a[2];
20 }
21 #pragma omp section
22 if (a[3])
23 y = a[3];
24 #pragma omp section
25 if (a[4])
26 x = a[4];
27 #pragma omp section
28 {
29 if (a[5])
30 x = a[5];
31 if (a[6])
32 y = a[6];
33 }
34 }
35 }
36
37 void
38 bar (const char *a)
39 {
40 #pragma omp parallel sections lastprivate (conditional: x, y) reduction (task, +: t)
41 {
42 if (a[0])
43 x = a[0];
44 #pragma omp section
45 {
46 if (a[1])
47 x = a[1];
48 if (a[2])
49 y = a[2];
50 #pragma omp task in_reduction (+: t)
51 t++;
52 }
53 #pragma omp section
54 if (a[3])
55 y = a[3];
56 #pragma omp section
57 if (a[4])
58 x = a[4];
59 #pragma omp section
60 {
61 #pragma omp task in_reduction (+: t)
62 ++t;
63 if (a[5])
64 x = a[5];
65 if (a[6])
66 y = a[6];
67 }
68 }
69 }
70
71 void
72 baz (const char *a)
73 {
74 #pragma omp parallel sections lastprivate (conditional: x, y) reduction (+: r, s)
75 {
76 if (a[0])
77 x = a[0];
78 #pragma omp section
79 {
80 if (a[1])
81 x = a[1];
82 ++r;
83 ++s;
84 if (a[2])
85 y = a[2];
86 }
87 #pragma omp section
88 if (a[3])
89 y = a[3];
90 #pragma omp section
91 {
92 ++s;
93 if (a[4])
94 x = a[4];
95 }
96 #pragma omp section
97 {
98 if (a[5])
99 x = a[5];
100 if (a[6])
101 y = a[6];
102 ++s;
103 }
104 }
105 }
106
107 int
108 main ()
109 {
110 foo ("\0\1\2\3\0\5");
111 if (x != 5 || y != 3)
112 abort ();
113
114 foo ("\6\0\0\0\0\0\7");
115 if (x != 6 || y != 7)
116 abort ();
117
118 foo ("\7\6\5\4\3\2\1");
119 if (x != 2 || y != 1)
120 abort ();
121
122 foo ("\0\0\4\3\0\7");
123 if (x != 7 || y != 3)
124 abort ();
125
126 bar ("\0\1\2\4\0\5");
127 if (x != 5 || y != 4 || t != 2)
128 abort ();
129
130 bar ("\6\0\0\0\0\0\7");
131 if (x != 6 || y != 7 || t != 4)
132 abort ();
133
134 bar ("\7\6\5\4\3\2\1");
135 if (x != 2 || y != 1 || t != 6)
136 abort ();
137
138 bar ("\0\0\4\3\0\7");
139 if (x != 7 || y != 3 || t != 8)
140 abort ();
141
142 baz ("\0\1\2\4\0\5");
143 if (x != 5 || y != 4 || r != 1 || s != 3)
144 abort ();
145
146 baz ("\6\0\0\0\0\0\7");
147 if (x != 6 || y != 7 || r != 2 || s != 6)
148 abort ();
149
150 baz ("\7\6\5\4\3\2\1");
151 if (x != 2 || y != 1 || r != 3 || s != 9)
152 abort ();
153
154 baz ("\0\0\4\3\0\7");
155 if (x != 7 || y != 3 || r != 4 || s != 12)
156 abort ();
157
158 return 0;
159 }