Debian Codegraph @

libgomp/testsuite/libgomp.c++/ind-base-1.C

raw
1 // { dg-do run }
2 // { dg-options "-fopenmp" }
3
4 #include <cassert>
5
6 struct S
7 {
8 int x[10];
9 };
10
11 struct T
12 {
13 struct S *s;
14 };
15
16 struct U
17 {
18 struct T *t;
19 };
20
21 void
22 foo_siblist (void)
23 {
24 U *u = new U;
25 u->t = new T;
26 u->t->s = new S;
27 for (int i = 0; i < 10; i++)
28 u->t->s->x[i] = 0;
29 #pragma omp target map(u->t, *(u->t), u->t->s, *u->t->s)
30 for (int i = 0; i < 10; i++)
31 u->t->s->x[i] = i * 3;
32 for (int i = 0; i < 10; i++)
33 assert (u->t->s->x[i] == i * 3);
34 delete u->t->s;
35 delete u->t;
36 delete u;
37 }
38
39 void
40 foo (void)
41 {
42 U *u = new U;
43 u->t = new T;
44 u->t->s = new S;
45 for (int i = 0; i < 10; i++)
46 u->t->s->x[i] = 0;
47 #pragma omp target map(*u, u->t, *(u->t), u->t->s, *u->t->s)
48 for (int i = 0; i < 10; i++)
49 u->t->s->x[i] = i * 3;
50 for (int i = 0; i < 10; i++)
51 assert (u->t->s->x[i] == i * 3);
52 delete u->t->s;
53 delete u->t;
54 delete u;
55 }
56
57 void
58 foo_tofrom (void)
59 {
60 U *u = new U;
61 u->t = new T;
62 u->t->s = new S;
63 for (int i = 0; i < 10; i++)
64 u->t->s->x[i] = 0;
65 #pragma omp target map(u, *u, u->t, *(u->t), u->t->s, *u->t->s)
66 for (int i = 0; i < 10; i++)
67 u->t->s->x[i] = i * 3;
68 for (int i = 0; i < 10; i++)
69 assert (u->t->s->x[i] == i * 3);
70 delete u->t->s;
71 delete u->t;
72 delete u;
73 }
74
75 void
76 bar (void)
77 {
78 U *u = new U;
79 U **up = &u;
80 u->t = new T;
81 u->t->s = new S;
82 for (int i = 0; i < 10; i++)
83 (*up)->t->s->x[i] = 0;
84 #pragma omp target map(*up, (*up)->t, *(*up)->t, (*up)->t->s, *(*up)->t->s)
85 for (int i = 0; i < 10; i++)
86 (*up)->t->s->x[i] = i * 3;
87 for (int i = 0; i < 10; i++)
88 assert ((*up)->t->s->x[i] == i * 3);
89 delete u->t->s;
90 delete u->t;
91 delete u;
92 }
93
94 void
95 bar_pp (void)
96 {
97 U *u = new U;
98 U **up = &u;
99 u->t = new T;
100 u->t->s = new S;
101 for (int i = 0; i < 10; i++)
102 (*up)->t->s->x[i] = 0;
103 #pragma omp target map(*up, **up, (*up)->t, *(*up)->t, (*up)->t->s, *(*up)->t->s)
104 for (int i = 0; i < 10; i++)
105 (*up)->t->s->x[i] = i * 3;
106 for (int i = 0; i < 10; i++)
107 assert ((*up)->t->s->x[i] == i * 3);
108 delete u->t->s;
109 delete u->t;
110 delete u;
111 }
112
113 void
114 bar_tofrom (void)
115 {
116 U *u = new U;
117 U **up = &u;
118 u->t = new T;
119 u->t->s = new S;
120 for (int i = 0; i < 10; i++)
121 (*up)->t->s->x[i] = 0;
122 #pragma omp target map(*up, up, (*up)->t, *(*up)->t, (*up)->t->s, *(*up)->t->s)
123 for (int i = 0; i < 10; i++)
124 (*up)->t->s->x[i] = i * 3;
125 for (int i = 0; i < 10; i++)
126 assert ((*up)->t->s->x[i] == i * 3);
127 delete u->t->s;
128 delete u->t;
129 delete u;
130 }
131
132 void
133 bar_tofrom_pp (void)
134 {
135 U *u = new U;
136 U **up = &u;
137 u->t = new T;
138 u->t->s = new S;
139 for (int i = 0; i < 10; i++)
140 (*up)->t->s->x[i] = 0;
141 #pragma omp target map(**up, *up, up, (*up)->t, *(*up)->t, (*up)->t->s, \
142 *(*up)->t->s)
143 for (int i = 0; i < 10; i++)
144 (*up)->t->s->x[i] = i * 3;
145 for (int i = 0; i < 10; i++)
146 assert ((*up)->t->s->x[i] == i * 3);
147 delete u->t->s;
148 delete u->t;
149 delete u;
150 }
151
152 int main (int argc, char *argv[])
153 {
154 foo_siblist ();
155 foo ();
156 foo_tofrom ();
157 bar ();
158 bar_pp ();
159 bar_tofrom ();
160 bar_tofrom_pp ();
161 return 0;
162 }