1 // REQUIRES: system-linux
2 // REQUIRES: x86-registered-target
3 // REQUIRES: amdgpu-registered-target
4 // REQUIRES: nvptx-registered-target
8 // RUN: cp %S/Inputs/amdgpu-arch/amdgpu_arch_fail %t/
9 // RUN: cp %S/Inputs/amdgpu-arch/amdgpu_arch_gfx906 %t/
10 // RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_fail %t/
11 // RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_sm_70 %t/
12 // RUN: echo '#!/bin/sh' > %t/amdgpu_arch_empty
13 // RUN: chmod +x %t/amdgpu_arch_fail
14 // RUN: chmod +x %t/amdgpu_arch_gfx906
15 // RUN: chmod +x %t/amdgpu_arch_empty
16 // RUN: echo '#!/bin/sh' > %t/nvptx_arch_empty
17 // RUN: chmod +x %t/nvptx_arch_fail
18 // RUN: chmod +x %t/nvptx_arch_sm_70
19 // RUN: chmod +x %t/nvptx_arch_empty
21 // case when nvptx-arch and amdgpu-arch return nothing or fails
22 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \
23 // RUN: --nvptx-arch-tool=%t/nvptx_arch_fail --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
24 // RUN: | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
25 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \
26 // RUN: --nvptx-arch-tool=%t/nvptx_arch_empty --amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \
27 // RUN: | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
28 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch= \
29 // RUN: --nvptx-arch-tool=%t/nvptx_arch_fail --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
30 // RUN: | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
31 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch= \
32 // RUN: --nvptx-arch-tool=%t/nvptx_arch_empty --amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \
33 // RUN: | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
34 // NO-OUTPUT-ERROR: error: failed to deduce triple for target architecture 'native'; specify the triple using '-fopenmp-targets' and '-Xopenmp-target' instead.
36 // case when amdgpu-arch succeeds.
37 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \
38 // RUN: --nvptx-arch-tool=%t/nvptx_arch_fail --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
39 // RUN: | FileCheck %s --check-prefix=ARCH-GFX906
40 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa \
41 // RUN: --nvptx-arch-tool=%t/nvptx_arch_fail --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
42 // RUN: | FileCheck %s --check-prefix=ARCH-GFX906
43 // ARCH-GFX906: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906"
45 // case when nvptx-arch succeeds.
46 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \
47 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
48 // RUN: | FileCheck %s --check-prefix=ARCH-SM_70
49 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
50 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
51 // RUN: | FileCheck %s --check-prefix=ARCH-SM_70
52 // ARCH-SM_70: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
54 // case when both nvptx-arch and amdgpu-arch succeed.
55 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \
56 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
57 // RUN: | FileCheck %s --check-prefix=ARCH-SM_70-GFX906
58 // ARCH-SM_70-GFX906: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906"
59 // ARCH-SM_70-GFX906: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
61 // case when both nvptx-arch and amdgpu-arch succeed with other archs.
62 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native,sm_75,gfx1030 \
63 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
64 // RUN: | FileCheck %s --check-prefix=ARCH-MULTIPLE
65 // ARCH-MULTIPLE: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx1030"
66 // ARCH-MULTIPLE: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906"
67 // ARCH-MULTIPLE: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
68 // ARCH-MULTIPLE: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_75"
70 // case when 'nvptx-arch' returns nothing using `-fopenmp-targets=`.
71 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp \
72 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda --nvptx-arch-tool=%t/nvptx_arch_empty %s 2>&1 \
73 // RUN: | FileCheck %s --check-prefix=NVPTX
74 // NVPTX: error: cannot determine nvptx64 architecture: No NVIDIA GPU detected in the system; consider passing it via '-march'
76 // case when 'amdgpu-arch' returns nothing using `-fopenmp-targets=`.
77 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp \
78 // RUN: -fopenmp-targets=amdgcn-amd-amdhsa --amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \
79 // RUN: | FileCheck %s --check-prefix=AMDGPU
80 // AMDGPU: error: cannot determine amdgcn architecture: No AMD GPU detected in the system; consider passing it via '-march'