Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Driver / hip-device-libs.hip
blob71d9554da696b421657c9e8ebdb1a1caf74f5ceb
1 // REQUIRES: x86-registered-target
2 // REQUIRES: amdgpu-registered-target
4 // Test if oclc_daz_opt_on or if oclc_daz_opt_off is linked depending on
5 // expected denormal mode.
7 // Test subtarget with flushing on by default.
8 // RUN: %clang -### --target=x86_64-linux-gnu \
9 // RUN:  --cuda-gpu-arch=gfx803 \
10 // RUN:  --rocm-path=%S/Inputs/rocm   \
11 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
12 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
15 // Test subtarget with flushing off by ddefault.
16 // RUN: %clang -### --target=x86_64-linux-gnu \
17 // RUN:  --cuda-gpu-arch=gfx900 \
18 // RUN:  --rocm-path=%S/Inputs/rocm \
19 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
20 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
23 // Test explicit flag, opposite of target default.
24 // RUN: %clang -### --target=x86_64-linux-gnu \
25 // RUN:   --cuda-gpu-arch=gfx900 \
26 // RUN:   -fgpu-flush-denormals-to-zero \
27 // RUN:   --rocm-path=%S/Inputs/rocm \
28 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
29 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
32 // Test explicit flag, opposite of target default.
33 // RUN: %clang -### --target=x86_64-linux-gnu \
34 // RUN:   --cuda-gpu-arch=gfx803 \
35 // RUN:   -fno-gpu-flush-denormals-to-zero \
36 // RUN:   --rocm-path=%S/Inputs/rocm \
37 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
38 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
41 // Test explicit flag, same as target default.
42 // RUN: %clang -### --target=x86_64-linux-gnu \
43 // RUN:   --cuda-gpu-arch=gfx900 \
44 // RUN:   -fno-gpu-flush-denormals-to-zero \
45 // RUN:   --rocm-path=%S/Inputs/rocm \
46 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
47 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
50 // Test explicit flag, same as target default.
51 // RUN: %clang -### --target=x86_64-linux-gnu \
52 // RUN:   --cuda-gpu-arch=gfx803 \
53 // RUN:   -fgpu-flush-denormals-to-zero \
54 // RUN:   --rocm-path=%S/Inputs/rocm \
55 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
56 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
59 // Test last flag wins, not flushing
60 // RUN: %clang -### --target=x86_64-linux-gnu \
61 // RUN:   --cuda-gpu-arch=gfx803 \
62 // RUN:   -fgpu-flush-denormals-to-zero -fno-gpu-flush-denormals-to-zero \
63 // RUN:   --rocm-path=%S/Inputs/rocm \
64 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
65 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
68 // RUN: %clang -### --target=x86_64-linux-gnu \
69 // RUN:   --cuda-gpu-arch=gfx900 \
70 // RUN:   -fgpu-flush-denormals-to-zero -fno-gpu-flush-denormals-to-zero \
71 // RUN:   --rocm-path=%S/Inputs/rocm   \
72 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
73 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
76 // RUN: %clang -### --target=x86_64-linux-gnu \
77 // RUN:   --cuda-gpu-arch=gfx900 \
78 // RUN:   -fno-gpu-flush-denormals-to-zero -fgpu-flush-denormals-to-zero \
79 // RUN:   --rocm-path=%S/Inputs/rocm   \
80 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
81 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
84 // RUN: %clang -### --target=x86_64-linux-gnu \
85 // RUN:   --cuda-gpu-arch=gfx803 \
86 // RUN:   -fno-gpu-flush-denormals-to-zero -fgpu-flush-denormals-to-zero \
87 // RUN:   --rocm-path=%S/Inputs/rocm \
88 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
89 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
91 // Test finding device lib in resource dir
92 // RUN: %clang -### --target=x86_64-linux-gnu \
93 // RUN:   --offload-arch=gfx803 -nogpuinc \
94 // RUN:   -resource-dir=%S/Inputs/rocm_resource_dir \
95 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
96 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,RESDIR
98 // Test --hip-device-lib-path flag
99 // RUN: %clang -### --target=x86_64-linux-gnu \
100 // RUN:   --cuda-gpu-arch=gfx803 -nogpuinc \
101 // RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode   \
102 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
103 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
105 // Test --hip-device-lib-path wins over -resource-dir
106 // RUN: %clang -### --target=x86_64-linux-gnu \
107 // RUN:   --cuda-gpu-arch=gfx803 -nogpuinc \
108 // RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode   \
109 // RUN:   -resource-dir=%S/Inputs/rocm_resource_dir \
110 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
111 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
113 // Test environment variable HIP_DEVICE_LIB_PATH
114 // RUN: env HIP_DEVICE_LIB_PATH=%S/Inputs/rocm/amdgcn/bitcode \
115 // RUN:   %clang -### --target=x86_64-linux-gnu \
116 // RUN:   --cuda-gpu-arch=gfx900 -nogpuinc \
117 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
118 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,ROCMDIR
120 // Test environment variable HIP_DEVICE_LIB_PATH wins over -resource-dir
121 // RUN: env HIP_DEVICE_LIB_PATH=%S/Inputs/rocm/amdgcn/bitcode \
122 // RUN:   %clang -### --target=x86_64-linux-gnu \
123 // RUN:   --cuda-gpu-arch=gfx900 -nogpuinc \
124 // RUN:   -resource-dir=%S/Inputs/rocm_resource_dir \
125 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
126 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,ROCMDIR
128 // Test --gpu-instrument-lib
129 // RUN: %clang -### --target=x86_64-linux-gnu \
130 // RUN:   --cuda-gpu-arch=gfx900 \
131 // RUN:   --rocm-path=%S/Inputs/rocm \
132 // RUN:   --gpu-instrument-lib=%S/Inputs/hip_multiple_inputs/instrument.bc \
133 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
134 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,INST,ROCMDIR
136 // Test -fast-math
137 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
138 // RUN:   -ffast-math --rocm-path=%S/Inputs/rocm \
139 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
140 // RUN: 2>&1 | FileCheck %s --check-prefixes=FAST
142 // Test -ffinite-math-only
143 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
144 // RUN:   -ffinite-math-only --rocm-path=%S/Inputs/rocm \
145 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
146 // RUN: 2>&1 | FileCheck %s --check-prefixes=FINITE
148 // Test -funsafe-math-optimizations
149 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
150 // RUN:   -funsafe-math-optimizations --rocm-path=%S/Inputs/rocm \
151 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
152 // RUN: 2>&1 | FileCheck %s --check-prefixes=UNSAFE
154 // Test -fno-hip-fp32-correctly-rounded-divide-sqrt
155 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
156 // RUN:   -fno-hip-fp32-correctly-rounded-divide-sqrt \
157 // RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
158 // RUN: 2>&1 | FileCheck %s --check-prefixes=DIVSQRT
160 // Test default code object version.
161 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
162 // RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
163 // RUN: 2>&1 | FileCheck %s --check-prefixes=ABI4
165 // Test default code object version with old device library without abi_version_400.bc
166 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
167 // RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver   \
168 // RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
169 // RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI4
171 // Test -mcode-object-version=3
172 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
173 // RUN:   -mcode-object-version=3 \
174 // RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
175 // RUN: 2>&1 | FileCheck %s --check-prefixes=ABI4
177 // Test -mcode-object-version=4
178 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
179 // RUN:   -mcode-object-version=4 \
180 // RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
181 // RUN: 2>&1 | FileCheck %s --check-prefixes=ABI4
183 // Test -mcode-object-version=4 with old device library without abi_version_400.bc
184 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
185 // RUN:   -mcode-object-version=4 \
186 // RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver   \
187 // RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
188 // RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI4
190 // Test -mcode-object-version=5
191 // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
192 // RUN:   -mcode-object-version=5 \
193 // RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
194 // RUN: 2>&1 | FileCheck %s --check-prefixes=ABI5
196 // Test -mcode-object-version=5 with old device library without abi_version_400.bc
197 // RUN: not %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
198 // RUN:   -mcode-object-version=5 \
199 // RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver   \
200 // RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
201 // RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI5
203 // ALL-NOT: error:
204 // ALL: {{"[^"]*clang[^"]*"}}
206 // RESDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm_resource_dir(/|\\\\)lib(64)?(/|\\\\)amdgcn(/|\\\\).*]]hip.bc"
207 // ROCMDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm(/|\\\\)amdgcn(/|\\\\).*]]hip.bc"
209 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ocml.bc"
210 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ockl.bc"
212 // FLUSHD-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_daz_opt_on.bc"
213 // NOFLUSHD-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_daz_opt_off.bc"
215 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_unsafe_math_off.bc"
216 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_finite_only_off.bc"
217 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_correctly_rounded_sqrt_on.bc"
218 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_wavefrontsize64_on.bc"
219 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_isa_version_{{[0-9]+}}.bc"
220 // INST-SAME: "-mlink-builtin-bitcode" "{{.*}}instrument.bc"
222 // FAST: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
223 // FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc"
224 // FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc"
225 // FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
227 // FINITE: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
228 // FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc"
229 // FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc"
230 // FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
232 // UNSAFE: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
233 // UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc"
234 // UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc"
235 // UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
237 // DIVSQRT: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
238 // DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc"
239 // DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc"
240 // DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_off.bc"
242 // ABI4-NOT: error:
243 // ABI4: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_400.bc"
244 // ABI5-NOT: error:
245 // ABI5: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_500.bc"
246 // NOABI4-NOT: error:
247 // NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_400.bc"
248 // NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_500.bc"
249 // 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