| 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,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,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,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,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,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,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,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,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,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,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,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,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,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=ABI6 |
| 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(/|\\\\).*]]ocml.bc" |
| 212 |
// ROCMDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm(/|\\\\)amdgcn(/|\\\\).*]]ocml.bc" |
| 213 |
|
| 214 |
// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ockl.bc" |
| 215 |
|
| 216 |
// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_unsafe_math_off.bc" |
| 217 |
// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_finite_only_off.bc" |
| 218 |
// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_correctly_rounded_sqrt_on.bc" |
| 219 |
// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_wavefrontsize64_on.bc" |
| 220 |
// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]oclc_isa_version_{{[0-9]+}}.bc" |
| 221 |
// INST-SAME: "-mlink-builtin-bitcode" "{{.*}}instrument.bc" |
| 222 |
|
| 223 |
// FAST: "-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" |
| 226 |
|
| 227 |
// FINITE: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc" |
| 228 |
// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc" |
| 229 |
// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc" |
| 230 |
|
| 231 |
// UNSAFE: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc" |
| 232 |
// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc" |
| 233 |
// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc" |
| 234 |
|
| 235 |
// DIVSQRT: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc" |
| 236 |
// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc" |
| 237 |
// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_off.bc" |
| 238 |
|
| 239 |
// ABI4-NOT: error: |
| 240 |
// ABI4: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_400.bc" |
| 241 |
// ABI5-NOT: error: |
| 242 |
// ABI5: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_500.bc" |
| 243 |
// ABI6-NOT: error: |
| 244 |
// ABI6: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_600.bc" |
| 245 |
// NOABI4-NOT: error: |
| 246 |
// NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_400.bc" |
| 247 |
// NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_500.bc" |
| 248 |
// 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 |
| 249 |
// NOABI6: error: cannot find ROCm device library for ABI version 6, which requires ROCm 6.3 or higher; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library |