Debian Codegraph @

libgomp/testsuite/libgomp.c++/target-48.C

raw
1 #include <cstring>
2 #include <cassert>
3
4 struct s {
5 int (&a)[10];
6 s(int (&a0)[10]) : a(a0) {}
7 };
8
9 int
10 main (int argc, char *argv[])
11 {
12 int la[10];
13 s v(la);
14
15 memset (la, 0, sizeof la);
16
17 #pragma omp target enter data map(to: v)
18
19 /* This mapping must use GOMP_MAP_ATTACH_DETACH not GOMP_MAP_ALWAYS_POINTER,
20 else the host reference v.a will be corrupted on copy-out. */
21
22 #pragma omp target map(v.a[0:10])
23 {
24 v.a[5]++;
25 }
26
27 #pragma omp target exit data map(from: v)
28
29 assert (v.a[5] == 1);
30
31 return 0;
32 }