Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / api / omp_target_memcpy_async1.c
blob1abcfde83dbd8cc7772007cb7b1485abb49b175a
1 // RUN: %libomptarget-compile-and-run-generic
3 // Test case for omp_target_memcpy_async, oringally from GCC
5 #include "stdio.h"
6 #include <omp.h>
7 #include <stdlib.h>
9 int main() {
10 int d = omp_get_default_device();
11 int id = omp_get_initial_device();
12 int q[128], i;
13 void *p;
15 if (d < 0 || d >= omp_get_num_devices())
16 d = id;
18 p = omp_target_alloc(130 * sizeof(int), d);
19 if (p == NULL)
20 return 0;
22 for (i = 0; i < 128; i++)
23 q[i] = i;
25 if (omp_target_memcpy_async(p, q, 128 * sizeof(int), sizeof(int), 0, d, id, 0,
26 NULL)) {
27 abort();
30 #pragma omp taskwait
32 int q2[128];
33 for (i = 0; i < 128; ++i)
34 q2[i] = 0;
35 if (omp_target_memcpy_async(q2, p, 128 * sizeof(int), 0, sizeof(int), id, d,
36 0, NULL))
37 abort();
39 #pragma omp taskwait
41 for (i = 0; i < 128; ++i)
42 if (q2[i] != q[i])
43 abort();
45 omp_target_free(p, d);
47 return 0;