| 1 |
// Tests the bindings generated for a CUDA offloading target for different |
| 2 |
// combinations of: |
| 3 |
// - Number of gpu architectures; |
| 4 |
// - Host/device-only compilation; |
| 5 |
// - User-requested final phase - binary or assembly. |
| 6 |
// It parallels cuda-phases.cu test, but verifies whether output file is temporary or not. |
| 7 |
|
| 8 |
// It's hard to check whether file name is temporary in a portable |
| 9 |
// way. Instead we check whether we've generated a permanent name on |
| 10 |
// device side, which appends '-device-cuda-<triple>' suffix. |
| 11 |
|
| 12 |
// |
| 13 |
// Test single gpu architecture with complete compilation. |
| 14 |
// No intermediary device files should have "-device-cuda..." in the name. |
| 15 |
// |
| 16 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s 2>&1 \ |
| 17 |
// RUN: | FileCheck -check-prefix=BIN %s |
| 18 |
// BIN: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: |
| 19 |
// BIN-NOT: cuda-bindings-device-cuda-nvptx64 |
| 20 |
// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output: |
| 21 |
// BIN-NOT: cuda-bindings-device-cuda-nvptx64 |
| 22 |
// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output: |
| 23 |
// BIN-NOT: cuda-bindings-device-cuda-nvptx64 |
| 24 |
// BIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: |
| 25 |
// BIN-NOT: cuda-bindings-device-cuda-nvptx64 |
| 26 |
// BIN: # "powerpc64le-ibm-linux-gnu" - "Offload::Linker", inputs:{{.*}}, output: "a.out" |
| 27 |
|
| 28 |
// |
| 29 |
// Test single gpu architecture up to the assemble phase. |
| 30 |
// |
| 31 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s -S 2>&1 \ |
| 32 |
// RUN: | FileCheck -check-prefix=ASM %s |
| 33 |
// ASM-DAG: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "[[PTX:.+]].s" |
| 34 |
// ASM-DAG: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s" |
| 35 |
|
| 36 |
// |
| 37 |
// Test two gpu architectures with complete compilation. |
| 38 |
// |
| 39 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 40 |
// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ |
| 41 |
// RUN: | FileCheck -check-prefixes=BIN2,AOUT %s |
| 42 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 43 |
// RUN: --offload-arch=sm_30,sm_35 %s 2>&1 \ |
| 44 |
// RUN: | FileCheck -check-prefixes=BIN2,AOUT %s |
| 45 |
// .. same, but with explicitly specified output. |
| 46 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 47 |
// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -o %t/out 2>&1 \ |
| 48 |
// RUN: | FileCheck -check-prefixes=BIN2,TOUT %s |
| 49 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 50 |
// RUN: --offload-arch=sm_30,sm_35 %s -o %t/out 2>&1 \ |
| 51 |
// RUN: | FileCheck -check-prefixes=BIN2,TOUT %s |
| 52 |
// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: |
| 53 |
// BIN2-NOT: cuda-bindings-device-cuda-nvptx64 |
| 54 |
// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output: |
| 55 |
// BIN2-NOT: cuda-bindings-device-cuda-nvptx64 |
| 56 |
// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: |
| 57 |
// BIN2-NOT: cuda-bindings-device-cuda-nvptx64 |
| 58 |
// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output: |
| 59 |
// BIN2-NOT: cuda-bindings-device-cuda-nvptx64 |
| 60 |
// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output: |
| 61 |
// BIN2-NOT: cuda-bindings-device-cuda-nvptx64 |
| 62 |
// BIN2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: |
| 63 |
// BIN2-NOT: cuda-bindings-device-cuda-nvptx64 |
| 64 |
// AOUT: # "powerpc64le-ibm-linux-gnu" - "Offload::Linker", inputs:{{.*}}, output: "a.out" |
| 65 |
// TOUT: # "powerpc64le-ibm-linux-gnu" - "Offload::Linker", inputs:{{.*}}, output: "{{.*}}/out" |
| 66 |
|
| 67 |
// .. same, but with -fsyntax-only |
| 68 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ |
| 69 |
// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ |
| 70 |
// RUN: | FileCheck -check-prefix=NDSYN %s |
| 71 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ |
| 72 |
// RUN: --offload-arch=sm_30,sm_35 %s -o %t/out 2>&1 \ |
| 73 |
// RUN: | FileCheck -check-prefix=NDSYN %s |
| 74 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ |
| 75 |
// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ |
| 76 |
// RUN: | FileCheck -check-prefix=NDSYN %s |
| 77 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ |
| 78 |
// RUN: --offload-arch=sm_30,sm_35 %s -o %t/out 2>&1 \ |
| 79 |
// RUN: | FileCheck -check-prefix=NDSYN %s |
| 80 |
// NDSYN-NOT: inputs: |
| 81 |
// NDSYN: # "nvptx64-nvidia-cuda" - "clang", inputs: [{{.*}}], output: (nothing) |
| 82 |
// NDSYN-NEXT: # "nvptx64-nvidia-cuda" - "clang", inputs: [{{.*}}], output: (nothing) |
| 83 |
// NDSYN-NEXT: # "powerpc64le-ibm-linux-gnu" - "clang", inputs: [{{.*}}], output: (nothing) |
| 84 |
// NDSYN-NOT: inputs: |
| 85 |
|
| 86 |
|
| 87 |
// |
| 88 |
// Test two gpu architectures up to the assemble phase. |
| 89 |
// |
| 90 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 91 |
// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -S 2>&1 \ |
| 92 |
// RUN: | FileCheck -check-prefix=ASM2 %s |
| 93 |
// ASM2-DAG: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "[[SM30:.+]].s" |
| 94 |
// ASM2-DAG: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "[[SM35:.+]].s" |
| 95 |
// ASM2-DAG: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s" |
| 96 |
|
| 97 |
// |
| 98 |
// Test one or more gpu architecture with complete compilation in host-only |
| 99 |
// compilation mode. |
| 100 |
// |
| 101 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 102 |
// RUN: --cuda-gpu-arch=sm_30 %s --cuda-host-only 2>&1 \ |
| 103 |
// RUN: | FileCheck -check-prefix=HBIN %s |
| 104 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 105 |
// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-host-only 2>&1 \ |
| 106 |
// RUN: | FileCheck -check-prefix=HBIN %s |
| 107 |
// HBIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: |
| 108 |
// HBIN-NOT: cuda-bindings-device-cuda-nvptx64 |
| 109 |
// HBIN: # "powerpc64le-ibm-linux-gnu" - "Offload::Linker", inputs:{{.*}}, output: "a.out" |
| 110 |
|
| 111 |
// |
| 112 |
// Test one or more gpu architecture up to the assemble phase in host-only |
| 113 |
// compilation mode. |
| 114 |
// |
| 115 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 116 |
// RUN: --cuda-gpu-arch=sm_30 %s --cuda-host-only -S 2>&1 \ |
| 117 |
// RUN: | FileCheck -check-prefix=HASM %s |
| 118 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 119 |
// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-host-only -S 2>&1 \ |
| 120 |
// RUN: | FileCheck -check-prefix=HASM %s |
| 121 |
// HASM: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s" |
| 122 |
|
| 123 |
// |
| 124 |
// Test single gpu architecture with complete compilation in device-only |
| 125 |
// compilation mode. |
| 126 |
// |
| 127 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 128 |
// RUN: --cuda-gpu-arch=sm_30 %s --cuda-device-only 2>&1 \ |
| 129 |
// RUN: | FileCheck -check-prefix=DBIN %s |
| 130 |
// DBIN: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: |
| 131 |
// DBIN-NOT: cuda-bindings-device-cuda-nvptx64 |
| 132 |
// DBIN: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output: "cuda-bindings-cuda-nvptx64-nvidia-cuda-sm_30.o" |
| 133 |
|
| 134 |
// |
| 135 |
// Test single gpu architecture up to the assemble phase in device-only |
| 136 |
// compilation mode. |
| 137 |
// |
| 138 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ |
| 139 |
// RUN: --cuda-gpu-arch=sm_30 %s --cuda-device-only -S 2>&1 \ |
| 140 |
// RUN: | FileCheck -check-prefix=DASM %s |
| 141 |
// DASM: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-cuda-nvptx64-nvidia-cuda-sm_30.s" |
| 142 |
|
| 143 |
// |
| 144 |
// Test two gpu architectures with complete compilation in device-only |
| 145 |
// compilation mode. |
| 146 |
// |
| 147 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --no-offload-new-driver \ |
| 148 |
// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-device-only 2>&1 \ |
| 149 |
// RUN: | FileCheck -check-prefix=DBIN2 %s |
| 150 |
// DBIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: |
| 151 |
// DBIN2-NOT: cuda-bindings-device-cuda-nvptx64 |
| 152 |
// DBIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output: "cuda-bindings-cuda-nvptx64-nvidia-cuda-sm_30.o" |
| 153 |
// DBIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: |
| 154 |
// DBIN2-NOT: cuda-bindings-device-cuda-nvptx64 |
| 155 |
// DBIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output: "cuda-bindings-cuda-nvptx64-nvidia-cuda-sm_35.o" |
| 156 |
|
| 157 |
// |
| 158 |
// Test two gpu architectures up to the assemble phase in device-only |
| 159 |
// compilation mode. |
| 160 |
// |
| 161 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --no-offload-new-driver \ |
| 162 |
// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-device-only -S 2>&1 \ |
| 163 |
// RUN: | FileCheck -check-prefix=DASM2 %s |
| 164 |
// DASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-cuda-nvptx64-nvidia-cuda-sm_30.s" |
| 165 |
// DASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-cuda-nvptx64-nvidia-cuda-sm_35.s" |
| 166 |
|
| 167 |
// |
| 168 |
// Ensure we output the user's specified name in device-only mode. |
| 169 |
// |
| 170 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -### \ |
| 171 |
// RUN: --cuda-gpu-arch=sm_52 --cuda-device-only -c -o foo.o --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ |
| 172 |
// RUN: | FileCheck -check-prefix=D_ONLY %s |
| 173 |
// RUN: %clang -target powerpc64le-ibm-linux-gnu -### --offload-new-driver \ |
| 174 |
// RUN: --cuda-gpu-arch=sm_52 --cuda-device-only -c -o foo.o --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ |
| 175 |
// RUN: | FileCheck -check-prefix=D_ONLY %s |
| 176 |
// D_ONLY: "foo.o" |
| 177 |
|
| 178 |
// |
| 179 |
// Check to make sure we can generate multiple outputs for device-only |
| 180 |
// compilation and fail with '-o'. |
| 181 |
// |
| 182 |
// RUN: %clang -### -target powerpc64le-ibm-linux-gnu --offload-new-driver -ccc-print-bindings \ |
| 183 |
// RUN: --offload-arch=sm_70 --offload-arch=sm_52 --offload-device-only -c %s 2>&1 \ |
| 184 |
// RUN: | FileCheck -check-prefix=MULTI-D-ONLY %s |
| 185 |
// MULTI-D-ONLY: # "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[PTX_70:.+]]" |
| 186 |
// MULTI-D-ONLY-NEXT: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[PTX_70]]"], output: "[[CUBIN_70:.+]]" |
| 187 |
// MULTI-D-ONLY-NEXT: # "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]"], output: "[[PTX_52:.+]]" |
| 188 |
// MULTI-D-ONLY-NEXT: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[PTX_52]]"], output: "[[CUBIN_52:.+]]" |
| 189 |
// |
| 190 |
// RUN: not %clang -### --target=powerpc64le-ibm-linux-gnu --offload-new-driver -ccc-print-bindings \ |
| 191 |
// RUN: --offload-arch=sm_70 --offload-arch=sm_52 --offload-device-only -c -o %t %s 2>&1 \ |
| 192 |
// RUN: | FileCheck -check-prefix=MULTI-D-ONLY-O %s |
| 193 |
// MULTI-D-ONLY-O: error: cannot specify -o when generating multiple output files |
| 194 |
|
| 195 |
// |
| 196 |
// Check to ensure that we can use '-fsyntax-only' for CUDA output with the new |
| 197 |
// driver. |
| 198 |
// |
| 199 |
// RUN: %clang -### -target powerpc64le-ibm-linux-gnu --offload-new-driver \ |
| 200 |
// RUN: -fsyntax-only --offload-arch=sm_70 --offload-arch=sm_52 -c --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda %s 2>&1 \ |
| 201 |
// RUN: | FileCheck -check-prefix=SYNTAX-ONLY %s |
| 202 |
// SYNTAX-ONLY: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-fsyntax-only" |
| 203 |
// SYNTAX-ONLY: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-fsyntax-only" |
| 204 |
// SYNTAX-ONLY: "-cc1" "-triple" "powerpc64le-ibm-linux-gnu"{{.*}}"-fsyntax-only" |
| 205 |
|
| 206 |
// |
| 207 |
// Check to ensure that we can use '-save-temps' when operating in RDC-mode. |
| 208 |
// |
| 209 |
// RUN: %clang -### -target powerpc64le-ibm-linux-gnu -save-temps --offload-new-driver \ |
| 210 |
// RUN: -fgpu-rdc --offload-arch=sm_70 --offload-arch=sm_52 -c --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda %s 2>&1 \ |
| 211 |
// RUN: | FileCheck -check-prefix=SAVE-TEMPS %s |
| 212 |
// SAVE-TEMPS: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_52" |
| 213 |
// SAVE-TEMPS: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70" |
| 214 |
// SAVE-TEMPS: "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" |
| 215 |
|
| 216 |
// |
| 217 |
// Check to ensure that we cannot use '-foffload' when not operating in RDC-mode. |
| 218 |
// |
| 219 |
// RUN: not %clang -### --target=powerpc64le-ibm-linux-gnu -fno-gpu-rdc --offload-new-driver \ |
| 220 |
// RUN: -foffload-lto --offload-arch=sm_70 --offload-arch=sm_52 -c %s 2>&1 \ |
| 221 |
// RUN: | FileCheck -check-prefix=LTO-NO-RDC %s |
| 222 |
// LTO-NO-RDC: error: unsupported option '-foffload-lto' for language mode '-fno-gpu-rdc' |