| 1 |
// Check that we properly detect CUDA installation. |
| 2 |
// RUN: %clang -v --target=i386-unknown-linux \ |
| 3 |
// RUN: --sysroot=%S/no-cuda-there --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA |
| 4 |
// RUN: %clang -v --target=i386-apple-macosx \ |
| 5 |
// RUN: --sysroot=%S/no-cuda-there --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA |
| 6 |
// RUN: %clang -v --target=x86_64-unknown-linux \ |
| 7 |
// RUN: --sysroot=%S/no-cuda-there --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA |
| 8 |
// RUN: %clang -v --target=x86_64-apple-macosx \ |
| 9 |
// RUN: --sysroot=%S/no-cuda-there --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA |
| 10 |
|
| 11 |
// RUN: %clang -v --target=i386-unknown-linux \ |
| 12 |
// RUN: --sysroot=%S/Inputs/CUDA --cuda-path-ignore-env 2>&1 | FileCheck %s |
| 13 |
// RUN: %clang -v --target=i386-apple-macosx \ |
| 14 |
// RUN: --sysroot=%S/Inputs/CUDA --cuda-path-ignore-env 2>&1 | FileCheck %s |
| 15 |
|
| 16 |
// RUN: %clang -v --target=i386-unknown-linux \ |
| 17 |
// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s |
| 18 |
// RUN: %clang -v --target=i386-apple-macosx \ |
| 19 |
// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s |
| 20 |
|
| 21 |
// Check that we don't find a CUDA installation without libdevice ... |
| 22 |
// RUN: %clang -v --target=i386-unknown-linux \ |
| 23 |
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA |
| 24 |
// RUN: %clang -v --target=i386-apple-macosx \ |
| 25 |
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA |
| 26 |
// RUN: %clang -v --target=x86_64-unknown-linux \ |
| 27 |
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA |
| 28 |
// RUN: %clang -v --target=x86_64-apple-macosx \ |
| 29 |
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA |
| 30 |
|
| 31 |
// ... unless the user doesn't need libdevice |
| 32 |
// RUN: %clang -v --target=i386-unknown-linux -nocudalib \ |
| 33 |
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE |
| 34 |
// RUN: %clang -v --target=i386-apple-macosx -nocudalib \ |
| 35 |
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE |
| 36 |
// RUN: %clang -v --target=x86_64-unknown-linux -nocudalib \ |
| 37 |
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE |
| 38 |
// RUN: %clang -v --target=x86_64-apple-macosx -nocudalib \ |
| 39 |
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE |
| 40 |
|
| 41 |
|
| 42 |
// Make sure we map libdevice bitcode files to proper GPUs. These |
| 43 |
// tests use Inputs/CUDA_80 which has full set of libdevice files. |
| 44 |
// However, libdevice mapping only matches CUDA-7.x at the moment. |
| 45 |
// sm_2x, sm_32 -> compute_20 |
| 46 |
// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_21 \ |
| 47 |
// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ |
| 48 |
// RUN: | FileCheck %s -check-prefix COMMON \ |
| 49 |
// RUN: -check-prefixes PTX42,LIBDEVICE,LIBDEVICE20 |
| 50 |
// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_32 \ |
| 51 |
// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ |
| 52 |
// RUN: | FileCheck %s -check-prefix COMMON \ |
| 53 |
// RUN: -check-prefixes PTX42,LIBDEVICE,LIBDEVICE20 |
| 54 |
// sm_30, sm_6x map to compute_30. |
| 55 |
// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \ |
| 56 |
// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ |
| 57 |
// RUN: | FileCheck %s -check-prefix COMMON \ |
| 58 |
// RUN: -check-prefixes PTX42,LIBDEVICE,LIBDEVICE30 |
| 59 |
// sm_5x is a special case. Maps to compute_30 for cuda-7.x only. |
| 60 |
// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \ |
| 61 |
// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \ |
| 62 |
// RUN: | FileCheck %s -check-prefix COMMON \ |
| 63 |
// RUN: -check-prefixes PTX42,LIBDEVICE,LIBDEVICE30 |
| 64 |
// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_60 \ |
| 65 |
// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ |
| 66 |
// RUN: | FileCheck %s -check-prefix COMMON \ |
| 67 |
// RUN: -check-prefixes PTX42,LIBDEVICE,LIBDEVICE30 |
| 68 |
// sm_35 and sm_37 -> compute_35 |
| 69 |
// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \ |
| 70 |
// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ |
| 71 |
// RUN: | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \ |
| 72 |
// RUN: -check-prefixes PTX42,LIBDEVICE,LIBDEVICE35 |
| 73 |
// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_37 \ |
| 74 |
// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ |
| 75 |
// RUN: | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \ |
| 76 |
// RUN: -check-prefixes PTX42,LIBDEVICE,LIBDEVICE35 |
| 77 |
// sm_5x -> compute_50 for CUDA-8.0 and newer. |
| 78 |
// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \ |
| 79 |
// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ |
| 80 |
// RUN: | FileCheck %s -check-prefix COMMON \ |
| 81 |
// RUN: -check-prefixes PTX42,LIBDEVICE,LIBDEVICE50 |
| 82 |
|
| 83 |
// CUDA-9+ uses the same libdevice for all GPU variants: |
| 84 |
// RUN: %clang -### -v --target=x86_64-unknown-linux --cuda-gpu-arch=sm_30 \ |
| 85 |
// RUN: --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda %s 2>&1 \ |
| 86 |
// RUN: | FileCheck %s -check-prefix COMMON64 \ |
| 87 |
// RUN: -check-prefixes PTX60,LIBDEVICE,LIBDEVICE10 |
| 88 |
// RUN: %clang -### -v --target=x86_64-unknown-linux --cuda-gpu-arch=sm_50 \ |
| 89 |
// RUN: --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda %s 2>&1 \ |
| 90 |
// RUN: | FileCheck %s -check-prefix COMMON64 \ |
| 91 |
// RUN: -check-prefixes PTX60,LIBDEVICE,LIBDEVICE10 |
| 92 |
// RUN: %clang -### -v --target=x86_64-unknown-linux --cuda-gpu-arch=sm_60 \ |
| 93 |
// RUN: --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda %s 2>&1 \ |
| 94 |
// RUN: | FileCheck %s -check-prefix COMMON64 \ |
| 95 |
// RUN: -check-prefixes PTX60,LIBDEVICE,LIBDEVICE10 |
| 96 |
|
| 97 |
|
| 98 |
// Verify that -nocudainc prevents adding include path to CUDA headers. |
| 99 |
// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \ |
| 100 |
// RUN: -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \ |
| 101 |
// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC \ |
| 102 |
// RUN: -check-prefixes PTX42,LIBDEVICE,LIBDEVICE35 |
| 103 |
// RUN: %clang -### -v --target=i386-apple-macosx --cuda-gpu-arch=sm_35 \ |
| 104 |
// RUN: -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \ |
| 105 |
// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC \ |
| 106 |
// RUN: -check-prefixes PTX42,LIBDEVICE,LIBDEVICE35 |
| 107 |
|
| 108 |
// We should not add any CUDA include paths if there's no valid CUDA installation |
| 109 |
// RUN: not %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \ |
| 110 |
// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \ |
| 111 |
// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC |
| 112 |
// RUN: not %clang -### -v --target=i386-apple-macosx --cuda-gpu-arch=sm_35 \ |
| 113 |
// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \ |
| 114 |
// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC |
| 115 |
|
| 116 |
// Verify that we get an error if there's no libdevice library to link with. |
| 117 |
// NOTE: Inputs/CUDA deliberately does *not* have libdevice.compute_20 for this purpose. |
| 118 |
// RUN: not %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_20 \ |
| 119 |
// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \ |
| 120 |
// RUN: | FileCheck %s -check-prefix COMMON -check-prefix MISSINGLIBDEVICE |
| 121 |
// RUN: not %clang -### -v --target=i386-apple-macosx --cuda-gpu-arch=sm_20 \ |
| 122 |
// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \ |
| 123 |
// RUN: | FileCheck %s -check-prefix COMMON -check-prefix MISSINGLIBDEVICE |
| 124 |
|
| 125 |
// Verify that -nocudalib prevents linking libdevice bitcode in. |
| 126 |
// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \ |
| 127 |
// RUN: -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \ |
| 128 |
// RUN: | FileCheck %s -check-prefix COMMON |
| 129 |
// RUN: %clang -### -v --target=i386-apple-macosx --cuda-gpu-arch=sm_35 \ |
| 130 |
// RUN: -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \ |
| 131 |
// RUN: | FileCheck %s -check-prefix COMMON |
| 132 |
|
| 133 |
// Verify that we don't add include paths, link with libdevice or |
| 134 |
// -include __clang_cuda_runtime_wrapper.h without valid CUDA installation. |
| 135 |
// RUN: not %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \ |
| 136 |
// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \ |
| 137 |
// RUN: | FileCheck %s -check-prefix COMMON \ |
| 138 |
// RUN: -check-prefix NOCUDAINC |
| 139 |
// RUN: not %clang -### -v --target=i386-apple-macosx --cuda-gpu-arch=sm_35 \ |
| 140 |
// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \ |
| 141 |
// RUN: | FileCheck %s -check-prefix COMMON \ |
| 142 |
// RUN: -check-prefix NOCUDAINC |
| 143 |
|
| 144 |
// Verify that C++ include paths are passed for both host and device frontends. |
| 145 |
// RUN: %clang -### --target=x86_64-linux-gnu %s \ |
| 146 |
// RUN: --stdlib=libstdc++ --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 \ |
| 147 |
// RUN: -nogpulib -nogpuinc 2>&1 \ |
| 148 |
// RUN: | FileCheck %s --check-prefix CHECK-CXXINCLUDE |
| 149 |
|
| 150 |
// Verify that CUDA SDK version is propagated to the CC1 compilations. |
| 151 |
// RUN: %clang -### -v --target=x86_64-linux-gnu --cuda-gpu-arch=sm_50 \ |
| 152 |
// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ |
| 153 |
// RUN: | FileCheck %s -check-prefix CUDA80 |
| 154 |
|
| 155 |
// Verify that if no version file is found, we report the default of 7.0. |
| 156 |
// RUN: %clang -### -v --target=x86_64-linux-gnu --cuda-gpu-arch=sm_50 \ |
| 157 |
// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \ |
| 158 |
// RUN: | FileCheck %s -check-prefix CUDA70 |
| 159 |
|
| 160 |
// CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda |
| 161 |
// NO-LIBDEVICE: Found CUDA installation: {{.*}}/Inputs/CUDA-nolibdevice/usr/local/cuda |
| 162 |
// NOCUDA-NOT: Found CUDA installation: |
| 163 |
|
| 164 |
// MISSINGLIBDEVICE: error: cannot find libdevice for sm_20; |
| 165 |
|
| 166 |
// COMMON: "-triple" "nvptx-nvidia-cuda" |
| 167 |
// COMMON64: "-triple" "nvptx64-nvidia-cuda" |
| 168 |
// COMMON-SAME: "-fcuda-is-device" |
| 169 |
// LIBDEVICE-SAME: "-mlink-builtin-bitcode" |
| 170 |
// LIBDEVICE10-SAME: libdevice.10.bc |
| 171 |
// LIBDEVICE20-SAME: libdevice.compute_20.10.bc |
| 172 |
// LIBDEVICE30-SAME: libdevice.compute_30.10.bc |
| 173 |
// LIBDEVICE35-SAME: libdevice.compute_35.10.bc |
| 174 |
// LIBDEVICE50-SAME: libdevice.compute_50.10.bc |
| 175 |
// PTX42-SAME: "-target-feature" "+ptx42" |
| 176 |
// PTX60-SAME: "-target-feature" "+ptx60" |
| 177 |
// CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h" |
| 178 |
// NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h" |
| 179 |
// CUDAINC-SAME: "-internal-isystem" "{{.*}}/Inputs/CUDA{{[_0-9]+}}/usr/local/cuda/include" |
| 180 |
// NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include" |
| 181 |
// -internal-externc-isystem flags must come *after* the cuda include flags, |
| 182 |
// because we must search the cuda include directory first. |
| 183 |
// CUDAINC-SAME: "-internal-externc-isystem" |
| 184 |
// COMMON-SAME: "-x" "cuda" |
| 185 |
// CHECK-CXXINCLUDE: "-cc1" "-triple" "nvptx64-nvidia-cuda" |
| 186 |
// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8" |
| 187 |
// CHECK-CXXINCLUDE: "-cc1" "-triple" "x86_64-unknown-linux-gnu" |
| 188 |
// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8" |
| 189 |
// CHECK-CXXINCLUDE: ld{{.*}}" |
| 190 |
|
| 191 |
// CUDA80: "-cc1" "-triple" "nvptx64-nvidia-cuda" |
| 192 |
// CUDA80-SAME: -target-sdk-version=8.0 |
| 193 |
// CUDA80: "-cc1" "-triple" "x86_64-unknown-linux-gnu" |
| 194 |
// CUDA80-SAME: -target-sdk-version=8.0 |
| 195 |
// CUDA80: ld{{.*}}" |
| 196 |
|
| 197 |
// CUDA70: "-cc1" "-triple" "nvptx64-nvidia-cuda" |
| 198 |
// CUDA70-SAME: -target-sdk-version=7.0 |
| 199 |
// CUDA70: "-cc1" "-triple" "x86_64-unknown-linux-gnu" |
| 200 |
// CUDA70-SAME: -target-sdk-version=7.0 |
| 201 |
// CUDA70: ld{{.*}}" |