| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */ |
| 3 |
|
| 4 |
#include <string.h> |
| 5 |
#include <stdlib.h> |
| 6 |
#include <openacc.h> |
| 7 |
|
| 8 |
int |
| 9 |
main (int argc, char **argv) |
| 10 |
{ |
| 11 |
const int N = 256; |
| 12 |
int i; |
| 13 |
unsigned char *h; |
| 14 |
void *d; |
| 15 |
|
| 16 |
acc_init (acc_device_default); |
| 17 |
|
| 18 |
h = (unsigned char *) malloc (N); |
| 19 |
|
| 20 |
for (i = 0; i < N; i++) |
| 21 |
{ |
| 22 |
h[i] = i; |
| 23 |
} |
| 24 |
|
| 25 |
d = acc_malloc (N); |
| 26 |
|
| 27 |
acc_memcpy_to_device (d, h, N); |
| 28 |
|
| 29 |
memset (&h[0], 0, N); |
| 30 |
|
| 31 |
acc_memcpy_to_device (d, h, 0); |
| 32 |
|
| 33 |
acc_memcpy_from_device (h, d, N); |
| 34 |
|
| 35 |
for (i = 0; i < N; i++) |
| 36 |
{ |
| 37 |
if (h[i] != i) |
| 38 |
abort (); |
| 39 |
} |
| 40 |
|
| 41 |
acc_free (d); |
| 42 |
|
| 43 |
free (h); |
| 44 |
|
| 45 |
acc_shutdown (acc_device_default); |
| 46 |
|
| 47 |
return 0; |
| 48 |
} |