Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / mapping / array_section_use_device_ptr.c
blob86e2875c35c4a5f96308e233558b86894003efce
1 // RUN: %libomptarget-compile-generic
2 // RUN: %libomptarget-run-generic 2>&1 \
3 // RUN: | %fcheck-generic
5 #include <stdio.h>
6 #include <stdlib.h>
8 #define N 1024
9 #define FROM 64
10 #define LENGTH 128
12 int main() {
13 float *A = (float *)malloc(N * sizeof(float));
15 #pragma omp target enter data map(to : A[FROM : LENGTH])
17 // A, has been mapped starting at index FROM, but inside the use_device_ptr
18 // clause it is captured by base so the library must look it up using the
19 // base address.
21 float *A_dev = NULL;
22 #pragma omp target data use_device_ptr(A)
23 { A_dev = A; }
24 #pragma omp target exit data map(delete : A[FROM : LENGTH])
26 // CHECK: Success
27 if (A_dev == NULL || A_dev == A)
28 fprintf(stderr, "Failure\n");
29 else
30 fprintf(stderr, "Success\n");
32 free(A);
34 return 0;