Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / api / omp_target_memset.c
blobea0c6d73fbdeefba7c1c8620efbd9e12919f3f54
1 // RUN: %libomptarget-compile-and-run-generic
3 #include "stdio.h"
4 #include <omp.h>
5 #include <stdlib.h>
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;
14 if (d < 0 || d >= omp_get_num_devices())
15 d = id;
17 p = omp_target_alloc(130 * sizeof(int), d);
18 if (p == NULL)
19 return 0;
21 for (i = 0; i < 128; i++)
22 q[i] = i;
24 result = omp_target_memset(p, 0, 130 * sizeof(int), d);
25 if (result != p) {
26 abort();
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();
36 #pragma omp taskwait
38 for (i = 0; i < 128; ++i)
39 if (q2[i] != 0)
40 abort();
42 omp_target_free(p, d);
44 return 0;