| 1 |
/* { dg-do run } */ |
| 2 |
|
| 3 |
#include <math.h> |
| 4 |
|
| 5 |
#define N 100 |
| 6 |
#define EPSILON 0.001 |
| 7 |
|
| 8 |
#pragma omp declare target |
| 9 |
void |
| 10 |
f (double a[], double x) { |
| 11 |
int i; |
| 12 |
|
| 13 |
#pragma omp metadirective \ |
| 14 |
when (construct={target}: distribute parallel for) \ |
| 15 |
default (parallel for simd) |
| 16 |
for (i = 0; i < N; i++) |
| 17 |
a[i] = x * i; |
| 18 |
} |
| 19 |
#pragma omp end declare target |
| 20 |
|
| 21 |
int |
| 22 |
main (void) |
| 23 |
{ |
| 24 |
double a[N]; |
| 25 |
int i; |
| 26 |
|
| 27 |
#pragma omp target teams map(from: a[0:N]) |
| 28 |
f (a, M_PI); |
| 29 |
|
| 30 |
for (i = 0; i < N; i++) |
| 31 |
if (fabs (a[i] - (M_PI * i)) > EPSILON) |
| 32 |
return 1; |
| 33 |
|
| 34 |
f (a, M_E); |
| 35 |
|
| 36 |
for (i = 0; i < N; i++) |
| 37 |
if (fabs (a[i] - (M_E * i)) > EPSILON) |
| 38 |
return 1; |
| 39 |
|
| 40 |
return 0; |
| 41 |
} |