Add workspace to Factor for allocation-free CHOLMOD solves#727
Add workspace to Factor for allocation-free CHOLMOD solves#727lorenzogambichler wants to merge 5 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #727 +/- ##
==========================================
+ Coverage 84.40% 84.42% +0.02%
==========================================
Files 13 13
Lines 9372 9381 +9
==========================================
+ Hits 7910 7920 +10
+ Misses 1462 1461 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
We already have a |
|
I see, this is a good point. It seems like that is essentially how UmfpackLU handles the workspace caching? I'll rework the PR to add a workspace on the Factor with a default getworkspace accessor, essentially trying to mirror UmfpackLU. |
…s cholmod_dense_struct wrappers and Y/E buffers so cholmod_solve2 reuses them across calls instead of reallocating
…similar to UmfpackWS inside UmfpackLU
5923f2f to
d1b785c
Compare
|
Instead of an optional workspace argument, the workspace now lives inside the Factor. I tried to keep it similar to UmfpackWS and UmfpackLU in umfpack.jl. This keeps the 3-arg ldiv! API, while making it allocation-free. |
| The workspace is finalizer-protected. The Y and E buffers are freed automatically | ||
| when the workspace is garbage-collected. | ||
| """ | ||
| mutable struct CholmodWorkspace |
There was a problem hiding this comment.
Not sure it's worth having a separate struct type here, as opposed to just making them fields of Factor
There was a problem hiding this comment.
The main arguments for the separate struct are that it keeps the finalizer for the cholmod buffers separate from the free!s for the cholmod_factor pointer and it allows using a single :workspace enttry inside getproperty instead of five. The performance overhead should be negligible too. If you prefer the inline version, I can do that though.
There was a problem hiding this comment.
What's the advantage of keeping the finalizer separate?
Can one ever use the workspace separately from a factor, or share the workspace between multiple factors?
There was a problem hiding this comment.
It's exactly one set of buffers per factor, right. I've added the fields directly to Factor.
Addresses #726
Makes repeated solves against a fixed sparse Cholesky factorization allocation-free by reusing CHOLMOD's
cholmod_solve2Y/Ebuffers across calls. EachFactorstores its own reusable workspace and aReentrantLock, so the existing API stays the same and eliminates all julia-sided allocations.