| 1 |
#include <omp.h> |
| 2 |
#include <stdlib.h> |
| 3 |
|
| 4 |
int |
| 5 |
main () |
| 6 |
{ |
| 7 |
int d = omp_get_default_device (); |
| 8 |
int id = omp_get_initial_device (); |
| 9 |
int x; |
| 10 |
void *p, *q; |
| 11 |
|
| 12 |
q = (void *) &x; |
| 13 |
|
| 14 |
if (d < 0 || d >= omp_get_num_devices ()) |
| 15 |
d = id; |
| 16 |
|
| 17 |
p = omp_target_alloc (sizeof (int), d); |
| 18 |
if (p == NULL) |
| 19 |
return 0; |
| 20 |
|
| 21 |
if (omp_target_associate_ptr (q, p, sizeof (int), 0, d) != 0) |
| 22 |
return 0; |
| 23 |
|
| 24 |
if (omp_get_mapped_ptr (q, -6) != NULL) |
| 25 |
abort (); |
| 26 |
|
| 27 |
if (omp_get_mapped_ptr (q, omp_get_num_devices () + 1) != NULL) |
| 28 |
abort (); |
| 29 |
|
| 30 |
if (omp_get_mapped_ptr (q, id) != q) |
| 31 |
abort (); |
| 32 |
|
| 33 |
if (omp_get_mapped_ptr (q, omp_initial_device) != q) |
| 34 |
abort (); |
| 35 |
|
| 36 |
if (omp_get_mapped_ptr (q, d) != p) |
| 37 |
abort (); |
| 38 |
|
| 39 |
if (omp_target_disassociate_ptr (q, d) != 0) |
| 40 |
abort (); |
| 41 |
|
| 42 |
if (omp_get_mapped_ptr (q, d) != NULL) |
| 43 |
abort (); |
| 44 |
|
| 45 |
omp_target_free (p, d); |
| 46 |
return 0; |
| 47 |
} |