1 // RUN: %libomptarget-compile-and-run-generic
9 int d
= omp_get_default_device();
10 int id
= omp_get_initial_device();
11 int a
[128], b
[64], c
[128], e
[16], q
[128], i
;
14 if (d
< 0 || d
>= omp_get_num_devices())
17 p
= omp_target_alloc(130 * sizeof(int), d
);
21 for (i
= 0; i
< 128; i
++)
23 if (omp_target_memcpy(p
, q
, 128 * sizeof(int), 0, 0, d
, id
) != 0)
26 size_t volume
[NUM_DIMS
] = {2, 2, 3};
27 size_t dst_offsets
[NUM_DIMS
] = {0, 0, 0};
28 size_t src_offsets
[NUM_DIMS
] = {0, 0, 0};
29 size_t dst_dimensions
[NUM_DIMS
] = {3, 4, 5};
30 size_t src_dimensions
[NUM_DIMS
] = {2, 3, 4};
32 for (i
= 0; i
< 128; i
++)
34 for (i
= 0; i
< 64; i
++)
36 for (i
= 0; i
< 128; i
++)
38 for (i
= 0; i
< 16; i
++)
43 #pragma omp parallel num_threads(5)
46 #pragma omp task depend(out : p)
47 omp_target_memcpy(p
, a
, 128 * sizeof(int), 0, 0, d
, id
);
49 #pragma omp task depend(inout : p)
50 omp_target_memcpy(p
, b
, 64 * sizeof(int), 0, 0, d
, id
);
52 #pragma omp task depend(out : c)
53 for (i
= 0; i
< 128; i
++)
56 #pragma omp depobj(obj[0]) depend(inout : p)
57 #pragma omp depobj(obj[1]) depend(in : c)
59 /* This produces: 1 2 3 - - 5 6 7 - - at positions 0..9 and
60 13 14 15 - - 17 18 19 - - at positions 20..29. */
61 omp_target_memcpy_rect_async(p
, c
, sizeof(int), NUM_DIMS
, volume
,
62 dst_offsets
, src_offsets
, dst_dimensions
,
63 src_dimensions
, d
, id
, 2, obj
);
65 #pragma omp task depend(in : p)
66 omp_target_memcpy(p
, e
, 16 * sizeof(int), 0, 0, d
, id
);
71 if (omp_target_memcpy(q
, p
, 128 * sizeof(int), 0, 0, id
, d
) != 0)
74 for (i
= 0; i
< 16; ++i
)
77 if (q
[20] != 13 || q
[21] != 14 || q
[22] != 15 || q
[25] != 17 || q
[26] != 18 ||
80 for (i
= 28; i
< 64; ++i
)
83 for (i
= 64; i
< 128; ++i
)
87 omp_target_free(p
, d
);