PR c/81417
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / lib-59.c
blob2f087aedccb17aa9a860a798628eabf6b6a05840
1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
4 #include <stdlib.h>
5 #include <openacc.h>
6 #include <stdint.h>
8 int
9 main (int argc, char **argv)
11 const int N = 256;
12 int i;
13 unsigned char *h;
14 void *d;
16 h = (unsigned char *) malloc (N);
18 d = acc_malloc (N);
20 acc_map_data (h, d, N);
22 for (i = 0; i < N; i++)
24 if (acc_hostptr ((void *)((uintptr_t) d + (uintptr_t) i)) !=
25 (void *)((uintptr_t) h + (uintptr_t) i))
26 abort ();
29 for (i = 0; i < N; i++)
31 if (acc_deviceptr ((void *)((uintptr_t) h + (uintptr_t) i)) !=
32 (void *)((uintptr_t) d + (uintptr_t) i))
33 abort ();
36 acc_unmap_data (h);
38 for (i = 0; i < N; i++)
40 if (acc_hostptr ((void *)((uintptr_t) d + (uintptr_t) i)) != 0)
41 abort ();
44 for (i = 0; i < N; i++)
46 if (acc_deviceptr (h + i) != 0)
47 abort ();
50 acc_free (d);
52 free (h);
54 return 0;