blob: d1575db727ba635da5d3d3e281164e65cc6a9291 [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.
9// RUN: | FileCheck -check-prefix CUDA-D1 \
10// 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
18// RUN: | FileCheck -check-prefix CUDA-D1 \
19// 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
36// RUN: | FileCheck -check-prefix CUDA-D1 \
37// 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
44// RUN: | FileCheck -check-prefix CUDA-D1 \
45// 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.
54// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1-SM35 \
55// Then compile host side and incorporate GPU code.
56// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
57// Make sure we don't link anything.
58// RUN: -check-prefix CUDA-NL %s
59
60// Verify that there is device-side compilation per --cuda-gpu-arch args
61// and that all results are included on the host side.
Artem Belevichdf7cd312015-07-16 17:24:18 +000062// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
Artem Belevich0ff05cd2015-07-13 23:27:56 +000063// Compile both device-sides to PTX assembly
64// RUN: | FileCheck \
65// RUN: -check-prefix CUDA-D1 -check-prefix CUDA-D1-SM35 \
66// RUN: -check-prefix CUDA-D2 -check-prefix CUDA-D2-SM30 \
67// Then compile host side and incorporate both device-side outputs
68// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 -check-prefix CUDA-H-I2 \
69// Make sure we don't link anything.
70// RUN: -check-prefix CUDA-NL %s
71
Artem Belevichbaae0932015-07-28 21:01:30 +000072// --cuda-host-only should never trigger unused arg warning.
73// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
74// RUN: FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
75// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
76// RUN: FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
77
78// --cuda-device-only should not produce warning compiling CUDA files
79// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
80// RUN: FileCheck -check-prefix CUDA-NO-UNUSED-CDO %s
81
82// --cuda-device-only should warn during non-CUDA compilation.
83// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
84// RUN: FileCheck -check-prefix CUDA-UNUSED-CDO %s
85
Artem Belevich0ff05cd2015-07-13 23:27:56 +000086// Match device-side compilation
87// CUDA-D1: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
88// CUDA-D1-SAME: "-fcuda-is-device"
89// CUDA-D1-SM35-SAME: "-target-cpu" "sm_35"
90// CUDA-D1-SAME: "-o" "[[GPUBINARY1:[^"]*]]"
91// CUDA-D1-SAME: "-x" "cuda"
92
93// Match anothe device-side compilation
94// CUDA-D2: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
95// CUDA-D2-SAME: "-fcuda-is-device"
96// CUDA-D2-SM30-SAME: "-target-cpu" "sm_30"
97// CUDA-D2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
98// CUDA-D2-SAME: "-x" "cuda"
99
100// Match no device-side compilation
101// CUDA-ND-NOT: "-cc1" "-triple" "nvptx{{64?}}-nvidia-cuda"
102// CUDA-ND-SAME-NOT: "-fcuda-is-device"
103
104// Match host-side compilation
105// CUDA-H: "-cc1" "-triple"
106// CUDA-H-SAME-NOT: "nvptx{{64?}}-nvidia-cuda"
107// CUDA-H-SAME-NOT: "-fcuda-is-device"
108// CUDA-H-SAME: "-o" "[[HOSTOBJ:[^"]*]]"
109// CUDA-H-SAME: "-x" "cuda"
110// CUDA-H-I1-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY1]]"
111// CUDA-H-I2-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY2]]"
112
113// Match no GPU code inclusion.
114// CUDA-H-NI-NOT: "-fcuda-include-gpubinary"
115
116// Match no CUDA compilation
117// CUDA-NH-NOT: "-cc1" "-triple"
118// CUDA-NH-SAME-NOT: "-x" "cuda"
119
120// Match linker
Yaron Keren4ca19032015-07-14 06:01:14 +0000121// CUDA-L: "{{.*}}{{ld|link}}{{(.exe)?}}"
Artem Belevich0ff05cd2015-07-13 23:27:56 +0000122// CUDA-L-SAME: "[[HOSTOBJ]]"
123
124// Match no linker
Yaron Keren4ca19032015-07-14 06:01:14 +0000125// CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
Artem Belevichbaae0932015-07-28 21:01:30 +0000126
127// CUDA-NO-UNUSED-CHO-NOT: warning: argument unused during compilation: '--cuda-host-only'
128// CUDA-UNUSED-CDO: warning: argument unused during compilation: '--cuda-device-only'
129// CUDA-NO-UNUSED-CDO-NOT: warning: argument unused during compilation: '--cuda-device-only'