Fix memory handling in KLU examples#449
Open
tamar-dewilde wants to merge 3 commits into
Open
Conversation
shakedregev
reviewed
Jul 14, 2026
shakedregev
left a comment
Collaborator
There was a problem hiding this comment.
This looks good, but I unfortunately can't test yet. Can you double check all the examples and add them to this PR if they need similar fixes?
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
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.
Description
Fixes the missing host allocation in the KLU examples reported in #448.
Both
kluFactor.cppandkluRefactor.cppcreate the solution vector but do not allocate its host storage before calling the KLU solve. This causes the solve to report:and
kluRefactor.exethen terminates with a segmentation fault.I also checked the remaining examples and found similar memory handling issues in four experimental KLU examples. These changes allocate host and device storage once, synchronize updated data before device use, and clean up the allocated objects.
The FGMRES example stored a pointer to a local preconditioner that was destroyed at the end of the iteration. The preconditioner now remains valid until cleanup.
Closes #448
@shakedregev
Proposed changes
kluFactor.cpp.kluRefactor.cpp.vec_rhs, the solver objects, and the handlers in the correct order.Checklist
make testandmake test_installper testing instructions). Code tested on-Wall -Wpedantic -Wconversion -Wextra.CHANGELOG.md.Further comments
On the current
developbranch,kluRefactor.exelater reaches a separate allocation failure inExampleHelper::printSummary(). That issue is addressed in #447. With the pending #447 fix temporarily applied, the 20-system ACTIVSg10k run completes with exit code 0.The experimental CUDA RF examples complete their initial KLU solves but still fail in the later RF path because of the separate factor transfer issue tracked in #451.
The experimental GLU example no longer reports allocation errors and its initial solve succeeds, but the later updated systems still produce inaccurate residuals. That issue is separate from the memory handling changes in this PR.