Fix cuSPARSE handle and test buffer leaks under ASAN - #461
Closed
zjin-lcf wants to merge 1 commit into
Closed
Conversation
The CuSPARSE ILU0 direct solver allocated matrix descriptors, sparse matrix descriptors, SpSV descriptors, an ILU02 info structure, and three device work buffers in setup() but never released them, so every solver instance leaked these resources. Under AddressSanitizer these surfaced as leaks originating from libcusparse, causing unit tests to fail. Release all of these resources in the destructor. Also free the scratch host buffer allocated in the device path of the sparse matrix copy test, which leaked on device builds. Fixes ORNL#387 Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
|
@zjin-lcf, thank you for your contribution. Please re-open the pull request when reproducible test results (before and after) are available together with hardware specs and CUDA version. Closing for now. |
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.
Summary
Addresses #387. When ReSolve is built with the address sanitizer (
-DRESOLVE_USE_ASAN=yes) on CUDA, many unit tests fail with leaks reported fromlibcusparse. The root cause is that the cuSPARSE ILU0 direct solver never releases the cuSPARSE resources it creates.LinSolverDirectCuSparseILU0::setup()allocates:descr_A_),mat_L_,mat_U_),descr_spsv_L_,descr_spsv_U_),csrilu02Info_tinfo structure (info_A_),buffer_,buffer_L_,buffer_U_),but the destructor only freed
d_aux1_,d_aux2_, andd_ILU_vals_. Every solver instance therefore leaked the descriptors, info struct, and buffers, which ASAN attributes to the cuSPARSE library.Changes
~LinSolverDirectCuSparseILU0().tests/unit/matrix/SparseTests.hpp), which leaked on device builds.This mirrors the approach taken for the rocSPARSE analog in #388.
Notes
Some of the allocations reported by ASAN in the issue originate inside NVIDIA libraries (
libcuda/libcublasone-time initialization viacuInit) and are outside ReSolve's control; those are not addressed here.Test plan
-DRESOLVE_USE_ASAN=yes -DRESOLVE_USE_UBSAN=yes -DRESOLVE_USE_CUDA=yesand runctest -j; verify the previously failing tests no longer report leaks from the ILU0 solver or the sparse matrix copy test.