46#ifndef MUELU_PRESERVEDIRICHLETAGGREGATIONALGORITHM_KOKKOS_DEF_HPP
47#define MUELU_PRESERVEDIRICHLETAGGREGATIONALGORITHM_KOKKOS_DEF_HPP
49#include <Teuchos_Comm.hpp>
50#include <Teuchos_CommHelpers.hpp>
52#include <Xpetra_Vector.hpp>
54#include "MueLu_PreserveDirichletAggregationAlgorithm_kokkos.hpp"
56#include "MueLu_LWGraph_kokkos.hpp"
57#include "MueLu_Aggregates_kokkos.hpp"
63 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 Kokkos::View<unsigned*, typename LWGraph_kokkos::device_type>& aggStat,
69 LO& numNonAggregatedNodes)
const {
70 Monitor m(*
this,
"BuildAggregates");
71 using local_ordinal_type =
typename LWGraph_kokkos::local_ordinal_type;
75 const bool preserve = params.get<
bool>(
"aggregation: preserve Dirichlet points");
78 const LO numNodes = graph.GetNodeNumVertices();
79 const int myRank = graph.GetComm()->getRank();
82 auto vertex2AggId = aggregates.GetVertex2AggId()->getDeviceLocalView(Xpetra::Access::ReadWrite);
83 auto procWinner = aggregates.GetProcWinner() ->getDeviceLocalView(Xpetra::Access::ReadWrite);
86 Kokkos::View<LO, device_type> aggCount(
"aggCount");
88 Kokkos::deep_copy(aggCount, aggregates.GetNumAggregates());
90 Kokkos::parallel_for(
"MueLu - PreserveDirichlet: tagging ignored nodes",
91 Kokkos::RangePolicy<local_ordinal_type, execution_space>(0, numNodes),
92 KOKKOS_LAMBDA(
const local_ordinal_type nodeIdx) {
95 const LO aggIdx = Kokkos::atomic_fetch_add(&aggCount(), 1);
100 vertex2AggId(nodeIdx, 0) = aggIdx;
101 procWinner(nodeIdx, 0) = myRank;
105 typename Kokkos::View<LO, device_type>::HostMirror aggCount_h
106 = Kokkos::create_mirror_view(aggCount);
107 Kokkos::deep_copy(aggCount_h, aggCount);
110 numNonAggregatedNodes -= (aggCount_h() - aggregates.GetNumAggregates());
114 aggregates.SetNumAggregates(aggCount_h());
Lightweight MueLu representation of a compressed row storage graph.
Timer to be used in non-factories.
void BuildAggregates(const Teuchos::ParameterList ¶ms, const LWGraph_kokkos &graph, Aggregates_kokkos &aggregates, Kokkos::View< unsigned *, device_type > &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
Namespace for MueLu classes and methods.