1 // RUN: %libomptarget-compilexx-run-and-check-generic 2 3 #include <cstdio> 4 #include <cstdlib> 5 6 typedef struct { 7 int a; 8 double *b; 9 } C; 10 #pragma omp declare mapper(id1 : C s) map(to : s.a) map(from : s.b [0:2]) 11 12 typedef struct { 13 int e; 14 C f; 15 int h; 16 short *g; 17 } D; 18 #pragma omp declare mapper(default \ 19 : D r) map(from \ 20 : r.e) map(mapper(id1), tofrom \ 21 : r.f) map(tofrom \ 22 : r.g [0:r.h]) 23 24 int main() { 25 constexpr int N = 10; 26 D s; 27 s.e = 111; 28 s.f.a = 222; 29 double x[2]; 30 x[1] = 20; 31 short y[N]; 32 y[1] = 30; 33 s.f.b = &x[0]; 34 s.g = &y[0]; 35 s.h = N; 36 37 D *sp = &s; 38 D **spp = &sp; 39 40 printf("%d %d %4.5f %d %d %d\n", spp[0][0].e, spp[0][0].f.a, spp[0][0].f.b[1], 41 spp[0][0].f.b == &x[0] ? 1 : 0, spp[0][0].g[1], 42 spp[0][0].g == &y[0] ? 1 : 0); 43 // CHECK: 111 222 20.00000 1 30 1 44 45 __intptr_t p = reinterpret_cast<__intptr_t>(&x[0]), 46 p1 = reinterpret_cast<__intptr_t>(&y[0]); 47 #pragma omp target map(tofrom : spp[0][0]) firstprivate(p, p1) 48 { 49 printf("%d %d %d %d\n", spp[0][0].f.a, 50 spp[0][0].f.b == reinterpret_cast<void *>(p) ? 1 : 0, spp[0][0].g[1], 51 spp[0][0].g == reinterpret_cast<void *>(p1) ? 1 : 0); 52 // CHECK: 222 0 30 0 53 spp[0][0].e = 333; 54 spp[0][0].f.a = 444; 55 spp[0][0].f.b[1] = 40; 56 spp[0][0].g[1] = 50; 57 } 58 printf("%d %d %4.5f %d %d %d\n", spp[0][0].e, spp[0][0].f.a, spp[0][0].f.b[1], 59 spp[0][0].f.b == &x[0] ? 1 : 0, spp[0][0].g[1], 60 spp[0][0].g == &y[0] ? 1 : 0); 61 // CHECK: 333 222 40.00000 1 50 1 62 } 63