1 /* { dg-do compile } */
2 /* { dg-additional-options "-fdump-tree-gimple" } */
3
4 struct S { int s; };
5 void foo (char *);
6 void bar (int, char *, struct S, int *);
7 #pragma omp declare target to (bar)
8 #define N 16
9
10 void
f1(int sc1,struct S ag1,int * pt1)11 f1 (int sc1, struct S ag1, int *pt1)
12 {
13 char ar1[N];
14 foo (ar1);
15 #pragma omp target
16 bar (sc1, ar1, ag1, pt1);
17 /* { dg-final { scan-tree-dump "firstprivate\\(sc1\\)" "gimple" } } */
18 /* { dg-final { scan-tree-dump "map\\(tofrom:ar1" "gimple" } } */
19 /* { dg-final { scan-tree-dump "map\\(tofrom:ag1" "gimple" } } */
20 /* { dg-final { scan-tree-dump "map\\(firstprivate:pt1 .pointer assign" "gimple" } } */
21 }
22
23 void
f2(int sc2,struct S ag2,int * pt2)24 f2 (int sc2, struct S ag2, int *pt2)
25 {
26 char ar2[N];
27 foo (ar2);
28 #pragma omp target firstprivate (sc2, ar2, ag2, pt2) defaultmap (none)
29 bar (sc2, ar2, ag2, pt2);
30 /* { dg-final { scan-tree-dump "firstprivate\\(sc2\\)" "gimple" } } */
31 /* { dg-final { scan-tree-dump "firstprivate\\(ar2\\)" "gimple" } } */
32 /* { dg-final { scan-tree-dump "firstprivate\\(ag2\\)" "gimple" } } */
33 /* { dg-final { scan-tree-dump "firstprivate\\(pt2\\)" "gimple" } } */
34 }
35
36 void
f3(int sc3,struct S ag3,int * pt3)37 f3 (int sc3, struct S ag3, int *pt3)
38 {
39 char ar3[N];
40 foo (ar3);
41 #pragma omp target defaultmap(none:scalar) defaultmap(none:aggregate) \
42 map (sc3, ar3, ag3, pt3) defaultmap(none:pointer)
43 bar (sc3, ar3, ag3, pt3);
44 /* { dg-final { scan-tree-dump "map\\(tofrom:sc3" "gimple" } } */
45 /* { dg-final { scan-tree-dump "map\\(tofrom:ar3" "gimple" } } */
46 /* { dg-final { scan-tree-dump "map\\(tofrom:ag3" "gimple" } } */
47 /* { dg-final { scan-tree-dump "map\\(tofrom:pt3" "gimple" } } */
48 }
49
50 void
f4(int sc4,struct S ag4,int * pt4)51 f4 (int sc4, struct S ag4, int *pt4)
52 {
53 char ar4[N];
54 foo (ar4);
55 #pragma omp target defaultmap(tofrom:scalar)
56 bar (sc4, ar4, ag4, pt4);
57 /* { dg-final { scan-tree-dump "map\\(tofrom:sc4" "gimple" } } */
58 /* { dg-final { scan-tree-dump "map\\(tofrom:ar4" "gimple" } } */
59 /* { dg-final { scan-tree-dump "map\\(tofrom:ag4" "gimple" } } */
60 /* { dg-final { scan-tree-dump "map\\(firstprivate:pt4 .pointer assign" "gimple" } } */
61 }
62
63 void
f5(int sc5,struct S ag5,int * pt5)64 f5 (int sc5, struct S ag5, int *pt5)
65 {
66 char ar5[N];
67 foo (ar5);
68 #pragma omp target defaultmap(to)
69 bar (sc5, ar5, ag5, pt5);
70 /* { dg-final { scan-tree-dump "map\\(to:sc5" "gimple" } } */
71 /* { dg-final { scan-tree-dump "map\\(to:ar5" "gimple" } } */
72 /* { dg-final { scan-tree-dump "map\\(to:ag5" "gimple" } } */
73 /* { dg-final { scan-tree-dump "map\\(to:pt5" "gimple" } } */
74 }
75
76 void
f6(int sc6,struct S ag6,int * pt6)77 f6 (int sc6, struct S ag6, int *pt6)
78 {
79 char ar6[N];
80 foo (ar6);
81 #pragma omp target defaultmap(firstprivate)
82 bar (sc6, ar6, ag6, pt6);
83 /* { dg-final { scan-tree-dump "firstprivate\\(sc6\\)" "gimple" } } */
84 /* { dg-final { scan-tree-dump "firstprivate\\(ar6\\)" "gimple" } } */
85 /* { dg-final { scan-tree-dump "firstprivate\\(ag6\\)" "gimple" } } */
86 /* { dg-final { scan-tree-dump "firstprivate\\(pt6\\)" "gimple" } } */
87 }
88
89 void
f7(int sc7,struct S ag7,int * pt7)90 f7 (int sc7, struct S ag7, int *pt7)
91 {
92 char ar7[N];
93 foo (ar7);
94 #pragma omp target defaultmap(alloc: scalar) defaultmap(from: aggregate) defaultmap(default: pointer)
95 {
96 int *q = &sc7;
97 *q = 6;
98 ag7.s = 5;
99 int i;
100 for (i = 0; i < N; ++i)
101 ar7[i] = 7;
102 bar (sc7, ar7, ag7, pt7);
103 }
104 /* { dg-final { scan-tree-dump "map\\(alloc:sc7" "gimple" } } */
105 /* { dg-final { scan-tree-dump "map\\(from:ar7" "gimple" } } */
106 /* { dg-final { scan-tree-dump "map\\(from:ag7" "gimple" } } */
107 /* { dg-final { scan-tree-dump "map\\(firstprivate:pt7 .pointer assign" "gimple" } } */
108 }
109
110 void
f8(int sc8,struct S ag8,int * pt8)111 f8 (int sc8, struct S ag8, int *pt8)
112 {
113 char ar8[N];
114 foo (ar8);
115 #pragma omp target defaultmap(firstprivate:aggregate) defaultmap(none:scalar) \
116 defaultmap(tofrom:pointer) map(to: sc8)
117 bar (sc8, ar8, ag8, pt8);
118 /* { dg-final { scan-tree-dump "map\\(to:sc8" "gimple" } } */
119 /* { dg-final { scan-tree-dump "firstprivate\\(ar8\\)" "gimple" } } */
120 /* { dg-final { scan-tree-dump "firstprivate\\(ag8\\)" "gimple" } } */
121 /* { dg-final { scan-tree-dump "map\\(tofrom:pt8" "gimple" } } */
122 }
123
124 void
f9(int sc9,struct S ag9)125 f9 (int sc9, struct S ag9)
126 {
127 char ar9[sc9 + 2];
128 foo (ar9);
129 #pragma omp target defaultmap(none) map(to: ar9, ag9) firstprivate (sc9)
130 bar (sc9, ar9, ag9, &sc9);
131 }
132