| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */ |
| 3 |
|
| 4 |
#include <openacc.h> |
| 5 |
#include <string.h> |
| 6 |
#include <stdio.h> |
| 7 |
#include <stdlib.h> |
| 8 |
#include <stdbool.h> |
| 9 |
|
| 10 |
int |
| 11 |
main(int argc, char **argv) |
| 12 |
{ |
| 13 |
int N = 8; |
| 14 |
float *a, *b; |
| 15 |
int i; |
| 16 |
|
| 17 |
a = (float *) malloc(N * sizeof (float)); |
| 18 |
b = (float *) malloc(N * sizeof (float)); |
| 19 |
|
| 20 |
for (i = 0; i < N; i++) |
| 21 |
{ |
| 22 |
a[i] = 2.0; |
| 23 |
b[i] = 5.0; |
| 24 |
} |
| 25 |
|
| 26 |
#pragma acc parallel copyin(a[2:4]) copyout(b[2:4]) |
| 27 |
{ |
| 28 |
b[2] = a[2]; |
| 29 |
b[3] = a[3]; |
| 30 |
} |
| 31 |
|
| 32 |
for (i = 2; i < 4; i++) |
| 33 |
{ |
| 34 |
if (a[i] != 2.0) |
| 35 |
abort(); |
| 36 |
|
| 37 |
if (b[i] != 2.0) |
| 38 |
abort(); |
| 39 |
} |
| 40 |
|
| 41 |
for (i = 0; i < N; i++) |
| 42 |
{ |
| 43 |
a[i] = 3.0; |
| 44 |
b[i] = 1.0; |
| 45 |
} |
| 46 |
|
| 47 |
#pragma acc parallel copyin(a[0:4]) copyout(b[0:4]) |
| 48 |
{ |
| 49 |
b[0] = a[0]; |
| 50 |
b[1] = a[1]; |
| 51 |
b[2] = a[2]; |
| 52 |
b[3] = a[3]; |
| 53 |
} |
| 54 |
|
| 55 |
for (i = 0; i < 4; i++) |
| 56 |
{ |
| 57 |
if (a[i] != 3.0) |
| 58 |
abort(); |
| 59 |
|
| 60 |
if (b[i] != 3.0) |
| 61 |
abort(); |
| 62 |
} |
| 63 |
|
| 64 |
for (i = 0; i < N; i++) |
| 65 |
{ |
| 66 |
a[i] = 9.0; |
| 67 |
b[i] = 6.0; |
| 68 |
} |
| 69 |
|
| 70 |
#pragma acc parallel copyin(a[0:4]) copyout(b[4:4]) |
| 71 |
{ |
| 72 |
b[4] = a[0]; |
| 73 |
b[5] = a[1]; |
| 74 |
b[6] = a[2]; |
| 75 |
b[7] = a[3]; |
| 76 |
} |
| 77 |
|
| 78 |
for (i = 0; i < 4; i++) |
| 79 |
{ |
| 80 |
if (a[i] != 9.0) |
| 81 |
abort(); |
| 82 |
} |
| 83 |
|
| 84 |
for (i = 4; i < 8; i++) |
| 85 |
{ |
| 86 |
if (b[i] != 9.0) |
| 87 |
abort(); |
| 88 |
} |
| 89 |
|
| 90 |
if (acc_is_present (a, (N * sizeof (float)))) |
| 91 |
abort(); |
| 92 |
|
| 93 |
if (acc_is_present (b, (N * sizeof (float)))) |
| 94 |
abort(); |
| 95 |
|
| 96 |
return 0; |
| 97 |
} |