1 /* TODO: move to ../libgomp.c-c++-common once C++ is implemented. */
2 /* NOTE: { target c } is unsupported with with the C compiler. */
5 /* { dg-additional-options "-fdump-tree-omplower" } */
7 /* For the 4 vars in omp_parallel, 4 in omp_target and 1 of 2 in no_alloc2_func. */
8 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_alloc \\(" 9 "omplower" } } */
9 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(" 9 "omplower" } } */
14 check_int (int *x
, int y
)
21 check_ptr (int **x
, int *y
)
31 /* There is no __builtin_GOMP_alloc / __builtin_GOMP_free as
32 allocator == omp_default_mem_alloc (known at compile time. */
34 #pragma omp allocate(no_alloc) allocator(omp_default_mem_alloc)
42 /* There is no __builtin_GOMP_alloc / __builtin_GOMP_free as
43 no_alloc2 is TREE_UNUSED. But there is for is_alloc2. */
44 int no_alloc2
, is_alloc2
;
45 #pragma omp allocate(no_alloc2, is_alloc2)
55 int iii
= 5, jjj
[5], kkk
[n
];
56 int *ptr
= (int *) 0x1234;
57 #pragma omp allocate(iii, jjj, kkk, ptr)
59 for (int i
= 0; i
< 5; i
++)
61 for (int i
= 0; i
< 6; i
++)
64 #pragma omp parallel default(none) firstprivate(iii, jjj, kkk, ptr) if(0)
70 for (int i
= 0; i
< 5; i
++)
73 for (int i
= 0; i
< 6; i
++)
76 for (int i
= 0; i
< 5; i
++)
78 for (int i
= 0; i
< 6; i
++)
80 for (int i
= 0; i
< 5; i
++)
81 check_int (&jjj
[i
], 4*i
);
82 for (int i
= 0; i
< 6; i
++)
83 check_int (&kkk
[i
], 8*i
);
84 if (ptr
!= (int *) 0x1234)
87 if (ptr
!= (int *) 0xabcd)
89 check_ptr (&ptr
, (int *) 0xabcd);
94 for (int i
= 0; i
< 5; i
++)
98 check_int (&jjj
[i
], 3*i
);
100 for (int i
= 0; i
< 6; i
++)
104 check_int (&kkk
[i
], 7*i
);
106 if (ptr
!= (int *) 0x1234)
108 check_ptr (&ptr
, (int *) 0x1234);
110 #pragma omp parallel default(firstprivate) if(0)
116 for (int i
= 0; i
< 5; i
++)
119 for (int i
= 0; i
< 6; i
++)
122 for (int i
= 0; i
< 5; i
++)
124 for (int i
= 0; i
< 6; i
++)
126 for (int i
= 0; i
< 5; i
++)
127 check_int (&jjj
[i
], 4*i
);
128 for (int i
= 0; i
< 6; i
++)
129 check_int (&kkk
[i
], 8*i
);
130 if (ptr
!= (int *) 0x1234)
132 ptr
= (int *) 0xabcd;
133 if (ptr
!= (int *) 0xabcd)
135 check_ptr (&ptr
, (int *) 0xabcd);
140 for (int i
= 0; i
< 5; i
++)
144 check_int (&jjj
[i
], 3*i
);
146 for (int i
= 0; i
< 6; i
++)
150 check_int (&kkk
[i
], 7*i
);
152 if (ptr
!= (int *) 0x1234)
154 check_ptr (&ptr
, (int *) 0x1234);
163 int iii
= 5, jjj
[5], kkk
[n
];
164 int *ptr
= (int *) 0x1234;
165 #pragma omp allocate(iii, jjj, kkk, ptr)
167 for (int i
= 0; i
< 5; i
++)
169 for (int i
= 0; i
< 6; i
++)
172 #pragma omp target defaultmap(none) firstprivate(iii, jjj, kkk, ptr)
178 for (int i
= 0; i
< 5; i
++)
181 for (int i
= 0; i
< 6; i
++)
184 for (int i
= 0; i
< 5; i
++)
186 for (int i
= 0; i
< 6; i
++)
188 for (int i
= 0; i
< 5; i
++)
189 check_int (&jjj
[i
], 4*i
);
190 for (int i
= 0; i
< 6; i
++)
191 check_int (&kkk
[i
], 8*i
);
192 if (ptr
!= (int *) 0x1234)
194 ptr
= (int *) 0xabcd;
195 if (ptr
!= (int *) 0xabcd)
197 check_ptr (&ptr
, (int *) 0xabcd);
202 for (int i
= 0; i
< 5; i
++)
206 check_int (&jjj
[i
], 3*i
);
208 for (int i
= 0; i
< 6; i
++)
212 check_int (&kkk
[i
], 7*i
);
214 if (ptr
!= (int *) 0x1234)
216 check_ptr (&ptr
, (int *) 0x1234);
218 #pragma omp target defaultmap(firstprivate)
224 for (int i
= 0; i
< 5; i
++)
227 for (int i
= 0; i
< 6; i
++)
230 for (int i
= 0; i
< 5; i
++)
232 for (int i
= 0; i
< 6; i
++)
234 for (int i
= 0; i
< 5; i
++)
235 check_int (&jjj
[i
], 4*i
);
236 for (int i
= 0; i
< 6; i
++)
237 check_int (&kkk
[i
], 8*i
);
238 if (ptr
!= (int *) 0x1234)
240 ptr
= (int *) 0xabcd;
241 if (ptr
!= (int *) 0xabcd)
243 check_ptr (&ptr
, (int *) 0xabcd);
248 for (int i
= 0; i
< 5; i
++)
252 check_int (&jjj
[i
], 3*i
);
254 for (int i
= 0; i
< 6; i
++)
258 check_int (&kkk
[i
], 7*i
);
260 if (ptr
!= (int *) 0x1234)
262 check_ptr (&ptr
, (int *) 0x1234);
264 #pragma omp target defaultmap(tofrom)
270 for (int i
= 0; i
< 5; i
++)
273 for (int i
= 0; i
< 6; i
++)
276 for (int i
= 0; i
< 5; i
++)
278 for (int i
= 0; i
< 6; i
++)
280 for (int i
= 0; i
< 5; i
++)
281 check_int (&jjj
[i
], 4*i
);
282 for (int i
= 0; i
< 6; i
++)
283 check_int (&kkk
[i
], 8*i
);
284 if (ptr
!= (int *) 0x1234)
286 ptr
= (int *) 0xabcd;
287 if (ptr
!= (int *) 0xabcd)
289 check_ptr (&ptr
, (int *) 0xabcd);
295 for (int i
= 0; i
< 5; i
++)
299 check_int (&jjj
[i
], 4*i
);
301 for (int i
= 0; i
< 6; i
++)
305 check_int (&kkk
[i
], 8*i
);
307 if (ptr
!= (int *) 0xabcd)
309 check_ptr (&ptr
, (int *) 0xabcd);