| 1 |
/* { dg-do run } */ |
| 2 |
|
| 3 |
#ifndef __cplusplus |
| 4 |
extern void abort (void); |
| 5 |
#else |
| 6 |
extern "C" void abort (void); |
| 7 |
#endif |
| 8 |
|
| 9 |
static int inner_loop_count = 0; |
| 10 |
static int intervening_code_count = 0; |
| 11 |
|
| 12 |
void |
| 13 |
g (int x, int y) |
| 14 |
{ |
| 15 |
inner_loop_count++; |
| 16 |
} |
| 17 |
|
| 18 |
int |
| 19 |
foo (int imax, int jmax) |
| 20 |
{ |
| 21 |
int j = 0; |
| 22 |
|
| 23 |
#pragma omp for collapse(2) |
| 24 |
for (int i = 0; i < imax; ++i) |
| 25 |
{ |
| 26 |
/* All the intervening code at the same level must be executed |
| 27 |
the same number of times. */ |
| 28 |
++intervening_code_count; |
| 29 |
for (int j = 0; j < jmax; ++j) |
| 30 |
{ |
| 31 |
g (i, j); |
| 32 |
} |
| 33 |
/* This is the outer j, not the one from the inner collapsed loop. */ |
| 34 |
++j; |
| 35 |
} |
| 36 |
return j; |
| 37 |
} |
| 38 |
|
| 39 |
int |
| 40 |
main (void) |
| 41 |
{ |
| 42 |
int j = foo (5, 3); |
| 43 |
if (j != intervening_code_count) |
| 44 |
abort (); |
| 45 |
if (inner_loop_count != 5 * 3) |
| 46 |
abort (); |
| 47 |
if (intervening_code_count < 5 || intervening_code_count > 5 * 3) |
| 48 |
abort (); |
| 49 |
} |