2 /// Perform several driver tests for OpenMP offloading
5 // REQUIRES: x86-registered-target
6 // REQUIRES: powerpc-registered-target
7 // REQUIRES: nvptx-registered-target
8 // REQUIRES: amdgpu-registered-target
10 /// ###########################################################################
12 /// Check -Xopenmp-target uses one of the archs provided when several archs are used.
13 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -nogpulib -nogpuinc \
14 // RUN: -Xopenmp-target -march=sm_52 -Xopenmp-target -march=sm_60 %s 2>&1 \
15 // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-ARCHS %s
17 // CHK-FOPENMP-TARGET-ARCHS: ptxas{{.*}}" "--gpu-name" "sm_60"
19 /// ###########################################################################
21 /// Check -Xopenmp-target -march=sm_52 works as expected when two triples are present.
22 // RUN: %clang -### -fopenmp=libomp \
23 // RUN: -fopenmp-targets=powerpc64le-ibm-linux-gnu,nvptx64-nvidia-cuda \
24 // RUN: -nogpulib -nogpuinc -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 %s 2>&1 \
25 // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-COMPILATION %s
27 // CHK-FOPENMP-TARGET-COMPILATION: ptxas{{.*}}" "--gpu-name" "sm_52"
29 /// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP.
30 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 \
31 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 | FileCheck -check-prefix=CHK-PTXAS-DEFAULT %s
33 // CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c"
35 /// ###########################################################################
37 /// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it.
38 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target \
39 // RUN: -nogpulib -nogpuinc --offload-arch=sm_52 -save-temps %s 2>&1 \
40 // RUN: | FileCheck -check-prefix=CHK-PTXAS-NORELO %s
42 // CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c"
44 /// ###########################################################################
46 /// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP
47 /// Check that the flag is passed when -fopenmp-relocatable-target is used.
48 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target \
49 // RUN: -nogpulib -nogpuinc --offload-arch=sm_52 -save-temps %s 2>&1 \
50 // RUN: | FileCheck -check-prefix=CHK-PTXAS-RELO %s
52 // CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
54 /// ###########################################################################
56 /// Check that error is not thrown by toolchain when no cuda lib flag is used.
57 /// Check that the flag is passed when -fopenmp-relocatable-target is used.
58 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \
59 // RUN: -nogpulib -nogpuinc -fopenmp-relocatable-target -save-temps %s 2>&1 \
60 // RUN: | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s
62 // CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_60
64 /// ###########################################################################
66 /// Check that error is not thrown by toolchain when no cuda lib device is found when using -S.
67 /// Check that the flag is passed when -fopenmp-relocatable-target is used.
68 // RUN: %clang -### -S -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \
69 // RUN: -fopenmp-relocatable-target -save-temps %s 2>&1 \
70 // RUN: | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
72 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
74 /// ###########################################################################
76 /// Check that the runtime bitcode library is part of the compile line.
77 /// Create a bogus bitcode library and specify it with libomptarget-nvptx-bc-path
78 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
79 // RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
80 // RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
81 // RUN: -fopenmp-relocatable-target -save-temps %s 2>&1 \
82 // RUN: | FileCheck -check-prefix=CHK-BCLIB %s
84 /// Specify the directory containing the bitcode lib, check clang picks the right one
85 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
86 // RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget \
87 // RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
88 // RUN: -fopenmp-relocatable-target -save-temps \
89 // RUN: %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB-DIR %s
91 /// Create a bogus bitcode library and find it with LIBRARY_PATH
92 // RUN: env LIBRARY_PATH=%S/Inputs/libomptarget/subdir %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
93 // RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
94 // RUN: -fopenmp-relocatable-target -save-temps \
95 // RUN: %s 2>&1 | FileCheck -check-prefix=CHK-ENV-BCLIB %s
97 // CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-test.bc
98 // CHK-BCLIB-DIR: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget{{/|\\\\}}libomptarget-nvptx-sm_52.bc
99 // CHK-ENV-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}subdir{{/|\\\\}}libomptarget-nvptx-sm_52.bc
100 // CHK-BCLIB-NOT: {{error:|warning:}}
102 /// ###########################################################################
104 /// Check that the warning is thrown when the libomptarget bitcode library is not found.
105 /// Libomptarget requires sm_52 or newer so an sm_52 bitcode library should never exist.
106 // RUN: not %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
107 // RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
108 // RUN: -fopenmp-relocatable-target -save-temps %s 2>&1 \
109 // RUN: | FileCheck -check-prefix=CHK-BCLIB-WARN %s
111 // CHK-BCLIB-WARN: no library 'libomptarget-nvptx-sm_52.bc' found in the default clang lib directory or in LIBRARY_PATH; use '--libomptarget-nvptx-bc-path' to specify nvptx bitcode library
113 /// ###########################################################################
115 /// Check that the error is thrown when the libomptarget bitcode library does not exist.
116 // RUN: not %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
117 // RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
118 // RUN: --libomptarget-nvptx-bc-path=not-exist.bc \
119 // RUN: -fopenmp-relocatable-target -save-temps %s 2>&1 \
120 // RUN: | FileCheck -check-prefix=CHK-BCLIB-ERROR %s
122 // CHK-BCLIB-ERROR: bitcode library 'not-exist.bc' does not exist
124 /// ###########################################################################
126 /// Check that the error is thrown when CUDA 9.1 or lower version is used.
127 // RUN: not %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
128 // RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda \
129 // RUN: -fopenmp-relocatable-target -save-temps %s 2>&1 \
130 // RUN: | FileCheck -check-prefix=CHK-CUDA-VERSION-ERROR %s
132 // CHK-CUDA-VERSION-ERROR: NVPTX target requires CUDA 9.2 or above; CUDA 9.0 detected
134 /// Check that debug info is emitted in dwarf-2
135 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O1 --no-cuda-noopt-device-debug 2>&1 \
136 // RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
137 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 2>&1 \
138 // RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
139 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 \
140 // RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
141 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g0 2>&1 \
142 // RUN: | FileCheck -check-prefix=NO_DEBUG %s
143 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 \
144 // RUN: | FileCheck -check-prefix=NO_DEBUG %s
145 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-directives-only 2>&1 \
146 // RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
148 // DEBUG_DIRECTIVES-NOT: warning: debug
149 // NO_DEBUG-NOT: warning: debug
150 // NO_DEBUG: "-fopenmp-is-target-device"
151 // NO_DEBUG-NOT: "-debug-info-kind=
153 // DEBUG_DIRECTIVES: "-triple" "nvptx64-nvidia-cuda"
154 // DEBUG_DIRECTIVES-SAME: "-debug-info-kind=line-directives-only"
155 // DEBUG_DIRECTIVES-SAME: "-fopenmp-is-target-device"
156 // DEBUG_DIRECTIVES: ptxas
157 // DEBUG_DIRECTIVES: "-lineinfo"
159 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \
160 // RUN: | FileCheck -check-prefix=HAS_DEBUG %s
161 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g 2>&1 \
162 // RUN: | FileCheck -check-prefix=HAS_DEBUG %s
163 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --cuda-noopt-device-debug 2>&1 \
164 // RUN: | FileCheck -check-prefix=HAS_DEBUG %s
165 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --cuda-noopt-device-debug 2>&1 \
166 // RUN: | FileCheck -check-prefix=HAS_DEBUG %s
167 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g2 2>&1 \
168 // RUN: | FileCheck -check-prefix=HAS_DEBUG %s
169 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb2 -O0 --cuda-noopt-device-debug 2>&1 \
170 // RUN: | FileCheck -check-prefix=HAS_DEBUG %s
171 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g3 -O3 --cuda-noopt-device-debug 2>&1 \
172 // RUN: | FileCheck -check-prefix=HAS_DEBUG %s
173 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \
174 // RUN: | FileCheck -check-prefix=HAS_DEBUG %s
175 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \
176 // RUN: | FileCheck -check-prefix=HAS_DEBUG %s
177 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \
178 // RUN: | FileCheck -check-prefix=HAS_DEBUG %s
180 // HAS_DEBUG-NOT: warning: debug
181 // HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda"
182 // HAS_DEBUG-SAME: "-debug-info-kind={{constructor|line-tables-only}}"
183 // HAS_DEBUG-SAME: "-dwarf-version=2"
184 // HAS_DEBUG-SAME: "-fopenmp-is-target-device"
186 // HAS_DEBUG-SAME: "-g"
187 // HAS_DEBUG-SAME: "--dont-merge-basicblocks"
188 // HAS_DEBUG-SAME: "--return-at-end"
190 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-mode 2>&1 \
191 // RUN: | FileCheck -check-prefix=CUDA_MODE %s
192 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fno-openmp-cuda-mode -fopenmp-cuda-mode 2>&1 \
193 // RUN: | FileCheck -check-prefix=CUDA_MODE %s
194 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fopenmp-cuda-mode 2>&1 \
195 // RUN: | FileCheck -check-prefix=CUDA_MODE %s
196 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fno-openmp-cuda-mode -fopenmp-cuda-mode 2>&1 \
197 // RUN: | FileCheck -check-prefix=CUDA_MODE %s
198 // CUDA_MODE: "-cc1"{{.*}}"-triple" "{{nvptx64-nvidia-cuda|amdgcn-amd-amdhsa}}"
199 // CUDA_MODE-SAME: "-fopenmp-cuda-mode"
200 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fno-openmp-cuda-mode 2>&1 \
201 // RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s
202 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-mode -fno-openmp-cuda-mode 2>&1 \
203 // RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s
204 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fno-openmp-cuda-mode 2>&1 \
205 // RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s
206 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fopenmp-cuda-mode -fno-openmp-cuda-mode 2>&1 \
207 // RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s
208 // NO_CUDA_MODE-NOT: "-{{fno-|f}}openmp-cuda-mode"
210 // RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-teams-reduction-recs-num=2048 2>&1 \
211 // RUN: | FileCheck -check-prefix=CUDA_RED_RECS %s
212 // CUDA_RED_RECS: "-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"
213 // CUDA_RED_RECS-SAME: "-fopenmp-cuda-teams-reduction-recs-num=2048"
215 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
216 // RUN: --offload-arch=sm_52 --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc %s 2>&1 \
217 // RUN: | FileCheck -check-prefix=OPENMP_NVPTX_WRAPPERS %s
218 // OPENMP_NVPTX_WRAPPERS: "-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"
219 // OPENMP_NVPTX_WRAPPERS-SAME: "-internal-isystem" "{{.*}}openmp_wrappers"
221 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -nogpulib -nogpuinc \
222 // RUN: --offload-arch=sm_52 -save-temps -ccc-print-bindings %s -o openmp-offload-gpu 2>&1 \
223 // RUN: | FileCheck -check-prefix=SAVE_TEMPS_NAMES %s
225 // SAVE_TEMPS_NAMES-NOT: "GNU::Linker"{{.*}}["[[SAVE_TEMPS_INPUT1:.*\.o]]", "[[SAVE_TEMPS_INPUT1]]"]
227 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 -march=sm_52 \
228 // RUN: -nogpulib -nogpuinc -save-temps %s -o openmp-offload-gpu 2>&1 \
229 // RUN: | FileCheck -check-prefix=TRIPLE %s
231 // TRIPLE: "-triple" "nvptx64-nvidia-cuda"
232 // TRIPLE: "-target-cpu" "sm_52"
234 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
235 // RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
236 // RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc %s 2>&1 \
237 // RUN: | FileCheck %s
238 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
239 // RUN: --offload-arch=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
240 // RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc %s 2>&1 \
241 // RUN: | FileCheck %s
243 // verify the tools invocations
244 // CHECK: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-emit-llvm-bc"{{.*}}"-x" "c"
245 // CHECK: "-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}}"-target-cpu" "sm_52"
246 // CHECK: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-emit-obj"
247 // CHECK: clang-linker-wrapper{{.*}}"--"{{.*}} "-o" "a.out"
249 // RUN: %clang -ccc-print-phases --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 %s 2>&1 \
250 // RUN: | FileCheck --check-prefix=CHECK-PHASES %s
251 // CHECK-PHASES: 0: input, "[[INPUT:.+]]", c, (host-openmp)
252 // CHECK-PHASES: 1: preprocessor, {0}, cpp-output, (host-openmp)
253 // CHECK-PHASES: 2: compiler, {1}, ir, (host-openmp)
254 // CHECK-PHASES: 3: input, "[[INPUT]]", c, (device-openmp)
255 // CHECK-PHASES: 4: preprocessor, {3}, cpp-output, (device-openmp)
256 // CHECK-PHASES: 5: compiler, {4}, ir, (device-openmp)
257 // CHECK-PHASES: 6: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (nvptx64-nvidia-cuda)" {5}, ir
258 // CHECK-PHASES: 7: backend, {6}, assembler, (device-openmp)
259 // CHECK-PHASES: 8: assembler, {7}, object, (device-openmp)
260 // CHECK-PHASES: 9: offload, "device-openmp (nvptx64-nvidia-cuda)" {8}, object
261 // CHECK-PHASES: 10: clang-offload-packager, {9}, image
262 // CHECK-PHASES: 11: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (x86_64-unknown-linux-gnu)" {10}, ir
263 // CHECK-PHASES: 12: backend, {11}, assembler, (host-openmp)
264 // CHECK-PHASES: 13: assembler, {12}, object, (host-openmp)
265 // CHECK-PHASES: 14: clang-linker-wrapper, {13}, image, (host-openmp)
267 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-BINDINGS
268 // CHECK-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[HOST_BC:.+]]"
269 // CHECK-BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[DEVICE_BC:.+]]"
270 // CHECK-BINDINGS: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_BC]]"], output: "[[DEVICE_OBJ:.+]]"
271 // CHECK-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[DEVICE_OBJ]]"], output: "[[BINARY:.+.out]]"
272 // CHECK-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[HOST_BC]]", "[[BINARY]]"], output: "[[HOST_OBJ:.+]]"
273 // CHECK-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out"
275 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib -save-temps %s 2>&1 | FileCheck %s --check-prefix=CHECK-TEMP-BINDINGS
276 // CHECK-TEMP-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[DEVICE_OBJ:.+]]"], output: "[[BINARY:.+.out]]"
278 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52 --offload-arch=sm_70 -nogpuinc -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS
279 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52,sm_70 -nogpuinc -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS
280 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52,sm_60,sm_70,sm_80 --no-offload-arch=sm_60,sm_80 -nogpuinc -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS
281 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.*]]"], output: "[[HOST_BC:.*]]"
282 // CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[DEVICE_BC_SM_52:.*]]"
283 // CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_BC_SM_52]]"], output: "[[DEVICE_OBJ_SM_52:.*]]"
284 // CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[DEVICE_BC_SM_70:.*]]"
285 // CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_BC_SM_70]]"], output: "[[DEVICE_OBJ_SM_70:.*]]"
286 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[DEVICE_OBJ_SM_52]]", "[[DEVICE_OBJ_SM_70]]"], output: "[[BINARY:.*]]"
287 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[HOST_BC]]", "[[BINARY]]"], output: "[[HOST_OBJ:.*]]"
288 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out"
290 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp \
291 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda,amdgcn-amd-amdhsa -Xopenmp-target=nvptx64-nvidia-cuda --offload-arch=sm_70 \
292 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda,amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa --offload-arch=gfx908 \
293 // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NVIDIA-AMDGPU
295 // CHECK-NVIDIA-AMDGPU: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[HOST_BC:.+]]"
296 // CHECK-NVIDIA-AMDGPU: "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[AMD_BC:.+]]"
297 // CHECK-NVIDIA-AMDGPU: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[NVIDIA_PTX:.+]]"
298 // CHECK-NVIDIA-AMDGPU: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[NVIDIA_PTX]]"], output: "[[NVIDIA_CUBIN:.+]]"
299 // CHECK-NVIDIA-AMDGPU: "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[AMD_BC]]", "[[NVIDIA_CUBIN]]"], output: "[[BINARY:.*]]"
300 // CHECK-NVIDIA-AMDGPU: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[HOST_BC]]", "[[BINARY]]"], output: "[[HOST_OBJ:.+]]"
301 // CHECK-NVIDIA-AMDGPU: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out"
303 // RUN: %clang -x ir -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp --offload-arch=sm_52 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-IR
305 // CHECK-IR: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT_IR:.+]]"], output: "[[OBJECT:.+]]"
306 // CHECK-IR: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[OBJECT]]"], output: "a.out"
308 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp=libomp --offload-device-only \
309 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 \
310 // RUN: | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR
311 // CHECK-EMIT-LLVM-IR: "-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"{{.*}}"-emit-llvm"
313 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp=libomp \
314 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 \
315 // RUN: | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR-BC
316 // CHECK-EMIT-LLVM-IR-BC: "-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"{{.*}}"-emit-llvm-bc"
318 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
319 // RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc \
320 // RUN: -nogpulib %s -o openmp-offload-gpu 2>&1 \
321 // RUN: | FileCheck -check-prefix=DRIVER_EMBEDDING %s
323 // DRIVER_EMBEDDING: -fembed-offload-object={{.*}}.out
325 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
326 // RUN: --offload-host-only -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HOST-ONLY
327 // CHECK-HOST-ONLY: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.*]]"], output: "[[OUTPUT:.*]]"
328 // CHECK-HOST-ONLY: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[OUTPUT]]"], output: "a.out"
330 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
331 // RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 --offload-device-only -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEVICE-ONLY
332 // CHECK-DEVICE-ONLY: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.*]]"], output: "[[HOST_BC:.*]]"
333 // CHECK-DEVICE-ONLY: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[DEVICE_ASM:.*]]"
334 // CHECK-DEVICE-ONLY: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_ASM]]"], output: "{{.*}}-openmp-nvptx64-nvidia-cuda.o"
336 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
337 // RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 --offload-device-only -E -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEVICE-ONLY-PP
338 // CHECK-DEVICE-ONLY-PP: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT:.*]]"], output: "-"
340 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
341 // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBRARY %s
343 // CHECK-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
345 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
346 // RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc %s 2>&1 \
347 // RUN: | FileCheck --check-prefix=CHECK-NO-LTO-LIBRARY %s
349 // CHECK-NO-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
351 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 -nogpulib \
352 // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LIBRARY %s
354 // CHECK-NO-LIBRARY-NOT: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
356 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 -nogpulib \
357 // RUN: -Xoffload-linker a -Xoffload-linker-nvptx64-nvidia-cuda b -Xoffload-linker-nvptx64 c \
358 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-XLINKER %s
360 // CHECK-XLINKER: -device-linker=a{{.*}}-device-linker=nvptx64-nvidia-cuda=b{{.*}}-device-linker=nvptx64-nvidia-cuda=c{{.*}}--
362 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 -nogpulib \
363 // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-FEATURES %s
365 // CHECK-LTO-FEATURES: clang-offload-packager{{.*}}--image={{.*}}feature=+ptx{{[0-9]+}}
367 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 -nogpulib \
368 // RUN: -Xopenmp-target=nvptx64-nvidia-cuda --cuda-feature=+ptx64 -foffload-lto %s 2>&1 \
369 // RUN: | FileCheck --check-prefix=CHECK-SET-FEATURES %s
371 // CHECK-SET-FEATURES: clang-offload-packager{{.*}}--image={{.*}}feature=+ptx64
374 // Check that `-Xarch_host` works for OpenMP offloading.
376 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
377 // RUN: --offload-arch=sm_52 -nogpulib -nogpuinc -Xarch_host -O3 %s 2>&1 \
378 // RUN: | FileCheck --check-prefix=XARCH-HOST %s
379 // XARCH-HOST: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-O3"
380 // XARCH-HOST-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-O3"
383 // Check that `-Xarch_device` works for OpenMP offloading.
385 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
386 // RUN: --offload-arch=sm_52 -nogpulib -nogpuinc -Xarch_device -O3 %s 2>&1 \
387 // RUN: | FileCheck --check-prefix=XARCH-DEVICE %s
388 // XARCH-DEVICE: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-O3"
389 // XARCH-DEVICE-NOT: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-O3"
392 // Check that `-gpulibc` includes the LLVM C libraries for the GPU.
394 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
395 // RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
396 // RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
397 // RUN: --offload-arch=sm_52 -gpulibc -nogpuinc %s 2>&1 \
398 // RUN: | FileCheck --check-prefix=LIBC-GPU %s
399 // LIBC-GPU: "-lcgpu"{{.*}}"-lmgpu"
401 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
402 // RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
403 // RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
404 // RUN: --offload-arch=sm_52 -nogpulibc -nogpuinc %s 2>&1 \
405 // RUN: | FileCheck --check-prefix=NO-LIBC-GPU %s
406 // NO-LIBC-GPU-NOT: "-lcgpu"{{.*}}"-lmgpu"