OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libgomp/] [testsuite/] [libgomp.c++/] [loop-9.C] - Blame information for rev 859

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 273 jeremybenn
// { dg-do run }
2
 
3
#include 
4
 
5
extern "C" void abort ();
6
 
7
#define LLONG_MAX __LONG_LONG_MAX__
8
#define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
9
#define INT_MAX __INT_MAX__
10
 
11
int arr[6 * 5];
12
 
13
void
14
set (int loopidx, int idx)
15
{
16
#pragma omp atomic
17
  arr[loopidx * 5 + idx]++;
18
}
19
 
20
#define check(var, val, loopidx, idx) \
21
  if (var == (val)) set (loopidx, idx); else
22
#define test(loopidx, count) \
23
  for (idx = 0; idx < 5; idx++) \
24
    if (arr[loopidx * 5 + idx] != idx < count) \
25
      abort (); \
26
    else \
27
      arr[loopidx * 5 + idx] = 0
28
 
29
int
30
test1 ()
31
{
32
  int e = 0, idx;
33
 
34
#pragma omp parallel reduction(+:e)
35
  {
36
    long long i;
37
    unsigned long long j;
38
    #pragma omp for schedule(dynamic,1) nowait
39
    for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000)
40
      {
41
        check (i, LLONG_MAX - 30001, 0, 0)
42
        check (i, LLONG_MAX - 20001, 0, 1)
43
        check (i, LLONG_MAX - 10001, 0, 2)
44
        e = 1;
45
      }
46
    #pragma omp for schedule(dynamic,1) nowait
47
    for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000)
48
      {
49
        check (i, -LLONG_MAX + 30000, 1, 0)
50
        check (i, -LLONG_MAX + 20000, 1, 1)
51
        check (i, -LLONG_MAX + 10000, 1, 2)
52
        e = 1;
53
      }
54
    #pragma omp for schedule(dynamic,1) nowait
55
    for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL)
56
      {
57
        check (j, 20, 2, 0)
58
        e = 1;
59
      }
60
    #pragma omp for schedule(dynamic,1) nowait
61
    for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL)
62
      {
63
        check (j, ULLONG_MAX - 3, 3, 0)
64
        e = 1;
65
      }
66
    #pragma omp for schedule(dynamic,1) nowait
67
    for (j = LLONG_MAX - 20000ULL; j <= LLONG_MAX + 10000ULL; j += 10000ULL)
68
      {
69
        check (j, LLONG_MAX - 20000ULL, 4, 0)
70
        check (j, LLONG_MAX - 10000ULL, 4, 1)
71
        check (j, LLONG_MAX, 4, 2)
72
        check (j, LLONG_MAX + 10000ULL, 4, 3)
73
        e = 1;
74
      }
75
    #pragma omp for schedule(dynamic,1) nowait
76
    for (i = -3LL * INT_MAX - 20000LL; i <= INT_MAX + 10000LL; i += INT_MAX + 200LL)
77
      {
78
        check (i, -3LL * INT_MAX - 20000LL, 5, 0)
79
        check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1)
80
        check (i, -INT_MAX - 20000LL + 400LL, 5, 2)
81
        check (i, -20000LL + 600LL, 5, 3)
82
        check (i, INT_MAX - 20000LL + 800LL, 5, 4)
83
        e = 1;
84
      }
85
  }
86
  if (e)
87
    abort ();
88
  test (0, 3);
89
  test (1, 3);
90
  test (2, 1);
91
  test (3, 1);
92
  test (4, 4);
93
  test (5, 5);
94
  return 0;
95
}
96
 
97
int
98
test2 ()
99
{
100
  int e = 0, idx;
101
 
102
#pragma omp parallel reduction(+:e)
103
  {
104
    long long i;
105
    unsigned long long j;
106
    #pragma omp for schedule(guided,1) nowait
107
    for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000)
108
      {
109
        check (i, LLONG_MAX - 30001, 0, 0)
110
        check (i, LLONG_MAX - 20001, 0, 1)
111
        check (i, LLONG_MAX - 10001, 0, 2)
112
        e = 1;
113
      }
114
    #pragma omp for schedule(guided,1) nowait
115
    for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000)
116
      {
117
        check (i, -LLONG_MAX + 30000, 1, 0)
118
        check (i, -LLONG_MAX + 20000, 1, 1)
119
        check (i, -LLONG_MAX + 10000, 1, 2)
120
        e = 1;
121
      }
122
    #pragma omp for schedule(guided,1) nowait
123
    for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL)
124
      {
125
        check (j, 20, 2, 0)
126
        e = 1;
127
      }
128
    #pragma omp for schedule(guided,1) nowait
129
    for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL)
130
      {
131
        check (j, ULLONG_MAX - 3, 3, 0)
132
        e = 1;
133
      }
134
    #pragma omp for schedule(guided,1) nowait
135
    for (j = LLONG_MAX - 20000ULL; j <= LLONG_MAX + 10000ULL; j += 10000ULL)
136
      {
137
        check (j, LLONG_MAX - 20000ULL, 4, 0)
138
        check (j, LLONG_MAX - 10000ULL, 4, 1)
139
        check (j, LLONG_MAX, 4, 2)
140
        check (j, LLONG_MAX + 10000ULL, 4, 3)
141
        e = 1;
142
      }
143
    #pragma omp for schedule(guided,1) nowait
144
    for (i = -3LL * INT_MAX - 20000LL; i <= INT_MAX + 10000LL; i += INT_MAX + 200LL)
145
      {
146
        check (i, -3LL * INT_MAX - 20000LL, 5, 0)
147
        check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1)
148
        check (i, -INT_MAX - 20000LL + 400LL, 5, 2)
149
        check (i, -20000LL + 600LL, 5, 3)
150
        check (i, INT_MAX - 20000LL + 800LL, 5, 4)
151
        e = 1;
152
      }
153
  }
154
  if (e)
155
    abort ();
156
  test (0, 3);
157
  test (1, 3);
158
  test (2, 1);
159
  test (3, 1);
160
  test (4, 4);
161
  test (5, 5);
162
  return 0;
163
}
164
 
165
int
166
test3 ()
167
{
168
  int e = 0, idx;
169
 
170
#pragma omp parallel reduction(+:e)
171
  {
172
    long long i;
173
    unsigned long long j;
174
    #pragma omp for schedule(static) nowait
175
    for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000)
176
      {
177
        check (i, LLONG_MAX - 30001, 0, 0)
178
        check (i, LLONG_MAX - 20001, 0, 1)
179
        check (i, LLONG_MAX - 10001, 0, 2)
180
        e = 1;
181
      }
182
    #pragma omp for schedule(static) nowait
183
    for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000)
184
      {
185
        check (i, -LLONG_MAX + 30000, 1, 0)
186
        check (i, -LLONG_MAX + 20000, 1, 1)
187
        check (i, -LLONG_MAX + 10000, 1, 2)
188
        e = 1;
189
      }
190
    #pragma omp for schedule(static) nowait
191
    for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL)
192
      {
193
        check (j, 20, 2, 0)
194
        e = 1;
195
      }
196
    #pragma omp for schedule(static) nowait
197
    for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL)
198
      {
199
        check (j, ULLONG_MAX - 3, 3, 0)
200
        e = 1;
201
      }
202
    #pragma omp for schedule(static) nowait
203
    for (j = LLONG_MAX - 20000ULL; j <= LLONG_MAX + 10000ULL; j += 10000ULL)
204
      {
205
        check (j, LLONG_MAX - 20000ULL, 4, 0)
206
        check (j, LLONG_MAX - 10000ULL, 4, 1)
207
        check (j, LLONG_MAX, 4, 2)
208
        check (j, LLONG_MAX + 10000ULL, 4, 3)
209
        e = 1;
210
      }
211
    #pragma omp for schedule(static) nowait
212
    for (i = -3LL * INT_MAX - 20000LL; i <= INT_MAX + 10000LL; i += INT_MAX + 200LL)
213
      {
214
        check (i, -3LL * INT_MAX - 20000LL, 5, 0)
215
        check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1)
216
        check (i, -INT_MAX - 20000LL + 400LL, 5, 2)
217
        check (i, -20000LL + 600LL, 5, 3)
218
        check (i, INT_MAX - 20000LL + 800LL, 5, 4)
219
        e = 1;
220
      }
221
  }
222
  if (e)
223
    abort ();
224
  test (0, 3);
225
  test (1, 3);
226
  test (2, 1);
227
  test (3, 1);
228
  test (4, 4);
229
  test (5, 5);
230
  return 0;
231
}
232
 
233
int
234
test4 ()
235
{
236
  int e = 0, idx;
237
 
238
#pragma omp parallel reduction(+:e)
239
  {
240
    long long i;
241
    unsigned long long j;
242
    #pragma omp for schedule(static,1) nowait
243
    for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000)
244
      {
245
        check (i, LLONG_MAX - 30001, 0, 0)
246
        check (i, LLONG_MAX - 20001, 0, 1)
247
        check (i, LLONG_MAX - 10001, 0, 2)
248
        e = 1;
249
      }
250
    #pragma omp for schedule(static,1) nowait
251
    for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000)
252
      {
253
        check (i, -LLONG_MAX + 30000, 1, 0)
254
        check (i, -LLONG_MAX + 20000, 1, 1)
255
        check (i, -LLONG_MAX + 10000, 1, 2)
256
        e = 1;
257
      }
258
    #pragma omp for schedule(static,1) nowait
259
    for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL)
260
      {
261
        check (j, 20, 2, 0)
262
        e = 1;
263
      }
264
    #pragma omp for schedule(static,1) nowait
265
    for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL)
266
      {
267
        check (j, ULLONG_MAX - 3, 3, 0)
268
        e = 1;
269
      }
270
    #pragma omp for schedule(static,1) nowait
271
    for (j = LLONG_MAX - 20000ULL; j <= LLONG_MAX + 10000ULL; j += 10000ULL)
272
      {
273
        check (j, LLONG_MAX - 20000ULL, 4, 0)
274
        check (j, LLONG_MAX - 10000ULL, 4, 1)
275
        check (j, LLONG_MAX, 4, 2)
276
        check (j, LLONG_MAX + 10000ULL, 4, 3)
277
        e = 1;
278
      }
279
    #pragma omp for schedule(static,1) nowait
280
    for (i = -3LL * INT_MAX - 20000LL; i <= INT_MAX + 10000LL; i += INT_MAX + 200LL)
281
      {
282
        check (i, -3LL * INT_MAX - 20000LL, 5, 0)
283
        check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1)
284
        check (i, -INT_MAX - 20000LL + 400LL, 5, 2)
285
        check (i, -20000LL + 600LL, 5, 3)
286
        check (i, INT_MAX - 20000LL + 800LL, 5, 4)
287
        e = 1;
288
      }
289
  }
290
  if (e)
291
    abort ();
292
  test (0, 3);
293
  test (1, 3);
294
  test (2, 1);
295
  test (3, 1);
296
  test (4, 4);
297
  test (5, 5);
298
  return 0;
299
}
300
 
301
int
302
test5 ()
303
{
304
  int e = 0, idx;
305
 
306
#pragma omp parallel reduction(+:e)
307
  {
308
    long long i;
309
    unsigned long long j;
310
    #pragma omp for schedule(runtime) nowait
311
    for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000)
312
      {
313
        check (i, LLONG_MAX - 30001, 0, 0)
314
        check (i, LLONG_MAX - 20001, 0, 1)
315
        check (i, LLONG_MAX - 10001, 0, 2)
316
        e = 1;
317
      }
318
    #pragma omp for schedule(runtime) nowait
319
    for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000)
320
      {
321
        check (i, -LLONG_MAX + 30000, 1, 0)
322
        check (i, -LLONG_MAX + 20000, 1, 1)
323
        check (i, -LLONG_MAX + 10000, 1, 2)
324
        e = 1;
325
      }
326
    #pragma omp for schedule(runtime) nowait
327
    for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL)
328
      {
329
        check (j, 20, 2, 0)
330
        e = 1;
331
      }
332
    #pragma omp for schedule(runtime) nowait
333
    for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL)
334
      {
335
        check (j, ULLONG_MAX - 3, 3, 0)
336
        e = 1;
337
      }
338
    #pragma omp for schedule(runtime) nowait
339
    for (j = LLONG_MAX - 20000ULL; j <= LLONG_MAX + 10000ULL; j += 10000ULL)
340
      {
341
        check (j, LLONG_MAX - 20000ULL, 4, 0)
342
        check (j, LLONG_MAX - 10000ULL, 4, 1)
343
        check (j, LLONG_MAX, 4, 2)
344
        check (j, LLONG_MAX + 10000ULL, 4, 3)
345
        e = 1;
346
      }
347
    #pragma omp for schedule(runtime) nowait
348
    for (i = -3LL * INT_MAX - 20000LL; i <= INT_MAX + 10000LL; i += INT_MAX + 200LL)
349
      {
350
        check (i, -3LL * INT_MAX - 20000LL, 5, 0)
351
        check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1)
352
        check (i, -INT_MAX - 20000LL + 400LL, 5, 2)
353
        check (i, -20000LL + 600LL, 5, 3)
354
        check (i, INT_MAX - 20000LL + 800LL, 5, 4)
355
        e = 1;
356
      }
357
  }
358
  if (e)
359
    abort ();
360
  test (0, 3);
361
  test (1, 3);
362
  test (2, 1);
363
  test (3, 1);
364
  test (4, 4);
365
  test (5, 5);
366
  return 0;
367
}
368
 
369
int
370
main ()
371
{
372
  if (2 * sizeof (int) != sizeof (long long))
373
    return 0;
374
  test1 ();
375
  test2 ();
376
  test3 ();
377
  test4 ();
378
  omp_set_schedule (omp_sched_static, 0);
379
  test5 ();
380
  omp_set_schedule (omp_sched_static, 3);
381
  test5 ();
382
  omp_set_schedule (omp_sched_dynamic, 5);
383
  test5 ();
384
  omp_set_schedule (omp_sched_guided, 2);
385
  test5 ();
386
  return 0;
387
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.