AVR: Assert minimal required bit width of section_common::flags.
[gcc.git] / libgomp / testsuite / libgomp.c / doacross-1.c
blob3d12f1cfc02b5990ab1d3caf71385c2a82802abd
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 depend(sink: i - 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 depend(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 depend(sink: i, j - 2, k - 1) \
47 depend(sink: i - 2, j - 2, k + 1)
48 #pragma omp ordered depend(sink: i - 3, j + 2, k - 2)
49 if (j >= 2 && k > 1)
51 #pragma omp atomic read
52 l = b[i][j - 2][k - 1];
53 if (l < 2)
54 abort ();
56 #pragma omp atomic write
57 b[i][j][k] = 2;
58 if (i >= 4 && j >= 2 && k < 3)
60 #pragma omp atomic read
61 l = b[i - 2][j - 2][k + 1];
62 if (l < 2)
63 abort ();
65 if (i >= 5 && j < N / 16 - 3 && k == 3)
67 #pragma omp atomic read
68 l = b[i - 3][j + 2][k - 2];
69 if (l < 2)
70 abort ();
72 #pragma omp ordered depend(source)
73 #pragma omp atomic write
74 b[i][j][k] = 3;
76 #define A(n) int n;
77 #define B(n) A(n##0) A(n##1) A(n##2) A(n##3)
78 #define C(n) B(n##0) B(n##1) B(n##2) B(n##3)
79 #define D(n) C(n##0) C(n##1) C(n##2) C(n##3)
80 D(m)
81 #undef A
82 #pragma omp for collapse (2) ordered(61) schedule(dynamic, 15)
83 for (i = 0; i < N / 32; i++)
84 for (j = 7; j > 1; j--)
85 for (k = 6; k >= 0; k -= 2)
86 #define A(n) for (n = 4; n < 5; n++)
87 D(m)
88 #undef A
90 #pragma omp atomic write
91 c[i][j][k] = 1;
92 #define A(n) ,n
93 #define E(n) C(n##0) C(n##1) C(n##2) B(n##30) B(n##31) A(n##320) A(n##321)
94 #pragma omp ordered depend (sink: i, j, k + 2 E(m)) \
95 depend (sink:i - 2, j + 1, k - 4 E(m)) \
96 depend(sink: i - 1, j - 2, k - 2 E(m))
97 if (k <= 4)
99 #pragma omp atomic read
100 l = c[i][j][k + 2];
101 if (l < 2)
102 abort ();
104 #pragma omp atomic write
105 c[i][j][k] = 2;
106 if (i >= 2 && j < 7 && k >= 4)
108 #pragma omp atomic read
109 l = c[i - 2][j + 1][k - 4];
110 if (l < 2)
111 abort ();
113 if (i >= 1 && j >= 4 && k >= 2)
115 #pragma omp atomic read
116 l = c[i - 1][j - 2][k - 2];
117 if (l < 2)
118 abort ();
120 #pragma omp ordered depend (source)
121 #pragma omp atomic write
122 c[i][j][k] = 3;
125 #pragma omp for collapse(2) ordered(4) lastprivate (i, j, k)
126 for (i = 0; i < d + 1; i++)
127 for (j = d + 1; j >= 0; j--)
128 for (k = 0; k < d; k++)
129 for (l = 0; l < d + 2; l++)
131 #pragma omp ordered depend (source)
132 #pragma omp ordered depend (sink:i - 2, j + 2, k - 2, l)
133 if (!e)
134 abort ();
136 #pragma omp single
138 if (i != 1 || j != -1 || k != 0)
139 abort ();
140 i = 8; j = 9; k = 10;
142 #pragma omp for collapse(2) ordered(4) lastprivate (i, j, k, m)
143 for (i = 0; i < d + 1; i++)
144 for (j = d + 1; j >= 0; j--)
145 for (k = 0; k < d + 2; k++)
146 for (m = 0; m < d; m++)
148 #pragma omp ordered depend (source)
149 #pragma omp ordered depend (sink:i - 2, j + 2, k - 2, m)
150 abort ();
152 #pragma omp single
153 if (i != 1 || j != -1 || k != 2 || m != 0)
154 abort ();
155 #pragma omp for collapse(2) ordered(4) nowait
156 for (i = 0; i < d + 1; i++)
157 for (j = d; j > 0; j--)
158 for (k = 0; k < d + 2; k++)
159 for (l = 0; l < d + 4; l++)
161 #pragma omp ordered depend (source)
162 #pragma omp ordered depend (sink:i - 2, j + 2, k - 2, l)
163 if (!e)
164 abort ();
166 #pragma omp for nowait
167 for (i = 0; i < N; i++)
168 if (a[i] != 3)
169 abort ();
170 #pragma omp for collapse(2) private(k) nowait
171 for (i = 0; i < N / 16; i++)
172 for (j = 0; j < 8; j++)
173 for (k = 0; k < 4; k++)
174 if (b[i][j][k] != 3 * (i >= 2 && i < N / 16 - 1 && (j & 1) == 0 && k >= 1))
175 abort ();
176 #pragma omp for collapse(3) nowait
177 for (i = 0; i < N / 32; i++)
178 for (j = 0; j < 8; j++)
179 for (k = 0; k < 8; k++)
180 if (c[i][j][k] != 3 * (j >= 2 && (k & 1) == 0))
181 abort ();
183 return 0;