1 // RUN: %libomptarget-compile-and-run-generic
10 int d
= omp_get_default_device();
11 int id
= omp_get_initial_device();
12 int q
[128], q2
[128], i
;
15 if (d
< 0 || d
>= omp_get_num_devices())
18 p
= omp_target_alloc(130 * sizeof(int), d
);
22 if (omp_target_memcpy_rect_async(NULL
, NULL
, 0, 0, NULL
, NULL
, NULL
, NULL
,
23 NULL
, d
, id
, 0, NULL
) < 3 ||
24 omp_target_memcpy_rect_async(NULL
, NULL
, 0, 0, NULL
, NULL
, NULL
, NULL
,
25 NULL
, id
, d
, 0, NULL
) < 3 ||
26 omp_target_memcpy_rect_async(NULL
, NULL
, 0, 0, NULL
, NULL
, NULL
, NULL
,
27 NULL
, id
, id
, 0, NULL
) < 3)
30 for (i
= 0; i
< 128; i
++)
32 if (omp_target_memcpy(p
, q
, 128 * sizeof(int), 0, 0, d
, id
) != 0)
35 for (i
= 0; i
< 128; i
++)
38 size_t volume
[NUM_DIMS
] = {1, 2, 3};
39 size_t dst_offsets
[NUM_DIMS
] = {0, 0, 0};
40 size_t src_offsets
[NUM_DIMS
] = {0, 0, 0};
41 size_t dst_dimensions
[NUM_DIMS
] = {3, 4, 5};
42 size_t src_dimensions
[NUM_DIMS
] = {2, 3, 4};
44 if (omp_target_memcpy_rect_async(p
, q
, sizeof(int), NUM_DIMS
, volume
,
45 dst_offsets
, src_offsets
, dst_dimensions
,
46 src_dimensions
, d
, id
, 0, NULL
) != 0)
51 for (i
= 0; i
< 128; i
++)
53 if (omp_target_memcpy(q2
, p
, 128 * sizeof(int), 0, 0, id
, d
) != 0)
56 /* q2 is expected to contain: 1 2 3 0 0 5 6 7 0 0 .. 0 */
57 if (q2
[0] != 1 || q2
[1] != 2 || q2
[2] != 3 || q2
[3] != 0 || q2
[4] != 0 ||
58 q2
[5] != 5 || q2
[6] != 6 || q2
[7] != 7)
60 for (i
= 8; i
< 128; ++i
)
64 omp_target_free(p
, d
);