Skip to content
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

Check isbanded in conversions #289

Merged
merged 2 commits into from
Feb 7, 2023

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Jan 10, 2023

While converting from an AbstractMatrix to a BandedMatrix, we may use a faster path if the argument is banded and has a BandedColumns{DenseColumnMajor}() memory layout .
On master

julia> D = Diagonal(rand(1000));

julia> @btime convert(BandedMatrix, $D);
  4.521 μs (4 allocations: 8.11 KiB)

julia> @btime BandedMatrix{Float32}($D);
  4.588 μs (2 allocations: 4.11 KiB)

julia> @btime BandedMatrix($D);
  2.396 μs (2 allocations: 7.98 KiB)

This PR

julia> @btime convert(BandedMatrix, $D);
  759.925 ns (6 allocations: 8.20 KiB)

julia> @btime BandedMatrix{Float32}($D);
  564.160 ns (4 allocations: 4.20 KiB)

julia> @btime BandedMatrix($D);
  641.483 ns (4 allocations: 8.06 KiB)

With some refactoring, all of these could become equally performant.

TBH I'm a bit surprised that this is necessary at all, since I would have thought that banded broadcast already handles this. Presumably, much of the gain comes from linear indexing and vectorization.

@codecov
Copy link

codecov bot commented Jan 10, 2023

Codecov Report

Base: 80.47% // Head: 80.59% // Increases project coverage by +0.12% 🎉

Coverage data is based on head (f357dfa) compared to base (7315691).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #289      +/-   ##
==========================================
+ Coverage   80.47%   80.59%   +0.12%     
==========================================
  Files          22       23       +1     
  Lines        3262     3283      +21     
==========================================
+ Hits         2625     2646      +21     
  Misses        637      637              
Impacted Files Coverage Δ
src/banded/BandedMatrix.jl 84.68% <100.00%> (+0.55%) ⬆️
src/interfaceimpl.jl 100.00% <100.00%> (ø)
src/BandedMatrices.jl 100.00% <0.00%> (ø)
src/generic/Band.jl 71.60% <0.00%> (+0.35%) ⬆️
src/lapack.jl 86.36% <0.00%> (+0.48%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dlfivefifty dlfivefifty merged commit 3cc0d8c into JuliaLinearAlgebra:master Feb 7, 2023
@jishnub jishnub deleted the bandedconvert branch February 16, 2023 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants