Skip to content

Commit a3f3f89

Browse files
Fixed indexing error with mpi in mat_mult_powers_share_sparsity_kokkos where we were accessing out of bounds an array
1 parent 3ca5664 commit a3f3f89

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Gmres_Polyk.kokkos.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,17 +334,19 @@ PETSC_INTERN void mat_mult_powers_share_sparsity_kokkos(Mat *input_mat, const in
334334
PetscInt row_of_col_j;
335335
// Do we have this row locally or have we retrieved it from other ranks?
336336
const bool row_of_col_j_local = j < local_cols_row_i;
337+
// This is only accesssed below if row_of_col_j_local is true
338+
PetscInt local_cols_row_of_col_j = 0;
337339
if (row_of_col_j_local)
338340
{
339341
row_of_col_j = device_local_j_sparsity[device_local_i_sparsity[i] + j];
342+
local_cols_row_of_col_j = device_local_i_input[row_of_col_j + 1] - device_local_i_input[row_of_col_j];
340343
}
341344
else
342345
{
343346
row_of_col_j = device_nonlocal_j_sparsity[device_nonlocal_i_sparsity[i] + (j - local_cols_row_i)];
344347
}
345348

346-
// Get how many local and non-local columns there are in the row of column j
347-
const PetscInt local_cols_row_of_col_j = device_local_i_input[row_of_col_j + 1] - device_local_i_input[row_of_col_j];
349+
// Get how many local and non-local columns there are in the row of column j
348350
PetscInt ncols_row_of_col_j = 0;
349351
if (row_of_col_j_local)
350352
{

0 commit comments

Comments
 (0)