Skip to content

Commit 3ca5664

Browse files
Merge pull request #98 from PFLAREProject/memory_leak_poly_kokkos_mpi
Fixed memory leak on the host in mat_mult_powers_share_sparsity_kokko…
2 parents 17d285d + 0997eaa commit 3ca5664

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/Gmres_Polyk.kokkos.cxx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ PETSC_INTERN void mat_mult_powers_share_sparsity_kokkos(Mat *input_mat, const in
6565
// Duplicate & copy the matrix, but ensure there is a diagonal present
6666
mat_duplicate_copy_plus_diag_kokkos(mat_sparsity_match, reuse_int_cmat, output_mat);
6767

68-
PetscInt *col_indices_off_proc_array, *row_indices_array;
68+
PetscInt *col_indices_off_proc_array;
6969
IS col_indices, row_indices;
7070
Mat *submatrices;
7171

@@ -86,7 +86,6 @@ PETSC_INTERN void mat_mult_powers_share_sparsity_kokkos(Mat *input_mat, const in
8686
// and the nonlocal rows that correspond to the nonlocal columns
8787
// from the input mat
8888
PetscMalloc1(cols_ad + cols_ao, &col_indices_off_proc_array);
89-
PetscMalloc1(cols_ao, &row_indices_array);
9089
size_cols = cols_ad + cols_ao;
9190
for (PetscInt i = 0; i < cols_ad; i++)
9291
{
@@ -95,14 +94,13 @@ PETSC_INTERN void mat_mult_powers_share_sparsity_kokkos(Mat *input_mat, const in
9594
for (PetscInt i = 0; i < cols_ao; i++)
9695
{
9796
col_indices_off_proc_array[cols_ad + i] = mat_mpi->garray[i];
98-
row_indices_array[i] = mat_mpi->garray[i];
9997
}
10098

10199
// Create the sequential IS we want with the cols we want (written as global indices)
102100
ISCreateGeneral(PETSC_COMM_SELF, size_cols, \
103101
col_indices_off_proc_array, PETSC_USE_POINTER, &col_indices);
104102
ISCreateGeneral(PETSC_COMM_SELF, cols_ao, \
105-
row_indices_array, PETSC_USE_POINTER, &row_indices);
103+
mat_mpi->garray, PETSC_USE_POINTER, &row_indices);
106104

107105
MatSetOption(*input_mat, MAT_SUBMAT_SINGLEIS, PETSC_TRUE);
108106
// Now this will be doing comms to get the non-local rows we want and returns in a sequential matrix
@@ -185,9 +183,6 @@ PETSC_INTERN void mat_mult_powers_share_sparsity_kokkos(Mat *input_mat, const in
185183
// Add in the 0th order term
186184
MatShift(*output_mat, coefficients[0]);
187185

188-
PetscInt local_rows_submat, local_cols_submat;
189-
MatGetLocalSize(submatrices[0], &local_rows_submat, &local_cols_submat);
190-
191186
// ~~~~~~~~~~~~~~
192187
// Find maximum non-zeros per row for sizing scratch memory
193188
// ~~~~~~~~~~~~~~
@@ -514,7 +509,7 @@ PETSC_INTERN void mat_mult_powers_share_sparsity_kokkos(Mat *input_mat, const in
514509
}
515510
delete[] matrix_powers;
516511
if (deallocate_submatrices) delete[] submatrices;
517-
(void)(col_indices_off_proc_array);
512+
(void)PetscFree(col_indices_off_proc_array);
518513

519514
return;
520515
}

0 commit comments

Comments
 (0)