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

Combine updateL! operations on diagonal blocks #648

Merged
merged 4 commits into from
Oct 5, 2022
Merged

Conversation

dmbates
Copy link
Collaborator

@dmbates dmbates commented Oct 5, 2022

closes #643

  • Previously the sequence of operations in updateL! was to copy blocks of A to the corresponding block of L then iterate over the random effects terms scaling the diagonal block and inflating the diagonal.
  • This PR combines those operations on the diagonal blocks, replacing separate calls to copyto! and scaleinflate! by copyscaleinflate!.
  • This reduces the number of times iterating over the diagonal elements, which may help with further enhancements such as using RectangularFullPacked storage for triangular blocks of L.
  • Closes Amalgamate copyto! and scaleinflate! in updateL! #643

Did behavior change? Did you add need features? If so, please update NEWS.md

  • add entry in NEWS.md
  • after opening this PR, add a reference and run docs/NEWS-update.jl to update the cross-references.

Should we release your changes right away? If so, bump the version:

  • I've bumped the version appropriately

src/remat.jl Outdated Show resolved Hide resolved
src/remat.jl Outdated Show resolved Hide resolved
src/remat.jl Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 5, 2022

Codecov Report

Base: 94.24% // Head: 94.23% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (caf5685) compared to base (70e3dc8).
Patch coverage: 88.88% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #648      +/-   ##
==========================================
- Coverage   94.24%   94.23%   -0.02%     
==========================================
  Files          29       29              
  Lines        2797     2792       -5     
==========================================
- Hits         2636     2631       -5     
  Misses        161      161              
Impacted Files Coverage Δ
src/arraytypes.jl 94.11% <ø> (-0.62%) ⬇️
src/precompile_MixedModels.jl 0.00% <0.00%> (ø)
src/linearmixedmodel.jl 98.09% <100.00%> (ø)
src/remat.jl 96.98% <100.00%> (+<0.01%) ⬆️

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.

@dmbates dmbates requested a review from palday October 5, 2022 15:06
@inbounds for i in diagind(Ljj)
Ljj[i] *= lambsq
Ljj[i] += one(T)
@inbounds for (i, a) in enumerate(Ajj.diag)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we only ever create Diagonal{T, Vector{T}} this shouldn't cause trouble, but strictly speaking, there could be Diagonal{T, StarWarsVector{T}} which would cause undefined behavior with @inbounds

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone who chooses to use a StarWarsVector in real life deserves undefined behavior. 😄

@palday
Copy link
Member

palday commented Oct 5, 2022

@dmbates don't forget to bump the patch

@palday
Copy link
Member

palday commented Oct 5, 2022

coverage suggests you could delete this method:

function Base.copyto!(dest::UniformBlockDiagonal{T}, src::UniformBlockDiagonal{T}) where {T}
    sdat = src.data
    ddat = dest.data
    size(ddat) == size(sdat) || throw(DimensionMismatch(""))
    copyto!(ddat, sdat)
    return dest
end

@palday palday merged commit 72ac0e1 into main Oct 5, 2022
@palday palday deleted the copyscaleinflate branch October 5, 2022 17:54
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.

Amalgamate copyto! and scaleinflate! in updateL!
2 participants