]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Driver/cuda-options.cu
Vendor import of clang trunk r242221:
[FreeBSD/FreeBSD.git] / test / Driver / cuda-options.cu
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:
7 // RUN: %clang -### -target=x86_64-linux-gnu -c %s 2>&1 \
8 // 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:
16 // RUN: %clang -### -target=x86_64-linux-gnu %s 2>&1 \
17 // 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
25 // RUN: %clang -### -target=x86_64-linux-gnu --cuda-host-only %s 2>&1 \
26 // 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 \
30 // Make sure we don't link anything.
31 // RUN:    -check-prefix CUDA-NL %s
32
33 // Verify that -cuda-no-host disables host-side compilation and linking
34 // RUN: %clang -### -target=x86_64-linux-gnu --cuda-device-only %s 2>&1 \
35 // 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.
42 // RUN: %clang -### -target=x86_64-linux-gnu -S -c %s 2>&1 \
43 // 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.
52 // RUN: %clang -### -target=x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
53 // 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.
62 // RUN: %clang -### -target=x86_64-linux-gnu --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
63 // 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
72 // Match device-side compilation
73 // CUDA-D1: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
74 // CUDA-D1-SAME: "-fcuda-is-device"
75 // CUDA-D1-SM35-SAME: "-target-cpu" "sm_35"
76 // CUDA-D1-SAME: "-o" "[[GPUBINARY1:[^"]*]]"
77 // CUDA-D1-SAME: "-x" "cuda"
78
79 // Match anothe device-side compilation
80 // CUDA-D2: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
81 // CUDA-D2-SAME: "-fcuda-is-device"
82 // CUDA-D2-SM30-SAME: "-target-cpu" "sm_30"
83 // CUDA-D2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
84 // CUDA-D2-SAME: "-x" "cuda"
85
86 // Match no device-side compilation
87 // CUDA-ND-NOT: "-cc1" "-triple" "nvptx{{64?}}-nvidia-cuda"
88 // CUDA-ND-SAME-NOT: "-fcuda-is-device"
89
90 // Match host-side compilation
91 // CUDA-H: "-cc1" "-triple"
92 // CUDA-H-SAME-NOT: "nvptx{{64?}}-nvidia-cuda"
93 // CUDA-H-SAME-NOT: "-fcuda-is-device"
94 // CUDA-H-SAME: "-o" "[[HOSTOBJ:[^"]*]]"
95 // CUDA-H-SAME: "-x" "cuda"
96 // CUDA-H-I1-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY1]]"
97 // CUDA-H-I2-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY2]]"
98
99 // Match no GPU code inclusion.
100 // CUDA-H-NI-NOT: "-fcuda-include-gpubinary"
101
102 // Match no CUDA compilation
103 // CUDA-NH-NOT: "-cc1" "-triple"
104 // CUDA-NH-SAME-NOT: "-x" "cuda"
105
106 // Match linker
107 // CUDA-L: "{{.*}}{{ld|link}}{{(.exe)?}}"
108 // CUDA-L-SAME: "[[HOSTOBJ]]"
109
110 // Match no linker
111 // CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"