| 1 |
#include <omp.h> |
| 2 |
#include <stdlib.h> |
| 3 |
|
| 4 |
int main (void) |
| 5 |
{ |
| 6 |
int d = omp_get_default_device (); |
| 7 |
int id = omp_get_initial_device (); |
| 8 |
|
| 9 |
if (d < 0 || d >= omp_get_num_devices ()) |
| 10 |
d = id; |
| 11 |
|
| 12 |
unsigned int a = 0xcdcdcdcd; |
| 13 |
#pragma omp target enter data map (to:a) |
| 14 |
|
| 15 |
a = 0xabababab; |
| 16 |
unsigned char *p = (unsigned char *) &a; |
| 17 |
unsigned char *q = p + 2; |
| 18 |
|
| 19 |
#pragma omp target enter data map (alloc:p[:1], q[:1]) |
| 20 |
|
| 21 |
if (d != id) |
| 22 |
{ |
| 23 |
if (!omp_target_is_present (&a, d)) |
| 24 |
abort (); |
| 25 |
if (!omp_target_is_present (&p[0], d)) |
| 26 |
abort (); |
| 27 |
if (!omp_target_is_present (&q[0], d)) |
| 28 |
abort (); |
| 29 |
} |
| 30 |
|
| 31 |
#pragma omp target exit data map (release:a) |
| 32 |
|
| 33 |
if (d != id) |
| 34 |
{ |
| 35 |
if (!omp_target_is_present (&a, d)) |
| 36 |
abort (); |
| 37 |
if (!omp_target_is_present (&p[0], d)) |
| 38 |
abort (); |
| 39 |
if (!omp_target_is_present (&q[0], d)) |
| 40 |
abort (); |
| 41 |
} |
| 42 |
|
| 43 |
#pragma omp target exit data map (from:q[:1]) |
| 44 |
|
| 45 |
if (d != id) |
| 46 |
{ |
| 47 |
if (omp_target_is_present (&a, d)) |
| 48 |
abort (); |
| 49 |
if (omp_target_is_present (&p[0], d)) |
| 50 |
abort (); |
| 51 |
if (omp_target_is_present (&q[0], d)) |
| 52 |
abort (); |
| 53 |
|
| 54 |
if (q[0] != 0xcd) |
| 55 |
abort (); |
| 56 |
if (p[0] != 0xab) |
| 57 |
abort (); |
| 58 |
} |
| 59 |
|
| 60 |
return 0; |
| 61 |
} |