xref: /llvm-project/offload/test/mapping/present/target_data.c (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // RUN: %libomptarget-compile-generic
2 // RUN: %libomptarget-run-fail-generic 2>&1 \
3 // RUN: | %fcheck-generic
4 
5 #include <stdio.h>
6 
main()7 int main() {
8   int i;
9 
10   // CHECK: addr=0x[[#%x,HOST_ADDR:]], size=[[#%u,SIZE:]]
11   fprintf(stderr, "addr=%p, size=%ld\n", &i, sizeof i);
12 
13   // CHECK-NOT: omptarget
14 #pragma omp target data map(alloc : i)
15 #pragma omp target data map(present, alloc : i)
16   ;
17 
18   // CHECK: i is present
19   fprintf(stderr, "i is present\n");
20 
21   // CHECK: omptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] ([[#SIZE]] bytes)
22   // CHECK: omptarget fatal error 1: failure of target construct while offloading is mandatory
23 #pragma omp target data map(present, alloc : i)
24   ;
25 
26   // CHECK-NOT: i is present
27   fprintf(stderr, "i is present\n");
28 
29   return 0;
30 }
31