1 // --------------------------------------------------
2 // Check extends before
3 // --------------------------------------------------
5 // RUN: %libomptarget-compile-generic \
6 // RUN: -DEXTENDS=BEFORE
7 // RUN: %libomptarget-run-generic 2>&1 \
8 // RUN: | %fcheck-generic
10 // --------------------------------------------------
11 // Check extends after
12 // --------------------------------------------------
14 // RUN: %libomptarget-compile-generic \
15 // RUN: -DEXTENDS=AFTER
16 // RUN: %libomptarget-run-generic 2>&1 \
17 // RUN: | %fcheck-generic
29 #define SMALL_BEG (SIZE - 2)
30 #define SMALL_END SIZE
32 #define LARGE_END SIZE
33 #elif EXTENDS == AFTER
37 #define LARGE_END SIZE
39 #error EXTENDS undefined
44 (SMALL_END - SMALL_BEG)
47 (LARGE_END - LARGE_BEG)
49 void check_not_present() {
52 for (int i
= 0; i
< SIZE
; ++i
)
55 // CHECK-LABEL: checking not present
56 fprintf(stderr
, "checking not present\n");
58 // arr[LARGE] isn't (fully) present at the end of the target data region, so
59 // the device-to-host transfer should not be performed, or it might fail.
60 #pragma omp target data map(tofrom : arr[LARGE])
62 #pragma omp target exit data map(delete : arr[LARGE])
63 #pragma omp target enter data map(alloc : arr[SMALL])
64 #pragma omp target map(alloc : arr[SMALL])
65 for (int i
= SMALL_BEG
; i
< SMALL_END
; ++i
)
69 // CHECK-NOT: omptarget
71 for (int i
= 0; i
< SIZE
; ++i
) {
73 fprintf(stderr
, "error: arr[%d]=%d\n", i
, arr
[i
]);
77 void check_is_present() {
80 for (int i
= 0; i
< SIZE
; ++i
)
83 // CHECK-LABEL: checking is present
84 fprintf(stderr
, "checking is present\n");
86 // arr[SMALL] is (fully) present at the end of the target data region, and the
87 // device-to-host transfer should be performed only for it even though more
88 // of the array is then present.
89 #pragma omp target data map(tofrom : arr[SMALL])
91 #pragma omp target exit data map(delete : arr[SMALL])
92 #pragma omp target enter data map(alloc : arr[LARGE])
93 #pragma omp target map(alloc : arr[LARGE])
94 for (int i
= LARGE_BEG
; i
< LARGE_END
; ++i
)
98 // CHECK-NOT: omptarget
100 for (int i
= 0; i
< SIZE
; ++i
) {
101 if (SMALL_BEG
<= i
&& i
< SMALL_END
) {
103 fprintf(stderr
, "error: arr[%d]=%d\n", i
, arr
[i
]);
104 } else if (arr
[i
] != 99) {
105 fprintf(stderr
, "error: arr[%d]=%d\n", i
, arr
[i
]);