xref: /llvm-project/clang/test/Driver/nvptx-cuda-system-arch.c (revision 03730cdd3d10c5270fe436777a37d50b0838a3bf)
1 // REQUIRES: shell
2 // XFAIL: target={{.*}}-zos{{.*}}
3 
4 // RUN: mkdir -p %t
5 // RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_fail %t/
6 // RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_sm_70 %t/
7 // RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_sm_89_sm_80 %t/
8 // RUN: echo '#!/bin/sh' > %t/nvptx_arch_empty
9 // RUN: chmod +x %t/nvptx_arch_fail
10 // RUN: chmod +x %t/nvptx_arch_sm_70
11 // RUN: chmod +x %t/nvptx_arch_sm_89_sm_80
12 // RUN: chmod +x %t/nvptx_arch_empty
13 
14 // case when nvptx-arch returns nothing or fails
15 // RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_fail -x cuda %s 2>&1 \
16 // RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
17 // RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-new-driver --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_fail -x cuda %s 2>&1 \
18 // RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
19 // NO-OUTPUT-ERROR: error: cannot determine nvptx64 architecture{{.*}}; consider passing it via '--offload-arch'
20 
21 // case when nvptx-arch does not return anything with successful execution
22 // RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_empty -x cuda %s 2>&1 \
23 // RUN:   | FileCheck %s --check-prefix=EMPTY-OUTPUT
24 // RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-new-driver --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_empty -x cuda %s 2>&1 \
25 // RUN:   | FileCheck %s --check-prefix=EMPTY-OUTPUT
26 // EMPTY-OUTPUT: error: cannot determine nvptx64 architecture: No NVIDIA GPU detected in the system; consider passing it via '--offload-arch'
27 
28 // case when nvptx-arch does not return anything with successful execution
29 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_sm_70 -x cuda --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda %s 2>&1 \
30 // RUN:   | FileCheck %s --check-prefix=ARCH-sm_70
31 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --offload-new-driver --nvptx-arch-tool=%t/nvptx_arch_sm_70 -x cuda --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda %s 2>&1 \
32 // RUN:   | FileCheck %s --check-prefix=ARCH-sm_70
33 // ARCH-sm_70: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
34 
35 // case when nvptx-arch is used via '-march=native'
36 // RUN:   %clang -### --target=nvptx64-nvidia-cuda -nogpulib -march=native --nvptx-arch-tool=%t/nvptx_arch_sm_70 \
37 // RUN:     --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda %s 2>&1 | FileCheck %s --check-prefix=MARCH-sm_70
38 // MARCH-sm_70: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
39 
40 // case when nvptx-arch is used via '-march=native'
41 // RUN:   %clang -### --target=nvptx64-nvidia-cuda -nogpulib -march=native --nvptx-arch-tool=%t/nvptx_arch_sm_89_sm_80 \
42 // RUN:     --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda %s 2>&1 | FileCheck %s --check-prefix=MARCH-sm_89
43 // MARCH-sm_89: warning: multiple nvptx64 architectures are detected: sm_89, sm_80; only the first one is used for '-march' [-Wmulti-gpu]
44 // MARCH-sm_89: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_89"
45 
46 // case when CLANG_TOOLCHAIN_PROGRAM_TIMEOUT is malformed.
47 // RUN: env CLANG_TOOLCHAIN_PROGRAM_TIMEOUT=foo \
48 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib \
49 // RUN:     --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_sm_70 \
50 // RUN:     --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda -x cuda %s 2>&1 | \
51 // RUN:   FileCheck %s --check-prefix=BAD-TIMEOUT
52 // BAD-TIMEOUT: clang: error: cannot determine nvptx64 architecture: CLANG_TOOLCHAIN_PROGRAM_TIMEOUT expected an integer, got 'foo'; consider passing it via '--offload-arch'; environment variable CLANG_TOOLCHAIN_PROGRAM_TIMEOUT specifies the tool timeout (integer secs, <=0 is infinite)
53