blob: ecb3f228eabd1b8701248092feee58e4fc1b9d19 [file] [log] [blame]
Artem Belevich0ff05cd2015-07-13 23:27:56 +00001// Tests CUDA compilation pipeline construction in Driver.
2// REQUIRES: clang-driver
3
4// Simple compilation case:
5// RUN: %clang -### -c %s 2>&1 \
6// Compile device-side to PTX assembly and make sure we use it on the host side.
7// RUN: | FileCheck -check-prefix CUDA-D1 \
8// Then compile host side and incorporate device code.
9// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
10// Make sure we don't link anything.
11// RUN: -check-prefix CUDA-NL %s
12
13// Typical compilation + link case:
14// RUN: %clang -### %s 2>&1 \
15// Compile device-side to PTX assembly and make sure we use it on the host side
16// RUN: | FileCheck -check-prefix CUDA-D1 \
17// Then compile host side and incorporate device code.
18// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
19// Then link things.
20// RUN: -check-prefix CUDA-L %s
21
22// Verify that -cuda-no-device disables device-side compilation and linking
23// RUN: %clang -### --cuda-host-only %s 2>&1 \
24// Make sure we didn't run device-side compilation.
25// RUN: | FileCheck -check-prefix CUDA-ND \
26// Then compile host side and make sure we don't attempt to incorporate GPU code.
27// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-NI \
28// Make sure we don't link anything.
29// RUN: -check-prefix CUDA-NL %s
30
31// Verify that -cuda-no-host disables host-side compilation and linking
32// RUN: %clang -### --cuda-device-only %s 2>&1 \
33// Compile device-side to PTX assembly
34// RUN: | FileCheck -check-prefix CUDA-D1 \
35// Make sure there are no host cmpilation or linking.
36// RUN: -check-prefix CUDA-NH -check-prefix CUDA-NL %s
37
38// Verify that with -S we compile host and device sides to assembly
39// and incorporate device code on the host side.
40// RUN: %clang -### -S -c %s 2>&1 \
41// Compile device-side to PTX assembly
42// RUN: | FileCheck -check-prefix CUDA-D1 \
43// Then compile host side and incorporate GPU code.
44// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
45// Make sure we don't link anything.
46// RUN: -check-prefix CUDA-NL %s
47
48// Verify that --cuda-gpu-arch option passes correct GPU
49// archtecture info to device compilation.
50// RUN: %clang -### --cuda-gpu-arch=sm_35 -c %s 2>&1 \
51// Compile device-side to PTX assembly.
52// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1-SM35 \
53// Then compile host side and incorporate GPU code.
54// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
55// Make sure we don't link anything.
56// RUN: -check-prefix CUDA-NL %s
57
58// Verify that there is device-side compilation per --cuda-gpu-arch args
59// and that all results are included on the host side.
60// RUN: %clang -### --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
61// Compile both device-sides to PTX assembly
62// RUN: | FileCheck \
63// RUN: -check-prefix CUDA-D1 -check-prefix CUDA-D1-SM35 \
64// RUN: -check-prefix CUDA-D2 -check-prefix CUDA-D2-SM30 \
65// Then compile host side and incorporate both device-side outputs
66// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 -check-prefix CUDA-H-I2 \
67// Make sure we don't link anything.
68// RUN: -check-prefix CUDA-NL %s
69
70// Match device-side compilation
71// CUDA-D1: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
72// CUDA-D1-SAME: "-fcuda-is-device"
73// CUDA-D1-SM35-SAME: "-target-cpu" "sm_35"
74// CUDA-D1-SAME: "-o" "[[GPUBINARY1:[^"]*]]"
75// CUDA-D1-SAME: "-x" "cuda"
76
77// Match anothe device-side compilation
78// CUDA-D2: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
79// CUDA-D2-SAME: "-fcuda-is-device"
80// CUDA-D2-SM30-SAME: "-target-cpu" "sm_30"
81// CUDA-D2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
82// CUDA-D2-SAME: "-x" "cuda"
83
84// Match no device-side compilation
85// CUDA-ND-NOT: "-cc1" "-triple" "nvptx{{64?}}-nvidia-cuda"
86// CUDA-ND-SAME-NOT: "-fcuda-is-device"
87
88// Match host-side compilation
89// CUDA-H: "-cc1" "-triple"
90// CUDA-H-SAME-NOT: "nvptx{{64?}}-nvidia-cuda"
91// CUDA-H-SAME-NOT: "-fcuda-is-device"
92// CUDA-H-SAME: "-o" "[[HOSTOBJ:[^"]*]]"
93// CUDA-H-SAME: "-x" "cuda"
94// CUDA-H-I1-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY1]]"
95// CUDA-H-I2-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY2]]"
96
97// Match no GPU code inclusion.
98// CUDA-H-NI-NOT: "-fcuda-include-gpubinary"
99
100// Match no CUDA compilation
101// CUDA-NH-NOT: "-cc1" "-triple"
102// CUDA-NH-SAME-NOT: "-x" "cuda"
103
104// Match linker
105// CUDA-L: "{{.*}}ld{{(.exe)?}}"
106// CUDA-L-SAME: "[[HOSTOBJ]]"
107
108// Match no linker
109// CUDA-NL-NOT: "{{.*}}ld{{(.exe)?}}"