Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / mapping / is_device_ptr.cpp
blob6433f822f9d53ac73c4b375b881bb4265f626a5d
1 // RUN: %libomptarget-compilexx-run-and-check-generic
3 #include <assert.h>
4 #include <iostream>
5 #include <omp.h>
7 struct view {
8 const int size = 10;
9 int *data_host;
10 int *data_device;
11 void foo() {
12 std::size_t bytes = size * sizeof(int);
13 const int host_id = omp_get_initial_device();
14 const int device_id = omp_get_default_device();
15 data_host = (int *)malloc(bytes);
16 data_device = (int *)omp_target_alloc(bytes, device_id);
17 #pragma omp target teams distribute parallel for is_device_ptr(data_device)
18 for (int i = 0; i < size; ++i)
19 data_device[i] = i;
20 omp_target_memcpy(data_host, data_device, bytes, 0, 0, host_id, device_id);
21 for (int i = 0; i < size; ++i)
22 assert(data_host[i] == i);
26 int main() {
27 view a;
28 a.foo();
29 // CHECK: PASSED
30 printf("PASSED\n");