blob: 4694cc0eb8d1196aa40e28fb1633476138ae5dbf [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
Artem Belevichd4d9dc82016-09-28 17:47:40 +000025// sm_30, sm_6x map to compute_30.
Artem Belevich02a1e972016-08-02 23:12:51 +000026// 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
Artem Belevichd4d9dc82016-09-28 17:47:40 +000030// sm_5x is a special case. Maps to compute_30 for cuda-7.x only.
Artem Belevich02a1e972016-08-02 23:12:51 +000031// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \
Artem Belevichd4d9dc82016-09-28 17:47:40 +000032// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
Artem Belevich02a1e972016-08-02 23:12:51 +000033// RUN: | FileCheck %s -check-prefix COMMON \
34// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
35// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_60 \
36// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
37// RUN: | FileCheck %s -check-prefix COMMON \
38// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
39// sm_35 and sm_37 -> compute_35
Artem Belevichfa11ab52015-11-17 22:28:46 +000040// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
Artem Belevich02a1e972016-08-02 23:12:51 +000041// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
Artem Belevich34f481a2015-11-17 22:28:50 +000042// RUN: | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \
43// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
Artem Belevich02a1e972016-08-02 23:12:51 +000044// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_37 \
45// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
46// RUN: | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \
47// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
Artem Belevichd4d9dc82016-09-28 17:47:40 +000048// sm_5x -> compute_50 for CUDA-8.0 and newer.
49// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \
50// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
51// RUN: | FileCheck %s -check-prefix COMMON \
52// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE50
53
Artem Belevich02a1e972016-08-02 23:12:51 +000054
Artem Belevich34f481a2015-11-17 22:28:50 +000055// Verify that -nocudainc prevents adding include path to CUDA headers.
Artem Belevichfa11ab52015-11-17 22:28:46 +000056// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
57// RUN: -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
Artem Belevich34f481a2015-11-17 22:28:50 +000058// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC \
59// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
Artem Belevichfa11ab52015-11-17 22:28:46 +000060// We should not add any CUDA include paths if there's no valid CUDA installation
61// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
62// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \
63// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC
64
Artem Belevich02a1e972016-08-02 23:12:51 +000065// Verify that we get an error if there's no libdevice library to link with.
Artem Belevichd4d9dc82016-09-28 17:47:40 +000066// NOTE: Inputs/CUDA deliberately does *not* have libdevice.compute_20 for this purpose.
67// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_20 \
Artem Belevich34f481a2015-11-17 22:28:50 +000068// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
Artem Belevich02a1e972016-08-02 23:12:51 +000069// RUN: | FileCheck %s -check-prefix COMMON -check-prefix MISSINGLIBDEVICE
70
71// Verify that -nocudalib prevents linking libdevice bitcode in.
Artem Belevich34f481a2015-11-17 22:28:50 +000072// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
73// RUN: -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
74// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
Artem Belevich86017332015-11-17 22:28:55 +000075// Verify that we don't add include paths, link with libdevice or
Artem Belevich7fda3c92015-12-16 18:51:59 +000076// -include __clang_cuda_runtime_wrapper.h without valid CUDA installation.
Artem Belevich86017332015-11-17 22:28:55 +000077// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
78// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \
79// RUN: | FileCheck %s -check-prefix COMMON \
80// RUN: -check-prefix NOCUDAINC -check-prefix NOLIBDEVICE
Artem Belevich34f481a2015-11-17 22:28:50 +000081
Samuel Antao3be88012016-08-09 17:27:24 +000082// Verify that C++ include paths are passed for both host and device frontends.
Benjamin Kramera203c412016-08-09 19:20:25 +000083// RUN: %clang -### -no-canonical-prefixes -target x86_64-linux-gnu %s \
Samuel Antao8de34a92016-08-16 14:38:39 +000084// RUN: --stdlib=libstdc++ --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 \
85// RUN: --gcc-toolchain="" 2>&1 \
Samuel Antao3be88012016-08-09 17:27:24 +000086// RUN: | FileCheck %s --check-prefix CHECK-CXXINCLUDE
87
Artem Belevich98607b62015-09-23 21:49:39 +000088// CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
89// NOCUDA-NOT: Found CUDA installation:
Artem Belevichfa11ab52015-11-17 22:28:46 +000090
Artem Belevichd4d9dc82016-09-28 17:47:40 +000091// MISSINGLIBDEVICE: error: cannot find libdevice for sm_20.
Artem Belevich02a1e972016-08-02 23:12:51 +000092
Artem Belevichfa11ab52015-11-17 22:28:46 +000093// COMMON: "-triple" "nvptx-nvidia-cuda"
94// COMMON-SAME: "-fcuda-is-device"
Artem Belevich34f481a2015-11-17 22:28:50 +000095// LIBDEVICE-SAME: "-mlink-cuda-bitcode"
96// NOLIBDEVICE-NOT: "-mlink-cuda-bitcode"
Artem Belevich02a1e972016-08-02 23:12:51 +000097// LIBDEVICE20-SAME: libdevice.compute_20.10.bc
98// LIBDEVICE30-SAME: libdevice.compute_30.10.bc
Artem Belevich34f481a2015-11-17 22:28:50 +000099// LIBDEVICE35-SAME: libdevice.compute_35.10.bc
Artem Belevichd4d9dc82016-09-28 17:47:40 +0000100// LIBDEVICE50-SAME: libdevice.compute_50.10.bc
Artem Belevich34f481a2015-11-17 22:28:50 +0000101// NOLIBDEVICE-NOT: libdevice.compute_{{.*}}.bc
102// LIBDEVICE-SAME: "-target-feature" "+ptx42"
103// NOLIBDEVICE-NOT: "-target-feature" "+ptx42"
Artem Belevich02a1e972016-08-02 23:12:51 +0000104// CUDAINC-SAME: "-internal-isystem" "{{.*}}/Inputs/CUDA{{[_0-9]+}}/usr/local/cuda/include"
Artem Belevichfa11ab52015-11-17 22:28:46 +0000105// NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
Artem Belevich7fda3c92015-12-16 18:51:59 +0000106// CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
107// NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
Justin Lebar9421ba62016-08-15 20:38:52 +0000108// -internal-externc-isystem flags must come *after* the cuda include flags,
109// because we must search the cuda include directory first.
110// CUDAINC-SAME: "-internal-externc-isystem"
Artem Belevichfa11ab52015-11-17 22:28:46 +0000111// COMMON-SAME: "-x" "cuda"
Samuel Antao3be88012016-08-09 17:27:24 +0000112// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
113// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
114// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "x86_64--linux-gnu"
115// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
116// CHECK-CXXINCLUDE: ld{{.*}}"