blob: 3d14041a13f81befe1bb89f0d288d4534ee88425 [file] [log] [blame]
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +00001///
2/// Perform several driver tests for OpenMP offloading
3///
4
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +00005// REQUIRES: clang-driver
6// REQUIRES: x86-registered-target
7// REQUIRES: powerpc-registered-target
8// REQUIRES: nvptx-registered-target
9
10/// ###########################################################################
11
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +000012/// Check -Xopenmp-target uses one of the archs provided when several archs are used.
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +000013// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
14// RUN: -Xopenmp-target -march=sm_35 -Xopenmp-target -march=sm_60 %s 2>&1 \
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +000015// RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-ARCHS %s
16
17// CHK-FOPENMP-TARGET-ARCHS: ptxas{{.*}}" "--gpu-name" "sm_60"
18// CHK-FOPENMP-TARGET-ARCHS: nvlink{{.*}}" "-arch" "sm_60"
19
20/// ###########################################################################
21
22/// Check -Xopenmp-target -march=sm_35 works as expected when two triples are present.
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +000023// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp \
24// RUN: -fopenmp-targets=powerpc64le-ibm-linux-gnu,nvptx64-nvidia-cuda \
25// RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_35 %s 2>&1 \
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +000026// RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-COMPILATION %s
27
28// CHK-FOPENMP-TARGET-COMPILATION: ptxas{{.*}}" "--gpu-name" "sm_35"
29// CHK-FOPENMP-TARGET-COMPILATION: nvlink{{.*}}" "-arch" "sm_35"
30
31/// ###########################################################################
32
33/// Check cubin file generation and usage by nvlink
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +000034// RUN: %clang -### -no-canonical-prefixes -target powerpc64le-unknown-linux-gnu -fopenmp=libomp \
35// RUN: -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \
36// RUN: | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s
37/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
38// RUN: %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp \
39// RUN: -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
40// RUN: | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +000041
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +000042// CHK-CUBIN-NVLINK: clang{{.*}}" "-o" "[[PTX:.*\.s]]"
43// CHK-CUBIN-NVLINK-NEXT: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX]]"
44// CHK-CUBIN-NVLINK-NEXT: nvlink{{.*}}" {{.*}}"[[CUBIN]]"
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +000045
46/// ###########################################################################
47
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +000048/// Check unbundlink of assembly file, cubin file generation and usage by nvlink
49// RUN: touch %t.s
Jonas Hahnfeld4609b252017-11-21 15:06:28 +000050// RUN: %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
51// RUN: -no-canonical-prefixes -save-temps %t.s 2>&1 \
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +000052// RUN: | FileCheck -check-prefix=CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK %s
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +000053
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +000054/// Use DAG to ensure that assembly file has been unbundled.
55// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX:.*\.s]]"
56// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=s" {{.*}}"-outputs={{.*}}[[PTX]]
57// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG-SAME: "-unbundle"
58// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK: nvlink{{.*}}" {{.*}}"[[CUBIN]]"
59
60/// ###########################################################################
61
62/// Check cubin file generation and bundling
Jonas Hahnfeld4609b252017-11-21 15:06:28 +000063// RUN: %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
64// RUN: -no-canonical-prefixes -save-temps %s -c 2>&1 \
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +000065// RUN: | FileCheck -check-prefix=CHK-PTXAS-CUBIN-BUNDLING %s
66
67// CHK-PTXAS-CUBIN-BUNDLING: clang{{.*}}" "-o" "[[PTX:.*\.s]]"
68// CHK-PTXAS-CUBIN-BUNDLING-NEXT: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX]]"
69// CHK-PTXAS-CUBIN-BUNDLING: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-inputs={{.*}}[[CUBIN]]
70
71/// ###########################################################################
72
73/// Check cubin file unbundling and usage by nvlink
74// RUN: touch %t.o
Jonas Hahnfeld4609b252017-11-21 15:06:28 +000075// RUN: %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
76// RUN: -no-canonical-prefixes -save-temps %t.o 2>&1 \
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +000077// RUN: | FileCheck -check-prefix=CHK-CUBIN-UNBUNDLING-NVLINK %s
78
79/// Use DAG to ensure that cubin file has been unbundled.
80// CHK-CUBIN-UNBUNDLING-NVLINK-DAG: nvlink{{.*}}" {{.*}}"[[CUBIN:.*\.cubin]]"
81// CHK-CUBIN-UNBUNDLING-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-outputs={{.*}}[[CUBIN]]
82// CHK-CUBIN-UNBUNDLING-NVLINK-DAG-SAME: "-unbundle"
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +000083
84/// ###########################################################################
85
86/// Check cubin file generation and usage by nvlink
87// RUN: touch %t1.o
88// RUN: touch %t2.o
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +000089// RUN: %clang -### -no-canonical-prefixes -target powerpc64le-unknown-linux-gnu -fopenmp=libomp \
90// RUN: -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
91// RUN: | FileCheck -check-prefix=CHK-TWOCUBIN %s
92/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
93// RUN: %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp \
94// RUN: -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +000095// RUN: | FileCheck -check-prefix=CHK-TWOCUBIN %s
96
Gheorghe-Teodor Bercea5636f4b2017-09-25 21:25:38 +000097// CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +000098
99/// ###########################################################################
100
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +0000101/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP.
102// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -no-canonical-prefixes %s 2>&1 \
103// RUN: | FileCheck -check-prefix=CHK-PTXAS-DEFAULT %s
104
105// CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c"
106
107/// ###########################################################################
108
109/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it.
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +0000110// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target \
111// RUN: -save-temps -no-canonical-prefixes %s 2>&1 \
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +0000112// RUN: | FileCheck -check-prefix=CHK-PTXAS-NORELO %s
113
114// CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c"
115
116/// ###########################################################################
117
118/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP
119/// Check that the flag is passed when -fopenmp-relocatable-target is used.
Jonas Hahnfeld7c78cc52017-11-21 14:44:45 +0000120// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target \
121// RUN: -save-temps -no-canonical-prefixes %s 2>&1 \
Gheorghe-Teodor Bercea9c525742017-08-11 15:46:22 +0000122// RUN: | FileCheck -check-prefix=CHK-PTXAS-RELO %s
123
124// CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
Gheorghe-Teodor Bercea20789a52017-09-25 21:56:32 +0000125
126/// ###########################################################################
127
128/// Check that error is not thrown by toolchain when no cuda lib flag is used.
129/// Check that the flag is passed when -fopenmp-relocatable-target is used.
130// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \
131// RUN: -nocudalib -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
132// RUN: | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s
133
134// CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_60
Gheorghe-Teodor Bercea5a3608c2017-09-26 15:36:20 +0000135
136/// ###########################################################################
137
138/// Check that error is not thrown by toolchain when no cuda lib device is found when using -S.
139/// Check that the flag is passed when -fopenmp-relocatable-target is used.
140// RUN: %clang -### -S -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \
141// RUN: -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
142// RUN: | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
143
144// CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
Gheorghe-Teodor Bercea0d5aa842018-03-13 23:19:52 +0000145
146/// ###########################################################################
147
148/// Check that the runtime bitcode library is part of the compile line. Create a bogus
149/// bitcode library and add it to the LIBRARY_PATH.
150// RUN: env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
151// RUN: -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
152// RUN: -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
153// RUN: | FileCheck -check-prefix=CHK-BCLIB %s
154
155// CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
156// CHK-BCLIB-NOT: {{error:|warning:}}
157
158/// ###########################################################################
159
160/// Check that the warning is thrown when the libomptarget bitcode library is not found.
161/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should never exist.
162// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
163// RUN: -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
164// RUN: -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
165// RUN: | FileCheck -check-prefix=CHK-BCLIB-WARN %s
166
167// CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
Alexey Bataeve36c67b2018-04-18 16:31:09 +0000168
169/// Check that debug info is emitted in dwarf-2
170// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \
171// RUN: | FileCheck -check-prefix=NO_DEBUG %s
172// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 2>&1 \
173// RUN: | FileCheck -check-prefix=NO_DEBUG %s
174// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 \
175// RUN: | FileCheck -check-prefix=NO_DEBUG %s
176// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g0 2>&1 \
177// RUN: | FileCheck -check-prefix=NO_DEBUG %s
178// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 \
179// RUN: | FileCheck -check-prefix=NO_DEBUG %s
180// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \
181// RUN: | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s
182// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \
183// RUN: | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s
184
185// NO_DEBUG: ptxas
186// LINE_TABLE: "-lineinfo"
187// NO_DEBUG-NOT: "-g"
188// NO_DEBUG: nvlink
189// NO_DEBUG-NOT: "-g"
190
191// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g 2>&1 \
192// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
193// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --cuda-noopt-device-debug 2>&1 \
194// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
195// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --cuda-noopt-device-debug 2>&1 \
196// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
197// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g2 2>&1 \
198// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
199// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb2 -O0 --cuda-noopt-device-debug 2>&1 \
200// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
201// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g3 -O3 --cuda-noopt-device-debug 2>&1 \
202// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
203// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \
204// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
205
206// HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda"
207// HAS_DEBUG-SAME: "-dwarf-version=2"
208// HAS_DEBUG-SAME: "-fopenmp-is-device"
209// HAS_DEBUG: ptxas
210// HAS_DEBUG-SAME: "-g"
211// HAS_DEBUG-SAME: "--dont-merge-basicblocks"
212// HAS_DEBUG-SAME: "--return-at-end"
213// HAS_DEBUG: nvlink
214// HAS_DEBUG-SAME: "-g"
215