blob: d673ab2bb59af52e54c4ce8af745e4cf8d2e4f29 [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// Same test as above, but with preceeding --cuda-device-only to make sure only
26// the last option has an effect.
Artem Belevich23256752015-09-22 17:23:09 +000027// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only --cuda-host-only %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000028// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
29// RUN: -check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
Artem Belevich23256752015-09-22 17:23:09 +000030
Justin Lebar388579f2016-01-13 01:24:35 +000031// Verify that --cuda-device-only disables host-side compilation and linking.
Artem Belevichdf7cd312015-07-16 17:24:18 +000032// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000033// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
34// RUN: -check-prefix NOHOST -check-prefix NOLINK %s
Artem Belevich0ff05cd2015-07-13 23:27:56 +000035
Justin Lebar388579f2016-01-13 01:24:35 +000036// Same test as above, but with preceeding --cuda-host-only to make sure only
37// the last option has an effect.
Artem Belevich23256752015-09-22 17:23:09 +000038// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only --cuda-device-only %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000039// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
40// RUN: -check-prefix NOHOST -check-prefix NOLINK %s
Artem Belevich23256752015-09-22 17:23:09 +000041
Justin Lebar388579f2016-01-13 01:24:35 +000042// Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
43// device compilation.
Artem Belevichdf7cd312015-07-16 17:24:18 +000044// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000045// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
46// RUN: -check-prefix DEVICE-SM35 -check-prefix HOST \
47// RUN: -check-prefix INCLUDES-DEVICE -check-prefix NOLINK %s
Artem Belevich0ff05cd2015-07-13 23:27:56 +000048
Justin Lebar388579f2016-01-13 01:24:35 +000049// Verify that there is one device-side compilation per --cuda-gpu-arch args
Artem Belevich0ff05cd2015-07-13 23:27:56 +000050// and that all results are included on the host side.
Artem Belevichf8144ab2015-08-27 18:10:41 +000051// RUN: %clang -### -target x86_64-linux-gnu \
Justin Lebar388579f2016-01-13 01:24:35 +000052// RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
53// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
54// RUN: -check-prefix DEVICE2 -check-prefix DEVICE-SM35 \
55// RUN: -check-prefix DEVICE2-SM30 -check-prefix HOST \
56// RUN: -check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
Justin Lebar21e5d4f2016-01-14 21:41:27 +000057// RUN: -check-prefix NOLINK %s
Artem Belevich0ff05cd2015-07-13 23:27:56 +000058
Justin Lebar388579f2016-01-13 01:24:35 +000059// Verify that device-side results are passed to the correct tool when
60// -save-temps is used.
Artem Belevichf8144ab2015-08-27 18:10:41 +000061// RUN: %clang -### -target x86_64-linux-gnu -save-temps -c %s 2>&1 \
Justin Lebar388579f2016-01-13 01:24:35 +000062// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-SAVE \
63// RUN: -check-prefix HOST -check-prefix HOST-SAVE -check-prefix NOLINK %s
Artem Belevichf8144ab2015-08-27 18:10:41 +000064
Justin Lebar388579f2016-01-13 01:24:35 +000065// Verify that device-side results are passed to the correct tool when
66// -fno-integrated-as is used.
Artem Belevichf8144ab2015-08-27 18:10:41 +000067// RUN: %clang -### -target x86_64-linux-gnu -fno-integrated-as -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 HOST -check-prefix HOST-NOSAVE \
70// RUN: -check-prefix HOST-AS -check-prefix NOLINK %s
Artem Belevichf8144ab2015-08-27 18:10:41 +000071
Justin Lebar388579f2016-01-13 01:24:35 +000072// Match device-side preprocessor and compiler phases with -save-temps.
73// DEVICE-SAVE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
74// DEVICE-SAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
75// DEVICE-SAVE-SAME: "-fcuda-is-device"
76// DEVICE-SAVE-SAME: "-x" "cuda"
Artem Belevich5e2a3ec2015-11-17 22:28:40 +000077
Justin Lebar388579f2016-01-13 01:24:35 +000078// DEVICE-SAVE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
79// DEVICE-SAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
80// DEVICE-SAVE-SAME: "-fcuda-is-device"
81// DEVICE-SAVE-SAME: "-x" "cuda-cpp-output"
Artem Belevich5e2a3ec2015-11-17 22:28:40 +000082
Justin Lebar388579f2016-01-13 01:24:35 +000083// Match the job that produces PTX assembly.
84// DEVICE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
85// DEVICE-NOSAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
86// DEVICE-SAME: "-fcuda-is-device"
87// DEVICE-SM35-SAME: "-target-cpu" "sm_35"
Justin Lebar21e5d4f2016-01-14 21:41:27 +000088// DEVICE-SAME: "-o" "[[PTXFILE:[^"]*]]"
Justin Lebar388579f2016-01-13 01:24:35 +000089// DEVICE-NOSAVE-SAME: "-x" "cuda"
90// DEVICE-SAVE-SAME: "-x" "ir"
Artem Belevich0ff05cd2015-07-13 23:27:56 +000091
Justin Lebar21e5d4f2016-01-14 21:41:27 +000092// Match the call to ptxas (which assembles PTX to SASS).
93// DEVICE:ptxas
94// DEVICE-SM35-DAG: "--gpu-name" "sm_35"
95// DEVICE-DAG: "--output-file" "[[CUBINFILE:[^"]*]]"
96// DEVICE-DAG: "[[PTXFILE]]"
97
Justin Lebar388579f2016-01-13 01:24:35 +000098// Match another device-side compilation.
99// DEVICE2: "-cc1" "-triple" "nvptx64-nvidia-cuda"
100// DEVICE2-SAME: "-aux-triple" "x86_64--linux-gnu"
101// DEVICE2-SAME: "-fcuda-is-device"
102// DEVICE2-SM30-SAME: "-target-cpu" "sm_30"
103// DEVICE2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
104// DEVICE2-SAME: "-x" "cuda"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000105
Justin Lebar388579f2016-01-13 01:24:35 +0000106// Match no device-side compilation.
107// NODEVICE-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
Paul Robinson4abe94f2016-02-10 02:08:24 +0000108// NODEVICE-NOT: "-fcuda-is-device"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000109
Justin Lebar21e5d4f2016-01-14 21:41:27 +0000110// INCLUDES-DEVICE:fatbinary
111// INCLUDES-DEVICE-DAG: "--create" "[[FATBINARY:[^"]*]]"
112// INCLUDES-DEVICE-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE]]"
113// INCLUDES-DEVICE-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE]]"
114
Justin Lebar388579f2016-01-13 01:24:35 +0000115// Match host-side preprocessor job with -save-temps.
116// HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu"
117// HOST-SAVE-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
Paul Robinson4abe94f2016-02-10 02:08:24 +0000118// HOST-SAVE-NOT: "-fcuda-is-device"
Justin Lebar388579f2016-01-13 01:24:35 +0000119// HOST-SAVE-SAME: "-x" "cuda"
Artem Belevichf8144ab2015-08-27 18:10:41 +0000120
Justin Lebar388579f2016-01-13 01:24:35 +0000121// Match host-side compilation.
122// HOST: "-cc1" "-triple" "x86_64--linux-gnu"
123// HOST-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
Paul Robinson4abe94f2016-02-10 02:08:24 +0000124// HOST-NOT: "-fcuda-is-device"
Justin Lebar388579f2016-01-13 01:24:35 +0000125// HOST-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
126// HOST-NOSAVE-SAME: "-x" "cuda"
127// HOST-SAVE-SAME: "-x" "cuda-cpp-output"
Justin Lebar21e5d4f2016-01-14 21:41:27 +0000128// INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[FATBINARY]]"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000129
Justin Lebar388579f2016-01-13 01:24:35 +0000130// Match external assembler that uses compilation output.
131// HOST-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
Artem Belevichf8144ab2015-08-27 18:10:41 +0000132
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000133// Match no GPU code inclusion.
Justin Lebar388579f2016-01-13 01:24:35 +0000134// NOINCLUDES-DEVICE-NOT: "-fcuda-include-gpubinary"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000135
Justin Lebar388579f2016-01-13 01:24:35 +0000136// Match no host compilation.
137// NOHOST-NOT: "-cc1" "-triple"
Paul Robinson4abe94f2016-02-10 02:08:24 +0000138// NOHOST-NOT: "-x" "cuda"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000139
Justin Lebar388579f2016-01-13 01:24:35 +0000140// Match linker.
141// LINK: "{{.*}}{{ld|link}}{{(.exe)?}}"
142// LINK-SAME: "[[HOSTOUTPUT]]"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000143
Justin Lebar388579f2016-01-13 01:24:35 +0000144// Match no linker.
145// NOLINK-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"