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
10typedef 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
16typedef 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
23typedef struct {
24 int e;
25 C f;
26 int h;
27} D;
28
29int main() {
30 constexpr int N = 10;
31 D sa[2];
32 double x[2], y[2];
33 double x1[2], y1[2];
34 y[1] = x[1] = 20;
35
36 sa[0].e = 111;
37 sa[0].f.a = 222;
38 sa[0].f.c.a = 777;
39 sa[0].f.b = &x[0];
40 sa[0].f.c.b = &x1[0];
41 sa[0].h = N;
42
43 sa[1].e = 111;
44 sa[1].f.a = 222;
45 sa[1].f.c.a = 777;
46 sa[1].f.b = &y[0];
47 sa[1].f.c.b = &y1[0];
48 sa[1].h = N;
49
50 printf(format: "%d %d %d %4.5f %d\n", sa[1].e, sa[1].f.a, sa[1].f.c.a, sa[1].f.b[1],
51 sa[1].f.b == &y[0] ? 1 : 0);
52 // CHECK: 111 222 777 20.00000 1
53
54 __intptr_t p = reinterpret_cast<__intptr_t>(&y[0]);
55#pragma omp target map(tofrom : sa) firstprivate(p)
56 {
57 printf(format: "%d %d %d\n", sa[1].f.a, sa[1].f.c.a,
58 sa[1].f.b == reinterpret_cast<void *>(p) ? 1 : 0);
59 // CHECK: 222 777 0
60 sa[1].e = 333;
61 sa[1].f.a = 444;
62 sa[1].f.c.a = 555;
63 sa[1].f.b[1] = 40;
64 }
65 printf(format: "%d %d %d %4.5f %d\n", sa[1].e, sa[1].f.a, sa[1].f.c.a, sa[1].f.b[1],
66 sa[1].f.b == &y[0] ? 1 : 0);
67 // CHECK: 333 222 777 40.00000 1
68}
69

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of offload/test/mapping/declare_mapper_nested_default_mappers_array.cpp