| 1 |
/* { dg-do run } */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
#include <stdio.h> |
| 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 |
const int S = 32; |
| 16 |
mystruct *m = (mystruct *) calloc (S, sizeof (*m)); |
| 17 |
int i, j; |
| 18 |
|
| 19 |
for (i = 0; i < S; i++) |
| 20 |
{ |
| 21 |
m[i].a = (int *) malloc (N * sizeof (int)); |
| 22 |
m[i].b = (int *) malloc (N * sizeof (int)); |
| 23 |
m[i].c = (int *) malloc (N * sizeof (int)); |
| 24 |
} |
| 25 |
|
| 26 |
for (j = 0; j < S; j++) |
| 27 |
for (i = 0; i < N; i++) |
| 28 |
{ |
| 29 |
m[j].a[i] = 0; |
| 30 |
m[j].b[i] = 0; |
| 31 |
m[j].c[i] = 0; |
| 32 |
} |
| 33 |
|
| 34 |
#pragma acc enter data copyin(m[0:1]) |
| 35 |
|
| 36 |
for (int i = 0; i < 99; i++) |
| 37 |
{ |
| 38 |
int j, k; |
| 39 |
for (k = 0; k < S; k++) |
| 40 |
#pragma acc parallel loop copy(m[k].a[0:N]) |
| 41 |
for (j = 0; j < N; j++) |
| 42 |
m[k].a[j]++; |
| 43 |
|
| 44 |
for (k = 0; k < S; k++) |
| 45 |
#pragma acc parallel loop copy(m[k].b[0:N], m[k].c[5:N-10]) |
| 46 |
for (j = 0; j < N; j++) |
| 47 |
{ |
| 48 |
m[k].b[j]++; |
| 49 |
if (j > 5 && j < N - 5) |
| 50 |
m[k].c[j]++; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
#pragma acc exit data copyout(m[0:1]) |
| 55 |
|
| 56 |
for (j = 0; j < S; j++) |
| 57 |
{ |
| 58 |
for (i = 0; i < N; i++) |
| 59 |
{ |
| 60 |
if (m[j].a[i] != 99) |
| 61 |
abort (); |
| 62 |
if (m[j].b[i] != 99) |
| 63 |
abort (); |
| 64 |
if (i > 5 && i < N-5) |
| 65 |
{ |
| 66 |
if (m[j].c[i] != 99) |
| 67 |
abort (); |
| 68 |
} |
| 69 |
else |
| 70 |
{ |
| 71 |
if (m[j].c[i] != 0) |
| 72 |
abort (); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
free (m[j].a); |
| 77 |
free (m[j].b); |
| 78 |
free (m[j].c); |
| 79 |
} |
| 80 |
free (m); |
| 81 |
|
| 82 |
return 0; |
| 83 |
} |