1 // --------------------------------------------------
2 // Check extends before
3 // --------------------------------------------------
4
5 // RUN: %libomptarget-compile-aarch64-unknown-linux-gnu \
6 // RUN: -fopenmp-version=51 -DEXTENDS=BEFORE
7 // RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \
8 // RUN: | %fcheck-aarch64-unknown-linux-gnu
9
10 // RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu \
11 // RUN: -fopenmp-version=51 -DEXTENDS=BEFORE
12 // RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \
13 // RUN: | %fcheck-powerpc64-ibm-linux-gnu
14
15 // RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu \
16 // RUN: -fopenmp-version=51 -DEXTENDS=BEFORE
17 // RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \
18 // RUN: | %fcheck-powerpc64le-ibm-linux-gnu
19
20 // RUN: %libomptarget-compile-x86_64-pc-linux-gnu \
21 // RUN: -fopenmp-version=51 -DEXTENDS=BEFORE
22 // RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \
23 // RUN: | %fcheck-x86_64-pc-linux-gnu
24
25 // --------------------------------------------------
26 // Check extends after
27 // --------------------------------------------------
28
29 // RUN: %libomptarget-compile-aarch64-unknown-linux-gnu \
30 // RUN: -fopenmp-version=51 -DEXTENDS=AFTER
31 // RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \
32 // RUN: | %fcheck-aarch64-unknown-linux-gnu
33
34 // RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu \
35 // RUN: -fopenmp-version=51 -DEXTENDS=AFTER
36 // RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \
37 // RUN: | %fcheck-powerpc64-ibm-linux-gnu
38
39 // RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu \
40 // RUN: -fopenmp-version=51 -DEXTENDS=AFTER
41 // RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \
42 // RUN: | %fcheck-powerpc64le-ibm-linux-gnu
43
44 // RUN: %libomptarget-compile-x86_64-pc-linux-gnu \
45 // RUN: -fopenmp-version=51 -DEXTENDS=AFTER
46 // RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \
47 // RUN: | %fcheck-x86_64-pc-linux-gnu
48
49 // END.
50
51 #include <stdio.h>
52
53 #define BEFORE 0
54 #define AFTER 1
55
56 #define SIZE 100
57
58 #if EXTENDS == BEFORE
59 # define SMALL_BEG (SIZE-2)
60 # define SMALL_END SIZE
61 # define LARGE_BEG 0
62 # define LARGE_END SIZE
63 #elif EXTENDS == AFTER
64 # define SMALL_BEG 0
65 # define SMALL_END 2
66 # define LARGE_BEG 0
67 # define LARGE_END SIZE
68 #else
69 # error EXTENDS undefined
70 #endif
71
72 #define SMALL_SIZE (SMALL_END-SMALL_BEG)
73 #define LARGE_SIZE (LARGE_END-LARGE_BEG)
74
75 #define SMALL SMALL_BEG:SMALL_SIZE
76 #define LARGE LARGE_BEG:LARGE_SIZE
77
main()78 int main() {
79 int arr[SIZE];
80
81 // CHECK: addr=0x[[#%x,SMALL_ADDR:]], size=[[#%u,SMALL_BYTES:]]
82 fprintf(stderr, "addr=%p, size=%ld\n", &arr[SMALL_BEG],
83 SMALL_SIZE * sizeof arr[0]);
84
85 // CHECK: addr=0x[[#%x,LARGE_ADDR:]], size=[[#%u,LARGE_BYTES:]]
86 fprintf(stderr, "addr=%p, size=%ld\n", &arr[LARGE_BEG],
87 LARGE_SIZE * sizeof arr[0]);
88
89 // CHECK-NOT: Libomptarget
90 #pragma omp target data map(alloc: arr[LARGE])
91 {
92 #pragma omp target data map(present, tofrom: arr[SMALL])
93 ;
94 }
95
96 // CHECK: arr is present
97 fprintf(stderr, "arr is present\n");
98
99 // CHECK: Libomptarget message: explicit extension not allowed: host address specified is 0x{{0*}}[[#LARGE_ADDR]] ([[#LARGE_BYTES]] bytes), but device allocation maps to host at 0x{{0*}}[[#SMALL_ADDR]] ([[#SMALL_BYTES]] bytes)
100 // CHECK: Libomptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#LARGE_ADDR]] ([[#LARGE_BYTES]] bytes)
101 // CHECK: Libomptarget error: Call to getOrAllocTgtPtr returned null pointer ('present' map type modifier).
102 // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory
103 #pragma omp target data map(alloc: arr[SMALL])
104 {
105 #pragma omp target data map(present, tofrom: arr[LARGE])
106 ;
107 }
108
109 // CHECK-NOT: arr is present
110 fprintf(stderr, "arr is present\n");
111
112 return 0;
113 }
114