blob: aaef89ac453d17cb2afaaf86ad6c063412d9da39 [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
Justin Lebar66c4fd72016-11-18 00:41:22 +00008// RUN: %clang -v --target=i386-apple-macosx \
9// RUN: --sysroot=%S/no-cuda-there 2>&1 | FileCheck %s -check-prefix NOCUDA
10
Artem Belevichfa11ab52015-11-17 22:28:46 +000011// RUN: %clang -v --target=i386-unknown-linux \
12// RUN: --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
Justin Lebar66c4fd72016-11-18 00:41:22 +000013// RUN: %clang -v --target=i386-apple-macosx \
14// RUN: --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
15
Artem Belevich98607b62015-09-23 21:49:39 +000016// RUN: %clang -v --target=i386-unknown-linux \
Artem Belevich98607b62015-09-23 21:49:39 +000017// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s
Justin Lebar66c4fd72016-11-18 00:41:22 +000018// RUN: %clang -v --target=i386-apple-macosx \
19// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s
Artem Belevich98607b62015-09-23 21:49:39 +000020
Artem Belevich02a1e972016-08-02 23:12:51 +000021// Make sure we map libdevice bitcode files to proper GPUs. These
22// tests use Inputs/CUDA_80 which has full set of libdevice files.
23// However, libdevice mapping only matches CUDA-7.x at the moment.
24// sm_2x, sm_32 -> compute_20
Artem Belevich34f481a2015-11-17 22:28:50 +000025// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_21 \
Artem Belevich02a1e972016-08-02 23:12:51 +000026// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
Artem Belevich34f481a2015-11-17 22:28:50 +000027// RUN: | FileCheck %s -check-prefix COMMON \
Artem Belevich02a1e972016-08-02 23:12:51 +000028// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE20
29// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_32 \
30// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
31// RUN: | FileCheck %s -check-prefix COMMON \
32// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE20
Artem Belevichd4d9dc82016-09-28 17:47:40 +000033// sm_30, sm_6x map to compute_30.
Artem Belevich02a1e972016-08-02 23:12:51 +000034// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \
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
Artem Belevichd4d9dc82016-09-28 17:47:40 +000038// sm_5x is a special case. Maps to compute_30 for cuda-7.x only.
Artem Belevich02a1e972016-08-02 23:12:51 +000039// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \
Artem Belevichd4d9dc82016-09-28 17:47:40 +000040// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
Artem Belevich02a1e972016-08-02 23:12:51 +000041// RUN: | FileCheck %s -check-prefix COMMON \
42// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
43// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_60 \
44// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
45// RUN: | FileCheck %s -check-prefix COMMON \
46// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
47// sm_35 and sm_37 -> compute_35
Artem Belevichfa11ab52015-11-17 22:28:46 +000048// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
Artem Belevich02a1e972016-08-02 23:12:51 +000049// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
Artem Belevich34f481a2015-11-17 22:28:50 +000050// RUN: | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \
51// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
Artem Belevich02a1e972016-08-02 23:12:51 +000052// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_37 \
53// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
54// RUN: | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \
55// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
Artem Belevichd4d9dc82016-09-28 17:47:40 +000056// sm_5x -> compute_50 for CUDA-8.0 and newer.
57// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \
58// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
59// RUN: | FileCheck %s -check-prefix COMMON \
60// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE50
61
Artem Belevich34f481a2015-11-17 22:28:50 +000062// Verify that -nocudainc prevents adding include path to CUDA headers.
Artem Belevichfa11ab52015-11-17 22:28:46 +000063// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
64// RUN: -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
Artem Belevich34f481a2015-11-17 22:28:50 +000065// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC \
66// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
Justin Lebar66c4fd72016-11-18 00:41:22 +000067// RUN: %clang -### -v --target=i386-apple-macosx --cuda-gpu-arch=sm_35 \
68// RUN: -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
69// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC \
70// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
71
Artem Belevichfa11ab52015-11-17 22:28:46 +000072// We should not add any CUDA include paths if there's no valid CUDA installation
73// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
74// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \
75// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC
Justin Lebar66c4fd72016-11-18 00:41:22 +000076// RUN: %clang -### -v --target=i386-apple-macosx --cuda-gpu-arch=sm_35 \
77// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \
78// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC
Artem Belevichfa11ab52015-11-17 22:28:46 +000079
Artem Belevich02a1e972016-08-02 23:12:51 +000080// Verify that we get an error if there's no libdevice library to link with.
Artem Belevichd4d9dc82016-09-28 17:47:40 +000081// NOTE: Inputs/CUDA deliberately does *not* have libdevice.compute_20 for this purpose.
82// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_20 \
Artem Belevich34f481a2015-11-17 22:28:50 +000083// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
Artem Belevich02a1e972016-08-02 23:12:51 +000084// RUN: | FileCheck %s -check-prefix COMMON -check-prefix MISSINGLIBDEVICE
Justin Lebar66c4fd72016-11-18 00:41:22 +000085// RUN: %clang -### -v --target=i386-apple-macosx --cuda-gpu-arch=sm_20 \
86// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
87// RUN: | FileCheck %s -check-prefix COMMON -check-prefix MISSINGLIBDEVICE
Artem Belevich02a1e972016-08-02 23:12:51 +000088
89// Verify that -nocudalib prevents linking libdevice bitcode in.
Artem Belevich34f481a2015-11-17 22:28:50 +000090// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
91// RUN: -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
92// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
Justin Lebar66c4fd72016-11-18 00:41:22 +000093// RUN: %clang -### -v --target=i386-apple-macosx --cuda-gpu-arch=sm_35 \
94// RUN: -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
95// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
96
Artem Belevich86017332015-11-17 22:28:55 +000097// Verify that we don't add include paths, link with libdevice or
Artem Belevich7fda3c92015-12-16 18:51:59 +000098// -include __clang_cuda_runtime_wrapper.h without valid CUDA installation.
Artem Belevich86017332015-11-17 22:28:55 +000099// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
100// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \
101// RUN: | FileCheck %s -check-prefix COMMON \
102// RUN: -check-prefix NOCUDAINC -check-prefix NOLIBDEVICE
Justin Lebar66c4fd72016-11-18 00:41:22 +0000103// RUN: %clang -### -v --target=i386-apple-macosx --cuda-gpu-arch=sm_35 \
104// RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \
105// RUN: | FileCheck %s -check-prefix COMMON \
106// RUN: -check-prefix NOCUDAINC -check-prefix NOLIBDEVICE
Artem Belevich34f481a2015-11-17 22:28:50 +0000107
Samuel Antao3be88012016-08-09 17:27:24 +0000108// Verify that C++ include paths are passed for both host and device frontends.
Benjamin Kramera203c412016-08-09 19:20:25 +0000109// RUN: %clang -### -no-canonical-prefixes -target x86_64-linux-gnu %s \
Samuel Antao8de34a92016-08-16 14:38:39 +0000110// RUN: --stdlib=libstdc++ --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 \
111// RUN: --gcc-toolchain="" 2>&1 \
Samuel Antao3be88012016-08-09 17:27:24 +0000112// RUN: | FileCheck %s --check-prefix CHECK-CXXINCLUDE
113
Artem Belevich98607b62015-09-23 21:49:39 +0000114// CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
115// NOCUDA-NOT: Found CUDA installation:
Artem Belevichfa11ab52015-11-17 22:28:46 +0000116
Artem Belevichd4d9dc82016-09-28 17:47:40 +0000117// MISSINGLIBDEVICE: error: cannot find libdevice for sm_20.
Artem Belevich02a1e972016-08-02 23:12:51 +0000118
Artem Belevichfa11ab52015-11-17 22:28:46 +0000119// COMMON: "-triple" "nvptx-nvidia-cuda"
120// COMMON-SAME: "-fcuda-is-device"
Artem Belevich34f481a2015-11-17 22:28:50 +0000121// LIBDEVICE-SAME: "-mlink-cuda-bitcode"
122// NOLIBDEVICE-NOT: "-mlink-cuda-bitcode"
Artem Belevich02a1e972016-08-02 23:12:51 +0000123// LIBDEVICE20-SAME: libdevice.compute_20.10.bc
124// LIBDEVICE30-SAME: libdevice.compute_30.10.bc
Artem Belevich34f481a2015-11-17 22:28:50 +0000125// LIBDEVICE35-SAME: libdevice.compute_35.10.bc
Artem Belevichd4d9dc82016-09-28 17:47:40 +0000126// LIBDEVICE50-SAME: libdevice.compute_50.10.bc
Artem Belevich34f481a2015-11-17 22:28:50 +0000127// NOLIBDEVICE-NOT: libdevice.compute_{{.*}}.bc
128// LIBDEVICE-SAME: "-target-feature" "+ptx42"
129// NOLIBDEVICE-NOT: "-target-feature" "+ptx42"
Artem Belevich02a1e972016-08-02 23:12:51 +0000130// CUDAINC-SAME: "-internal-isystem" "{{.*}}/Inputs/CUDA{{[_0-9]+}}/usr/local/cuda/include"
Artem Belevichfa11ab52015-11-17 22:28:46 +0000131// NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
Artem Belevich7fda3c92015-12-16 18:51:59 +0000132// CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
133// NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
Justin Lebar9421ba62016-08-15 20:38:52 +0000134// -internal-externc-isystem flags must come *after* the cuda include flags,
135// because we must search the cuda include directory first.
136// CUDAINC-SAME: "-internal-externc-isystem"
Artem Belevichfa11ab52015-11-17 22:28:46 +0000137// COMMON-SAME: "-x" "cuda"
Samuel Antao3be88012016-08-09 17:27:24 +0000138// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
139// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
140// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "x86_64--linux-gnu"
141// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
142// CHECK-CXXINCLUDE: ld{{.*}}"