Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions resolve/LinSolverDirectCuSparseILU0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,55 @@ namespace ReSolve
mem_.deleteOnDevice(d_aux1_);
mem_.deleteOnDevice(d_aux2_);
mem_.deleteOnDevice(d_ILU_vals_);

if (buffer_ != nullptr)
{
mem_.deleteOnDevice(buffer_);
buffer_ = nullptr;
}
if (buffer_L_ != nullptr)
{
mem_.deleteOnDevice(buffer_L_);
buffer_L_ = nullptr;
}
if (buffer_U_ != nullptr)
{
mem_.deleteOnDevice(buffer_U_);
buffer_U_ = nullptr;
}

if (descr_spsv_L_ != nullptr)
{
cusparseSpSV_destroyDescr(descr_spsv_L_);
descr_spsv_L_ = nullptr;
}
if (descr_spsv_U_ != nullptr)
{
cusparseSpSV_destroyDescr(descr_spsv_U_);
descr_spsv_U_ = nullptr;
}

if (mat_L_ != nullptr)
{
cusparseDestroySpMat(mat_L_);
mat_L_ = nullptr;
}
if (mat_U_ != nullptr)
{
cusparseDestroySpMat(mat_U_);
mat_U_ = nullptr;
}

if (info_A_ != nullptr)
{
cusparseDestroyCsrilu02Info(info_A_);
info_A_ = nullptr;
}
if (descr_A_ != nullptr)
{
cusparseDestroyMatDescr(descr_A_);
descr_A_ = nullptr;
}
}

int LinSolverDirectCuSparseILU0::setup(matrix::Sparse* A,
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/matrix/SparseTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ namespace ReSolve
// Clean up allocated memory
delete[] val_data;

// In the device case h_val_data is a scratch host buffer allocated
// above; on host it aliases the matrix-owned data and must not be freed.
if (memspace_ != memory::HOST)
{
delete[] h_val_data;
}

if (A.destroyMatrixData(memspace_) != 0)
{
std::cout << "Failed to destroy matrix data.\n";
Expand Down
Loading