Debian Codegraph @

flang/test/Driver/omp-driver-offload.f90

raw
1 ! Test that flang-new OpenMP and OpenMP offload related
2 ! commands forward or expand to the appropriate commands
3 ! for flang-new -fc1 as expected. Assumes a gfx90a, aarch64,
4 ! and sm_70 architecture, but doesn't require one to be
5 ! installed or compiled for, just testing the appropriate
6 ! generation of jobs are created with the correct
7 ! corresponding arguments.
8
9 ! Test regular -fopenmp with no offload
10 ! RUN: %flang -### -fopenmp %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP %s
11 ! CHECK-OPENMP: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}}.f90"
12 ! CHECK-OPENMP-NOT: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" {{.*}}.f90"
13
14 ! Test regular -fopenmp with offload, and invocation filtering options
15 ! RUN: %flang -S -### %s -o %t 2>&1 \
16 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 \
17 ! RUN: --target=aarch64-unknown-linux-gnu \
18 ! RUN: | FileCheck %s --check-prefix=OFFLOAD-HOST-AND-DEVICE
19
20 ! RUN: %flang -S -### %s -o %t 2>&1 \
21 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 --offload-host-device \
22 ! RUN: --target=aarch64-unknown-linux-gnu \
23 ! RUN: | FileCheck %s --check-prefix=OFFLOAD-HOST-AND-DEVICE
24
25 ! OFFLOAD-HOST-AND-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
26 ! OFFLOAD-HOST-AND-DEVICE-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa"
27 ! OFFLOAD-HOST-AND-DEVICE-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "nvptx64-nvidia-cuda"
28 ! OFFLOAD-HOST-AND-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
29
30 ! RUN: %flang -S -### %s -o %t 2>&1 \
31 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 --offload-host-only \
32 ! RUN: --target=aarch64-unknown-linux-gnu \
33 ! RUN: | FileCheck %s --check-prefix=OFFLOAD-HOST
34
35 ! OFFLOAD-HOST: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
36 ! OFFLOAD-HOST-NOT: "-triple" "amdgcn-amd-amdhsa"
37 ! OFFLOAD-HOST-NOT: "-triple" "nvptx64-nvidia-cuda"
38 ! OFFLOAD-HOST-NOT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
39
40 ! RUN: %flang -S -### %s 2>&1 \
41 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 --offload-device-only \
42 ! RUN: --target=aarch64-unknown-linux-gnu \
43 ! RUN: | FileCheck %s --check-prefix=OFFLOAD-DEVICE
44
45 ! OFFLOAD-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
46 ! OFFLOAD-DEVICE-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa"
47 ! OFFLOAD-DEVICE-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "nvptx64-nvidia-cuda"
48 ! OFFLOAD-DEVICE-NOT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
49
50 ! Test regular -fopenmp with offload for basic fopenmp-is-target-device flag addition and correct fopenmp
51 ! RUN: %flang -### -fopenmp --offload-arch=gfx90a -fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP-IS-TARGET-DEVICE %s
52 ! CHECK-OPENMP-IS-TARGET-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" {{.*}}.f90"
53
54 ! Testing appropriate flags are gnerated and appropriately assigned by the driver when offloading
55 ! RUN: %flang -S -### %s -o %t 2>&1 \
56 ! RUN: -fopenmp --offload-arch=gfx90a \
57 ! RUN: --target=aarch64-unknown-linux-gnu \
58 ! RUN: | FileCheck %s --check-prefix=OPENMP-OFFLOAD-ARGS
59 ! OPENMP-OFFLOAD-ARGS: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}}.f90"
60 ! OPENMP-OFFLOAD-ARGS-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa"
61 ! OPENMP-OFFLOAD-ARGS-SAME: "-fopenmp"
62 ! OPENMP-OFFLOAD-ARGS-SAME: "-fopenmp-host-ir-file-path" "{{.*}}.bc" "-fopenmp-is-target-device"
63 ! OPENMP-OFFLOAD-ARGS-SAME: {{.*}}.f90"
64 ! OPENMP-OFFLOAD-ARGS: "{{[^"]*}}clang-offload-packager{{.*}}" {{.*}} "--image=file={{.*}}.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp"
65 ! OPENMP-OFFLOAD-ARGS-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
66 ! OPENMP-OFFLOAD-ARGS-SAME: "-fopenmp"
67 ! OPENMP-OFFLOAD-ARGS-SAME: "-fembed-offload-object={{.*}}.out" {{.*}}.bc"
68
69 ! Test -fopenmp with offload for RTL Flag Options
70 ! RUN: %flang -### %s -o %t 2>&1 \
71 ! RUN: -fopenmp --offload-arch=gfx90a \
72 ! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
73 ! RUN: -fopenmp-assume-threads-oversubscription \
74 ! RUN: | FileCheck %s --check-prefixes=CHECK-THREADS-OVS
75 ! RUN: %flang -### %s -o %t 2>&1 \
76 ! RUN: -fopenmp --offload-arch=sm_70 \
77 ! RUN: -fopenmp-targets=nvptx64-nvidia-cuda \
78 ! RUN: -fopenmp-assume-threads-oversubscription \
79 ! RUN: | FileCheck %s --check-prefixes=CHECK-THREADS-OVS
80 ! CHECK-THREADS-OVS: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-assume-threads-oversubscription" {{.*}}.f90"
81
82 ! RUN: %flang -### %s -o %t 2>&1 \
83 ! RUN: -fopenmp --offload-arch=gfx90a \
84 ! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
85 ! RUN: -fopenmp-assume-teams-oversubscription \
86 ! RUN: | FileCheck %s --check-prefixes=CHECK-TEAMS-OVS
87 ! RUN: %flang -### %s -o %t 2>&1 \
88 ! RUN: -fopenmp --offload-arch=sm_70 \
89 ! RUN: -fopenmp-targets=nvptx64-nvidia-cuda \
90 ! RUN: -fopenmp-assume-teams-oversubscription \
91 ! RUN: | FileCheck %s --check-prefixes=CHECK-TEAMS-OVS
92 ! CHECK-TEAMS-OVS: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-assume-teams-oversubscription" {{.*}}.f90"
93
94 ! RUN: %flang -### %s -o %t 2>&1 \
95 ! RUN: -fopenmp --offload-arch=gfx90a \
96 ! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
97 ! RUN: -fopenmp-assume-no-nested-parallelism \
98 ! RUN: | FileCheck %s --check-prefixes=CHECK-NEST-PAR
99 ! RUN: %flang -### %s -o %t 2>&1 \
100 ! RUN: -fopenmp --offload-arch=sm_70 \
101 ! RUN: -fopenmp-targets=nvptx64-nvidia-cuda \
102 ! RUN: -fopenmp-assume-no-nested-parallelism \
103 ! RUN: | FileCheck %s --check-prefixes=CHECK-NEST-PAR
104 ! CHECK-NEST-PAR: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-assume-no-nested-parallelism" {{.*}}.f90"
105
106 ! RUN: %flang -### %s -o %t 2>&1 \
107 ! RUN: -fopenmp --offload-arch=gfx90a \
108 ! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
109 ! RUN: -fopenmp-assume-no-thread-state \
110 ! RUN: | FileCheck %s --check-prefixes=CHECK-THREAD-STATE
111 ! RUN: %flang -### %s -o %t 2>&1 \
112 ! RUN: -fopenmp --offload-arch=sm_70 \
113 ! RUN: -fopenmp-targets=nvptx64-nvidia-cuda \
114 ! RUN: -fopenmp-assume-no-thread-state \
115 ! RUN: | FileCheck %s --check-prefixes=CHECK-THREAD-STATE
116 ! CHECK-THREAD-STATE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-assume-no-thread-state" {{.*}}.f90"
117
118 ! RUN: %flang -### %s -o %t 2>&1 \
119 ! RUN: -fopenmp --offload-arch=gfx90a \
120 ! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
121 ! RUN: -fopenmp-target-debug \
122 ! RUN: | FileCheck %s --check-prefixes=CHECK-TARGET-DEBUG
123 ! RUN: %flang -### %s -o %t 2>&1 \
124 ! RUN: -fopenmp --offload-arch=sm_70 \
125 ! RUN: -fopenmp-targets=nvptx64-nvidia-cuda \
126 ! RUN: -fopenmp-target-debug \
127 ! RUN: | FileCheck %s --check-prefixes=CHECK-TARGET-DEBUG
128 ! CHECK-TARGET-DEBUG: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-target-debug" {{.*}}.f90"
129
130 ! RUN: %flang -### %s -o %t 2>&1 \
131 ! RUN: -fopenmp --offload-arch=gfx90a \
132 ! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
133 ! RUN: -fopenmp-target-debug \
134 ! RUN: | FileCheck %s --check-prefixes=CHECK-TARGET-DEBUG
135 ! RUN: %flang -### %s -o %t 2>&1 \
136 ! RUN: -fopenmp --offload-arch=sm_70 \
137 ! RUN: -fopenmp-targets=nvptx64-nvidia-cuda \
138 ! RUN: -fopenmp-target-debug \
139 ! RUN: | FileCheck %s --check-prefixes=CHECK-TARGET-DEBUG
140 ! CHECK-TARGET-DEBUG-EQ: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-target-debug=111" {{.*}}.f90"
141
142 ! RUN: %flang -S -### %s -o %t 2>&1 \
143 ! RUN: -fopenmp --offload-arch=gfx90a \
144 ! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
145 ! RUN: -fopenmp-target-debug -fopenmp-assume-threads-oversubscription \
146 ! RUN: -fopenmp-assume-teams-oversubscription -fopenmp-assume-no-nested-parallelism \
147 ! RUN: -fopenmp-assume-no-thread-state \
148 ! RUN: | FileCheck %s --check-prefixes=CHECK-RTL-ALL
149 ! RUN: %flang -S -### %s -o %t 2>&1 \
150 ! RUN: -fopenmp --offload-arch=sm_70 \
151 ! RUN: -fopenmp-targets=nvptx64-nvidia-cuda \
152 ! RUN: -fopenmp-target-debug -fopenmp-assume-threads-oversubscription \
153 ! RUN: -fopenmp-assume-teams-oversubscription -fopenmp-assume-no-nested-parallelism \
154 ! RUN: -fopenmp-assume-no-thread-state \
155 ! RUN: | FileCheck %s --check-prefixes=CHECK-RTL-ALL
156 ! CHECK-RTL-ALL: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-target-debug" "-fopenmp-assume-teams-oversubscription"
157 ! CHECK-RTL-ALL: "-fopenmp-assume-threads-oversubscription" "-fopenmp-assume-no-thread-state" "-fopenmp-assume-no-nested-parallelism"
158 ! CHECK-RTL-ALL: {{.*}}.f90"
159
160 ! RUN: %flang -### %s -o %t 2>&1 \
161 ! RUN: -fopenmp --offload-arch=gfx90a \
162 ! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
163 ! RUN: -fopenmp-version=45 \
164 ! RUN: | FileCheck %s --check-prefixes=CHECK-OPENMP-VERSION
165 ! RUN: %flang -### %s -o %t 2>&1 \
166 ! RUN: -fopenmp --offload-arch=sm_70 \
167 ! RUN: -fopenmp-targets=nvptx64-nvidia-cuda \
168 ! RUN: -fopenmp-version=45 \
169 ! RUN: | FileCheck %s --check-prefixes=CHECK-OPENMP-VERSION
170 ! CHECK-OPENMP-VERSION: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" "-fopenmp-version=45" {{.*}}.f90"
171
172 ! Test diagnostic error when host IR file is non-existent
173 ! RUN: not %flang_fc1 %s -o %t 2>&1 -fopenmp -fopenmp-is-target-device \
174 ! RUN: -fopenmp-host-ir-file-path non-existant-file.bc \
175 ! RUN: | FileCheck %s --check-prefix=HOST-IR-MISSING
176 ! HOST-IR-MISSING: error: provided host compiler IR file 'non-existant-file.bc' is required to generate code for OpenMP target regions but cannot be found
177
178 ! Check that `-gpulibc` includes the LLVM C libraries for the GPU.
179 ! RUN: %flang -### --target=x86_64-unknown-linux-gnu -fopenmp \
180 ! RUN: --offload-arch=sm_52 \
181 ! RUN: -gpulibc %s 2>&1 \
182 ! RUN: | FileCheck --check-prefix=LIBC-GPU-NVPTX %s
183 ! LIBC-GPU-NVPTX-DAG: "-lcgpu-nvptx"
184 ! LIBC-GPU-NVPTX-DAG: "-lmgpu-nvptx"
185
186 ! RUN: %flang -### --target=x86_64-unknown-linux-gnu -fopenmp \
187 ! RUN: --offload-arch=sm_52 \
188 ! RUN: -nogpulibc %s 2>&1 \
189 ! RUN: | FileCheck --check-prefix=NO-LIBC-GPU-NVPTX %s
190 ! NO-LIBC-GPU-NVPTX-NOT: "-lcgpu-nvptx"
191
192 ! RUN: %flang -### --target=x86_64-unknown-linux-gnu -fopenmp \
193 ! RUN: --offload-arch=gfx90a \
194 ! RUN: -gpulibc %s 2>&1 \
195 ! RUN: | FileCheck --check-prefix=LIBC-GPU-AMDGPU %s
196 ! LIBC-GPU-AMDGPU-DAG: "-lcgpu-amdgpu"
197 ! LIBC-GPU-AMDGPU-DAG: "-lmgpu-amdgpu"
198
199 ! RUN: %flang -### --target=x86_64-unknown-linux-gnu -fopenmp \
200 ! RUN: --offload-arch=gfx90a \
201 ! RUN: -nogpulibc %s 2>&1 \
202 ! RUN: | FileCheck --check-prefix=NO-LIBC-GPU-AMDGPU %s
203 ! NO-LIBC-GPU-AMDGPU-NOT: "-lcgpu-amdgpu"
204
205 ! RUN: %flang -### -v --target=x86_64-unknown-linux-gnu -fopenmp \
206 ! RUN: --offload-arch=gfx900 \
207 ! RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \
208 ! RUN: | FileCheck --check-prefix=ROCM-PATH %s
209 ! ROCM-PATH: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd
210
211 ! Test -fopenmp-force-usm option without offload
212 ! RUN: %flang -S -### %s -o %t 2>&1 \
213 ! RUN: -fopenmp -fopenmp-force-usm \
214 ! RUN: --target=aarch64-unknown-linux-gnu \
215 ! RUN: | FileCheck %s --check-prefix=FORCE-USM-NO-OFFLOAD
216
217 ! FORCE-USM-NO-OFFLOAD: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
218 ! FORCE-USM-NO-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm"
219
220 ! Test -fopenmp-force-usm option with offload
221 ! RUN: %flang -S -### %s -o %t 2>&1 \
222 ! RUN: -fopenmp -fopenmp-force-usm --offload-arch=gfx90a \
223 ! RUN: --target=aarch64-unknown-linux-gnu \
224 ! RUN: | FileCheck %s --check-prefix=FORCE-USM-OFFLOAD
225
226 ! FORCE-USM-OFFLOAD: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
227 ! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm"
228 ! FORCE-USM-OFFLOAD-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa"
229 ! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm"