-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Unwrap parent in triangular broadcast #55604
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
Author
|
This PR may be simplified quite a bit after #55626, as processing the structured matrices may not be necessary. |
jishnub
added a commit
that referenced
this pull request
Aug 30, 2024
This provides most of the benefits seen in #55604. The simpler implementation appears to help with branch-prediction in inferring the zero elements of the structured matrices. The improved performance as a consequence: ```julia julia> using LinearAlgebra julia> U = UpperTriangular(rand(3000,3000)); D = Diagonal(rand(size(U,1))); julia> @Btime $U .+ $D; 23.405 ms (3 allocations: 68.66 MiB) # nightly 15.266 ms (3 allocations: 68.66 MiB) # This PR ``` --------- Co-authored-by: Matt Bauman <[email protected]>
4e563f4 to
a8439c1
Compare
KristofferC
pushed a commit
that referenced
this pull request
Sep 12, 2024
This provides most of the benefits seen in #55604. The simpler implementation appears to help with branch-prediction in inferring the zero elements of the structured matrices. The improved performance as a consequence: ```julia julia> using LinearAlgebra julia> U = UpperTriangular(rand(3000,3000)); D = Diagonal(rand(size(U,1))); julia> @Btime $U .+ $D; 23.405 ms (3 allocations: 68.66 MiB) # nightly 15.266 ms (3 allocations: 68.66 MiB) # This PR ``` --------- Co-authored-by: Matt Bauman <[email protected]>
a8439c1 to
bf12d91
Compare
KristofferC
pushed a commit
to JuliaLang/LinearAlgebra.jl
that referenced
this pull request
Nov 14, 2024
This provides most of the benefits seen in JuliaLang/julia#55604. The simpler implementation appears to help with branch-prediction in inferring the zero elements of the structured matrices. The improved performance as a consequence: ```julia julia> using LinearAlgebra julia> U = UpperTriangular(rand(3000,3000)); D = Diagonal(rand(size(U,1))); julia> @Btime $U .+ $D; 23.405 ms (3 allocations: 68.66 MiB) # nightly 15.266 ms (3 allocations: 68.66 MiB) # This PR ``` --------- Co-authored-by: Matt Bauman <[email protected]>
Member
|
We have moved the LinearAlgebra stdlib to an external repo: https://github.com/JuliaLang/LinearAlgebra.jl @jishnub If you think that this PR is still relevant, please open a new PR on the LinearAlgebra.jl repo. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This replaces
AbstractTriangularmatrices by their parents in certain broadcast operations, where we only loop over the filled half. We also replaceDiagonal/Bidiagonal/Tridiaognal/SymTridiagonalmatrices by the corresponding zeros away from the bands. As a consequence, this removes branching in the indexing operations in the broadcast, which improves performance considerably.Also
Most of the performance gain comes from replacing the
Diagonalbyzero(eltype(D))in the broadcasting. It's a bit surprising that branch-prediction doesn't do this already.