• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Tests CUDA compilation pipeline construction in Driver.
2 // REQUIRES: clang-driver
3 // REQUIRES: x86-registered-target
4 // REQUIRES: nvptx-registered-target
5 
6 // Simple compilation case. Compile device-side to PTX assembly and make sure
7 // we use it on the host side.
8 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
9 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
10 // RUN:    -check-prefix HOST -check-prefix INCLUDES-DEVICE \
11 // RUN:    -check-prefix NOLINK %s
12 
13 // Typical compilation + link case.
14 // RUN: %clang -### -target x86_64-linux-gnu %s 2>&1 \
15 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
16 // RUN:    -check-prefix HOST -check-prefix INCLUDES-DEVICE \
17 // RUN:    -check-prefix LINK %s
18 
19 // Verify that --cuda-host-only disables device-side compilation, but doesn't
20 // disable host-side compilation/linking.
21 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only %s 2>&1 \
22 // RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
23 // RUN:    -check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
24 
25 // Verify that --cuda-device-only disables host-side compilation and linking.
26 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
27 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
28 // RUN:    -check-prefix NOHOST -check-prefix NOLINK %s
29 
30 // 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 \
45 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
46 // RUN:    -check-prefix NOHOST -check-prefix NOLINK %s
47 
48 // 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 
65 // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
66 // device compilation.
67 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
68 // 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
71 
72 // Verify that there is one device-side compilation per --cuda-gpu-arch args
73 // and that all results are included on the host side.
74 // RUN: %clang -### -target x86_64-linux-gnu \
75 // 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 \
80 // RUN:    -check-prefix NOLINK %s
81 
82 // Verify that device-side results are passed to the correct tool when
83 // -save-temps is used.
84 // RUN: %clang -### -target x86_64-linux-gnu -save-temps -c %s 2>&1 \
85 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-SAVE \
86 // RUN:    -check-prefix HOST -check-prefix HOST-SAVE -check-prefix NOLINK %s
87 
88 // Verify that device-side results are passed to the correct tool when
89 // -fno-integrated-as is used.
90 // RUN: %clang -### -target x86_64-linux-gnu -fno-integrated-as -c %s 2>&1 \
91 // 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
94 
95 // 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"
100 
101 // 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"
105 
106 // 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"
111 // DEVICE-SAME: "-o" "[[PTXFILE:[^"]*]]"
112 // DEVICE-NOSAVE-SAME: "-x" "cuda"
113 // DEVICE-SAVE-SAME: "-x" "ir"
114 
115 // 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 
121 // 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"
128 
129 // Match no device-side compilation.
130 // NODEVICE-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
131 // NODEVICE-NOT: "-fcuda-is-device"
132 
133 // 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 
138 // 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"
141 // HOST-SAVE-NOT: "-fcuda-is-device"
142 // HOST-SAVE-SAME: "-x" "cuda"
143 
144 // Match host-side compilation.
145 // HOST: "-cc1" "-triple" "x86_64--linux-gnu"
146 // HOST-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
147 // HOST-NOT: "-fcuda-is-device"
148 // HOST-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
149 // HOST-NOSAVE-SAME: "-x" "cuda"
150 // HOST-SAVE-SAME: "-x" "cuda-cpp-output"
151 // INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[FATBINARY]]"
152 
153 // Match external assembler that uses compilation output.
154 // HOST-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
155 
156 // Match no GPU code inclusion.
157 // NOINCLUDES-DEVICE-NOT: "-fcuda-include-gpubinary"
158 
159 // Match no host compilation.
160 // NOHOST-NOT: "-cc1" "-triple"
161 // NOHOST-NOT: "-x" "cuda"
162 
163 // Match linker.
164 // LINK: "{{.*}}{{ld|link}}{{(.exe)?}}"
165 // LINK-SAME: "[[HOSTOUTPUT]]"
166 
167 // Match no linker.
168 // NOLINK-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
169