Debian Codegraph @

clang/test/Driver/hip-device-libs.hip

raw
1 // Test if oclc_daz_opt_on or if oclc_daz_opt_off is linked depending on
2 // expected denormal mode.
3
4 // Test subtarget with flushing on by default.
5 // RUN: %clang -### --target=x86_64-linux-gnu \
6 // RUN: --cuda-gpu-arch=gfx803 \
7 // RUN: --rocm-path=%S/Inputs/rocm \
8 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
9 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
10
11
12 // Test subtarget with flushing off by ddefault.
13 // RUN: %clang -### --target=x86_64-linux-gnu \
14 // RUN: --cuda-gpu-arch=gfx900 \
15 // RUN: --rocm-path=%S/Inputs/rocm \
16 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
17 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
18
19
20 // Test explicit flag, opposite of target default.
21 // RUN: %clang -### --target=x86_64-linux-gnu \
22 // RUN: --cuda-gpu-arch=gfx900 \
23 // RUN: -fgpu-flush-denormals-to-zero \
24 // RUN: --rocm-path=%S/Inputs/rocm \
25 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
26 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
27
28
29 // Test explicit flag, opposite of target default.
30 // RUN: %clang -### --target=x86_64-linux-gnu \
31 // RUN: --cuda-gpu-arch=gfx803 \
32 // RUN: -fno-gpu-flush-denormals-to-zero \
33 // RUN: --rocm-path=%S/Inputs/rocm \
34 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
35 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
36
37
38 // Test explicit flag, same as target default.
39 // RUN: %clang -### --target=x86_64-linux-gnu \
40 // RUN: --cuda-gpu-arch=gfx900 \
41 // RUN: -fno-gpu-flush-denormals-to-zero \
42 // RUN: --rocm-path=%S/Inputs/rocm \
43 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
44 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
45
46
47 // Test explicit flag, same as target default.
48 // RUN: %clang -### --target=x86_64-linux-gnu \
49 // RUN: --cuda-gpu-arch=gfx803 \
50 // RUN: -fgpu-flush-denormals-to-zero \
51 // RUN: --rocm-path=%S/Inputs/rocm \
52 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
53 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
54
55
56 // Test last flag wins, not flushing
57 // RUN: %clang -### --target=x86_64-linux-gnu \
58 // RUN: --cuda-gpu-arch=gfx803 \
59 // RUN: -fgpu-flush-denormals-to-zero -fno-gpu-flush-denormals-to-zero \
60 // RUN: --rocm-path=%S/Inputs/rocm \
61 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
62 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
63
64
65 // RUN: %clang -### --target=x86_64-linux-gnu \
66 // RUN: --cuda-gpu-arch=gfx900 \
67 // RUN: -fgpu-flush-denormals-to-zero -fno-gpu-flush-denormals-to-zero \
68 // RUN: --rocm-path=%S/Inputs/rocm \
69 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
70 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
71
72
73 // RUN: %clang -### --target=x86_64-linux-gnu \
74 // RUN: --cuda-gpu-arch=gfx900 \
75 // RUN: -fno-gpu-flush-denormals-to-zero -fgpu-flush-denormals-to-zero \
76 // RUN: --rocm-path=%S/Inputs/rocm \
77 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
78 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
79
80
81 // RUN: %clang -### --target=x86_64-linux-gnu \
82 // RUN: --cuda-gpu-arch=gfx803 \
83 // RUN: -fno-gpu-flush-denormals-to-zero -fgpu-flush-denormals-to-zero \
84 // RUN: --rocm-path=%S/Inputs/rocm \
85 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
86 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
87
88 // Test finding device lib in resource dir
89 // RUN: %clang -### --target=x86_64-linux-gnu \
90 // RUN: --offload-arch=gfx803 -nogpuinc \
91 // RUN: -resource-dir=%S/Inputs/rocm_resource_dir \
92 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
93 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,RESDIR
94
95 // Test --hip-device-lib-path flag
96 // RUN: %clang -### --target=x86_64-linux-gnu \
97 // RUN: --cuda-gpu-arch=gfx803 -nogpuinc \
98 // RUN: --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode \
99 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
100 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
101
102 // Test --hip-device-lib-path wins over -resource-dir
103 // RUN: %clang -### --target=x86_64-linux-gnu \
104 // RUN: --cuda-gpu-arch=gfx803 -nogpuinc \
105 // RUN: --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode \
106 // RUN: -resource-dir=%S/Inputs/rocm_resource_dir \
107 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
108 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
109
110 // Test environment variable HIP_DEVICE_LIB_PATH
111 // RUN: env HIP_DEVICE_LIB_PATH=%S/Inputs/rocm/amdgcn/bitcode \
112 // RUN: %clang -### --target=x86_64-linux-gnu \
113 // RUN: --cuda-gpu-arch=gfx900 -nogpuinc \
114 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
115 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,ROCMDIR
116
117 // Test environment variable HIP_DEVICE_LIB_PATH wins over -resource-dir
118 // RUN: env HIP_DEVICE_LIB_PATH=%S/Inputs/rocm/amdgcn/bitcode \
119 // RUN: %clang -### --target=x86_64-linux-gnu \
120 // RUN: --cuda-gpu-arch=gfx900 -nogpuinc \
121 // RUN: -resource-dir=%S/Inputs/rocm_resource_dir \
122 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
123 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,ROCMDIR
124
125 // Test --gpu-instrument-lib
126 // RUN: %clang -### --target=x86_64-linux-gnu \
127 // RUN: --cuda-gpu-arch=gfx900 \
128 // RUN: --rocm-path=%S/Inputs/rocm \
129 // RUN: --gpu-instrument-lib=%S/Inputs/hip_multiple_inputs/instrument.bc \
130 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
131 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,INST,ROCMDIR
132
133 // Test -fast-math
134 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
135 // RUN: -ffast-math --rocm-path=%S/Inputs/rocm \
136 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
137 // RUN: 2>&1 | FileCheck %s --check-prefixes=FAST
138
139 // Test -ffinite-math-only
140 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
141 // RUN: -ffinite-math-only --rocm-path=%S/Inputs/rocm \
142 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
143 // RUN: 2>&1 | FileCheck %s --check-prefixes=FINITE
144
145 // Test -funsafe-math-optimizations
146 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
147 // RUN: -funsafe-math-optimizations --rocm-path=%S/Inputs/rocm \
148 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
149 // RUN: 2>&1 | FileCheck %s --check-prefixes=UNSAFE
150
151 // Test -fno-hip-fp32-correctly-rounded-divide-sqrt
152 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
153 // RUN: -fno-hip-fp32-correctly-rounded-divide-sqrt \
154 // RUN: --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
155 // RUN: 2>&1 | FileCheck %s --check-prefixes=DIVSQRT
156
157 // Test default code object version.
158 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
159 // RUN: --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
160 // RUN: 2>&1 | FileCheck %s --check-prefixes=ABI4
161
162 // Test default code object version with old device library without abi_version_400.bc
163 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
164 // RUN: --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver \
165 // RUN: --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
166 // RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI4
167
168 // Test -mcode-object-version=4
169 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
170 // RUN: -mcode-object-version=4 \
171 // RUN: --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
172 // RUN: 2>&1 | FileCheck %s --check-prefixes=ABI4
173
174 // Test -mcode-object-version=4 with old device library without abi_version_400.bc
175 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
176 // RUN: -mcode-object-version=4 \
177 // RUN: --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver \
178 // RUN: --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
179 // RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI4
180
181 // Test -mcode-object-version=5
182 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
183 // RUN: -mcode-object-version=5 \
184 // RUN: --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
185 // RUN: 2>&1 | FileCheck %s --check-prefixes=ABI5
186
187 // Test -mcode-object-version=5 with old device library without abi_version_500.bc
188 // RUN: not %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
189 // RUN: -mcode-object-version=5 \
190 // RUN: --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver \
191 // RUN: --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
192 // RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI5
193
194 // Test -mcode-object-version=6
195 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
196 // RUN: -mcode-object-version=6 \
197 // RUN: --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
198 // RUN: 2>&1 | FileCheck %s --check-prefixes=ABI6
199
200 // Test -mcode-object-version=6 with old device library without abi_version_600.bc
201 // RUN: not %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
202 // RUN: -mcode-object-version=6 \
203 // RUN: --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver \
204 // RUN: --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
205 // RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI6
206
207 // ALL-NOT: error:
208 // ALL: {{"[^"]*clang[^"]*"}}
209
210 // RESDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm_resource_dir(/|\\\\)lib(64)?(/|\\\\)amdgcn(/|\\\\).*]]hip.bc"
211 // ROCMDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm(/|\\\\)amdgcn(/|\\\\).*]]hip.bc"
212
213 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ocml.bc"
214 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ockl.bc"
215
216 // FLUSHD-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_daz_opt_on.bc"
217 // NOFLUSHD-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_daz_opt_off.bc"
218
219 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_unsafe_math_off.bc"
220 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_finite_only_off.bc"
221 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_correctly_rounded_sqrt_on.bc"
222 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_wavefrontsize64_on.bc"
223 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_isa_version_{{[0-9]+}}.bc"
224 // INST-SAME: "-mlink-builtin-bitcode" "{{.*}}instrument.bc"
225
226 // FAST: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
227 // FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc"
228 // FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc"
229 // FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
230
231 // FINITE: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
232 // FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc"
233 // FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc"
234 // FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
235
236 // UNSAFE: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
237 // UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc"
238 // UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc"
239 // UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
240
241 // DIVSQRT: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
242 // DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc"
243 // DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc"
244 // DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_off.bc"
245
246 // ABI4-NOT: error:
247 // ABI4: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_400.bc"
248 // ABI5-NOT: error:
249 // ABI5: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_500.bc"
250 // ABI6-NOT: error:
251 // ABI6: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_600.bc"
252 // NOABI4-NOT: error:
253 // NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_400.bc"
254 // NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_500.bc"
255 // NOABI5: error: cannot find ROCm device libraryfor ABI version 5; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library
256 // NOABI6: error: cannot find ROCm device libraryfor ABI version 6; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library