Skip to content

Commit

Permalink
Merge Pull Request trilinos#6623 from trilinos/Trilinos/csiefer-8683cc9
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: MueLu: Adding timer granularity to Kokkos-ized prolongator smoothing
PR Author: csiefer2
  • Loading branch information
trilinos-autotester authored Jan 21, 2020
2 parents 2a8abf5 + 8683cc9 commit 6c249fc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,19 @@ namespace MueLu {

{
SubFactoryMonitor m2(*this, "Fused (I-omega*D^{-1} A)*Ptent", coarseLevel);
RCP<Vector> invDiag = Utilities_kokkos::GetMatrixDiagonalInverse(*A);

RCP<Vector> invDiag;
{
SubFactoryMonitor m3(*this, "Diagonal Extraction", coarseLevel);
invDiag = Utilities_kokkos::GetMatrixDiagonalInverse(*A);
}
SC omega = dampingFactor / lambdaMax;
TEUCHOS_TEST_FOR_EXCEPTION(!std::isfinite(Teuchos::ScalarTraits<SC>::magnitude(omega)), Exceptions::RuntimeError, "Prolongator damping factor needs to be finite.");

// finalP = Ptent + (I - \omega D^{-1}A) Ptent
finalP = Xpetra::IteratorOps<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Jacobi(omega, *invDiag, *A, *Ptent, finalP, GetOStream(Statistics2), std::string("MueLu::SaP-") + toString(coarseLevel.GetLevelID()), APparams);
{
SubFactoryMonitor m3(*this, "Xpetra::IteratorOps::Jacobi", coarseLevel);
// finalP = Ptent + (I - \omega D^{-1}A) Ptent
finalP = Xpetra::IteratorOps<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Jacobi(omega, *invDiag, *A, *Ptent, finalP, GetOStream(Statistics2), std::string("MueLu::SaP-") + toString(coarseLevel.GetLevelID()), APparams);
}
}

} else {
Expand Down
1 change: 1 addition & 0 deletions packages/muelu/src/Utils/MueLu_UtilitiesBase_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ namespace MueLu {
NOTE -- it's assumed that A has been fillComplete'd.
*/
static RCP<Vector> GetMatrixDiagonalInverse(const Matrix& A, Magnitude tol = Teuchos::ScalarTraits<Scalar>::eps()*100) {
Teuchos::TimeMonitor MM = *Teuchos::TimeMonitor::getNewTimer("UtilitiesBase::GetMatrixDiagonalInverse");

RCP<const Matrix> rcpA = Teuchos::rcpFromRef(A);

Expand Down
7 changes: 4 additions & 3 deletions packages/muelu/src/Utils/MueLu_Utilities_kokkos_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ namespace MueLu {
Teuchos::RCP<Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
Utilities_kokkos<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
GetMatrixDiagonalInverse(const Matrix& A, Magnitude tol) {
Teuchos::TimeMonitor MM = *Teuchos::TimeMonitor::getNewTimer("Utilities_kokkos::GetMatrixDiagonalInverse");
// Some useful type definitions
using local_matrix_type = typename Matrix::local_matrix_type;
using local_graph_type = typename local_matrix_type::staticcrsgraph_type;
Expand All @@ -154,14 +155,13 @@ namespace MueLu {

// Get/Create distributed objects
RCP<const Map> rowMap = A.getRowMap();
RCP<Vector> diag = VectorFactory::Build(rowMap);
RCP<Vector> diag = VectorFactory::Build(rowMap,false);

// Now generate local objects
local_matrix_type localMatrix = A.getLocalMatrix();
local_graph_type localGraph = localMatrix.graph;
auto diagVals = diag->template getLocalView<memory_space>();

ordinal_type numRows = localGraph.numRows();
ordinal_type numRows = localMatrix.graph.numRows();

// Note: 2019-11-21, LBV
// This could be implemented with a TeamPolicy over the rows
Expand All @@ -180,6 +180,7 @@ namespace MueLu {
} else {
diagVals(rowIdx, 0) = KAT::zero();
}
break;
}
}

Expand Down

0 comments on commit 6c249fc

Please sign in to comment.