1 // REQUIRES: clang-driver
2 // REQUIRES: x86-registered-target
3 // REQUIRES: nvptx-registered-target
4 
5 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_20 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
6 // RUN:    FileCheck %s --check-prefix=OK
7 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda 2>&1 %s | \
8 // RUN:    FileCheck %s --check-prefix=OK
9 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda 2>&1 %s | \
10 // RUN:    FileCheck %s --check-prefix=OK
11 // Test version guess when no version.txt or cuda.h are found
12 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
13 // RUN:    FileCheck %s --check-prefix=UNKNOWN_VERSION
14 // Unknown version with version.txt present
15 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda 2>&1 %s | \
16 // RUN:    FileCheck %s --check-prefix=UNKNOWN_VERSION_V
17 // Unknown version with no version.txt but with version info present in cuda.h
18 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda 2>&1 %s | \
19 // RUN:    FileCheck %s --check-prefix=UNKNOWN_VERSION_H
20 // Make sure that we don't warn about CUDA version during C++ compilation.
21 // RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
22 // RUN:    --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
23 // RUN:    FileCheck %s --check-prefix=UNKNOWN_VERSION_CXX
24 
25 // The installation at Inputs/CUDA is CUDA 7.0, which doesn't support sm_60.
26 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
27 // RUN:    FileCheck %s --check-prefix=ERR_SM60
28 
29 // This should only complain about sm_60, not sm_35.
30 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-gpu-arch=sm_35 \
31 // RUN:    --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
32 // RUN:    FileCheck %s --check-prefix=ERR_SM60 --check-prefix=OK_SM35
33 
34 // We should get two errors here, one for sm_60 and one for sm_61.
35 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-gpu-arch=sm_61 \
36 // RUN:    --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
37 // RUN:    FileCheck %s --check-prefix=ERR_SM60 --check-prefix=ERR_SM61
38 
39 // We should still get an error if we pass -nocudainc, because this compilation
40 // would invoke ptxas, and we do a version check on that, too.
41 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
42 // RUN:    FileCheck %s --check-prefix=ERR_SM60
43 
44 // If with -nocudainc and -E, we don't touch the CUDA install, so we
45 // shouldn't get an error.
46 // RUN: %clang --target=x86_64-linux -v -### -E --cuda-device-only --cuda-gpu-arch=sm_60 -nocudainc \
47 // RUN:    --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
48 // RUN:    FileCheck %s --check-prefix=OK
49 
50 // --no-cuda-version-check should suppress all of these errors.
51 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 \
52 // RUN:    --no-cuda-version-check %s | \
53 // RUN:    FileCheck %s --check-prefix=OK
54 
55 // We need to make sure the version check is done only for the device toolchain,
56 // therefore we should not get an error in host-only mode. We use the -S here
57 // to avoid the error being produced in case by the assembler tool, which does
58 // the same check.
59 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-host-only --cuda-path=%S/Inputs/CUDA/usr/local/cuda -S 2>&1 %s | \
60 // RUN:    FileCheck %s --check-prefix=OK
61 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-device-only --cuda-path=%S/Inputs/CUDA/usr/local/cuda -S 2>&1 %s | \
62 // RUN:    FileCheck %s --check-prefix=ERR_SM60
63 
64 // OK-NOT: error: GPU arch
65 
66 // OK_SM35-NOT: error: GPU arch sm_35
67 
68 // We should only get one error per architecture.
69 // ERR_SM60: error: GPU arch sm_60 {{.*}}
70 // ERR_SM60-NOT: error: GPU arch sm_60
71 
72 // ERR_SM61: error: GPU arch sm_61 {{.*}}
73 // ERR_SM61-NOT: error: GPU arch sm_61
74 
75 // UNKNOWN_VERSION_V: Unknown CUDA version. version.txt:{{.*}}. Assuming the latest supported version
76 // UNKNOWN_VERSION_H: Unknown CUDA version. cuda.h: CUDA_VERSION={{.*}}. Assuming the latest supported version
77 // UNKNOWN_VERSION: Unknown CUDA version. No version found in version.txt or cuda.h. Assuming the latest supported version
78 // UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version
79