gcc.c-torture/execute/builtins/fputs.c: fputs_unlocked prototype
[official-gcc.git] / libgomp / testsuite / libgomp.c / doacross-5.c
blob7bb1993647c42f95a2f73655fd02285bd5eb2487
1 extern void abort (void);
3 #define N 256
4 int a[N], b[N / 16][8][4], c[N / 32][8][8];
5 volatile int d, e;
7 int
8 main ()
10 int i, j, k, l, m;
11 #pragma omp parallel private (l)
13 #pragma omp for schedule(static, 1) ordered (1) nowait
14 for (i = 0; i < N; i++)
16 #pragma omp atomic write
17 a[i] = 1;
18 #pragma omp ordered doacross(sink: omp_cur_iteration - 1)
19 if (i)
21 #pragma omp atomic read
22 l = a[i - 1];
23 if (l < 2)
24 abort ();
26 #pragma omp atomic write
27 a[i] = 2;
28 if (i < N - 1)
30 #pragma omp atomic read
31 l = a[i + 1];
32 if (l == 3)
33 abort ();
35 #pragma omp ordered doacross(source :)
36 #pragma omp atomic write
37 a[i] = 3;
39 #pragma omp for schedule(static) ordered (3) nowait
40 for (i = 2; i < N / 16 - 1; i++)
41 for (j = 0; j < 8; j += 2)
42 for (k = 1; k <= 3; k++)
44 #pragma omp atomic write
45 b[i][j][k] = 1;
46 #pragma omp ordered doacross(sink: omp_cur_iteration - 1) \
47 doacross(sink: i - 2, j - 2, k + 1)
48 #pragma omp ordered doacross(sink: i - 3, j + 2, k - 2)
49 if (i != 2 || j || k != 1)
51 if (k != 1)
52 #pragma omp atomic read
53 l = b[i][j][k - 1];
54 else if (j)
55 #pragma omp atomic read
56 l = b[i][j - 2][3];
57 else
58 #pragma omp atomic read
59 l = b[i - 1][6][3];
60 if (l < 2)
61 abort ();
63 #pragma omp atomic write
64 b[i][j][k] = 2;
65 if (i >= 4 && j >= 2 && k < 3)
67 #pragma omp atomic read
68 l = b[i - 2][j - 2][k + 1];
69 if (l < 2)
70 abort ();
72 if (i >= 5 && j < N / 16 - 3 && k == 3)
74 #pragma omp atomic read
75 l = b[i - 3][j + 2][k - 2];
76 if (l < 2)
77 abort ();
79 #pragma omp ordered doacross(source : omp_cur_iteration)
80 #pragma omp atomic write
81 b[i][j][k] = 3;
83 #define A(n) int n;
84 #define B(n) A(n##0) A(n##1) A(n##2) A(n##3)
85 #define C(n) B(n##0) B(n##1) B(n##2) B(n##3)
86 #define D(n) C(n##0) C(n##1) C(n##2) C(n##3)
87 D(m)
88 #undef A
89 #pragma omp for collapse (2) ordered(61) schedule(dynamic, 15)
90 for (i = 0; i < N / 32; i++)
91 for (j = 7; j > 1; j--)
92 for (k = 6; k >= 0; k -= 2)
93 #define A(n) for (n = 4; n < 5; n++)
94 D(m)
95 #undef A
97 #pragma omp atomic write
98 c[i][j][k] = 1;
99 #define A(n) ,n
100 #define E(n) C(n##0) C(n##1) C(n##2) B(n##30) B(n##31) A(n##320) A(n##321)
101 #pragma omp ordered doacross (sink: i, j, k + 2 E(m)) \
102 doacross (sink:omp_cur_iteration - 1) \
103 doacross(sink: i - 1, j - 2, k - 2 E(m))
104 if (k <= 4)
106 #pragma omp atomic read
107 l = c[i][j][k + 2];
108 if (l < 2)
109 abort ();
111 #pragma omp atomic write
112 c[i][j][k] = 2;
113 if (i || j != 7 && k != 6)
115 if (k != 6)
116 #pragma omp atomic read
117 l = c[i][j][k + 2];
118 else if (j != 7)
119 #pragma omp atomic read
120 l = c[i][j + 1][0];
121 else
122 #pragma omp atomic read
123 l = c[i - 1][2][0];
124 if (l < 2)
125 abort ();
127 if (i >= 1 && j >= 4 && k >= 2)
129 #pragma omp atomic read
130 l = c[i - 1][j - 2][k - 2];
131 if (l < 2)
132 abort ();
134 #pragma omp ordered doacross (source: )
135 #pragma omp atomic write
136 c[i][j][k] = 3;
139 #pragma omp for collapse(2) ordered(4) lastprivate (i, j, k)
140 for (i = 0; i < d + 1; i++)
141 for (j = d + 1; j >= 0; j--)
142 for (k = 0; k < d; k++)
143 for (l = 0; l < d + 2; l++)
145 #pragma omp ordered doacross (source : omp_cur_iteration)
146 #pragma omp ordered doacross (sink: omp_cur_iteration - 1)
147 if (!e)
148 abort ();
150 #pragma omp single
152 if (i != 1 || j != -1 || k != 0)
153 abort ();
154 i = 8; j = 9; k = 10;
156 #pragma omp for collapse(2) ordered(4) lastprivate (i, j, k, m)
157 for (i = 0; i < d + 1; i++)
158 for (j = d + 1; j >= 0; j--)
159 for (k = 0; k < d + 2; k++)
160 for (m = 0; m < d; m++)
162 #pragma omp ordered doacross (source : )
163 #pragma omp ordered doacross (sink:omp_cur_iteration - 1)
164 abort ();
166 #pragma omp single
167 if (i != 1 || j != -1 || k != 2 || m != 0)
168 abort ();
169 #pragma omp for collapse(2) ordered(4) nowait
170 for (i = 0; i < d + 1; i++)
171 for (j = d; j > 0; j--)
172 for (k = 0; k < d + 2; k++)
173 for (l = 0; l < d + 4; l++)
175 #pragma omp ordered doacross (source : omp_cur_iteration)
176 #pragma omp ordered doacross (sink:omp_cur_iteration - 1)
177 if (!e)
178 abort ();
180 #pragma omp for nowait
181 for (i = 0; i < N; i++)
182 if (a[i] != 3)
183 abort ();
184 #pragma omp for collapse(2) private(k) nowait
185 for (i = 0; i < N / 16; i++)
186 for (j = 0; j < 8; j++)
187 for (k = 0; k < 4; k++)
188 if (b[i][j][k] != 3 * (i >= 2 && i < N / 16 - 1 && (j & 1) == 0 && k >= 1))
189 abort ();
190 #pragma omp for collapse(3) nowait
191 for (i = 0; i < N / 32; i++)
192 for (j = 0; j < 8; j++)
193 for (k = 0; k < 8; k++)
194 if (c[i][j][k] != 3 * (j >= 2 && (k & 1) == 0))
195 abort ();
197 return 0;