-
Notifications
You must be signed in to change notification settings - Fork 246
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
[Core] Optimizing code generated by sympy fe utilities #12872
Conversation
Oh, it can be done automatically. I did my own expansion at the time (I was aware of this) |
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
Just for my curiosity, what you mean by really bad for performance? @uxuech FYI. |
@rubenzorrilla it depends on the compiler, but it seems that in most cases, compilers use a different algorithm to compute pow(x,2) and x*x, being "pow" much slower as it needs to be more generic, so if you have a code that calls this function many times you can really feel the impact. I cant tell you exactly how much impact this has as we did several years ago, I think it was @jrubiogonzalez who found this solution. |
Good compilers decompose pow of integer values, but unfortunately compilers sometimes are not that smart. Specially for the compiler of very big company that owns this platform. |
|
I guess that very big company spends its time and money making its compiler worse. |
|
While we were doing the profile of our symbolic element for filling simulation (two fluid navier stokes) we found that using pow instead of just multiplying the terms was really bad for performance (I mean writing pow(x,2) instead of x*x )
It seems they are aware of this problem in sympy so that is why they added a function called "create_expand_pow_optimization" exactly to do this. We've been using in our side for a couple of years, but I'd like to use the code from the core now, so that is why Im bringing this optimization to sympy fe utilities now, so we all take advantage of this.