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