| 1 |
/* { dg-do compile } */ |
| 2 |
|
| 3 |
#include <stdio.h> |
| 4 |
extern float average (float, float, float); |
| 5 |
void |
| 6 |
a12 (float *x, float *xold, int n, float tol) |
| 7 |
{ |
| 8 |
int c, i, toobig; |
| 9 |
float error, y; |
| 10 |
c = 0; |
| 11 |
#pragma omp parallel |
| 12 |
{ |
| 13 |
do |
| 14 |
{ |
| 15 |
#pragma omp for private(i) |
| 16 |
for (i = 1; i < n - 1; ++i) |
| 17 |
{ |
| 18 |
xold[i] = x[i]; |
| 19 |
} |
| 20 |
#pragma omp single |
| 21 |
{ |
| 22 |
toobig = 0; |
| 23 |
} |
| 24 |
#pragma omp for private(i,y,error) reduction(+:toobig) |
| 25 |
for (i = 1; i < n - 1; ++i) |
| 26 |
{ |
| 27 |
y = x[i]; |
| 28 |
x[i] = average (xold[i - 1], x[i], xold[i + 1]); |
| 29 |
error = y - x[i]; |
| 30 |
if (error > tol || error < -tol) |
| 31 |
++toobig; |
| 32 |
} |
| 33 |
#pragma omp master |
| 34 |
{ |
| 35 |
++c; |
| 36 |
printf ("iteration %d, toobig=%d\n", c, toobig); |
| 37 |
} |
| 38 |
} |
| 39 |
while (toobig > 0); |
| 40 |
} |
| 41 |
} |