Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tpetra: early exit from CRS remove zeros #11715

Merged
merged 1 commit into from
Mar 24, 2023
Merged
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
14 changes: 11 additions & 3 deletions packages/tpetra/core/src/Tpetra_CrsMatrix_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4141,10 +4141,18 @@ namespace Tpetra {
Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::magnitude( Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::zero() ))
{
auto localMatrix = matrix.getLocalMatrixDevice();
size_t nnzBefore = localMatrix.nnz();
localMatrix = KokkosSparse::removeCrsMatrixZeros(localMatrix,threshold);
matrix.resumeFill();
matrix.setAllValues(localMatrix);
matrix.expertStaticFillComplete(matrix.getDomainMap(),matrix.getRangeMap());
size_t localNNZRemoved = nnzBefore - localMatrix.nnz();
//Skip the expertStaticFillComplete if no entries were removed on any process.
//The fill complete can perform MPI collectives, so it can only be skipped on all processes or none.
size_t globalNNZRemoved = 0;
Teuchos::reduceAll<int, size_t> (*(matrix.getComm()), Teuchos::REDUCE_SUM, 1, &localNNZRemoved, &globalNNZRemoved);
if(globalNNZRemoved != size_t(0)) {
matrix.resumeFill();
matrix.setAllValues(localMatrix);
matrix.expertStaticFillComplete(matrix.getDomainMap(),matrix.getRangeMap());
}
}

} // namespace Tpetra
Expand Down