xref: /llvm-project/offload/test/mapping/data_absent_at_exit.c (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // RUN: %libomptarget-compile-run-and-check-generic
2 
3 #include <stdio.h>
4 
5 // OpenMP 5.1, sec. 2.21.7.1 "map Clause", p. 351 L14-16:
6 // "If the map clause appears on a target, target data, or target exit data
7 // construct and a corresponding list item of the original list item is not
8 // present in the device data environment on exit from the region then the
9 // list item is ignored."
10 
main(void)11 int main(void) {
12   int f = 5, r = 6, d = 7, af = 8;
13 
14 // Check exit from omp target data.
15 // CHECK: f = 5, af = 8
16 #pragma omp target data map(from : f) map(always, from : af)
17   {
18 #pragma omp target exit data map(delete : f, af)
19   } printf("f = %d, af = %d\n", f, af);
20 
21 // Check omp target exit data.
22 // CHECK: f = 5, r = 6, d = 7, af = 8
23 #pragma omp target exit data map(from : f) map(release : r) map(delete : d)    \
24     map(always, from : af)
25   printf("f = %d, r = %d, d = %d, af = %d\n", f, r, d, af);
26 
27   return 0;
28 }
29