libgomp testsuite: OpenACC C++ testing.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / lib-66.c
blob360c05b0cd2fe349a0a8d94451b58b279a280fe4
1 /* { dg-do run } */
3 #include <string.h>
4 #include <stdlib.h>
5 #include <openacc.h>
7 int
8 main (int argc, char **argv)
10 const int N = 256;
11 int i;
12 unsigned char *h;
13 void *d;
15 acc_init (acc_device_nvidia);
17 h = (unsigned char *) malloc (N);
19 for (i = 0; i < N; i++)
21 h[i] = i;
24 d = acc_malloc (N);
26 acc_memcpy_to_device (d, h, N);
28 memset (&h[0], 0, N);
30 acc_memcpy_to_device (d, h, 0);
32 acc_memcpy_from_device (h, d, N);
34 for (i = 0; i < N; i++)
36 if (h[i] != i)
37 abort ();
40 acc_free (d);
42 free (h);
44 acc_shutdown (acc_device_nvidia);
46 return 0;