Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / libomptarget / test / mapping / present / target_update_array_extension.c
blob45895044e122a86fad18cc17ad010634c6c24ef8
1 // --------------------------------------------------
2 // Check 'to' and extends before
3 // --------------------------------------------------
5 // RUN: %libomptarget-compile-generic \
6 // RUN: -DCLAUSE=to -DEXTENDS=BEFORE
7 // RUN: %libomptarget-run-fail-generic 2>&1 \
8 // RUN: | %fcheck-generic
10 // --------------------------------------------------
11 // Check 'from' and extends before
12 // --------------------------------------------------
14 // RUN: %libomptarget-compile-generic \
15 // RUN: -DCLAUSE=from -DEXTENDS=BEFORE
16 // RUN: %libomptarget-run-fail-generic 2>&1 \
17 // RUN: | %fcheck-generic
19 // --------------------------------------------------
20 // Check 'to' and extends after
21 // --------------------------------------------------
23 // RUN: %libomptarget-compile-generic \
24 // RUN: -DCLAUSE=to -DEXTENDS=AFTER
25 // RUN: %libomptarget-run-fail-generic 2>&1 \
26 // RUN: | %fcheck-generic
28 // --------------------------------------------------
29 // Check 'from' and extends after
30 // --------------------------------------------------
32 // RUN: %libomptarget-compile-generic \
33 // RUN: -DCLAUSE=from -DEXTENDS=AFTER
34 // RUN: %libomptarget-run-fail-generic 2>&1 \
35 // RUN: | %fcheck-generic
37 // END.
39 #include <stdio.h>
41 #define BEFORE 0
42 #define AFTER 1
44 #if EXTENDS == BEFORE
45 #define SMALL 2 : 3
46 #define LARGE 0 : 5
47 #elif EXTENDS == AFTER
48 #define SMALL 0 : 3
49 #define LARGE 0 : 5
50 #else
51 #error EXTENDS undefined
52 #endif
54 int main() {
55 int arr[5];
57 // CHECK: addr=0x[[#%x,HOST_ADDR:]], size=[[#%u,SIZE:]]
58 fprintf(stderr, "addr=%p, size=%ld\n", arr, sizeof arr);
60 // CHECK-NOT: Libomptarget
61 #pragma omp target data map(alloc : arr[LARGE])
63 #pragma omp target update CLAUSE(present : arr[SMALL])
66 // CHECK: arr is present
67 fprintf(stderr, "arr is present\n");
69 // CHECK: Libomptarget message: device mapping required by 'present' motion modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] ([[#SIZE]] bytes)
70 // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory
71 #pragma omp target data map(alloc : arr[SMALL])
73 #pragma omp target update CLAUSE(present : arr[LARGE])
76 // CHECK-NOT: arr is present
77 fprintf(stderr, "arr is present\n");
79 return 0;