blob: 5d650761fb2280c29bf30ee96389fc4c6d031cb8 [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
Justin Lebar388579f2016-01-13 01:24:35 +00006// Simple compilation case. Compile device-side to PTX assembly and make sure
7// we use it on the host side.
Artem Belevichdf7cd312015-07-16 17:24:18 +00008// RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +00009// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
10// RUN: -check-prefix HOST -check-prefix INCLUDES-DEVICE \
11// RUN: -check-prefix NOLINK %s
Artem Belevich0ff05cd2015-07-13 23:27:56 +000012
Justin Lebar388579f2016-01-13 01:24:35 +000013// Typical compilation + link case.
Artem Belevichdf7cd312015-07-16 17:24:18 +000014// RUN: %clang -### -target x86_64-linux-gnu %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000015// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
16// RUN: -check-prefix HOST -check-prefix INCLUDES-DEVICE \
17// RUN: -check-prefix LINK %s
Artem Belevich0ff05cd2015-07-13 23:27:56 +000018
Justin Lebar388579f2016-01-13 01:24:35 +000019// Verify that --cuda-host-only disables device-side compilation, but doesn't
20// disable host-side compilation/linking.
Artem Belevichdf7cd312015-07-16 17:24:18 +000021// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000022// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
23// RUN: -check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
Artem Belevich0ff05cd2015-07-13 23:27:56 +000024
Justin Lebar388579f2016-01-13 01:24:35 +000025// Verify that --cuda-device-only disables host-side compilation and linking.
Artem Belevichdf7cd312015-07-16 17:24:18 +000026// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000027// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
28// RUN: -check-prefix NOHOST -check-prefix NOLINK %s
Artem Belevich0ff05cd2015-07-13 23:27:56 +000029
Justin Lebardc3c5042016-04-19 02:27:07 +000030// Check that the last of --cuda-compile-host-device, --cuda-host-only, and
31// --cuda-device-only wins.
32
33// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
34// RUN: --cuda-host-only %s 2>&1 \
35// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
36// RUN: -check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
37
38// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device \
39// RUN: --cuda-host-only %s 2>&1 \
40// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
41// RUN: -check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
42
43// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only \
44// RUN: --cuda-device-only %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000045// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
46// RUN: -check-prefix NOHOST -check-prefix NOLINK %s
Artem Belevich23256752015-09-22 17:23:09 +000047
Justin Lebardc3c5042016-04-19 02:27:07 +000048// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device \
49// RUN: --cuda-device-only %s 2>&1 \
50// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
51// RUN: -check-prefix NOHOST -check-prefix NOLINK %s
52
53// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only \
54// RUN: --cuda-compile-host-device %s 2>&1 \
55// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
56// RUN: -check-prefix HOST -check-prefix INCLUDES-DEVICE \
57// RUN: -check-prefix LINK %s
58
59// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
60// RUN: --cuda-compile-host-device %s 2>&1 \
61// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
62// RUN: -check-prefix HOST -check-prefix INCLUDES-DEVICE \
63// RUN: -check-prefix LINK %s
64
Justin Lebar388579f2016-01-13 01:24:35 +000065// Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
66// device compilation.
Artem Belevichdf7cd312015-07-16 17:24:18 +000067// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000068// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
69// RUN: -check-prefix DEVICE-SM35 -check-prefix HOST \
70// RUN: -check-prefix INCLUDES-DEVICE -check-prefix NOLINK %s
Artem Belevich0ff05cd2015-07-13 23:27:56 +000071
Justin Lebar388579f2016-01-13 01:24:35 +000072// Verify that there is one device-side compilation per --cuda-gpu-arch args
Artem Belevich0ff05cd2015-07-13 23:27:56 +000073// and that all results are included on the host side.
Artem Belevichf8144ab2015-08-27 18:10:41 +000074// RUN: %clang -### -target x86_64-linux-gnu \
Justin Lebar388579f2016-01-13 01:24:35 +000075// RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
76// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
77// RUN: -check-prefix DEVICE2 -check-prefix DEVICE-SM35 \
78// RUN: -check-prefix DEVICE2-SM30 -check-prefix HOST \
79// RUN: -check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
Justin Lebar21e5d4f2016-01-14 21:41:27 +000080// RUN: -check-prefix NOLINK %s
Artem Belevich0ff05cd2015-07-13 23:27:56 +000081
Justin Lebar388579f2016-01-13 01:24:35 +000082// Verify that device-side results are passed to the correct tool when
83// -save-temps is used.
Artem Belevichf8144ab2015-08-27 18:10:41 +000084// RUN: %clang -### -target x86_64-linux-gnu -save-temps -c %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000085// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-SAVE \
86// RUN: -check-prefix HOST -check-prefix HOST-SAVE -check-prefix NOLINK %s
Artem Belevichf8144ab2015-08-27 18:10:41 +000087
Justin Lebar388579f2016-01-13 01:24:35 +000088// Verify that device-side results are passed to the correct tool when
89// -fno-integrated-as is used.
Artem Belevichf8144ab2015-08-27 18:10:41 +000090// RUN: %clang -### -target x86_64-linux-gnu -fno-integrated-as -c %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000091// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
92// RUN: -check-prefix HOST -check-prefix HOST-NOSAVE \
93// RUN: -check-prefix HOST-AS -check-prefix NOLINK %s
Artem Belevichf8144ab2015-08-27 18:10:41 +000094
Justin Lebar388579f2016-01-13 01:24:35 +000095// Match device-side preprocessor and compiler phases with -save-temps.
96// DEVICE-SAVE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
97// DEVICE-SAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
98// DEVICE-SAVE-SAME: "-fcuda-is-device"
99// DEVICE-SAVE-SAME: "-x" "cuda"
Artem Belevich5e2a3ec2015-11-17 22:28:40 +0000100
Justin Lebar388579f2016-01-13 01:24:35 +0000101// DEVICE-SAVE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
102// DEVICE-SAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
103// DEVICE-SAVE-SAME: "-fcuda-is-device"
104// DEVICE-SAVE-SAME: "-x" "cuda-cpp-output"
Artem Belevich5e2a3ec2015-11-17 22:28:40 +0000105
Justin Lebar388579f2016-01-13 01:24:35 +0000106// Match the job that produces PTX assembly.
107// DEVICE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
108// DEVICE-NOSAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
109// DEVICE-SAME: "-fcuda-is-device"
110// DEVICE-SM35-SAME: "-target-cpu" "sm_35"
Justin Lebar21e5d4f2016-01-14 21:41:27 +0000111// DEVICE-SAME: "-o" "[[PTXFILE:[^"]*]]"
Justin Lebar388579f2016-01-13 01:24:35 +0000112// DEVICE-NOSAVE-SAME: "-x" "cuda"
113// DEVICE-SAVE-SAME: "-x" "ir"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000114
Justin Lebar21e5d4f2016-01-14 21:41:27 +0000115// Match the call to ptxas (which assembles PTX to SASS).
116// DEVICE:ptxas
117// DEVICE-SM35-DAG: "--gpu-name" "sm_35"
118// DEVICE-DAG: "--output-file" "[[CUBINFILE:[^"]*]]"
119// DEVICE-DAG: "[[PTXFILE]]"
120
Justin Lebar388579f2016-01-13 01:24:35 +0000121// Match another device-side compilation.
122// DEVICE2: "-cc1" "-triple" "nvptx64-nvidia-cuda"
123// DEVICE2-SAME: "-aux-triple" "x86_64--linux-gnu"
124// DEVICE2-SAME: "-fcuda-is-device"
125// DEVICE2-SM30-SAME: "-target-cpu" "sm_30"
126// DEVICE2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
127// DEVICE2-SAME: "-x" "cuda"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000128
Justin Lebar388579f2016-01-13 01:24:35 +0000129// Match no device-side compilation.
130// NODEVICE-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
Paul Robinson4abe94f2016-02-10 02:08:24 +0000131// NODEVICE-NOT: "-fcuda-is-device"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000132
Justin Lebar21e5d4f2016-01-14 21:41:27 +0000133// INCLUDES-DEVICE:fatbinary
134// INCLUDES-DEVICE-DAG: "--create" "[[FATBINARY:[^"]*]]"
135// INCLUDES-DEVICE-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE]]"
136// INCLUDES-DEVICE-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE]]"
137
Justin Lebar388579f2016-01-13 01:24:35 +0000138// Match host-side preprocessor job with -save-temps.
139// HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu"
140// HOST-SAVE-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
Paul Robinson4abe94f2016-02-10 02:08:24 +0000141// HOST-SAVE-NOT: "-fcuda-is-device"
Justin Lebar388579f2016-01-13 01:24:35 +0000142// HOST-SAVE-SAME: "-x" "cuda"
Artem Belevichf8144ab2015-08-27 18:10:41 +0000143
Justin Lebar388579f2016-01-13 01:24:35 +0000144// Match host-side compilation.
145// HOST: "-cc1" "-triple" "x86_64--linux-gnu"
146// HOST-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
Paul Robinson4abe94f2016-02-10 02:08:24 +0000147// HOST-NOT: "-fcuda-is-device"
Justin Lebar388579f2016-01-13 01:24:35 +0000148// HOST-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
149// HOST-NOSAVE-SAME: "-x" "cuda"
150// HOST-SAVE-SAME: "-x" "cuda-cpp-output"
Justin Lebar21e5d4f2016-01-14 21:41:27 +0000151// INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[FATBINARY]]"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000152
Justin Lebar388579f2016-01-13 01:24:35 +0000153// Match external assembler that uses compilation output.
154// HOST-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
Artem Belevichf8144ab2015-08-27 18:10:41 +0000155
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000156// Match no GPU code inclusion.
Justin Lebar388579f2016-01-13 01:24:35 +0000157// NOINCLUDES-DEVICE-NOT: "-fcuda-include-gpubinary"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000158
Justin Lebar388579f2016-01-13 01:24:35 +0000159// Match no host compilation.
160// NOHOST-NOT: "-cc1" "-triple"
Paul Robinson4abe94f2016-02-10 02:08:24 +0000161// NOHOST-NOT: "-x" "cuda"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000162
Justin Lebar388579f2016-01-13 01:24:35 +0000163// Match linker.
164// LINK: "{{.*}}{{ld|link}}{{(.exe)?}}"
165// LINK-SAME: "[[HOSTOUTPUT]]"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000166
Justin Lebar388579f2016-01-13 01:24:35 +0000167// Match no linker.
168// NOLINK-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"