Make @fastmath aware of Base.literal_pow#21099
Make @fastmath aware of Base.literal_pow#21099ajkeller34 wants to merge 1 commit intoJuliaLang:masterfrom
@fastmath aware of Base.literal_pow#21099Conversation
|
dunno if nanosoldier will really notice lowering performance, but may as well trigger @nanosoldier |
|
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
|
It would make more sense to do this in the |
100% – we can't go around having special cases for every macro anyone might need special behavior for in the parser. |
|
Yeah, good point, I'll see what I can do. |
|
Updated, this approach seems much better and obvious in retrospect. I guess this is what happens when you learn about how lisp works for the first time and get a little too exuberant. |
Base.FastMath.pow_fast(x,p) for integer literal p... @fastmath aware of Base.literal_pow
|
Let's rerun CI and Nanosoldier and try get this merged. |
|
@nanosoldier |
|
It would be nice to have |
|
Tests seems to fail now. Is it because the |
|
I updated the PR, squashed, and rebased. |
|
@KristofferC want to try triggering nanosoldier again? Looks like the tests passed (travis timed out for likely unrelated reasons). |
|
Another Nanosoldier run is unlikely to work, Nanosoldier itself is still having problems (unrelated to this PR) |
|
I thought it worked a few times yesterday @nanosoldier |
|
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
|
It's been working randomly but failing most of the time |
@fastmath aware of Base.literal_pow@fastmath aware of Base.literal_pow
|
This is ready to merge as far as I can tell. Does anything else need to be done here? |
|
Bump. |
|
Any chance of merging this? |
|
From triage: seems fine, just rebase please. |
|
Rebased. |
|
The test this PR adds is the one that's failing. |
|
Interacting badly with #24240, will fix. |
|
Actually, #24240 already seems to fix this issue in another way — So maybe this can be closed? |
as
Base.literal_pow(Base.FastMath.pow_fast, x, Val{p}).Thanks to PRs #20530 and #20889, exponentiation of a dimensionful quantity can be type-stable in some important circumstances. However, because macro expansion occurs before the
Vallowering happens,@fastmath x^2cannot be type-stable for dimensionful quantities, whereasx^2could be. This is because@fastmath x^2is macro-expanded toBase.FastMath.pow_fast(x,2)and so we can never catch the^symbol. See the tests I added to get an idea of how this works.Provided the premise of this PR isn't flawed somehow, it would probably good to have someone more familiar with
julia_syntax.scmsee if there’s a better way to implement this change. Because I tie into the mechanism introduced in #20889 I don't expect any "surprising behaviors" to be introduced here, though I haven't checked to see if there are any performance implications.