Skip to content

Conversation

@jishnub
Copy link
Member

@jishnub jishnub commented Feb 26, 2025

Currently. rmul!(A'::Adjoint, D::Diagonal) loops over CartesianIndices(A'), which is not cache-friendly. In this PR, we use the fact that A' = A' * D may be rewritten as A = D' * A, and that D' isa Diagonal by design. The operation therefore becomes lmul!(D'::Diagonal, A), which is cache-friendly.
On master,

julia> using LinearAlgebra, Chairmarks

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

julia> A = rand(size(D)...);

julia> @b (A', D) rmul!(_[1], _[2])
103.276 ms

whereas, with this PR,

julia> @b (A', D) rmul!(_[1], _[2])
9.994 ms

@jishnub jishnub added the performance Must go faster label Feb 26, 2025
@codecov
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.00%. Comparing base (f781708) to head (a9ee0f5).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1229      +/-   ##
==========================================
+ Coverage   91.93%   92.00%   +0.06%     
==========================================
  Files          34       34              
  Lines       15392    15400       +8     
==========================================
+ Hits        14151    14168      +17     
+ Misses       1241     1232       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jishnub jishnub merged commit 508e77f into master Feb 27, 2025
4 checks passed
@jishnub jishnub deleted the jishnub/rmul_adjtrans branch February 27, 2025 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants