blob: 16c321b9f4998966d9a27561c81a301fb01e12ea [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