1 | // RUN: %libomptarget-compile-run-and-check-generic |
2 | |
3 | #include <omp.h> |
4 | #include <stdio.h> |
5 | |
6 | int main() { |
7 | const int N = 64; |
8 | |
9 | int *hst_ptr = omp_alloc(N * sizeof(int), llvm_omp_target_host_mem_alloc); |
10 | |
11 | for (int i = 0; i < N; ++i) |
12 | hst_ptr[i] = 2; |
13 | |
14 | #pragma omp target teams distribute parallel for map(tofrom : hst_ptr[0 : N]) |
15 | for (int i = 0; i < N; ++i) |
16 | hst_ptr[i] -= 1; |
17 | |
18 | int sum = 0; |
19 | for (int i = 0; i < N; ++i) |
20 | sum += hst_ptr[i]; |
21 | |
22 | omp_free(hst_ptr, llvm_omp_target_host_mem_alloc); |
23 | // CHECK: PASS |
24 | if (sum == N) |
25 | printf(format: "PASS\n" ); |
26 | } |
27 | |