Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 1 | // Tests CUDA compilation pipeline construction in Driver. |
| 2 | // REQUIRES: clang-driver |
Artem Belevich | b73313d | 2015-07-14 18:49:17 +0000 | [diff] [blame] | 3 | // REQUIRES: x86-registered-target |
| 4 | // REQUIRES: nvptx-registered-target |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 5 | |
| 6 | // Simple compilation case: |
Artem Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 7 | // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 8 | // Compile device-side to PTX assembly and make sure we use it on the host side. |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 9 | // RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 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 Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 16 | // RUN: %clang -### -target x86_64-linux-gnu %s 2>&1 \ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 17 | // Compile device-side to PTX assembly and make sure we use it on the host side |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 18 | // RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 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 Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 25 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only %s 2>&1 \ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 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 \ |
Artem Belevich | 4242f41 | 2015-07-28 21:01:21 +0000 | [diff] [blame] | 30 | // Linking is allowed to happen, even if we're missing GPU code. |
| 31 | // RUN: -check-prefix CUDA-L %s |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 32 | |
| 33 | // Verify that -cuda-no-host disables host-side compilation and linking |
Artem Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 34 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 35 | // Compile device-side to PTX assembly |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 36 | // RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 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 Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 42 | // RUN: %clang -### -target x86_64-linux-gnu -S -c %s 2>&1 \ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 43 | // Compile device-side to PTX assembly |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 44 | // RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 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 Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 52 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 53 | // Compile device-side to PTX assembly. |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 54 | // RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS \ |
| 55 | // RUN: -check-prefix CUDA-D1-SM35 \ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 56 | // Then compile host side and incorporate GPU code. |
| 57 | // RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \ |
| 58 | // Make sure we don't link anything. |
| 59 | // RUN: -check-prefix CUDA-NL %s |
| 60 | |
| 61 | // Verify that there is device-side compilation per --cuda-gpu-arch args |
| 62 | // and that all results are included on the host side. |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 63 | // RUN: %clang -### -target x86_64-linux-gnu \ |
| 64 | // RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 65 | // Compile both device-sides to PTX assembly |
| 66 | // RUN: | FileCheck \ |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 67 | // RUN: -check-prefix CUDA-D1 -check-prefix CUDA-D1NS -check-prefix CUDA-D1-SM35 \ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 68 | // RUN: -check-prefix CUDA-D2 -check-prefix CUDA-D2-SM30 \ |
| 69 | // Then compile host side and incorporate both device-side outputs |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 70 | // RUN: -check-prefix CUDA-H -check-prefix CUDA-HNS \ |
| 71 | // RUN: -check-prefix CUDA-H-I1 -check-prefix CUDA-H-I2 \ |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 72 | // Make sure we don't link anything. |
| 73 | // RUN: -check-prefix CUDA-NL %s |
| 74 | |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 75 | // Verify that device-side results are passed to correct tool when |
| 76 | // -save-temps is used |
| 77 | // RUN: %clang -### -target x86_64-linux-gnu -save-temps -c %s 2>&1 \ |
| 78 | // Compile device-side to PTX assembly and make sure we use it on the host side. |
| 79 | // RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1S \ |
| 80 | // Then compile host side and incorporate device code. |
| 81 | // RUN: -check-prefix CUDA-H -check-prefix CUDA-HS -check-prefix CUDA-HS-I1 \ |
| 82 | // Make sure we don't link anything. |
| 83 | // RUN: -check-prefix CUDA-NL %s |
| 84 | |
| 85 | // Verify that device-side results are passed to correct tool when |
| 86 | // -fno-integrated-as is used |
| 87 | // RUN: %clang -### -target x86_64-linux-gnu -fno-integrated-as -c %s 2>&1 \ |
| 88 | // Compile device-side to PTX assembly and make sure we use it on the host side. |
| 89 | // RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS \ |
| 90 | // Then compile host side and incorporate device code. |
| 91 | // RUN: -check-prefix CUDA-H -check-prefix CUDA-HNS -check-prefix CUDA-HS-I1 \ |
| 92 | // RUN: -check-prefix CUDA-H-AS \ |
| 93 | // Make sure we don't link anything. |
| 94 | // RUN: -check-prefix CUDA-NL %s |
| 95 | |
| 96 | // Match device-side preprocessor, and compiler phases with -save-temps |
| 97 | // CUDA-D1S: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda" |
| 98 | // CUDA-D1S-SAME: "-fcuda-is-device" |
| 99 | // CUDA-D1S-SAME: "-x" "cuda" |
| 100 | // CUDA-D1S: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda" |
| 101 | // CUDA-D1S-SAME: "-fcuda-is-device" |
| 102 | // CUDA-D1S-SAME: "-x" "cuda-cpp-output" |
| 103 | |
Artem Belevich | baae093 | 2015-07-28 21:01:30 +0000 | [diff] [blame] | 104 | // --cuda-host-only should never trigger unused arg warning. |
| 105 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \ |
| 106 | // RUN: FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s |
| 107 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \ |
| 108 | // RUN: FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s |
| 109 | |
| 110 | // --cuda-device-only should not produce warning compiling CUDA files |
| 111 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \ |
| 112 | // RUN: FileCheck -check-prefix CUDA-NO-UNUSED-CDO %s |
| 113 | |
| 114 | // --cuda-device-only should warn during non-CUDA compilation. |
| 115 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \ |
| 116 | // RUN: FileCheck -check-prefix CUDA-UNUSED-CDO %s |
| 117 | |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 118 | // Match the job that produces PTX assembly |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 119 | // CUDA-D1: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda" |
| 120 | // CUDA-D1-SAME: "-fcuda-is-device" |
| 121 | // CUDA-D1-SM35-SAME: "-target-cpu" "sm_35" |
| 122 | // CUDA-D1-SAME: "-o" "[[GPUBINARY1:[^"]*]]" |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 123 | // CUDA-D1NS-SAME: "-x" "cuda" |
| 124 | // CUDA-D1S-SAME: "-x" "ir" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 125 | |
| 126 | // Match anothe device-side compilation |
| 127 | // CUDA-D2: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda" |
| 128 | // CUDA-D2-SAME: "-fcuda-is-device" |
| 129 | // CUDA-D2-SM30-SAME: "-target-cpu" "sm_30" |
| 130 | // CUDA-D2-SAME: "-o" "[[GPUBINARY2:[^"]*]]" |
| 131 | // CUDA-D2-SAME: "-x" "cuda" |
| 132 | |
| 133 | // Match no device-side compilation |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 134 | // CUDA-ND-NOT: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 135 | // CUDA-ND-SAME-NOT: "-fcuda-is-device" |
| 136 | |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 137 | // Match host-side preprocessor job with -save-temps |
| 138 | // CUDA-HS: "-cc1" "-triple" |
| 139 | // CUDA-HS-SAME-NOT: "nvptx{{(64)?}}-nvidia-cuda" |
| 140 | // CUDA-HS-SAME-NOT: "-fcuda-is-device" |
| 141 | // CUDA-HS-SAME: "-x" "cuda" |
| 142 | |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 143 | // Match host-side compilation |
| 144 | // CUDA-H: "-cc1" "-triple" |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 145 | // CUDA-H-SAME-NOT: "nvptx{{(64)?}}-nvidia-cuda" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 146 | // CUDA-H-SAME-NOT: "-fcuda-is-device" |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 147 | // CUDA-H-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]" |
| 148 | // CUDA-HNS-SAME: "-x" "cuda" |
| 149 | // CUDA-HS-SAME: "-x" "cuda-cpp-output" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 150 | // CUDA-H-I1-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY1]]" |
| 151 | // CUDA-H-I2-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY2]]" |
| 152 | |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 153 | // Match external assembler that uses compilation output |
| 154 | // CUDA-H-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]" |
| 155 | |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 156 | // Match no GPU code inclusion. |
| 157 | // CUDA-H-NI-NOT: "-fcuda-include-gpubinary" |
| 158 | |
| 159 | // Match no CUDA compilation |
| 160 | // CUDA-NH-NOT: "-cc1" "-triple" |
| 161 | // CUDA-NH-SAME-NOT: "-x" "cuda" |
| 162 | |
| 163 | // Match linker |
Yaron Keren | 4ca1903 | 2015-07-14 06:01:14 +0000 | [diff] [blame] | 164 | // CUDA-L: "{{.*}}{{ld|link}}{{(.exe)?}}" |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame^] | 165 | // CUDA-L-SAME: "[[HOSTOUTPUT]]" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 166 | |
| 167 | // Match no linker |
Yaron Keren | 4ca1903 | 2015-07-14 06:01:14 +0000 | [diff] [blame] | 168 | // CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}" |
Artem Belevich | baae093 | 2015-07-28 21:01:30 +0000 | [diff] [blame] | 169 | |
| 170 | // CUDA-NO-UNUSED-CHO-NOT: warning: argument unused during compilation: '--cuda-host-only' |
| 171 | // CUDA-UNUSED-CDO: warning: argument unused during compilation: '--cuda-device-only' |
| 172 | // CUDA-NO-UNUSED-CDO-NOT: warning: argument unused during compilation: '--cuda-device-only' |