1 // REQUIRES: shell 2 // XFAIL: target={{.*}}-zos{{.*}} 3 4 // RUN: mkdir -p %t 5 // RUN: cp %S/Inputs/amdgpu-arch/amdgpu_arch_fail %t/ 6 // RUN: cp %S/Inputs/amdgpu-arch/amdgpu_arch_gfx906 %t/ 7 // RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_fail %t/ 8 // RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_sm_70 %t/ 9 // RUN: echo '#!/bin/sh' > %t/amdgpu_arch_empty 10 // RUN: chmod +x %t/amdgpu_arch_fail 11 // RUN: chmod +x %t/amdgpu_arch_gfx906 12 // RUN: chmod +x %t/amdgpu_arch_empty 13 // RUN: echo '#!/bin/sh' > %t/nvptx_arch_empty 14 // RUN: chmod +x %t/nvptx_arch_fail 15 // RUN: chmod +x %t/nvptx_arch_sm_70 16 // RUN: chmod +x %t/nvptx_arch_empty 17 18 // case when nvptx-arch and amdgpu-arch return nothing or fails 19 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \ 20 // RUN: --nvptx-arch-tool=%t/nvptx_arch_fail --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \ 21 // RUN: | FileCheck %s --check-prefix=NO-OUTPUT-ERROR 22 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \ 23 // RUN: --nvptx-arch-tool=%t/nvptx_arch_empty --amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \ 24 // RUN: | FileCheck %s --check-prefix=NO-OUTPUT-ERROR 25 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch= \ 26 // RUN: --nvptx-arch-tool=%t/nvptx_arch_fail --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \ 27 // RUN: | FileCheck %s --check-prefix=NO-OUTPUT-ERROR 28 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch= \ 29 // RUN: --nvptx-arch-tool=%t/nvptx_arch_empty --amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \ 30 // RUN: | FileCheck %s --check-prefix=NO-OUTPUT-ERROR 31 // NO-OUTPUT-ERROR: error: failed to deduce triple for target architecture 'native'; specify the triple using '-fopenmp-targets' and '-Xopenmp-target' instead 32 33 // case when amdgpu-arch succeeds. 34 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \ 35 // RUN: --nvptx-arch-tool=%t/nvptx_arch_fail --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \ 36 // RUN: | FileCheck %s --check-prefix=ARCH-GFX906 37 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa \ 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 // ARCH-GFX906: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" 41 42 // case when nvptx-arch succeeds. 43 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \ 44 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \ 45 // RUN: | FileCheck %s --check-prefix=ARCH-SM_70 46 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ 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 // ARCH-SM_70: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70" 50 51 // case when both nvptx-arch and amdgpu-arch succeed. 52 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \ 53 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \ 54 // RUN: | FileCheck %s --check-prefix=ARCH-SM_70-GFX906 55 // ARCH-SM_70-GFX906: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" 56 // ARCH-SM_70-GFX906: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70" 57 58 // case when both nvptx-arch and amdgpu-arch succeed with other archs. 59 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native,sm_75,gfx1030 \ 60 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \ 61 // RUN: | FileCheck %s --check-prefix=ARCH-MULTIPLE 62 // ARCH-MULTIPLE: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx1030" 63 // ARCH-MULTIPLE: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" 64 // ARCH-MULTIPLE: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70" 65 // ARCH-MULTIPLE: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_75" 66 67 // case when 'nvptx-arch' returns nothing using `-fopenmp-targets=`. 68 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp \ 69 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda --nvptx-arch-tool=%t/nvptx_arch_empty %s 2>&1 \ 70 // RUN: | FileCheck %s --check-prefix=NVPTX 71 // NVPTX: error: cannot determine nvptx64 architecture: No NVIDIA GPU detected in the system; consider passing it via '-march' 72 73 // case when 'amdgpu-arch' returns nothing using `-fopenmp-targets=`. 74 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp \ 75 // RUN: -fopenmp-targets=amdgcn-amd-amdhsa --amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \ 76 // RUN: | FileCheck %s --check-prefix=AMDGPU 77 // AMDGPU: error: cannot determine amdgcn architecture: No AMD GPU detected in the system; consider passing it via '-march' 78 79 // case when CLANG_TOOLCHAIN_PROGRAM_TIMEOUT is malformed for nvptx-arch. 80 // RUN: env CLANG_TOOLCHAIN_PROGRAM_TIMEOUT=foo \ 81 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \ 82 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -nogpulib \ 83 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 %s 2>&1 | \ 84 // RUN: FileCheck %s --check-prefix=BAD-TIMEOUT-NVPTX 85 // BAD-TIMEOUT-NVPTX: clang: error: cannot determine nvptx64 architecture: CLANG_TOOLCHAIN_PROGRAM_TIMEOUT expected an integer, got 'foo'; consider passing it via '-march'; environment variable CLANG_TOOLCHAIN_PROGRAM_TIMEOUT specifies the tool timeout (integer secs, <=0 is infinite) 86 87 // case when CLANG_TOOLCHAIN_PROGRAM_TIMEOUT is malformed for amdgpu-arch. 88 // RUN: env CLANG_TOOLCHAIN_PROGRAM_TIMEOUT= \ 89 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \ 90 // RUN: -fopenmp-targets=amdgcn-amd-amdhsa -nogpulib \ 91 // RUN: --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 | \ 92 // RUN: FileCheck %s --check-prefix=BAD-TIMEOUT-AMDGPU 93 // BAD-TIMEOUT-AMDGPU: clang: error: cannot determine amdgcn architecture: CLANG_TOOLCHAIN_PROGRAM_TIMEOUT expected an integer, got ''; consider passing it via '-march'; environment variable CLANG_TOOLCHAIN_PROGRAM_TIMEOUT specifies the tool timeout (integer secs, <=0 is infinite) 94