| 1 |
#include <stdlib.h> |
| 2 |
#include <string.h> |
| 3 |
#include <assert.h> |
| 4 |
#include <stdio.h> |
| 5 |
|
| 6 |
#define N 32 |
| 7 |
|
| 8 |
typedef struct { |
| 9 |
int x2[10][N]; |
| 10 |
} x1type; |
| 11 |
|
| 12 |
typedef struct { |
| 13 |
x1type x1[10]; |
| 14 |
} p2type; |
| 15 |
|
| 16 |
typedef struct { |
| 17 |
p2type *p2; |
| 18 |
} p1type; |
| 19 |
|
| 20 |
typedef struct { |
| 21 |
p1type *p1; |
| 22 |
} x0type; |
| 23 |
|
| 24 |
typedef struct { |
| 25 |
x0type x0[10]; |
| 26 |
} p0type; |
| 27 |
|
| 28 |
int main(int argc, char *argv[]) |
| 29 |
{ |
| 30 |
p0type *p0; |
| 31 |
int k1 = 0, k2 = 0, k3 = 0, n = N; |
| 32 |
|
| 33 |
p0 = (p0type *) malloc (sizeof *p0); |
| 34 |
p0->x0[0].p1 = (p1type *) malloc (sizeof *p0->x0[0].p1); |
| 35 |
p0->x0[0].p1->p2 = (p2type *) malloc (sizeof *p0->x0[0].p1->p2); |
| 36 |
memset (p0->x0[0].p1->p2, 0, sizeof *p0->x0[0].p1->p2); |
| 37 |
|
| 38 |
#pragma omp target map(tofrom: p0->x0[k1].p1->p2[k2].x1[k3].x2[4][0:n]) \ |
| 39 |
map(to: p0->x0[k1].p1, p0->x0[k1].p1->p2) \ |
| 40 |
map(to: p0->x0[k1].p1[0]) |
| 41 |
{ |
| 42 |
for (int i = 0; i < n; i++) |
| 43 |
p0->x0[k1].p1->p2[k2].x1[k3].x2[4][i] = i; |
| 44 |
} |
| 45 |
|
| 46 |
for (int i = 0; i < n; i++) |
| 47 |
assert (i == p0->x0[k1].p1->p2[k2].x1[k3].x2[4][i]); |
| 48 |
|
| 49 |
return 0; |
| 50 |
} |