-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dialects: (riscv_snitch) add fastmath flags in vector ops #2913
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2913 +/- ##
=======================================
Coverage 89.90% 89.90%
=======================================
Files 403 403
Lines 50424 50424
Branches 7788 7788
=======================================
Hits 45334 45334
Misses 3862 3862
Partials 1228 1228 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do RISC-V operations have fast math actually? I'd have thought that fast math would be gone past instruction selection (aka arith to riscv lowering).
Does this enable anything that cannot be done on arith
?
fmadd |
I'd have expected this to be implemented within Shouldn't be a correctness issue though I guess, so if this is the state of the world then so be it. |
My understanding is that this follows the behaviour of LLVM, although we might want to diverge from it. Also, isn't that the definition of fastmath, to diverge from the semantics? |
Can you clarify how this 'follows the behaviour of LLVM'. I am not sure what you are precisely referring to. It might indeed be interesting to investigate how LLVM implements fastmath. Typically fastmath flags are at the LLVM-IR level, but I am unsure if it also maintains them in the backend. It may or may not, and I would find it useful to understand what LLVM does. In general, we should follow LLVM except if there good reasons to do sth different. |
What I mean is that LLVM did emit fmadd instructions in our flow without the fastmath flags. I think @compor initially added the flags to our experimental setup and set up the corresponding infrastructure in xDSL to make sure that we also emit fmadd instructions when explicitly specified by the user. |
Are you saying for C-code that was compiled with clang, fmadds were created. Or that LLVM-IR that you generated without fastmath flags was fused by LLVM (or later in its backend). The link you posted suggests that only the former is legal. On the other hand, @nazavode's research seems to suggest that LLVM indeed maintains fastmath flags up until the very end. |
What I'm saying is with the flags, fmadds were created by the backend, and without they were not. |
It feels like fastmath is still appropriate on the vector ops, also it will make the lowering a little less tedious, by making the vector and scalar arithmetic ops a little more uniform.