File: rocm-detect.hip

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (172 lines) | stat: -rw-r--r-- 8,932 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// REQUIRES: x86-registered-target
// REQUIRES: amdgpu-registered-target
// UNSUPPORTED: system-windows

// Make sure the appropriate device specific library is available.

// We don't include every target in the test directory, so just pick a valid
// target not included in the test.

// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 \
// RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s

// Should not interpret -nostdlib as disabling offload libraries.
// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nostdlib \
// RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s

// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nogpulib \
// RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=COMMON,NODEFAULTLIBS %s

// Test environment variable ROCM_PATH.
// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### -target x86_64-linux-gnu \
// RUN:   --print-rocm-search-dirs %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=ROCM-ENV %s

// Test interaction between environment variables HIP_PATH and ROCM_PATH.
// Device libs are found under ROCM_PATH. HIP include files and HIP runtime library
// are found under HIP_PATH.

// RUN: rm -rf %t/myhip
// RUN: mkdir -p %t/myhip
// RUN: cp -r %S/Inputs/rocm/bin %t/myhip

// Test HIP_PATH overrides ROCM_PATH.
// RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip \
// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
// RUN:   --print-rocm-search-dirs %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s

// Test --hip-path overrides ROCM_PATH.
// RUN: env ROCM_PATH=%S/Inputs/rocm \
// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
// RUN:   --hip-path=%t/myhip \
// RUN:   --print-rocm-search-dirs %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s

// Test --hip-path overrides --rocm-path.
// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
// RUN:   --hip-path=%t/myhip --rocm-path=%S/Inputs/rocm \
// RUN:   --print-rocm-search-dirs %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s

// Test HIP_PATH overrides --rocm-path.
// RUN: env HIP_PATH=%t/myhip %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
// RUN:   --rocm-path=%S/Inputs/rocm \
// RUN:   --print-rocm-search-dirs %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s

// Test empty HIP_PATH does not override --rocm-path.
// RUN: env HIP_PATH= \
// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
// RUN:   --rocm-path=%S/Inputs/rocm --print-rocm-search-dirs %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=ROCM-PATH %s

// Test --hip-path option overrides environment variable HIP_PATH.

// RUN: rm -rf %t/myhip
// RUN: rm -rf %t/myhip_nouse
// RUN: mkdir -p %t/myhip
// RUN: mkdir -p %t/myhip_nouse
// RUN: cp -r %S/Inputs/rocm/bin %t/myhip
// RUN: cp -r %S/Inputs/rocm/bin %t/myhip_nouse
// RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip_nouse \
// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
// RUN:   --hip-path=%t/myhip --print-rocm-search-dirs %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s

// Test detecting latest /opt/rocm-{release} directory.
// RUN: rm -rf %T/opt
// RUN: mkdir -p %T/opt
// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.9.0-1234
// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.10.0
// RUN: %clang -### -target x86_64-linux-gnu --sysroot=%T \
// RUN:   --print-rocm-search-dirs %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=ROCM-REL %s

// Test ROCm installation built by SPACK by invoke clang at %T/rocm-spack/llvm-amdgpu-*
// directory through a soft link.

// RUN: rm -rf %T/rocm-spack
// RUN: cp -r %S/Inputs/rocm-spack %T
// RUN: ln -fs %clang %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
// RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
// RUN:   -resource-dir=%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang \
// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 --print-rocm-search-dirs %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=SPACK %s

// Test SPACK installation with multiple hip and rocm-device-libs packages of the same
// ROCm release. Clang cannot determine which one to use and emit diagnostics. --hip-path
// and --rocm-device-lib-path can be used to specify them.

// RUN: cp -r %T/rocm-spack/hip-* %T/rocm-spack/hip-4.0.0-abcd
// RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=SPACK-MULT %s
// RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 \
// RUN:   --hip-path=%T/rocm-spack/hip-4.0.0-abcd \
// RUN:    %s 2>&1 | FileCheck -check-prefixes=SPACK-SET %s

// Test invalid SPACK ROCm installation missing hip and rocm-device-libs packages.
// The message about SPACK is emitted only if -v is specified.

// RUN: rm -rf %T/rocm-spack/hip-*
// RUN: rm -rf %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn
// RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
// RUN:   | FileCheck -check-prefixes=SPACK-MISS %s
// RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang --version 2>&1 \
// RUN:   | FileCheck -check-prefixes=SPACK-MISS-SILENT %s

// 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

// NODEFAULTLIBS-NOT: error: cannot find

// COMMON: "-triple" "amdgcn-amd-amdhsa"

// ROCM-ENV: ROCm installation search path: [[ROCM_PATH:.*/Inputs/rocm]]

// HIP-PATH: "-mlink-builtin-bitcode" "[[ROCM_PATH]]/amdgcn/bitcode/oclc_isa_version_1010.bc"
// HIP-PATH: "-idirafter" "[[HIP_PATH:.*/myhip]]/include"
// HIP-PATH: "-L[[HIP_PATH]]/lib" "-lamdhip64"

// ROCM-PATH: ROCm installation search path: [[ROCM_PATH:.*/Inputs/rocm]]
// ROCM-PATH: "-mlink-builtin-bitcode" "[[ROCM_PATH]]/amdgcn/bitcode/oclc_isa_version_1010.bc"
// ROCM-PATH: "-idirafter" "[[ROCM_PATH]]/include"
// ROCM-PATH: "-L[[ROCM_PATH]]/lib" "-lamdhip64"

// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm
// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-3.10.0

// SPACK: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
// SPACK: ROCm installation search path (Spack 4.0.0): [[DIR]]
// SPACK: ROCm installation search path: [[CLANG:.*]]
// SPACK: ROCm installation search path: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z
// SPACK: ROCm installation search path: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
// SPACK: ROCm installation search path: /opt/rocm
// SPACK: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
// SPACK: "-triple" "amdgcn-amd-amdhsa"
// SPACK-SAME: "-mlink-builtin-bitcode" "[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc"
// SPACK-SAME: "-idirafter" "[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"

// SPACK-MULT: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
// SPACK-MULT-DAG: Cannot use SPACK package hip-4.0.0 at [[DIR]] due to multiple installations for the same version
// SPACK-MULT-NOT: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
// SPACK-MULT-NOT: "-internal-isystem" "[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"

// SPACK-SET: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
// SPACK-SET: Found HIP installation: [[DIR]]/hip-4.0.0-abcd, version 4.0.20214-a2917cd
// SPACK-SET: "-triple" "amdgcn-amd-amdhsa"
// SPACK-SET-SAME: "-mlink-builtin-bitcode" "[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc"
// SPACK-SET-SAME: "-idirafter" "[[DIR]]/hip-4.0.0-abcd/include"

// SPACK-MISS: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
// SPACK-MISS-DAG: SPACK package hip-4.0.0 not found at [[DIR]]
// SPACK-MISS-NOT: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
// SPACK-MISS-NOT: "-idirafter" "[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"

// SPACK-MISS-SILENT-NOT: SPACK package hip-{{.*}} not found at
// SPACK-MISS-SILENT-NOT: Found HIP installation