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

MueLu: Material dropping #13662

Merged
merged 16 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ CreateTpetraPreconditioner(const Teuchos::RCP<Tpetra::Operator<Scalar, LocalOrdi
userList.set<RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::coordinateType, LO, GO, NO> > >("Coordinates", coordinates);
}

if (userList.isParameter("Material")) {
RCP<MultiVector> material = Teuchos::null;
try {
material = TpetraMultiVector_To_XpetraMultiVector<SC, LO, GO, NO>(userList.get<RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > >("Material"));
} catch (Teuchos::Exceptions::InvalidParameterType&) {
material = userList.get<RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > >("Material");
}
userList.set<RCP<MultiVector> >("Material", material);
}

if (userList.isParameter("Nullspace")) {
RCP<MultiVector> nullspace = Teuchos::null;
try {
Expand Down
36 changes: 35 additions & 1 deletion packages/muelu/doc/UsersGuide/masterList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,15 @@

<aggregation>

<parameter>
<name>aggregation: backend</name>
<type>string</type>
<default>"default"</default>
<description>Aggregation scheme. Possible values: "default", "host", "kokkos"</description>
<visible>false</visible>
<comment-ML>parameter not existing in ML</comment-ML>
</parameter>

<parameter>
<name>aggregation: type</name>
<type>string</type>
Expand Down Expand Up @@ -504,6 +513,14 @@
<comment-ML>parameter not existing in ML</comment-ML>
</parameter>

<parameter>
<name>aggregation: distance laplacian metric</name>
<type>string</type>
<default>unweighted</default>
<description>Metric used to compute the distance Laplacian. Possible values: "unweighted", "material"</description>
<comment-ML>parameter not existing in ML</comment-ML>
</parameter>

<parameter>
<name>aggregation: classical algo</name>
<type>string</type>
Expand Down Expand Up @@ -884,6 +901,14 @@
<comment-ML>parameter not existing in ML</comment-ML>
</parameter>

<parameter>
<name>aggregation: output file: material</name>
<type>bool</type>
<default>false</default>
<description>Whether to plot the material.</description>
<comment-ML>parameter not existing in ML</comment-ML>
</parameter>

<parameter>
<name>aggregation: params</name>
<type>\parameterlist</type>
Expand Down Expand Up @@ -1513,6 +1538,15 @@ Only used when tentative: calculate qr is set to false.</description>
<comment-ML>not supported by ML</comment-ML>
</parameter>

<parameter>
<name>matrix: compute analysis</name>
<type>bool</type>
<default>false</default>
<description>Perform matrix analysis. Checks several matrix properties and prints statistics.</description>
<visible>false</visible>
cgcgcg marked this conversation as resolved.
Show resolved Hide resolved
<comment-ML>not supported by ML</comment-ML>
</parameter>

<parameter>
<name>emin: iterative method</name>
<type>string</type>
Expand Down Expand Up @@ -1793,7 +1827,7 @@ Only used when tentative: calculate qr is set to false.</description>
<visible>false</visible>
</parameter>


</rebalancing>

<rap>
Expand Down
4 changes: 4 additions & 0 deletions packages/muelu/doc/UsersGuide/options_aggregation.tex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
aggregation. Possible values: "classical", "distance laplacian",
"unsupported vector smoothing"}

\cbb{aggregation: distance laplacian metric}{string}{unweighted}{Metric used to compute the distance Laplacian. Possible values: "unweighted", "material"}

\cbb{aggregation: drop tol}{double}{0.0}{Connectivity dropping threshold for a graph used in aggregation.}

\cbb{aggregation: use ml scaling of drop tol}{bool}{false}{Enables ML-style scaling of drop tol, where the drop tol halves with each successive level.}
Expand Down Expand Up @@ -64,6 +66,8 @@

\cbb{aggregation: output file: aggregate qualities}{bool}{false}{Whether to plot the aggregate quality.}

\cbb{aggregation: output file: material}{bool}{false}{Whether to plot the material.}

\cbb{aggregation: mesh layout}{string}{Global Lexicographic}{Type of ordering for structured mesh aggregation. Possible values: "Global Lexicographic" and "Local Lexicographic".}

\cbb{aggregation: output type}{string}{Aggregates}{Type of object holding the aggregation data. Possible values: "Aggregates" or "CrsGraph".}
Expand Down
4 changes: 4 additions & 0 deletions packages/muelu/doc/UsersGuide/paramlist.tex
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
aggregation. Possible values: "classical", "distance laplacian",
"unsupported vector smoothing"}

\cbb{aggregation: distance laplacian metric}{string}{unweighted}{Metric used to compute the distance Laplacian. Possible values: "unweighted", "material"}

\cbb{aggregation: drop tol}{double}{0.0}{Connectivity dropping threshold for a graph used in aggregation.}

\cbb{aggregation: use ml scaling of drop tol}{bool}{false}{Enables ML-style scaling of drop tol, where the drop tol halves with each successive level.}
Expand Down Expand Up @@ -117,6 +119,8 @@

\cbb{aggregation: output file: aggregate qualities}{bool}{false}{Whether to plot the aggregate quality.}

\cbb{aggregation: output file: material}{bool}{false}{Whether to plot the material.}

\cbb{aggregation: mesh layout}{string}{Global Lexicographic}{Type of ordering for structured mesh aggregation. Possible values: "Global Lexicographic" and "Local Lexicographic".}

\cbb{aggregation: output type}{string}{Aggregates}{Type of object holding the aggregation data. Possible values: "Aggregates" or "CrsGraph".}
Expand Down
8 changes: 8 additions & 0 deletions packages/muelu/doc/UsersGuide/paramlist_hidden.tex
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@

\cbb{coarse: overlap}{int}{0}{Coarse solver subdomain overlap.}

\cbb{aggregation: backend}{string}{"default"}{Aggregation scheme. Possible values: "default", "host", "kokkos"}

\cbb{aggregation: type}{string}{"uncoupled"}{Aggregation scheme. Possible values: see Table~\ref{t:aggregation}.}

\cbb{aggregation: mode}{string}{"uncoupled"}{Controls whether aggregates are allowed to cross processor boundaries. Possible values: "coupled" aggregates can cross processor boundaries, "uncoupled" aggregates cannot cross processor boundaries.}
Expand Down Expand Up @@ -91,6 +93,8 @@

\cbb{aggregation: distance laplacian algo}{string}{"default"}{Type of sub-algorithm for "distance laplacian" dropping. Possible values: "default", "unscaled cut", "scaled cut".}

\cbb{aggregation: distance laplacian metric}{string}{unweighted}{Metric used to compute the distance Laplacian. Possible values: "unweighted", "material"}

\cbb{aggregation: classical algo}{string}{"default"}{Type of sub-algorithm for "classical" dropping. Possible values: "default", "unscaled cut", "scaled cut".}

\cbb{aggregation: drop tol}{double}{0.0}{Connectivity dropping threshold for a graph used in aggregation.}
Expand Down Expand Up @@ -185,6 +189,8 @@

\cbb{aggregation: output file: aggregate qualities}{bool}{false}{Whether to plot the aggregate quality.}

\cbb{aggregation: output file: material}{bool}{false}{Whether to plot the material.}

\cba{aggregation: params}{\parameterlist}{Sublist of options for use by aggregation.}

\cba{strength-of-connection: params}{\parameterlist}{Sublist of options for use by coalesce/drop.}
Expand Down Expand Up @@ -341,6 +347,8 @@

\cbb{filtered matrix: reuse graph}{bool}{true}{Set values to zero instead of constructing a new graph.}

\cbb{matrix: compute analysis}{bool}{false}{Perform matrix analysis. Checks several matrix properties and prints statistics.}

\cbb{emin: iterative method}{string}{"cg"}{Iterative method to use for energy minimization of initial prolongator in energy-minimization. Possible values: "cg" (conjugate gradient), "gmres" (generalized minimum residual), "sd" (steepest descent).}

\cbb{emin: num iterations}{int}{2}{Number of iterations to minimize initial prolongator energy in energy-minimization.}
Expand Down
3 changes: 3 additions & 0 deletions packages/muelu/src/Graph/Containers/MueLu_LWGraph_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "MueLu_LWGraph_fwd.hpp"
#include "MueLu_LWGraphBase.hpp"
#include "MueLu_LWGraph_kokkos_fwd.hpp"

namespace MueLu {

Expand All @@ -32,6 +33,8 @@ template <class LocalOrdinal = DefaultLocalOrdinal,
class LWGraph : public MueLu::LWGraphBase<LocalOrdinal, GlobalOrdinal, Node, true> {
public:
using LWGraphBase<LocalOrdinal, GlobalOrdinal, Node, true>::LWGraphBase;

RCP<MueLu::LWGraph_kokkos<LocalOrdinal, GlobalOrdinal, Node> > copyToDevice();
};

} // namespace MueLu
Expand Down
28 changes: 28 additions & 0 deletions packages/muelu/src/Graph/Containers/MueLu_LWGraph_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,38 @@
#ifndef MUELU_LWGRAPH_DEF_HPP
#define MUELU_LWGRAPH_DEF_HPP

#include "MueLu_LWGraph_kokkos.hpp"
#include "MueLu_LWGraph_decl.hpp"

namespace MueLu {

template <class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<MueLu::LWGraph_kokkos<LocalOrdinal, GlobalOrdinal, Node> > MueLu::LWGraph<LocalOrdinal, GlobalOrdinal, Node>::copyToDevice() {
// This could be improved to skip copies for UVM.

auto graph = this->getGraph();

cgcgcg marked this conversation as resolved.
Show resolved Hide resolved
using dev_crs_graph_type = typename MueLu::LWGraph_kokkos<LocalOrdinal, GlobalOrdinal, Node>::crs_graph_type;
auto rows = typename dev_crs_graph_type::local_graph_type::row_map_type::non_const_type("rows", graph.numRows() + 1);
auto entries = typename dev_crs_graph_type::local_graph_type::entries_type::non_const_type("columns", graph.entries.extent(0));
Kokkos::deep_copy(rows, graph.row_map);
Kokkos::deep_copy(entries, graph.entries);

using local_graph_type_device = typename MueLu::LWGraphBase<LocalOrdinal, GlobalOrdinal, Node, false>::local_graph_type;
auto graph_d = local_graph_type_device(entries, rows);

auto lw_d = rcp(new MueLu::LWGraph_kokkos<LocalOrdinal, GlobalOrdinal, Node>(graph_d, this->GetDomainMap(), this->GetImportMap(), this->getObjectLabel()));

using bndry_nodes_type = typename MueLu::LWGraphBase<LocalOrdinal, GlobalOrdinal, Node, false>::boundary_nodes_type;

auto bndry = this->GetBoundaryNodeMap();
auto bndry_d = bndry_nodes_type("boundary_nodes", bndry.extent(0));
Kokkos::deep_copy(bndry_d, bndry);
lw_d->SetBoundaryNodeMap(bndry_d);

return lw_d;
}

} // namespace MueLu

#endif // MUELU_LWGRAPH_DEF_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace MueLu {

template <class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<MueLu::LWGraph<LocalOrdinal, GlobalOrdinal, Node> > MueLu::LWGraph_kokkos<LocalOrdinal, GlobalOrdinal, Node>::copyToHost() {
// This could be improved to skip copies for UVM.

auto graph = this->getGraph();

auto row_map_h = Kokkos::create_mirror_view(graph.row_map);
Expand Down
Loading
Loading