blob: 2ac4fbf34c6c7c47c68441b46a8b86e9e88f94f8 [file] [log] [blame]
Artem Belevich0ff05cd2015-07-13 23:27:56 +00001// Tests CUDA compilation pipeline construction in Driver.
2// REQUIRES: clang-driver
Artem Belevichb73313d2015-07-14 18:49:17 +00003// REQUIRES: x86-registered-target
4// REQUIRES: nvptx-registered-target
Artem Belevich0ff05cd2015-07-13 23:27:56 +00005
6// Simple compilation case:
Artem Belevichdf7cd312015-07-16 17:24:18 +00007// RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +00008// Compile device-side to PTX assembly and make sure we use it on the host side.
Artem Belevichf8144ab2015-08-27 18:10:41 +00009// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
Artem Belevich0ff05cd2015-07-13 23:27:56 +000010// Then compile host side and incorporate device code.
11// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
12// Make sure we don't link anything.
13// RUN: -check-prefix CUDA-NL %s
14
15// Typical compilation + link case:
Artem Belevichdf7cd312015-07-16 17:24:18 +000016// RUN: %clang -### -target x86_64-linux-gnu %s 2>&1 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +000017// Compile device-side to PTX assembly and make sure we use it on the host side
Artem Belevichf8144ab2015-08-27 18:10:41 +000018// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
Artem Belevich0ff05cd2015-07-13 23:27:56 +000019// Then compile host side and incorporate device code.
20// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
21// Then link things.
22// RUN: -check-prefix CUDA-L %s
23
24// Verify that -cuda-no-device disables device-side compilation and linking
Artem Belevichdf7cd312015-07-16 17:24:18 +000025// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only %s 2>&1 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +000026// Make sure we didn't run device-side compilation.
27// RUN: | FileCheck -check-prefix CUDA-ND \
28// Then compile host side and make sure we don't attempt to incorporate GPU code.
29// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-NI \
Artem Belevich4242f412015-07-28 21:01:21 +000030// Linking is allowed to happen, even if we're missing GPU code.
31// RUN: -check-prefix CUDA-L %s
Artem Belevich0ff05cd2015-07-13 23:27:56 +000032
33// Verify that -cuda-no-host disables host-side compilation and linking
Artem Belevichdf7cd312015-07-16 17:24:18 +000034// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +000035// Compile device-side to PTX assembly
Artem Belevichf8144ab2015-08-27 18:10:41 +000036// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
Artem Belevich0ff05cd2015-07-13 23:27:56 +000037// Make sure there are no host cmpilation or linking.
38// RUN: -check-prefix CUDA-NH -check-prefix CUDA-NL %s
39
40// Verify that with -S we compile host and device sides to assembly
41// and incorporate device code on the host side.
Artem Belevichdf7cd312015-07-16 17:24:18 +000042// RUN: %clang -### -target x86_64-linux-gnu -S -c %s 2>&1 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +000043// Compile device-side to PTX assembly
Artem Belevichf8144ab2015-08-27 18:10:41 +000044// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
Artem Belevich0ff05cd2015-07-13 23:27:56 +000045// Then compile host side and incorporate GPU code.
46// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
47// Make sure we don't link anything.
48// RUN: -check-prefix CUDA-NL %s
49
50// Verify that --cuda-gpu-arch option passes correct GPU
51// archtecture info to device compilation.
Artem Belevichdf7cd312015-07-16 17:24:18 +000052// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +000053// Compile device-side to PTX assembly.
Artem Belevichf8144ab2015-08-27 18:10:41 +000054// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS \
55// RUN: -check-prefix CUDA-D1-SM35 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +000056// Then compile host side and incorporate GPU code.
57// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
58// Make sure we don't link anything.
59// RUN: -check-prefix CUDA-NL %s
60
61// Verify that there is device-side compilation per --cuda-gpu-arch args
62// and that all results are included on the host side.
Artem Belevichf8144ab2015-08-27 18:10:41 +000063// RUN: %clang -### -target x86_64-linux-gnu \
64// RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +000065// Compile both device-sides to PTX assembly
66// RUN: | FileCheck \
Artem Belevichf8144ab2015-08-27 18:10:41 +000067// RUN: -check-prefix CUDA-D1 -check-prefix CUDA-D1NS -check-prefix CUDA-D1-SM35 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +000068// RUN: -check-prefix CUDA-D2 -check-prefix CUDA-D2-SM30 \
69// Then compile host side and incorporate both device-side outputs
Artem Belevichf8144ab2015-08-27 18:10:41 +000070// RUN: -check-prefix CUDA-H -check-prefix CUDA-HNS \
71// RUN: -check-prefix CUDA-H-I1 -check-prefix CUDA-H-I2 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +000072// Make sure we don't link anything.
73// RUN: -check-prefix CUDA-NL %s
74
Artem Belevichf8144ab2015-08-27 18:10:41 +000075// Verify that device-side results are passed to correct tool when
76// -save-temps is used
77// RUN: %clang -### -target x86_64-linux-gnu -save-temps -c %s 2>&1 \
78// Compile device-side to PTX assembly and make sure we use it on the host side.
79// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1S \
80// Then compile host side and incorporate device code.
81// RUN: -check-prefix CUDA-H -check-prefix CUDA-HS -check-prefix CUDA-HS-I1 \
82// Make sure we don't link anything.
83// RUN: -check-prefix CUDA-NL %s
84
85// Verify that device-side results are passed to correct tool when
86// -fno-integrated-as is used
87// RUN: %clang -### -target x86_64-linux-gnu -fno-integrated-as -c %s 2>&1 \
88// Compile device-side to PTX assembly and make sure we use it on the host side.
89// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS \
90// Then compile host side and incorporate device code.
91// RUN: -check-prefix CUDA-H -check-prefix CUDA-HNS -check-prefix CUDA-HS-I1 \
92// RUN: -check-prefix CUDA-H-AS \
93// Make sure we don't link anything.
94// RUN: -check-prefix CUDA-NL %s
95
96// Match device-side preprocessor, and compiler phases with -save-temps
97// CUDA-D1S: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
98// CUDA-D1S-SAME: "-fcuda-is-device"
99// CUDA-D1S-SAME: "-x" "cuda"
100// CUDA-D1S: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
101// CUDA-D1S-SAME: "-fcuda-is-device"
102// CUDA-D1S-SAME: "-x" "cuda-cpp-output"
103
Artem Belevichbaae0932015-07-28 21:01:30 +0000104// --cuda-host-only should never trigger unused arg warning.
105// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
106// RUN: FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
107// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
108// RUN: FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
109
110// --cuda-device-only should not produce warning compiling CUDA files
111// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
112// RUN: FileCheck -check-prefix CUDA-NO-UNUSED-CDO %s
113
114// --cuda-device-only should warn during non-CUDA compilation.
115// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
116// RUN: FileCheck -check-prefix CUDA-UNUSED-CDO %s
117
Artem Belevichf8144ab2015-08-27 18:10:41 +0000118// Match the job that produces PTX assembly
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000119// CUDA-D1: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
120// CUDA-D1-SAME: "-fcuda-is-device"
121// CUDA-D1-SM35-SAME: "-target-cpu" "sm_35"
122// CUDA-D1-SAME: "-o" "[[GPUBINARY1:[^"]*]]"
Artem Belevichf8144ab2015-08-27 18:10:41 +0000123// CUDA-D1NS-SAME: "-x" "cuda"
124// CUDA-D1S-SAME: "-x" "ir"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000125
126// Match anothe device-side compilation
127// CUDA-D2: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
128// CUDA-D2-SAME: "-fcuda-is-device"
129// CUDA-D2-SM30-SAME: "-target-cpu" "sm_30"
130// CUDA-D2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
131// CUDA-D2-SAME: "-x" "cuda"
132
133// Match no device-side compilation
Artem Belevichf8144ab2015-08-27 18:10:41 +0000134// CUDA-ND-NOT: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000135// CUDA-ND-SAME-NOT: "-fcuda-is-device"
136
Artem Belevichf8144ab2015-08-27 18:10:41 +0000137// Match host-side preprocessor job with -save-temps
138// CUDA-HS: "-cc1" "-triple"
139// CUDA-HS-SAME-NOT: "nvptx{{(64)?}}-nvidia-cuda"
140// CUDA-HS-SAME-NOT: "-fcuda-is-device"
141// CUDA-HS-SAME: "-x" "cuda"
142
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000143// Match host-side compilation
144// CUDA-H: "-cc1" "-triple"
Artem Belevichf8144ab2015-08-27 18:10:41 +0000145// CUDA-H-SAME-NOT: "nvptx{{(64)?}}-nvidia-cuda"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000146// CUDA-H-SAME-NOT: "-fcuda-is-device"
Artem Belevichf8144ab2015-08-27 18:10:41 +0000147// CUDA-H-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
148// CUDA-HNS-SAME: "-x" "cuda"
149// CUDA-HS-SAME: "-x" "cuda-cpp-output"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000150// CUDA-H-I1-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY1]]"
151// CUDA-H-I2-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY2]]"
152
Artem Belevichf8144ab2015-08-27 18:10:41 +0000153// Match external assembler that uses compilation output
154// CUDA-H-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
155
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000156// Match no GPU code inclusion.
157// CUDA-H-NI-NOT: "-fcuda-include-gpubinary"
158
159// Match no CUDA compilation
160// CUDA-NH-NOT: "-cc1" "-triple"
161// CUDA-NH-SAME-NOT: "-x" "cuda"
162
163// Match linker
Yaron Keren4ca19032015-07-14 06:01:14 +0000164// CUDA-L: "{{.*}}{{ld|link}}{{(.exe)?}}"
Artem Belevichf8144ab2015-08-27 18:10:41 +0000165// CUDA-L-SAME: "[[HOSTOUTPUT]]"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000166
167// Match no linker
Yaron Keren4ca19032015-07-14 06:01:14 +0000168// CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
Artem Belevichbaae0932015-07-28 21:01:30 +0000169
170// CUDA-NO-UNUSED-CHO-NOT: warning: argument unused during compilation: '--cuda-host-only'
171// CUDA-UNUSED-CDO: warning: argument unused during compilation: '--cuda-device-only'
172// CUDA-NO-UNUSED-CDO-NOT: warning: argument unused during compilation: '--cuda-device-only'