Skip various cmp-mem-const tests on lp64 hppa*-*-*
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / lastprivate-conditional-2.c
blobf252206f5b372edb11d5a54c9ce3a66ae9466259
1 /* { dg-do run } */
2 /* { dg-require-effective-target tls_runtime } */
3 /* { dg-additional-options "-std=gnu99" {target c } } */
5 #include <omp.h>
6 #include <stdlib.h>
8 int r, s, u, v, r2, s2, u2, v2, r3, s3, u3, v3, t;
9 long long w, w2, w3, p, p2, p3;
10 int *x, *x2, *x3;
11 short y, y2, y3;
12 int z;
13 int thr1, thr2;
14 #pragma omp threadprivate (thr1, thr2)
16 void
17 foo (int *a, long long int b, long long int c)
19 int i;
20 long long j;
21 #pragma omp for lastprivate (conditional: u, x) reduction (task, +: t)
22 for (i = 15; i < 64; i++)
24 ++t;
25 if ((a[i] % 5) == 3)
26 u = i;
27 if ((a[i] % 7) == 2)
28 x = &a[i];
30 #pragma omp for lastprivate (conditional: v) reduction (+:r, s) schedule (nonmonotonic: static) reduction (task, +: t)
31 for (i = -3; i < 119; i += 2)
33 ++s;
34 ++t;
35 if ((a[i + 4] % 11) == 9)
36 v = i;
37 else
38 ++r;
40 #pragma omp for schedule (monotonic: static) lastprivate (conditional: w) reduction (task, +: t)
41 for (j = b; j < b + 115 * c; j += (b & 3) + 7)
43 if ((a[j] % 13) == 5)
44 w = j * 2;
45 ++t;
47 #pragma omp for schedule (auto) lastprivate (conditional: p) collapse(3) reduction (task, +: t)
48 for (i = -5; i < (int) (b + 5); i += 2)
49 for (j = b + 12 + c; j > b; --j)
50 for (int k = 0; k < 5; k += c)
52 ++t;
53 if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
54 p = i * 10000 + j * 100 + k;
57 #pragma omp for schedule (nonmonotonic: static, 2) reduction (task, +: t) lastprivate (conditional: u2, x2)
58 for (i = 15; i < 64; i++)
60 if ((a[i] % 5) == 3)
61 u2 = i;
62 if ((a[i] % 7) == 2)
63 x2 = &a[i];
64 t++;
66 #pragma omp for schedule (static, 3) lastprivate (conditional: v2) reduction (+:r2, s2) reduction (task, +: t)
67 for (i = -3; i < 119; i += 2)
69 ++s2;
70 if ((a[i + 4] % 11) == 9)
71 v2 = i;
72 else
73 ++r2;
74 t++;
76 #pragma omp for lastprivate (conditional: w2) schedule (static, 1) reduction (task, +: t)
77 for (j = b; j < b + 115 * c; j += (b & 3) + 7)
79 if ((a[j] % 13) == 5)
80 w2 = j * 2;
81 t += 1;
83 #pragma omp for schedule (static, 3) collapse (3) reduction (task, +: t) lastprivate (conditional: p2)
84 for (i = -5; i < (int) (b + 5); i += 2)
85 for (j = b + 12 + c; j > b; --j)
86 for (int k = 0; k < 5; k += c)
88 ++t;
89 if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
90 p2 = i * 10000 + j * 100 + k;
93 #pragma omp for lastprivate (conditional: u3, x3) reduction (task, +: t) schedule (runtime)
94 for (i = 15; i < 64; i++)
96 t = t + 1;
97 if ((a[i] % 5) == 3)
98 u3 = i;
99 if ((a[i] % 7) == 2)
100 x3 = &a[i];
102 #pragma omp for reduction (task, +: t) lastprivate (conditional: v3) reduction (+:r3, s3) schedule (nonmonotonic: dynamic)
103 for (i = -3; i < 119; i += 2)
105 ++s3;
106 if ((a[i + 4] % 11) == 9)
107 v3 = i;
108 else
109 ++r3;
110 ++t;
112 #pragma omp for schedule (monotonic: guided, 3) lastprivate (conditional: w3) reduction (task, +: t)
113 for (j = b; j < b + 115 * c; j += (b & 3) + 7)
115 if ((a[j] % 13) == 5)
116 w3 = j * 2;
117 t++;
119 #pragma omp for schedule (dynamic, 4) lastprivate (conditional: p3) collapse(3) reduction (task, +: t)
120 for (i = -5; i < (int) (b + 5); i += 2)
121 for (j = b + 12 + c; j > b; --j)
122 for (int k = 0; k < 5; k += c)
124 ++t;
125 if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
126 p3 = i * 10000 + j * 100 + k;
129 /* Nasty testcase, verify that even a no-op assignment is accounted
130 for in lastprivate(conditional:). */
131 #pragma omp for schedule (monotonic: static, 2) firstprivate (z) \
132 lastprivate (conditional: z) reduction (task, +: t)
133 for (int k = -2000; k < 8000; ++k)
135 t++;
136 if (k < 3000 && (k & 3) == 1)
138 z = k;
139 thr1 = k;
141 else if (k == 7931)
143 z = z;
144 thr2 = 1;
148 if (thr2 && z != thr1)
149 abort ();
153 main ()
155 int a[128], i;
156 volatile int j = 0;
157 for (i = 0; i < 128; i++)
158 a[i] = i;
159 w = 1234;
160 #pragma omp parallel
161 foo (a, j, j + 1);
162 if (u != 63 || v != 115 || w != 140 || x != &a[58] || r != 55 || s != 61 || p != 30104)
163 abort ();
164 if (u2 != 63 || v2 != 115 || w2 != 140 || x2 != &a[58] || r2 != 55 || s2 != 61 || p2 != 30104)
165 abort ();
166 if (u3 != 63 || v3 != 115 || w3 != 140 || x3 != &a[58] || r3 != 55 || s3 != 61 || p3 != 30104)
167 abort ();
168 if (t != 11356)
169 abort ();
170 return 0;