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