Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / lastprivate-conditional-5.c
blobde6b9a87c1f343f238f56dce1e9d731f49e0faae
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;
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 parallel for lastprivate (conditional: u, x)
22 for (i = 15; i < 64; i++)
24 if ((a[i] % 5) == 3)
25 u = i;
26 if ((a[i] % 7) == 2)
27 x = &a[i];
29 #pragma omp parallel for lastprivate (conditional: v) reduction (+:r, s) schedule (nonmonotonic: static)
30 for (i = -3; i < 119; i += 2)
32 ++s;
33 if ((a[i + 4] % 11) == 9)
34 v = i;
35 else
36 ++r;
38 #pragma omp parallel for schedule (monotonic: static) lastprivate (conditional: w)
39 for (j = b; j < b + 115 * c; j += (b & 3) + 7)
40 if ((a[j] % 13) == 5)
41 w = j * 2;
42 #pragma omp parallel for schedule (auto) lastprivate (conditional: p) collapse(3)
43 for (i = -5; i < (int) (b + 5); i += 2)
44 for (j = b + 12 + c; j > b; --j)
45 for (int k = 0; k < 5; k += c)
46 if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
47 p = i * 10000 + j * 100 + k;
49 #pragma omp parallel for schedule (nonmonotonic: static, 2) lastprivate (conditional: u2, x2)
50 for (i = 15; i < 64; i++)
52 if ((a[i] % 5) == 3)
53 u2 = i;
54 if ((a[i] % 7) == 2)
55 x2 = &a[i];
57 #pragma omp parallel for schedule (static, 3) lastprivate (conditional: v2) reduction (+:r2, s2)
58 for (i = -3; i < 119; i += 2)
60 ++s2;
61 if ((a[i + 4] % 11) == 9)
62 v2 = i;
63 else
64 ++r2;
66 #pragma omp parallel for lastprivate (conditional: w2) schedule (static, 1)
67 for (j = b; j < b + 115 * c; j += (b & 3) + 7)
68 if ((a[j] % 13) == 5)
69 w2 = j * 2;
70 #pragma omp parallel for schedule (static, 3) collapse (3) lastprivate (conditional: p2)
71 for (i = -5; i < (int) (b + 5); i += 2)
72 for (j = b + 12 + c; j > b; --j)
73 for (int k = 0; k < 5; k += c)
74 if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
75 p2 = i * 10000 + j * 100 + k;
77 #pragma omp parallel for lastprivate (conditional: u3, x3) schedule (runtime)
78 for (i = 15; i < 64; i++)
80 if ((a[i] % 5) == 3)
81 u3 = i;
82 if ((a[i] % 7) == 2)
83 x3 = &a[i];
85 #pragma omp parallel for lastprivate (conditional: v3) reduction (+:r3, s3) schedule (nonmonotonic: dynamic)
86 for (i = -3; i < 119; i += 2)
88 ++s3;
89 if ((a[i + 4] % 11) == 9)
90 v3 = i;
91 else
92 ++r3;
94 #pragma omp parallel for schedule (monotonic: guided, 3) lastprivate (conditional: w3)
95 for (j = b; j < b + 115 * c; j += (b & 3) + 7)
96 if ((a[j] % 13) == 5)
97 w3 = j * 2;
98 #pragma omp parallel for schedule (dynamic, 4) lastprivate (conditional: p3) collapse(3)
99 for (i = -5; i < (int) (b + 5); i += 2)
100 for (j = b + 12 + c; j > b; --j)
101 for (int k = 0; k < 5; k += c)
102 if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
103 p3 = i * 10000 + j * 100 + k;
105 /* Nasty testcase, verify that even a no-op assignment is accounted
106 for in lastprivate(conditional:). */
107 #pragma omp parallel for schedule (monotonic: static, 2) firstprivate (z) \
108 lastprivate (conditional: z)
109 for (int k = -2000; k < 8000; ++k)
111 if (k < 3000 && (k & 3) == 1)
113 z = k;
114 thr1 = k;
116 else if (k == 7931)
118 z = z;
119 thr2 = 1;
123 if (thr2 && z != thr1)
124 abort ();
128 main ()
130 int a[128], i;
131 volatile int j = 0;
132 for (i = 0; i < 128; i++)
133 a[i] = i;
134 w = 1234;
135 foo (a, j, j + 1);
136 if (u != 63 || v != 115 || w != 140 || x != &a[58] || r != 55 || s != 61 || p != 30104)
137 abort ();
138 if (u2 != 63 || v2 != 115 || w2 != 140 || x2 != &a[58] || r2 != 55 || s2 != 61 || p2 != 30104)
139 abort ();
140 if (u3 != 63 || v3 != 115 || w3 != 140 || x3 != &a[58] || r3 != 55 || s3 != 61 || p3 != 30104)
141 abort ();
142 return 0;