-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add preference to disable LoopVectorization #2295
base: main
Are you sure you want to change the base?
Conversation
Review checklistThis checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging. Purpose and scope
Code quality
Documentation
Testing
Performance
Verification
Created with ❤️ by the Trixi.jl community. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2295 +/- ##
==========================================
- Coverage 96.91% 96.89% -0.02%
==========================================
Files 492 493 +1
Lines 40201 40212 +11
==========================================
+ Hits 38960 38961 +1
- Misses 1241 1251 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ 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.
Very nice! Just a small naming suggestion...
Why is |
src/Trixi.jl
Outdated
# TODO: We should insert !loopinfo !julia.ivdep !julia.simd | ||
# but SimdLoop.compile doesn't deal with nested for loops. | ||
# esc(Base.SimdLoop.compile(body, Symbol("julia.ivdep"))) | ||
return esc(body) |
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.
I believe @turbo
also implies @inbounds
. Right now this slows down simulations quite a bit.
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.
Yes, it does.
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.
Shall we go ahead with this PR as it is or would you like to change something?
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.
What kind of simulations do you look at to observe the significant slowdown?
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.
if Meta.isexpr(expr, :for) | ||
# TODO: Should we insert LLVM loopinfo or `julia.ivdep`? | ||
push!(expr.args, Expr(:loopinfo, Symbol("julia.simdloop"))) | ||
end |
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.
Can you add a few comments here, please? Is this a public API, or are you doing something that may break at any time?
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.
It's an internal API (https://github.com/JuliaLang/julia/blob/9f7cdfdc28290063ee021a5c6e180e82feee32c8/doc/src/devdocs/ast.md?plain=1#L464).
Most notably, it is used for the @simd
macro https://github.com/JuliaLang/julia/blob/9f7cdfdc28290063ee021a5c6e180e82feee32c8/base/simdloop.jl#L79
There is also an old PR of mine that exposes some more of the knobs available through this API, that is used by a couple of consumers JuliaLang/julia#31376
- https://github.com/JuliaSIMD/LLVMLoopInfo.jl/blob/main/src/LLVMLoopInfo.jl
- https://github.com/YingboMa/MaBLAS.jl/blob/master/src/loopinfo.jl
- https://github.com/JuliaGPU/KernelAbstractions.jl/blob/main/src/extras/loopinfo.jl
It is an internal API that directly interacts with the LLVM optimizer. It has not seen recent change, and I am not predicting any, worst case these annotations may be silently dropped.
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.
Thanks. It's fine with me in this case. Could you please add a few comments/links to the code, check the TODO note, and let me know when this PR is finished from your point of view?
Enzyme struggles with differentiation through the code that LoopVectorization
generates.
https://docs.sciml.ai/SciMLSensitivity/stable/faq/#How-do-I-isolate-potential-gradient-issues-and-improve-performance?
Is a good way to check if an Elixir's rhs is differentiable.
I ran into this when playing around with https://github.com/trixi-framework/Trixi.jl/blob/31e3c8fee15d9955af8c7c6a64e3bfcfea1c3e94/examples/p4est_2d_dgsem/elixir_navierstokes_NACA0012airfoil_mach08.jl and SciMLSensitivity.jl