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 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 6 | // Simple compilation case. Compile device-side to PTX assembly and make sure |
| 7 | // we use it on the host side. |
Artem Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 8 | // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \ |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 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 |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 12 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 13 | // Typical compilation + link case. |
Artem Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 14 | // RUN: %clang -### -target x86_64-linux-gnu %s 2>&1 \ |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 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 |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 18 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 19 | // Verify that --cuda-host-only disables device-side compilation, but doesn't |
| 20 | // disable host-side compilation/linking. |
Artem Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 21 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only %s 2>&1 \ |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 22 | // RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \ |
| 23 | // RUN: -check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 24 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 25 | // Same test as above, but with preceeding --cuda-device-only to make sure only |
| 26 | // the last option has an effect. |
Artem Belevich | 2325675 | 2015-09-22 17:23:09 +0000 | [diff] [blame] | 27 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only --cuda-host-only %s 2>&1 \ |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 28 | // RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \ |
| 29 | // RUN: -check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s |
Artem Belevich | 2325675 | 2015-09-22 17:23:09 +0000 | [diff] [blame] | 30 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 31 | // Verify that --cuda-device-only disables host-side compilation and linking. |
Artem Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 32 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \ |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 33 | // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \ |
| 34 | // RUN: -check-prefix NOHOST -check-prefix NOLINK %s |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 35 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 36 | // Same test as above, but with preceeding --cuda-host-only to make sure only |
| 37 | // the last option has an effect. |
Artem Belevich | 2325675 | 2015-09-22 17:23:09 +0000 | [diff] [blame] | 38 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only --cuda-device-only %s 2>&1 \ |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 39 | // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \ |
| 40 | // RUN: -check-prefix NOHOST -check-prefix NOLINK %s |
Artem Belevich | 2325675 | 2015-09-22 17:23:09 +0000 | [diff] [blame] | 41 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 42 | // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to |
| 43 | // device compilation. |
Artem Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame] | 44 | // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \ |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 45 | // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \ |
| 46 | // RUN: -check-prefix DEVICE-SM35 -check-prefix HOST \ |
| 47 | // RUN: -check-prefix INCLUDES-DEVICE -check-prefix NOLINK %s |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 48 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 49 | // Verify that there is one device-side compilation per --cuda-gpu-arch args |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 50 | // and that all results are included on the host side. |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame] | 51 | // RUN: %clang -### -target x86_64-linux-gnu \ |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 52 | // RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \ |
| 53 | // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \ |
| 54 | // RUN: -check-prefix DEVICE2 -check-prefix DEVICE-SM35 \ |
| 55 | // RUN: -check-prefix DEVICE2-SM30 -check-prefix HOST \ |
| 56 | // RUN: -check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \ |
Justin Lebar | 21e5d4f | 2016-01-14 21:41:27 +0000 | [diff] [blame] | 57 | // RUN: -check-prefix NOLINK %s |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 58 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 59 | // Verify that device-side results are passed to the correct tool when |
| 60 | // -save-temps is used. |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame] | 61 | // RUN: %clang -### -target x86_64-linux-gnu -save-temps -c %s 2>&1 \ |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 62 | // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-SAVE \ |
| 63 | // RUN: -check-prefix HOST -check-prefix HOST-SAVE -check-prefix NOLINK %s |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame] | 64 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 65 | // Verify that device-side results are passed to the correct tool when |
| 66 | // -fno-integrated-as is used. |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame] | 67 | // RUN: %clang -### -target x86_64-linux-gnu -fno-integrated-as -c %s 2>&1 \ |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 68 | // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \ |
| 69 | // RUN: -check-prefix HOST -check-prefix HOST-NOSAVE \ |
| 70 | // RUN: -check-prefix HOST-AS -check-prefix NOLINK %s |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame] | 71 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 72 | // Match device-side preprocessor and compiler phases with -save-temps. |
| 73 | // DEVICE-SAVE: "-cc1" "-triple" "nvptx64-nvidia-cuda" |
| 74 | // DEVICE-SAVE-SAME: "-aux-triple" "x86_64--linux-gnu" |
| 75 | // DEVICE-SAVE-SAME: "-fcuda-is-device" |
| 76 | // DEVICE-SAVE-SAME: "-x" "cuda" |
Artem Belevich | 5e2a3ec | 2015-11-17 22:28:40 +0000 | [diff] [blame] | 77 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 78 | // DEVICE-SAVE: "-cc1" "-triple" "nvptx64-nvidia-cuda" |
| 79 | // DEVICE-SAVE-SAME: "-aux-triple" "x86_64--linux-gnu" |
| 80 | // DEVICE-SAVE-SAME: "-fcuda-is-device" |
| 81 | // DEVICE-SAVE-SAME: "-x" "cuda-cpp-output" |
Artem Belevich | 5e2a3ec | 2015-11-17 22:28:40 +0000 | [diff] [blame] | 82 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 83 | // Match the job that produces PTX assembly. |
| 84 | // DEVICE: "-cc1" "-triple" "nvptx64-nvidia-cuda" |
| 85 | // DEVICE-NOSAVE-SAME: "-aux-triple" "x86_64--linux-gnu" |
| 86 | // DEVICE-SAME: "-fcuda-is-device" |
| 87 | // DEVICE-SM35-SAME: "-target-cpu" "sm_35" |
Justin Lebar | 21e5d4f | 2016-01-14 21:41:27 +0000 | [diff] [blame] | 88 | // DEVICE-SAME: "-o" "[[PTXFILE:[^"]*]]" |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 89 | // DEVICE-NOSAVE-SAME: "-x" "cuda" |
| 90 | // DEVICE-SAVE-SAME: "-x" "ir" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 91 | |
Justin Lebar | 21e5d4f | 2016-01-14 21:41:27 +0000 | [diff] [blame] | 92 | // Match the call to ptxas (which assembles PTX to SASS). |
| 93 | // DEVICE:ptxas |
| 94 | // DEVICE-SM35-DAG: "--gpu-name" "sm_35" |
| 95 | // DEVICE-DAG: "--output-file" "[[CUBINFILE:[^"]*]]" |
| 96 | // DEVICE-DAG: "[[PTXFILE]]" |
| 97 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 98 | // Match another device-side compilation. |
| 99 | // DEVICE2: "-cc1" "-triple" "nvptx64-nvidia-cuda" |
| 100 | // DEVICE2-SAME: "-aux-triple" "x86_64--linux-gnu" |
| 101 | // DEVICE2-SAME: "-fcuda-is-device" |
| 102 | // DEVICE2-SM30-SAME: "-target-cpu" "sm_30" |
| 103 | // DEVICE2-SAME: "-o" "[[GPUBINARY2:[^"]*]]" |
| 104 | // DEVICE2-SAME: "-x" "cuda" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 105 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 106 | // Match no device-side compilation. |
| 107 | // NODEVICE-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda" |
Paul Robinson | 4abe94f | 2016-02-10 02:08:24 +0000 | [diff] [blame^] | 108 | // NODEVICE-NOT: "-fcuda-is-device" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 109 | |
Justin Lebar | 21e5d4f | 2016-01-14 21:41:27 +0000 | [diff] [blame] | 110 | // INCLUDES-DEVICE:fatbinary |
| 111 | // INCLUDES-DEVICE-DAG: "--create" "[[FATBINARY:[^"]*]]" |
| 112 | // INCLUDES-DEVICE-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE]]" |
| 113 | // INCLUDES-DEVICE-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE]]" |
| 114 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 115 | // Match host-side preprocessor job with -save-temps. |
| 116 | // HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu" |
| 117 | // HOST-SAVE-SAME: "-aux-triple" "nvptx64-nvidia-cuda" |
Paul Robinson | 4abe94f | 2016-02-10 02:08:24 +0000 | [diff] [blame^] | 118 | // HOST-SAVE-NOT: "-fcuda-is-device" |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 119 | // HOST-SAVE-SAME: "-x" "cuda" |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame] | 120 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 121 | // Match host-side compilation. |
| 122 | // HOST: "-cc1" "-triple" "x86_64--linux-gnu" |
| 123 | // HOST-SAME: "-aux-triple" "nvptx64-nvidia-cuda" |
Paul Robinson | 4abe94f | 2016-02-10 02:08:24 +0000 | [diff] [blame^] | 124 | // HOST-NOT: "-fcuda-is-device" |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 125 | // HOST-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]" |
| 126 | // HOST-NOSAVE-SAME: "-x" "cuda" |
| 127 | // HOST-SAVE-SAME: "-x" "cuda-cpp-output" |
Justin Lebar | 21e5d4f | 2016-01-14 21:41:27 +0000 | [diff] [blame] | 128 | // INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[FATBINARY]]" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 129 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 130 | // Match external assembler that uses compilation output. |
| 131 | // HOST-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]" |
Artem Belevich | f8144ab | 2015-08-27 18:10:41 +0000 | [diff] [blame] | 132 | |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 133 | // Match no GPU code inclusion. |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 134 | // NOINCLUDES-DEVICE-NOT: "-fcuda-include-gpubinary" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 135 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 136 | // Match no host compilation. |
| 137 | // NOHOST-NOT: "-cc1" "-triple" |
Paul Robinson | 4abe94f | 2016-02-10 02:08:24 +0000 | [diff] [blame^] | 138 | // NOHOST-NOT: "-x" "cuda" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 139 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 140 | // Match linker. |
| 141 | // LINK: "{{.*}}{{ld|link}}{{(.exe)?}}" |
| 142 | // LINK-SAME: "[[HOSTOUTPUT]]" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 143 | |
Justin Lebar | 388579f | 2016-01-13 01:24:35 +0000 | [diff] [blame] | 144 | // Match no linker. |
| 145 | // NOLINK-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}" |