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

Trilinos Master Merge PR Generator: Auto PR created to promote from master_merge_20210804_000543 branch to master #9521

Merged
merged 9 commits into from
Aug 4, 2021
2 changes: 1 addition & 1 deletion cmake/TPLs/FindTPLCholmod.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES( Cholmod
REQUIRED_HEADERS cholmod.h cholmod_core.h
REQUIRED_LIBS_NAMES libcholmod.a libamd.a libcolamd.a libsuitesparseconfig.a
REQUIRED_LIBS_NAMES libcholmod.a libamd.a libcolamd.a libccolamd.a libcamd.a libsuitesparseconfig.a
)


15 changes: 10 additions & 5 deletions packages/muelu/src/Utils/MueLu_Utilities_kokkos_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ namespace MueLu {

/*! @brief Extract Matrix Diagonal

Returns Matrix diagonal in ArrayRCP.
Returns Matrix diagonal in RCP<Vector>.

NOTE -- it's assumed that A has been fillComplete'd.
*/
static Teuchos::ArrayRCP<SC> GetMatrixDiagonal(const Matrix& A); // FIXME
static RCP<Vector> GetMatrixDiagonal(const Matrix& A); // FIXME

/*! @brief Extract Matrix Diagonal

Expand Down Expand Up @@ -269,7 +269,7 @@ namespace MueLu {
static void ZeroDirichletRows(RCP<MultiVector>& X, const Kokkos::View<const bool*, typename NO::device_type>& dirichletRows, SC replaceWith=Teuchos::ScalarTraits<SC>::zero());

static void ZeroDirichletCols(RCP<Matrix>& A, const Kokkos::View<const bool*, typename NO::device_type>& dirichletCols, SC replaceWith=Teuchos::ScalarTraits<SC>::zero());

static void ApplyRowSumCriterion(const Matrix& A,
const typename Teuchos::ScalarTraits<Scalar>::magnitudeType rowSumTol,
Kokkos::View<bool*, typename NO::device_type> & dirichletRows);
Expand Down Expand Up @@ -380,8 +380,13 @@ namespace MueLu {
#endif
static RCP<Xpetra::Matrix<SC,LO,GO,NO> > Crs2Op(RCP<CrsMatrix> Op) { return Utilities::Crs2Op(Op); }

static ArrayRCP<SC> GetMatrixDiagonal(const Matrix& A) {
return UtilitiesBase::GetMatrixDiagonal(A);
static RCP<Vector> GetMatrixDiagonal(const Matrix& A) {
const auto rowMap = A.getRowMap();
auto diag = Xpetra::VectorFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Build(rowMap,true);

A.getLocalDiagCopy(*diag);

return diag;
}
static RCP<Vector> GetMatrixDiagonalInverse(const Matrix& A, Magnitude tol = Teuchos::ScalarTraits<SC>::eps()*100, const bool doLumped=false) {
return UtilitiesBase::GetMatrixDiagonalInverse(A, tol, doLumped);
Expand Down
47 changes: 14 additions & 33 deletions packages/muelu/src/Utils/MueLu_Utilities_kokkos_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,13 @@ namespace MueLu {


template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
Teuchos::ArrayRCP<Scalar> Utilities_kokkos<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
Teuchos::RCP<Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
Utilities_kokkos<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
GetMatrixDiagonal(const Matrix& A) {
// FIXME_KOKKOS
const auto rowMap = A.getRowMap();
auto diag = Xpetra::VectorFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(rowMap, true);

size_t numRows = A.getRowMap()->getNodeNumElements();
Teuchos::ArrayRCP<SC> diag(numRows);

Teuchos::ArrayView<const LO> cols;
Teuchos::ArrayView<const SC> vals;
for (size_t i = 0; i < numRows; ++i) {
A.getLocalRowView(i, cols, vals);

LO j = 0;
for (; j < cols.size(); ++j) {
if (Teuchos::as<size_t>(cols[j]) == i) {
diag[i] = vals[j];
break;
}
}
if (j == cols.size()) {
// Diagonal entry is absent
diag[i] = Teuchos::ScalarTraits<SC>::zero();
}
}
A.getLocalDiagCopy(*diag);

return diag;
} //GetMatrixDiagonal
Expand Down Expand Up @@ -226,11 +209,9 @@ namespace MueLu {
crsOp->getLocalDiagCopy(*localDiag,offsets());
}
else {
ArrayRCP<SC> localDiagVals = localDiag->getDataNonConst(0);
Teuchos::ArrayRCP<SC> diagVals = GetMatrixDiagonal(A);
for (LO i = 0; i < localDiagVals.size(); i++)
localDiagVals[i] = diagVals[i];
localDiagVals = diagVals = null;
auto localDiagVals = localDiag->getDeviceLocalView(Xpetra::Access::ReadWrite);
const auto diagVals = GetMatrixDiagonal(A)->getDeviceLocalView(Xpetra::Access::ReadOnly);
Kokkos::deep_copy(localDiagVals, diagVals);
}

RCP<Vector> diagonal = VectorFactory::Build(colMap);
Expand Down Expand Up @@ -612,7 +593,7 @@ namespace MueLu {
return MueLu::ZeroDirichletCols<double,int,int,Node>(A, dirichletCols, replaceWith);
}

// Applies rowsum criterion
// Applies rowsum criterion
template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
void ApplyRowSumCriterion(const Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>& A,
const typename Teuchos::ScalarTraits<Scalar>::magnitudeType rowSumTol,
Expand Down Expand Up @@ -711,7 +692,7 @@ namespace MueLu {
<device, typename local_graph_type::row_map_type, typename local_graph_type::entries_type, lno_nnz_view_t>
(localGraph.row_map, localGraph.entries);

RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> > retval =
RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> > retval =
Xpetra::VectorFactory<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node>::Build(Op.getRowMap());

// Copy out and reorder data
Expand All @@ -723,7 +704,7 @@ namespace MueLu {
});
return retval;
}

template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
Teuchos::RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> > CuthillMcKee(const Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Op) {
using local_matrix_type = typename Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>::local_matrix_type;
Expand All @@ -740,7 +721,7 @@ namespace MueLu {
<device, typename local_graph_type::row_map_type, typename local_graph_type::entries_type, lno_nnz_view_t>
(localGraph.row_map, localGraph.entries);

RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> > retval =
RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> > retval =
Xpetra::VectorFactory<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node>::Build(Op.getRowMap());

// Copy out data
Expand All @@ -761,7 +742,7 @@ namespace MueLu {
}

template <class Node>
Teuchos::RCP<Xpetra::Vector<int,int,int,Node> >
Teuchos::RCP<Xpetra::Vector<int,int,int,Node> >
Utilities_kokkos<double,int,int,Node>::ReverseCuthillMcKee(const Matrix &Op) {
return MueLu::ReverseCuthillMcKee<double,int,int,Node>(Op);
}
Expand All @@ -773,7 +754,7 @@ namespace MueLu {
}

template <class Node>
Teuchos::RCP<Xpetra::Vector<int,int,int,Node> >
Teuchos::RCP<Xpetra::Vector<int,int,int,Node> >
Utilities_kokkos<double,int,int,Node>::CuthillMcKee(const Matrix &Op) {
return MueLu::CuthillMcKee<double,int,int,Node>(Op);
}
Expand Down
Loading