1 | // RUN: %libomptarget-compile-generic |
2 | // RUN: %libomptarget-run-generic 2>&1 \ |
3 | // RUN: | %fcheck-generic |
4 | |
5 | // END. |
6 | |
7 | #include <omp.h> |
8 | #include <stdio.h> |
9 | |
10 | int main() { |
11 | int arr[100]; |
12 | |
13 | #pragma omp target data map(alloc : arr[50 : 2]) // partially mapped |
14 | { |
15 | // CHECK: arr[50] must present: 1 |
16 | fprintf(stderr, format: "arr[50] must present: %d\n" , |
17 | omp_target_is_present(&arr[50], omp_get_default_device())); |
18 | |
19 | // CHECK: arr[0] should not present: 0 |
20 | fprintf(stderr, format: "arr[0] should not present: %d\n" , |
21 | omp_target_is_present(&arr[0], omp_get_default_device())); |
22 | |
23 | // CHECK: arr[49] should not present: 0 |
24 | fprintf(stderr, format: "arr[49] should not present: %d\n" , |
25 | omp_target_is_present(&arr[49], omp_get_default_device())); |
26 | |
27 | #pragma omp target // would implicitly map with full size but already present |
28 | { |
29 | arr[50] = 5; |
30 | arr[51] = 6; |
31 | } // must treat as present (dec ref count) even though full size not present |
32 | } // wouldn't delete if previous ref count dec didn't happen |
33 | |
34 | // CHECK: arr[50] still present: 0 |
35 | fprintf(stderr, format: "arr[50] still present: %d\n" , |
36 | omp_target_is_present(&arr[50], omp_get_default_device())); |
37 | |
38 | return 0; |
39 | } |
40 | |