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. |
| 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 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 |
| 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 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 \ |
| 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 |
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 |
| 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 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 |
| 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 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. |
| 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 Belevich | df7cd31 | 2015-07-16 17:24:18 +0000 | [diff] [blame^] | 62 | // RUN: %clang -### -target x86_64-linux-gnu --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] | 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 |
Yaron Keren | 4ca1903 | 2015-07-14 06:01:14 +0000 | [diff] [blame] | 107 | // CUDA-L: "{{.*}}{{ld|link}}{{(.exe)?}}" |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 108 | // CUDA-L-SAME: "[[HOSTOBJ]]" |
| 109 | |
| 110 | // Match no linker |
Yaron Keren | 4ca1903 | 2015-07-14 06:01:14 +0000 | [diff] [blame] | 111 | // CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}" |