-
Notifications
You must be signed in to change notification settings - Fork 814
Description
I think there is a need for a means to provide users the ability to completely undo the effects of passing -ffast-math flag to the compiler if icpx is going to be using -ffast-math by default. I'm not sure what the best solution to this is right now. I'm opening this issue to raise discussion.
I think we need a solution to this for the following reasons.
First, note that recently a bunch of e2e tests were adjusted with mathflags which added the -fno-fast-math flag (see this PR which undoes this for some tests: #9723). I believe that this was to allow tests to pass when compiling with icpx which uses -ffast-math always. A problem is that -fno-fast-math does not undo -ffast-math (see the relevant section here
llvm/clang/docs/UsersManual.rst
Line 1462 in 0267c1b
| .. option:: -fno-fast-math |
-fno-fast-math did not work in the nvptx64 backend for these tests (they still failed). I also find that there is at least one test that still fails for at least one opencl cpu device (scalar_math.cpp).I find that in both opencl cpu and nvptx64 backends, although you get different results when just passing
-ffast-math to the compiler (e.g. different fp contract behaviour) the effect of adding -fno-fast-math in front of -ffast-math to the output of -### is you get an extra "-fdenormal-fp-math-f32=ieee,ieee". So -fno-fast-math does not undo any of the math flags that are added by -ffast-math.
Since -ffast-math and -fno-fast-math also don't commute, sometimes the precision sensitive tests that dont like -ffast-math pass if I pass -fno-fast-math before -ffast-math, when they failed if the flags are passed in the opposite order.
In either ordering case, In the -fno-fast-math -ffast-math order, I find that the FAST_MATH macro is defined, which means that -fno-fast-math (when used in combination with -ffast-math) results in sycl math functions calling sycl native math functions. I believe this means that icpx currently has no way of calling sycl math functions for the cases where corresponding sycl native math functions exist. I suppose this should probably be considered a bug, since technically this would mean icpx cannot implement this part of the sycl math function specification.