blob: f14e7b299144fe902c29cf533fc3ca8a20abd19c [file] [log] [blame]
Artem Belevich98607b62015-09-23 21:49:39 +00001// REQUIRES: clang-driver
2// REQUIRES: x86-registered-target
Artem Belevichfa11ab52015-11-17 22:28:46 +00003// REQUIRES: nvptx-registered-target
Artem Belevich98607b62015-09-23 21:49:39 +00004//
Artem Belevichfa11ab52015-11-17 22:28:46 +00005// # Check that we properly detect CUDA installation.
Artem Belevich98607b62015-09-23 21:49:39 +00006// RUN: %clang -v --target=i386-unknown-linux \
Artem Belevichfa11ab52015-11-17 22:28:46 +00007// RUN: --sysroot=%S/no-cuda-there 2>&1 | FileCheck %s -check-prefix NOCUDA
8// RUN: %clang -v --target=i386-unknown-linux \
9// RUN: --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
Artem Belevich98607b62015-09-23 21:49:39 +000010// RUN: %clang -v --target=i386-unknown-linux \
Artem Belevich98607b62015-09-23 21:49:39 +000011// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s
12
Artem Belevich02a1e972016-08-02 23:12:51 +000013// Make sure we map libdevice bitcode files to proper GPUs. These
14// tests use Inputs/CUDA_80 which has full set of libdevice files.
15// However, libdevice mapping only matches CUDA-7.x at the moment.
16// sm_2x, sm_32 -> compute_20
Artem Belevich34f481a2015-11-17 22:28:50 +000017// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_21 \
Artem Belevich02a1e972016-08-02 23:12:51 +000018// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
Artem Belevich34f481a2015-11-17 22:28:50 +000019// RUN: | FileCheck %s -check-prefix COMMON \
Artem Belevich02a1e972016-08-02 23:12:51 +000020// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE20
21// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_32 \
22// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
23// RUN: | FileCheck %s -check-prefix COMMON \
24// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE20
25// sm_30, sm_5x and sm_6x map to compute_30
26// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \
27// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
28// RUN: | FileCheck %s -check-prefix COMMON \
29// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
30// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \
31// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
32// RUN: | FileCheck %s -check-prefix COMMON \
33// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
34// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_60 \
35// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
36// RUN: | FileCheck %s -check-prefix COMMON \
37// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
38// sm_35 and sm_37 -> compute_35
Artem Belevichfa11ab52015-11-17 22:28:46 +000039// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
Artem Belevich02a1e972016-08-02 23:12:51 +000040// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
Artem Belevich34f481a2015-11-17 22:28:50 +000041// RUN: | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \
42// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
Artem Belevich02a1e972016-08-02 23:12:51 +000043// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_37 \
44// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
45// RUN: | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \
46// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
47
Artem Belevich34f481a2015-11-17 22:28:50 +000048// Verify that -nocudainc prevents adding include path to CUDA headers.
Artem Belevichfa11ab52015-11-17 22:28:46 +000049// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
50// RUN: -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
Artem Belevich34f481a2015-11-17 22:28:50 +000051// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC \
52// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
Artem Belevichfa11ab52015-11-17 22:28:46 +000053// We should not add any CUDA include paths if there's no valid CUDA installation
54// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
55// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \
56// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC
57
Artem Belevich02a1e972016-08-02 23:12:51 +000058// Verify that we get an error if there's no libdevice library to link with.
59// NOTE: Inputs/CUDA deliberately does *not* have libdevice.compute_30 for this purpose.
Artem Belevich34f481a2015-11-17 22:28:50 +000060// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \
61// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
Artem Belevich02a1e972016-08-02 23:12:51 +000062// RUN: | FileCheck %s -check-prefix COMMON -check-prefix MISSINGLIBDEVICE
63
64// Verify that -nocudalib prevents linking libdevice bitcode in.
Artem Belevich34f481a2015-11-17 22:28:50 +000065// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
66// RUN: -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
67// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
Artem Belevich86017332015-11-17 22:28:55 +000068// Verify that we don't add include paths, link with libdevice or
Artem Belevich7fda3c92015-12-16 18:51:59 +000069// -include __clang_cuda_runtime_wrapper.h without valid CUDA installation.
Artem Belevich86017332015-11-17 22:28:55 +000070// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
71// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \
72// RUN: | FileCheck %s -check-prefix COMMON \
73// RUN: -check-prefix NOCUDAINC -check-prefix NOLIBDEVICE
Artem Belevich34f481a2015-11-17 22:28:50 +000074
Samuel Antao3be88012016-08-09 17:27:24 +000075// Verify that C++ include paths are passed for both host and device frontends.
Benjamin Kramera203c412016-08-09 19:20:25 +000076// RUN: %clang -### -no-canonical-prefixes -target x86_64-linux-gnu %s \
Samuel Antao3be88012016-08-09 17:27:24 +000077// RUN: --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 2>&1 \
78// RUN: | FileCheck %s --check-prefix CHECK-CXXINCLUDE
79
Artem Belevich98607b62015-09-23 21:49:39 +000080// CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
81// NOCUDA-NOT: Found CUDA installation:
Artem Belevichfa11ab52015-11-17 22:28:46 +000082
Artem Belevich02a1e972016-08-02 23:12:51 +000083// MISSINGLIBDEVICE: error: cannot find libdevice for sm_30.
84
Artem Belevichfa11ab52015-11-17 22:28:46 +000085// COMMON: "-triple" "nvptx-nvidia-cuda"
86// COMMON-SAME: "-fcuda-is-device"
Artem Belevich34f481a2015-11-17 22:28:50 +000087// LIBDEVICE-SAME: "-mlink-cuda-bitcode"
88// NOLIBDEVICE-NOT: "-mlink-cuda-bitcode"
Artem Belevich02a1e972016-08-02 23:12:51 +000089// LIBDEVICE20-SAME: libdevice.compute_20.10.bc
90// LIBDEVICE30-SAME: libdevice.compute_30.10.bc
Artem Belevich34f481a2015-11-17 22:28:50 +000091// LIBDEVICE35-SAME: libdevice.compute_35.10.bc
92// NOLIBDEVICE-NOT: libdevice.compute_{{.*}}.bc
93// LIBDEVICE-SAME: "-target-feature" "+ptx42"
94// NOLIBDEVICE-NOT: "-target-feature" "+ptx42"
Artem Belevich02a1e972016-08-02 23:12:51 +000095// CUDAINC-SAME: "-internal-isystem" "{{.*}}/Inputs/CUDA{{[_0-9]+}}/usr/local/cuda/include"
Artem Belevichfa11ab52015-11-17 22:28:46 +000096// NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
Artem Belevich7fda3c92015-12-16 18:51:59 +000097// CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
98// NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
Artem Belevichfa11ab52015-11-17 22:28:46 +000099// COMMON-SAME: "-x" "cuda"
Samuel Antao3be88012016-08-09 17:27:24 +0000100// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
101// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
102// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "x86_64--linux-gnu"
103// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
104// CHECK-CXXINCLUDE: ld{{.*}}"