CHIP-SPV / chipStar

chipStar is a tool for compiling and running HIP/CUDA on SPIR-V via OpenCL or Level Zero APIs.
Other
184 stars 29 forks source link

Add mapping to OpenCL native_* on -ffast-math #721

Closed linehill closed 9 months ago

linehill commented 9 months ago

Map HIP device builtin functions to corresponding OpenCL native built-ins on -ffast-math. The rationale is based on -ffast-math specification [1] which gives permission to approximate transcendental functions (-fapprox-func).

[1] https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffast-math

pvelesko commented 9 months ago

Shouldn't we compile two versions of devicelib.bc - one with fast math and one without? Then link in the appropriate on hipcc?

linehill commented 9 months ago

Shouldn't we compile two versions of devicelib.bc - one with fast math and one without?

Sure, if there is a case where we can't select the fast-math version in the HIP headers.

We would probably need multiple devicelib versions for cases where other relaxed math options are used (e.g. -fapprox-func, -ffinite-math-only, -fassociateve-math, fno-signed-zeros, etc.). For those clang does not emit macros as it does for -ffast-math.

pvelesko commented 9 months ago

rebased on main