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 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
10 // RUN: %clang -v --target=i386-unknown-linux \
11 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s
12 
13 // Make sure we map libdevice bitcode files to proper GPUs.
14 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_21 \
15 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
16 // RUN:   | FileCheck %s -check-prefix COMMON \
17 // RUN:     -check-prefix LIBDEVICE -check-prefix LIBDEVICE21
18 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
19 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
20 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \
21 // RUN:     -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
22 // Verify that -nocudainc prevents adding include path to CUDA headers.
23 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
24 // RUN:   -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
25 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC \
26 // RUN:     -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
27 // We should not add any CUDA include paths if there's no valid CUDA installation
28 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
29 // RUN:   --cuda-path=%S/no-cuda-there %s 2>&1 \
30 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC
31 
32 // Verify that no options related to bitcode linking are passes if
33 // there's no bitcode file.
34 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \
35 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
36 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
37 // .. or if we explicitly passed -nocudalib
38 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
39 // RUN:   -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
40 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
41 // Verify that we don't add include paths, link with libdevice or
42 // -include __clang_cuda_runtime_wrapper.h without valid CUDA installation.
43 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
44 // RUN:   --cuda-path=%S/no-cuda-there %s 2>&1 \
45 // RUN:   | FileCheck %s -check-prefix COMMON \
46 // RUN:     -check-prefix NOCUDAINC -check-prefix NOLIBDEVICE
47 
48 // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
49 // NOCUDA-NOT: Found CUDA installation:
50 
51 // COMMON: "-triple" "nvptx-nvidia-cuda"
52 // COMMON-SAME: "-fcuda-is-device"
53 // LIBDEVICE-SAME: "-mlink-cuda-bitcode"
54 // NOLIBDEVICE-NOT: "-mlink-cuda-bitcode"
55 // LIBDEVICE21-SAME: libdevice.compute_20.10.bc
56 // LIBDEVICE35-SAME: libdevice.compute_35.10.bc
57 // NOLIBDEVICE-NOT: libdevice.compute_{{.*}}.bc
58 // LIBDEVICE-SAME: "-target-feature" "+ptx42"
59 // NOLIBDEVICE-NOT: "-target-feature" "+ptx42"
60 // CUDAINC-SAME: "-internal-isystem" "{{.*}}/Inputs/CUDA/usr/local/cuda/include"
61 // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
62 // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
63 // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
64 // COMMON-SAME: "-x" "cuda"
65