Skip to content

Commit

Permalink
Merge pull request #10815 from cgcgcg/mueluGetMatrixDiagonalInverse
Browse files Browse the repository at this point in the history
MueLu_Utilities_kokkos: GetMatrixDiagonalInverse Kokkos impl for all GO
  • Loading branch information
cgcgcg authored Aug 8, 2022
2 parents db63ea8 + 60f56ff commit 35b4d4d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/muelu/example/basic/mg-gpu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<!-- =========== AGGREGATION =========== -->
<Parameter name="aggregation: type" type="string" value="uncoupled"/>
<Parameter name="aggregation: drop scheme" type="string" value="classical"/>
<Parameter name="aggregation: deterministic" type="bool" value="true"/>
<!-- Uncomment the next line to enable dropping of weak connections, which can help AMG convergence
for anisotropic problems. The exact value is problem dependent. -->
<!--
Expand Down
1 change: 1 addition & 0 deletions packages/muelu/example/basic/set3-mg-chebyshev.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<!-- =========== AGGREGATION =========== -->
<Parameter name="aggregation: type" type="string" value="uncoupled"/>
<Parameter name="aggregation: drop scheme" type="string" value="classical"/>
<Parameter name="aggregation: deterministic" type="bool" value="true"/>
<!-- Uncomment the next line to enable dropping of weak connections, which can help AMG convergence
for anisotropic problems. The exact value is problem dependent. -->
<!--
Expand Down
1 change: 1 addition & 0 deletions packages/muelu/example/basic/set3-mg-gs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<!-- =========== AGGREGATION =========== -->
<Parameter name="aggregation: type" type="string" value="uncoupled"/>
<Parameter name="aggregation: drop scheme" type="string" value="classical"/>
<Parameter name="aggregation: deterministic" type="bool" value="true"/>
<!-- Uncomment the next line to enable dropping of weak connections, which can help AMG convergence
for anisotropic problems. The exact value is problem dependent. -->
<!--
Expand Down
1 change: 1 addition & 0 deletions packages/muelu/example/basic/set3-mg-jacobi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<!-- =========== AGGREGATION =========== -->
<Parameter name="aggregation: type" type="string" value="uncoupled"/>
<Parameter name="aggregation: drop scheme" type="string" value="classical"/>
<Parameter name="aggregation: deterministic" type="bool" value="true"/>
<!-- Uncomment the next line to enable dropping of weak connections, which can help AMG convergence
for anisotropic problems. The exact value is problem dependent. -->
<!--
Expand Down
1 change: 1 addition & 0 deletions packages/muelu/example/basic/set3-mg-sgs-reuse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<!-- =========== AGGREGATION =========== -->
<Parameter name="aggregation: type" type="string" value="uncoupled"/>
<Parameter name="aggregation: drop scheme" type="string" value="classical"/>
<Parameter name="aggregation: deterministic" type="bool" value="true"/>
<!-- Uncomment the next line to enable dropping of weak connections, which can help AMG convergence
for anisotropic problems. The exact value is problem dependent. -->
<!--
Expand Down
1 change: 1 addition & 0 deletions packages/muelu/example/basic/set3-mg-sgs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<!-- =========== AGGREGATION =========== -->
<Parameter name="aggregation: type" type="string" value="uncoupled"/>
<Parameter name="aggregation: drop scheme" type="string" value="classical"/>
<Parameter name="aggregation: deterministic" type="bool" value="true"/>
<!-- Uncomment the next line to enable dropping of weak connections, which can help AMG convergence
for anisotropic problems. The exact value is problem dependent. -->
<!--
Expand Down
5 changes: 2 additions & 3 deletions packages/muelu/src/Utils/MueLu_Utilities_kokkos_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,8 @@ namespace MueLu {

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);
}
static RCP<Vector> GetMatrixDiagonalInverse(const Matrix& A, Magnitude tol = Teuchos::ScalarTraits<SC>::eps()*100, const bool doLumped=false);

static RCP<Vector> GetLumpedMatrixDiagonal(Matrix const &A, const bool doReciprocal=false, Magnitude tol = Teuchos::ScalarTraits<Scalar>::eps()*100, Scalar tolReplacement = Teuchos::ScalarTraits<Scalar>::zero(), const bool replaceSingleEntryRowWithZero = false, const bool useAverageAbsDiagVal = false) {
return UtilitiesBase::GetLumpedMatrixDiagonal(A, doReciprocal, tol, tolReplacement, replaceSingleEntryRowWithZero, useAverageAbsDiagVal);
}
Expand Down
24 changes: 22 additions & 2 deletions packages/muelu/src/Utils/MueLu_Utilities_kokkos_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ namespace MueLu {

template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
Teuchos::RCP<Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
Utilities_kokkos<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
GetMatrixDiagonalInverse(const Matrix& A, Magnitude tol, const bool doLumped) {
GetMatrixDiagonalInverse(const Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>& A,
typename Teuchos::ScalarTraits<Scalar>::magnitudeType tol, const bool doLumped) {
Teuchos::TimeMonitor MM = *Teuchos::TimeMonitor::getNewTimer("Utilities_kokkos::GetMatrixDiagonalInverse");
// Some useful type definitions
using Matrix = Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>;
using Map = Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node>;
using Vector = Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>;
using VectorFactory = Xpetra::VectorFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>;
using local_matrix_type = typename Matrix::local_matrix_type;
using local_graph_type = typename local_matrix_type::staticcrsgraph_type;
using value_type = typename local_matrix_type::value_type;
Expand Down Expand Up @@ -194,6 +198,22 @@ namespace MueLu {
return diag;
} //GetMatrixDiagonalInverse

template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
Teuchos::RCP<Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal,Node> >
Utilities_kokkos<Scalar, LocalOrdinal, GlobalOrdinal,Node>::
GetMatrixDiagonalInverse(const Matrix& A, Magnitude tol, const bool doLumped)
{
return MueLu::GetMatrixDiagonalInverse<Scalar, LocalOrdinal, GlobalOrdinal, Node>(A,tol,doLumped);
}

template <class Node>
Teuchos::RCP<Xpetra::Vector<double,int,int,Node> >
Utilities_kokkos<double,int,int,Node>::
GetMatrixDiagonalInverse(const Matrix& A, Magnitude tol, const bool doLumped)
{
return MueLu::GetMatrixDiagonalInverse<double, int, int, Node>(A,tol,doLumped);
}

template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
Utilities_kokkos<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
Expand Down

0 comments on commit 35b4d4d

Please sign in to comment.