libgomp testsuite: OpenACC C++ testing.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / lib-38.c
blob1e16a1d1a6c0a398435d39a2af66bc3755fedb24
1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
4 #include <string.h>
5 #include <stdlib.h>
6 #include <openacc.h>
8 int
9 main (int argc, char **argv)
11 const int N = 256;
12 int i;
13 unsigned char *h;
14 void *d1, *d2;
16 h = (unsigned char *) malloc (N);
18 for (i = 0; i < N; i++)
20 h[i] = i;
23 d1 = acc_present_or_copyin (h, N);
24 if (!d1)
25 abort ();
27 for (i = 0; i < N; i++)
29 h[i] = 0xab;
32 d2 = acc_present_or_copyin (h, N);
33 if (!d2)
34 abort ();
36 if (d1 != d2)
37 abort ();
39 memset (&h[0], 0, N);
41 acc_copyout (h, N);
43 for (i = 0; i < N; i++)
45 if (h[i] != i)
46 abort ();
49 d2 = acc_pcopyin (h, N);
50 if (!d2)
51 abort ();
53 if (d1 != d2)
54 abort ();
56 acc_copyout (h, N);
58 for (i = 0; i < N; i++)
60 if (h[i] != i)
61 abort ();
64 free (h);
66 return 0;