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