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