1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
3
4 #include <stdlib.h>
5 #include <openacc.h>
6 #include <stdint.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 h = (unsigned char *) malloc (N);
17
18 d = acc_malloc (N);
19
20 acc_map_data (h, d, N);
21
22 for (i = 0; i < N; i++)
23 {
24 if (acc_hostptr ((void *)((uintptr_t) d + (uintptr_t) i)) !=
25 (void *)((uintptr_t) h + (uintptr_t) i))
26 abort ();
27 }
28
29 for (i = 0; i < N; i++)
30 {
31 if (acc_deviceptr ((void *)((uintptr_t) h + (uintptr_t) i)) !=
32 (void *)((uintptr_t) d + (uintptr_t) i))
33 abort ();
34 }
35
36 acc_unmap_data (h);
37
38 for (i = 0; i < N; i++)
39 {
40 if (acc_hostptr ((void *)((uintptr_t) d + (uintptr_t) i)) != 0)
41 abort ();
42 }
43
44 for (i = 0; i < N; i++)
45 {
46 if (acc_deviceptr (h + i) != 0)
47 abort ();
48 }
49
50 acc_free (d);
51
52 free (h);
53
54 return 0;
55 }