-
-
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
Remove fast paths when scaling arrays #29726
Conversation
This reverts commit 0ba31aa.
the Julia implementations are as fast. Clean up.
εδ = eps(one(nrm))/δ | ||
rmul!(v, εδ) | ||
rmul!(v, inv(nrm*εδ)) | ||
end | ||
|
||
return v | ||
v |
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.
-1 for removing explicit returns.
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'm ok for both style. But I want the consistency of the same module.
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 added the return
in the commit I'm reverting and I'm no longer touching that function. I also prefer explicit return statements.
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.
Oops, sorry.
suggests there is a performance difference? |
That is a long vector. I only tested up to julia> @btime LinearAlgebra.generic_rmul!(y, 0.4) setup=(y=randn(10^6));
305.301 μs (0 allocations: 0 bytes)
julia> @btime BLAS.scal!(length(y), 0.4, y, 1) setup=(y=randn(10^6));
380.453 μs (0 allocations: 0 bytes) Maybe multithreading has a little effect for very long vectors. |
I get
on a 2015 MBP so I guess it depends on the cpu. |
I'll merge. There might be some architectures where BLAS is a bit faster that us but it looks like the opposite is also the case and for smaller arrays, I think we are generally as faster or faster. This is not an operation where we should expect BLAS to do better than LLVM. |
Too big of a behavior change to backport. |
What is breaking about this change? The description and discussion make it seem like a removal of a unhelpful fast path but the "minor change" label and the fact that this seems to have broken BandedMatrices and BlockArrays indicates that it's breaking. |
Julia 1.0.2
while on master (due to this PR)
(which is the reason both of those packages fail). |
The new behavior seems like a bug fix... |
It is a bug fix. I'll take a look at the packages that break because of this to figure out what is going on. |
Even though it's a bug fix I think we should lean conservative with point releases and not backport. |
This was removed from the backport list for 1.0.2 because it broke packages. (#29726 (reference)) |
This broke a single test in each of the two packages we know are affected by this and the maintainer is aware of this change. The two tests specifically tested the buggy behavior, i.e. the failures weren't indirect from other functions that relied on this behavior. We are not aware of any other cases where this change has had an effect. |
So what you are saying is that you want this in 1.0.3? |
Never mind. I read this as a discussion of exclusion from 1.1 and missed that Stefan said point release. |
As pointed out in #29691 (comment). If the scaled array contains
Inf
orNaN
then the fast path wasn't valid. This bug was also in BLAS so two array scaling methods no longer call BLAS for large arrays. I couldn't measure any slowdown. It's a very simple function so this isn't a surprise.This reverts commit 0ba31aa but still fixes #29681.