| 1 |
#include <stdlib.h> |
| 2 |
|
| 3 |
/* Test multiple struct dereferences on one directive, and slices starting at |
| 4 |
non-zero. */ |
| 5 |
|
| 6 |
typedef struct { |
| 7 |
int *a; |
| 8 |
int *b; |
| 9 |
int *c; |
| 10 |
} mystruct; |
| 11 |
|
| 12 |
int main(int argc, char* argv[]) |
| 13 |
{ |
| 14 |
const int N = 1024; |
| 15 |
mystruct *m = (mystruct *) malloc (sizeof (*m)); |
| 16 |
int i; |
| 17 |
|
| 18 |
m->a = (int *) malloc (N * sizeof (int)); |
| 19 |
m->b = (int *) malloc (N * sizeof (int)); |
| 20 |
m->c = (int *) malloc (N * sizeof (int)); |
| 21 |
|
| 22 |
for (i = 0; i < N; i++) |
| 23 |
{ |
| 24 |
m->a[i] = 0; |
| 25 |
m->b[i] = 0; |
| 26 |
m->c[i] = 0; |
| 27 |
} |
| 28 |
|
| 29 |
#pragma acc enter data copyin(m[0:1]) |
| 30 |
|
| 31 |
for (int i = 0; i < 99; i++) |
| 32 |
{ |
| 33 |
int j; |
| 34 |
#pragma acc parallel loop copy(m->a[0:N]) |
| 35 |
for (j = 0; j < N; j++) |
| 36 |
m->a[j]++; |
| 37 |
#pragma acc parallel loop copy(m->b[0:N], m->c[5:N-10]) |
| 38 |
for (j = 0; j < N; j++) |
| 39 |
{ |
| 40 |
m->b[j]++; |
| 41 |
if (j > 5 && j < N - 5) |
| 42 |
m->c[j]++; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
#pragma acc exit data copyout(m[0:1]) |
| 47 |
|
| 48 |
for (i = 0; i < N; i++) |
| 49 |
{ |
| 50 |
if (m->a[i] != 99) |
| 51 |
abort (); |
| 52 |
if (m->b[i] != 99) |
| 53 |
abort (); |
| 54 |
if (i > 5 && i < N-5) |
| 55 |
{ |
| 56 |
if (m->c[i] != 99) |
| 57 |
abort (); |
| 58 |
} |
| 59 |
else |
| 60 |
{ |
| 61 |
if (m->c[i] != 0) |
| 62 |
abort (); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
free (m->a); |
| 67 |
free (m->b); |
| 68 |
free (m->c); |
| 69 |
free (m); |
| 70 |
|
| 71 |
return 0; |
| 72 |
} |