| 1 |
// UNSUPPORTED: system-windows |
| 2 |
|
| 3 |
// Make sure the appropriate device specific library is available. |
| 4 |
|
| 5 |
// We don't include every target in the test directory, so just pick a valid |
| 6 |
// target not included in the test. |
| 7 |
|
| 8 |
// RUN: not %clang -### -v --target=x86_64-linux-gnu --cuda-gpu-arch=gfx902 \ |
| 9 |
// RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \ |
| 10 |
// RUN: | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s |
| 11 |
|
| 12 |
// Should not interpret -nostdlib as disabling offload libraries. |
| 13 |
// RUN: not %clang -### -v --target=x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nostdlib \ |
| 14 |
// RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \ |
| 15 |
// RUN: | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s |
| 16 |
|
| 17 |
// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nogpulib \ |
| 18 |
// RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \ |
| 19 |
// RUN: | FileCheck -check-prefixes=COMMON,NODEFAULTLIBS %s |
| 20 |
|
| 21 |
// Test environment variable ROCM_PATH. |
| 22 |
// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### --target=x86_64-linux-gnu \ |
| 23 |
// RUN: --print-rocm-search-dirs --offload-arch=gfx1010 %s 2>&1 \ |
| 24 |
// RUN: | FileCheck -check-prefixes=ROCM-ENV %s |
| 25 |
|
| 26 |
// Test interaction between environment variables HIP_PATH and ROCM_PATH. |
| 27 |
// Device libs are found under ROCM_PATH. HIP include files and HIP runtime library |
| 28 |
// are found under HIP_PATH. |
| 29 |
|
| 30 |
// RUN: rm -rf %t/myhip |
| 31 |
// RUN: mkdir -p %t/myhip |
| 32 |
// RUN: cp -r %S/Inputs/rocm/bin %t/myhip |
| 33 |
|
| 34 |
// Test HIP_PATH overrides ROCM_PATH. |
| 35 |
// RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip \ |
| 36 |
// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \ |
| 37 |
// RUN: --print-rocm-search-dirs %s 2>&1 \ |
| 38 |
// RUN: | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s |
| 39 |
|
| 40 |
// Test --hip-path overrides ROCM_PATH. |
| 41 |
// RUN: env ROCM_PATH=%S/Inputs/rocm \ |
| 42 |
// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \ |
| 43 |
// RUN: --hip-path=%t/myhip \ |
| 44 |
// RUN: --print-rocm-search-dirs %s 2>&1 \ |
| 45 |
// RUN: | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s |
| 46 |
|
| 47 |
// Test --hip-path overrides --rocm-path. |
| 48 |
// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \ |
| 49 |
// RUN: --hip-path=%t/myhip --rocm-path=%S/Inputs/rocm \ |
| 50 |
// RUN: --print-rocm-search-dirs %s 2>&1 \ |
| 51 |
// RUN: | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s |
| 52 |
|
| 53 |
// Test HIP_PATH overrides --rocm-path. |
| 54 |
// RUN: env HIP_PATH=%t/myhip %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \ |
| 55 |
// RUN: --rocm-path=%S/Inputs/rocm \ |
| 56 |
// RUN: --print-rocm-search-dirs %s 2>&1 \ |
| 57 |
// RUN: | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s |
| 58 |
|
| 59 |
// Test empty HIP_PATH does not override --rocm-path. |
| 60 |
// RUN: env HIP_PATH= \ |
| 61 |
// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \ |
| 62 |
// RUN: --rocm-path=%S/Inputs/rocm --print-rocm-search-dirs %s 2>&1 \ |
| 63 |
// RUN: | FileCheck -check-prefixes=ROCM-PATH %s |
| 64 |
|
| 65 |
// Test --hip-path option overrides environment variable HIP_PATH. |
| 66 |
|
| 67 |
// RUN: rm -rf %t/myhip |
| 68 |
// RUN: rm -rf %t/myhip_nouse |
| 69 |
// RUN: mkdir -p %t/myhip |
| 70 |
// RUN: mkdir -p %t/myhip_nouse |
| 71 |
// RUN: cp -r %S/Inputs/rocm/bin %t/myhip |
| 72 |
// RUN: cp -r %S/Inputs/rocm/bin %t/myhip_nouse |
| 73 |
// RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip_nouse \ |
| 74 |
// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \ |
| 75 |
// RUN: --hip-path=%t/myhip --print-rocm-search-dirs %s 2>&1 \ |
| 76 |
// RUN: | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s |
| 77 |
|
| 78 |
// Test detecting /usr directory. |
| 79 |
// RUN: rm -rf %t/* |
| 80 |
// RUN: cp -r %S/Inputs/rocm %t/usr |
| 81 |
// RUN: mkdir -p %t/usr/share/hip |
| 82 |
// RUN: mv %t/usr/bin/.hipVersion %t/usr/share/hip/version |
| 83 |
// RUN: mkdir -p %t/usr/local |
| 84 |
// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx1010 --sysroot=%t \ |
| 85 |
// RUN: --print-rocm-search-dirs --hip-link %s 2>&1 \ |
| 86 |
// RUN: | FileCheck -check-prefixes=USR %s |
| 87 |
|
| 88 |
// Test detecting latest /opt/rocm-{release} directory. |
| 89 |
// RUN: rm -rf %t/* |
| 90 |
// RUN: mkdir -p %t/opt |
| 91 |
// RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.9.0-1234 |
| 92 |
// RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.10.0 |
| 93 |
// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx1010 --sysroot=%t \ |
| 94 |
// RUN: --print-rocm-search-dirs %s 2>&1 \ |
| 95 |
// RUN: | FileCheck -check-prefixes=ROCM-REL %s |
| 96 |
|
| 97 |
// GFX902-DEFAULTLIBS: error: cannot find ROCm device library for gfx902; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library |
| 98 |
|
| 99 |
// NODEFAULTLIBS-NOT: error: cannot find |
| 100 |
|
| 101 |
// COMMON: "-triple" "amdgcn-amd-amdhsa" |
| 102 |
|
| 103 |
// ROCM-ENV: ROCm installation search path: [[ROCM_PATH:.*/Inputs/rocm]] |
| 104 |
|
| 105 |
// HIP-PATH: "-mlink-builtin-bitcode" "[[ROCM_PATH]]/amdgcn/bitcode/oclc_isa_version_1010.bc" |
| 106 |
// HIP-PATH: "-idirafter" "[[HIP_PATH:.*/myhip]]/include" |
| 107 |
// HIP-PATH: "-L[[HIP_PATH]]/lib" {{.*}}"-lamdhip64" |
| 108 |
|
| 109 |
// ROCM-PATH: ROCm installation search path: [[ROCM_PATH:.*/Inputs/rocm]] |
| 110 |
// ROCM-PATH: "-mlink-builtin-bitcode" "[[ROCM_PATH]]/amdgcn/bitcode/oclc_isa_version_1010.bc" |
| 111 |
// ROCM-PATH: "-idirafter" "[[ROCM_PATH]]/include" |
| 112 |
// ROCM-PATH: "-L[[ROCM_PATH]]/lib" {{.*}}"-lamdhip64" |
| 113 |
|
| 114 |
// USR: ROCm installation search path: [[ROCM_PATH:.*/usr$]] |
| 115 |
// USR: "-mlink-builtin-bitcode" "[[ROCM_PATH]]/amdgcn/bitcode/oclc_isa_version_1010.bc" |
| 116 |
// USR: "-idirafter" "[[ROCM_PATH]]/include" |
| 117 |
// USR: "-L[[ROCM_PATH]]/lib" {{.*}}"-lamdhip64" |
| 118 |
|
| 119 |
// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm |
| 120 |
// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-3.10.0 |