1 | // RUN: %libomptarget-compile-and-run-generic |
2 | |
3 | #include "stdio.h" |
4 | #include <omp.h> |
5 | #include <stdlib.h> |
6 | |
7 | int main() { |
8 | int d = omp_get_default_device(); |
9 | int id = omp_get_initial_device(); |
10 | int q[128], i; |
11 | void *p; |
12 | void *result; |
13 | |
14 | if (d < 0 || d >= omp_get_num_devices()) |
15 | d = id; |
16 | |
17 | p = omp_target_alloc(130 * sizeof(int), d); |
18 | if (p == NULL) |
19 | return 0; |
20 | |
21 | for (i = 0; i < 128; i++) |
22 | q[i] = i; |
23 | |
24 | result = omp_target_memset(p, 0, 130 * sizeof(int), d); |
25 | if (result != p) { |
26 | abort(); |
27 | } |
28 | |
29 | int q2[128]; |
30 | for (i = 0; i < 128; ++i) |
31 | q2[i] = i; |
32 | if (omp_target_memcpy_async(q2, p, 128 * sizeof(int), 0, sizeof(int), id, d, |
33 | 0, NULL)) |
34 | abort(); |
35 | |
36 | #pragma omp taskwait |
37 | |
38 | for (i = 0; i < 128; ++i) |
39 | if (q2[i] != 0) |
40 | abort(); |
41 | |
42 | omp_target_free(p, d); |
43 | |
44 | return 0; |
45 | } |
46 | |