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