46#ifndef MUELU_ONEPTAGGREGATIONALGORITHM_DEF_HPP
47#define MUELU_ONEPTAGGREGATIONALGORITHM_DEF_HPP
49#include <Teuchos_Comm.hpp>
50#include <Teuchos_CommHelpers.hpp>
52#include <Xpetra_Vector.hpp>
54#include "MueLu_OnePtAggregationAlgorithm_kokkos.hpp"
56#include "MueLu_LWGraph_kokkos.hpp"
57#include "MueLu_Aggregates_kokkos.hpp"
63 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
73 Kokkos::View<unsigned*, typename LWGraph_kokkos::device_type>& aggstat,
74 LO& numNonAggregatedNodes)
const {
75 Monitor m(*
this,
"BuildAggregates");
77 typename Kokkos::View<unsigned*, device_type>::HostMirror aggstatHost
78 = Kokkos::create_mirror(aggstat);
79 Kokkos::deep_copy(aggstatHost, aggstat);
80 std::vector<unsigned> aggStat;
81 aggStat.resize(aggstatHost.extent(0));
82 for(
size_t idx = 0; idx < aggstatHost.extent(0); ++idx) {
83 aggStat[idx] = aggstatHost(idx);
87 const int myRank = graph.GetComm()->getRank();
90 Teuchos::ArrayRCP<LocalOrdinal> vertex2AggId = aggregates.GetVertex2AggId()->getDataNonConst(0);
91 Teuchos::ArrayRCP<LocalOrdinal> procWinner = aggregates.GetProcWinner()->getDataNonConst(0);
94 LocalOrdinal nLocalAggregates = aggregates.GetNumAggregates();
98 while (iNode1 < nRows) {
100 if (aggStat[iNode1] ==
ONEPT) {
102 aggregates.SetIsRoot(iNode1);
103 std::vector<int> aggList;
104 aggList.push_back(iNode1);
105 int aggIndex = nLocalAggregates++;
108 for (
size_t k = 0; k < aggList.size(); k++) {
110 vertex2AggId[aggList[k]] = aggIndex;
111 procWinner[aggList[k]] = myRank;
113 numNonAggregatedNodes -= aggList.size();
119 for(
size_t idx = 0; idx < aggstatHost.extent(0); ++idx) {
120 aggstatHost(idx) = aggStat[idx];
122 Kokkos::deep_copy(aggstat, aggstatHost);
125 aggregates.SetNumAggregates(nLocalAggregates);
MueLu::DefaultLocalOrdinal LocalOrdinal
Lightweight MueLu representation of a compressed row storage graph.
Timer to be used in non-factories.
void BuildAggregates(Teuchos::ParameterList const ¶ms, LWGraph_kokkos const &graph, Aggregates_kokkos &aggregates, Kokkos::View< unsigned *, device_type > &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
OnePtAggregationAlgorithm_kokkos(RCP< const FactoryBase > const &graphFact=Teuchos::null)
Constructor.
Namespace for MueLu classes and methods.