1 extern void abort (void);
2
3 #define N 256
4 int a[N], b[N / 16][8][4], c[N / 32][8][8], g[N / 16][8][6];
5 volatile int d, e;
6 volatile unsigned long long f;
7
8 int
main()9 main ()
10 {
11 unsigned long long i;
12 int j, k, l, m;
13 #pragma omp parallel private (l)
14 {
15 #pragma omp for schedule(guided, 3) ordered (1) nowait
16 for (i = 1; i < N + f; i++)
17 {
18 #pragma omp atomic write
19 a[i] = 1;
20 #pragma omp ordered depend(sink: i - 1)
21 if (i > 1)
22 {
23 #pragma omp atomic read
24 l = a[i - 1];
25 if (l < 2)
26 abort ();
27 }
28 #pragma omp atomic write
29 a[i] = 2;
30 if (i < N - 1)
31 {
32 #pragma omp atomic read
33 l = a[i + 1];
34 if (l == 3)
35 abort ();
36 }
37 #pragma omp ordered depend(source)
38 #pragma omp atomic write
39 a[i] = 3;
40 }
41 #pragma omp for schedule(guided) ordered (3) nowait
42 for (i = 3; i < N / 16 - 1 + f; i++)
43 for (j = 0; j < 8; j += 2)
44 for (k = 1; k <= 3; k++)
45 {
46 #pragma omp atomic write
47 b[i][j][k] = 1;
48 #pragma omp ordered depend(sink: i, j - 2, k - 1) \
49 depend(sink: i - 2, j - 2, k + 1)
50 #pragma omp ordered depend(sink: i - 3, j + 2, k - 2)
51 if (j >= 2 && k > 1)
52 {
53 #pragma omp atomic read
54 l = b[i][j - 2][k - 1];
55 if (l < 2)
56 abort ();
57 }
58 #pragma omp atomic write
59 b[i][j][k] = 2;
60 if (i >= 5 && j >= 2 && k < 3)
61 {
62 #pragma omp atomic read
63 l = b[i - 2][j - 2][k + 1];
64 if (l < 2)
65 abort ();
66 }
67 if (i >= 6 && j < N / 16 - 3 && k == 3)
68 {
69 #pragma omp atomic read
70 l = b[i - 3][j + 2][k - 2];
71 if (l < 2)
72 abort ();
73 }
74 #pragma omp ordered depend(source)
75 #pragma omp atomic write
76 b[i][j][k] = 3;
77 }
78 #define A(n) int n;
79 #define B(n) A(n##0) A(n##1) A(n##2) A(n##3)
80 #define C(n) B(n##0) B(n##1) B(n##2) B(n##3)
81 #define D(n) C(n##0) C(n##1) C(n##2) C(n##3)
82 D(m)
83 #undef A
84 #pragma omp for collapse (2) ordered(61) schedule(guided, 15)
85 for (i = 2; i < N / 32 + f; i++)
86 for (j = 7; j > 1; j--)
87 for (k = 6; k >= 0; k -= 2)
88 #define A(n) for (n = 4; n < 5; n++)
89 D(m)
90 #undef A
91 {
92 #pragma omp atomic write
93 c[i][j][k] = 1;
94 #define A(n) ,n
95 #define E(n) C(n##0) C(n##1) C(n##2) B(n##30) B(n##31) A(n##320) A(n##321)
96 #pragma omp ordered depend (sink: i, j, k + 2 E(m)) \
97 depend (sink:i - 2, j + 1, k - 4 E(m)) \
98 depend(sink: i - 1, j - 2, k - 2 E(m))
99 if (k <= 4)
100 {
101 #pragma omp atomic read
102 l = c[i][j][k + 2];
103 if (l < 2)
104 abort ();
105 }
106 #pragma omp atomic write
107 c[i][j][k] = 2;
108 if (i >= 4 && j < 7 && k >= 4)
109 {
110 #pragma omp atomic read
111 l = c[i - 2][j + 1][k - 4];
112 if (l < 2)
113 abort ();
114 }
115 if (i >= 3 && j >= 4 && k >= 2)
116 {
117 #pragma omp atomic read
118 l = c[i - 1][j - 2][k - 2];
119 if (l < 2)
120 abort ();
121 }
122 #pragma omp ordered depend (source)
123 #pragma omp atomic write
124 c[i][j][k] = 3;
125 }
126 #pragma omp for schedule(guided, 5) ordered (3) nowait
127 for (j = 0; j < N / 16 - 1; j++)
128 for (k = 0; k < 8; k += 2)
129 for (i = 3; i <= 5 + f; i++)
130 {
131 #pragma omp atomic write
132 g[j][k][i] = 1;
133 #pragma omp ordered depend(sink: j, k - 2, i - 1) \
134 depend(sink: j - 2, k - 2, i + 1)
135 #pragma omp ordered depend(sink: j - 3, k + 2, i - 2)
136 if (k >= 2 && i > 3)
137 {
138 #pragma omp atomic read
139 l = g[j][k - 2][i - 1];
140 if (l < 2)
141 abort ();
142 }
143 #pragma omp atomic write
144 g[j][k][i] = 2;
145 if (j >= 2 && k >= 2 && i < 5)
146 {
147 #pragma omp atomic read
148 l = g[j - 2][k - 2][i + 1];
149 if (l < 2)
150 abort ();
151 }
152 if (j >= 3 && k < N / 16 - 3 && i == 5)
153 {
154 #pragma omp atomic read
155 l = g[j - 3][k + 2][i - 2];
156 if (l < 2)
157 abort ();
158 }
159 #pragma omp ordered depend(source)
160 #pragma omp atomic write
161 g[j][k][i] = 3;
162 }
163 #pragma omp for collapse(2) ordered(4) lastprivate (i, j, k)
164 for (i = 2; i < f + 3; i++)
165 for (j = d + 1; j >= 0; j--)
166 for (k = 0; k < d; k++)
167 for (l = 0; l < d + 2; l++)
168 {
169 #pragma omp ordered depend (source)
170 #pragma omp ordered depend (sink:i - 2, j + 2, k - 2, l)
171 if (!e)
172 abort ();
173 }
174 #pragma omp single
175 {
176 if (i != 3 || j != -1 || k != 0)
177 abort ();
178 i = 8; j = 9; k = 10;
179 }
180 #pragma omp for collapse(2) ordered(4) lastprivate (i, j, k, m)
181 for (i = 2; i < f + 3; i++)
182 for (j = d + 1; j >= 0; j--)
183 for (k = 0; k < d + 2; k++)
184 for (m = 0; m < d; m++)
185 {
186 #pragma omp ordered depend (source)
187 #pragma omp ordered depend (sink:i - 2, j + 2, k - 2, m)
188 abort ();
189 }
190 #pragma omp single
191 if (i != 3 || j != -1 || k != 2 || m != 0)
192 abort ();
193 #pragma omp for collapse(2) ordered(4) nowait
194 for (i = 2; i < f + 3; i++)
195 for (j = d; j > 0; j--)
196 for (k = 0; k < d + 2; k++)
197 for (l = 0; l < d + 4; l++)
198 {
199 #pragma omp ordered depend (source)
200 #pragma omp ordered depend (sink:i - 2, j + 2, k - 2, l)
201 if (!e)
202 abort ();
203 }
204 #pragma omp for nowait
205 for (i = 0; i < N; i++)
206 if (a[i] != 3 * (i >= 1))
207 abort ();
208 #pragma omp for collapse(2) private(k) nowait
209 for (i = 0; i < N / 16; i++)
210 for (j = 0; j < 8; j++)
211 for (k = 0; k < 4; k++)
212 if (b[i][j][k] != 3 * (i >= 3 && i < N / 16 - 1 && (j & 1) == 0 && k >= 1))
213 abort ();
214 #pragma omp for collapse(3) nowait
215 for (i = 0; i < N / 32; i++)
216 for (j = 0; j < 8; j++)
217 for (k = 0; k < 8; k++)
218 if (c[i][j][k] != 3 * (i >= 2 && j >= 2 && (k & 1) == 0))
219 abort ();
220 #pragma omp for collapse(2) private(k) nowait
221 for (i = 0; i < N / 16; i++)
222 for (j = 0; j < 8; j++)
223 for (k = 0; k < 6; k++)
224 if (g[i][j][k] != 3 * (i < N / 16 - 1 && (j & 1) == 0 && k >= 3))
225 abort ();
226 }
227 return 0;
228 }
229