xref: /llvm-project/clang/test/Driver/hip-device-libs.hip (revision ff936ce62bda2f9148575caae527cc4c6ab282a5)
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=ABI5
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:   -mcode-object-version=4 \
165// RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver \
166// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
167// RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI4
168
169// Test -mcode-object-version=4
170// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
171// RUN:   -mcode-object-version=4 \
172// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
173// RUN: 2>&1 | FileCheck %s --check-prefixes=ABI4
174
175// Test -mcode-object-version=4 with old device library without abi_version_400.bc
176// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
177// RUN:   -mcode-object-version=4 \
178// RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver   \
179// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
180// RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI4
181
182// Test -mcode-object-version=5
183// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
184// RUN:   -mcode-object-version=5 \
185// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
186// RUN: 2>&1 | FileCheck %s --check-prefixes=ABI5
187
188// Test -mcode-object-version=5 with old device library without abi_version_500.bc
189// RUN: not %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
190// RUN:   -mcode-object-version=5 \
191// RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver   \
192// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
193// RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI5
194
195// Test -mcode-object-version=6
196// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
197// RUN:   -mcode-object-version=6 \
198// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
199// RUN: 2>&1 | FileCheck %s --check-prefixes=ABI6
200
201// Test -mcode-object-version=6 with old device library without abi_version_600.bc
202// RUN: not %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 \
203// RUN:   -mcode-object-version=6 \
204// RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver   \
205// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
206// RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI6
207
208// ALL-NOT: error:
209// ALL: {{"[^"]*clang[^"]*"}}
210
211// RESDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm_resource_dir(/|\\\\)lib(64)?(/|\\\\)amdgcn(/|\\\\).*]]hip.bc"
212// ROCMDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm(/|\\\\)amdgcn(/|\\\\).*]]hip.bc"
213
214// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ocml.bc"
215// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ockl.bc"
216
217// FLUSHD-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_daz_opt_on.bc"
218// NOFLUSHD-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_daz_opt_off.bc"
219
220// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_unsafe_math_off.bc"
221// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_finite_only_off.bc"
222// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_correctly_rounded_sqrt_on.bc"
223// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_wavefrontsize64_on.bc"
224// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_isa_version_{{[0-9]+}}.bc"
225// INST-SAME: "-mlink-builtin-bitcode" "{{.*}}instrument.bc"
226
227// FAST: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
228// FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc"
229// FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc"
230// FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
231
232// FINITE: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
233// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc"
234// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc"
235// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
236
237// UNSAFE: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
238// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc"
239// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc"
240// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
241
242// DIVSQRT: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
243// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc"
244// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc"
245// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_off.bc"
246
247// ABI4-NOT: error:
248// ABI4: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_400.bc"
249// ABI5-NOT: error:
250// ABI5: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_500.bc"
251// ABI6-NOT: error:
252// ABI6: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_600.bc"
253// NOABI4-NOT: error:
254// NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_400.bc"
255// NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_500.bc"
256// NOABI5: error: cannot find ROCm device library for ABI version 5; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library
257// NOABI6: error: cannot find ROCm device library for ABI version 6; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library
258