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