Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / loop-1.c
blobde696081d166c224bd3aa2f6e9214de7ad51f6ea
1 extern
2 #ifdef __cplusplus
3 "C"
4 #endif
5 void abort (void);
6 #define N 256
7 int r;
9 void
10 foo (int *a)
12 int i, j;
13 #pragma omp loop bind(thread) order(concurrent) private (j) lastprivate (i) reduction(+:r) collapse(1)
14 for (i = 0; i < N; i++)
16 j = i - 2;
17 a[i] = j;
18 r += j;
22 void
23 bar (int *a)
25 int i, j;
26 #pragma omp loop bind(parallel) order(concurrent) private (j) lastprivate (i) reduction(+:r) collapse(1)
27 for (i = 0; i < N; i++)
29 j = i;
30 a[i] = j;
31 r += j;
35 void
36 baz (int *a)
38 int i, j;
39 #pragma omp loop bind(teams) order(concurrent) private (j) lastprivate (i) reduction(+:r)
40 for (i = 0; i < N; i++)
42 j = i + 2;
43 a[i] = j;
44 r += j;
48 int
49 main ()
51 int a[N], i, j;
52 foo (a);
53 for (i = 0; i < N; ++i)
54 if (a[i] != i - 2)
55 abort ();
56 else
57 a[i] = -35;
58 if (r != N * (N - 5) / 2)
59 abort ();
60 else
61 r = 0;
62 bar (a);
63 for (i = 0; i < N; ++i)
64 if (a[i] != i)
65 abort ();
66 else
67 a[i] = -35;
68 if (r != N * (N - 1) / 2)
69 abort ();
70 else
71 r = 0;
72 #pragma omp parallel loop private (j) lastprivate (i) reduction(+:r)
73 for (i = 0; i < N; i++)
75 j = i + 4;
76 a[i] = j;
77 r += j;
79 if (i != N)
80 abort ();
81 for (i = 0; i < N; ++i)
82 if (a[i] != i + 4)
83 abort ();
84 else
85 a[i] = -35;
86 if (r != N * (N + 7) / 2)
87 abort ();
88 else
89 r = 0;
90 #pragma omp parallel
91 bar (a);
92 for (i = 0; i < N; ++i)
93 if (a[i] != i)
94 abort ();
95 else
96 a[i] = -35;
97 if (r != N * (N - 1) / 2)
98 abort ();
99 else
100 r = 0;
101 #pragma omp teams
102 baz (a);
103 for (i = 0; i < N; ++i)
104 if (a[i] != i + 2)
105 abort ();
106 else
107 a[i] = -35;
108 if (r != N * (N + 3) / 2)
109 abort ();
110 else
111 r = 0;
112 #pragma omp teams loop order(concurrent) private (j) lastprivate (i) reduction(+:r) collapse(1)
113 for (i = 0; i < N; i++)
115 j = i - 4;
116 a[i] = j;
117 r += j;
119 if (i != N)
120 abort ();
121 for (i = 0; i < N; ++i)
122 if (a[i] != i - 4)
123 abort ();
124 if (r != N * (N - 9) / 2)
125 abort ();
126 return 0;