-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Same function, same arguments, different generated code #20913
Comments
Also note that the built in sum time is slower than the one I wrote up there (although probably more robust against accumulating floating point errors): julia> @btime sum($m)
17.394 ns (0 allocations: 0 bytes)
36.441929014270464 |
What's |
Sorry! |
julia> @btime sum2($m);
9.603 ns (0 allocations: 0 bytes)
julia> @btime sum3($m);
9.341 ns (0 allocations: 0 bytes) EDIT: Above timings were for 5x5 matrix. For 8x8: julia> @btime sum2($m);
111.510 ns (0 allocations: 0 bytes)
julia> @btime sum3($m);
9.231 ns (0 allocations: 0 bytes) |
What version? Is the generated code the same for you? |
My master was 11 days old... maybe it has been fixed already. Will look. |
I got the same generated code but for a 5x5 case. See my edit in the comment above. |
Yes for 5x5 I think everything gets unrolled. |
Same result on 0.5. |
The only difference in IR seems to be a constant 0.0 vs. |
That would be either a serious bug in LLVM or a pass order problem. Either way we should find out. |
Any ideas here? AFAIU this inihibits simd for the reductions in StaticArrays. |
Still happens |
This seems to be fixed on 0.7 🎉.
|
Consider the following small fixedsize matrix implementation together with a reduce function and two implementations of
sum
:Now,
sum2
andsum3
will (should?) clearly call the same method with the same arguments when the matrix is of typeFloat64
(which I confirmed by putting a@which
in there).However:
In fact, the generated code is vastly different (one uses SIMD, the other one does not).
How can so different code be generated when the exact same function is called with the same arguments?
The text was updated successfully, but these errors were encountered: