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