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

source code of offload/test/api/omp_target_memcpy_async1.c