31 Monitor m(*
this,
"BuildAggregatesNonKokkos");
32 bool matchMLbehavior = params.get<
bool>(
"aggregation: match ML phase2b");
35 const int myRank = graph.
GetComm()->getRank();
37 ArrayRCP<LO> vertex2AggId = aggregates.
GetVertex2AggId()->getDataNonConst(0);
38 ArrayRCP<LO> procWinner = aggregates.
GetProcWinner()->getDataNonConst(0);
42 const LO defaultConnectWeight = 100;
43 const LO penaltyConnectWeight = 10;
45 std::vector<LO> aggWeight(numLocalAggregates, 0);
46 std::vector<LO> connectWeight(numRows, defaultConnectWeight);
47 std::vector<LO> aggPenalties(numRows, 0);
55 for (
int k = 0; k < 2; k++) {
56 for (LO i = 0; i < numRows; i++) {
57 if (aggStat[i] !=
READY)
62 for (
int j = 0; j < neighOfINode.length; j++) {
63 LO neigh = neighOfINode(j);
67 aggWeight[vertex2AggId[neigh]] += connectWeight[neigh];
70 int bestScore = -100000;
74 for (
int j = 0; j < neighOfINode.length; j++) {
75 LO neigh = neighOfINode(j);
76 int aggId = vertex2AggId[neigh];
80 int score = aggWeight[aggId] - aggPenalties[aggId];
82 if (score > bestScore) {
85 bestConnect = connectWeight[neigh];
87 }
else if (aggId == bestAggId && connectWeight[neigh] > bestConnect) {
88 bestConnect = connectWeight[neigh];
98 vertex2AggId[i] = bestAggId;
99 procWinner[i] = myRank;
101 numNonAggregatedNodes--;
103 aggPenalties[bestAggId]++;
104 connectWeight[i] = bestConnect - penaltyConnectWeight;
235 LO& numNonAggregatedNodes)
const {
239 bool matchMLbehavior = params.get<
bool>(
"aggregation: match ML phase2b");
242 const int myRank = graph.
GetComm()->getRank();
244 auto vertex2AggId = aggregates.
GetVertex2AggId()->getDeviceLocalView(Xpetra::Access::ReadWrite);
245 auto procWinner = aggregates.
GetProcWinner()->getDeviceLocalView(Xpetra::Access::ReadWrite);
250 const LO defaultConnectWeight = 100;
251 const LO penaltyConnectWeight = 10;
253 Kokkos::View<LO*, device_type> connectWeight(Kokkos::ViewAllocateWithoutInitializing(
"connectWeight"), numRows);
254 Kokkos::View<LO*, device_type> aggPenalties(
"aggPenalties", numLocalAggregates);
255 Kokkos::View<LO*, device_type> aggPenaltyUpdates;
257 aggPenaltyUpdates = Kokkos::View<LO*, device_type>(
"aggPenaltyUpdates", numLocalAggregates);
259 Kokkos::deep_copy(connectWeight, defaultConnectWeight);
269 int maxNodesPerAggregate = params.get<
int>(
"aggregation: max agg size");
270 if (maxNodesPerAggregate == std::numeric_limits<int>::max()) {
273 for (
int iter = 0; iter < maxIters; ++iter) {
274 for (LO color = 1; color <= numColors; ++color) {
277 LO numAggregated = 0;
279 if constexpr (deterministic) {
280 if (matchMLbehavior) {
281 auto functor =
ExpansionFunctor<decltype(aggStat), decltype(procWinner), decltype(vertex2AggId), decltype(colors), decltype(graph), decltype(aggPenalties), LO, true, true>(aggStat, procWinner, vertex2AggId, colors, graph, aggPenalties, aggPenaltyUpdates, connectWeight, penaltyConnectWeight, color, myRank);
283 Kokkos::parallel_reduce(
"Aggregation Phase 2b: aggregates expansion",
284 Kokkos::RangePolicy<execution_space>(0, numRows),
288 auto functor =
ExpansionFunctor<decltype(aggStat), decltype(procWinner), decltype(vertex2AggId), decltype(colors), decltype(graph), decltype(aggPenalties), LO, true, false>(aggStat, procWinner, vertex2AggId, colors, graph, aggPenalties, aggPenaltyUpdates, connectWeight, penaltyConnectWeight, color, myRank);
290 Kokkos::parallel_reduce(
"Aggregation Phase 2b: aggregates expansion",
291 Kokkos::RangePolicy<execution_space>(0, numRows),
296 if (matchMLbehavior) {
297 auto functor =
ExpansionFunctor<decltype(aggStat), decltype(procWinner), decltype(vertex2AggId), decltype(colors), decltype(graph), decltype(aggPenalties), LO, false, true>(aggStat, procWinner, vertex2AggId, colors, graph, aggPenalties, connectWeight, penaltyConnectWeight, color, myRank);
299 Kokkos::parallel_reduce(
"Aggregation Phase 2b: aggregates expansion",
300 Kokkos::RangePolicy<execution_space>(0, numRows),
304 auto functor =
ExpansionFunctor<decltype(aggStat), decltype(procWinner), decltype(vertex2AggId), decltype(colors), decltype(graph), decltype(aggPenalties), LO, false, false>(aggStat, procWinner, vertex2AggId, colors, graph, aggPenalties, connectWeight, penaltyConnectWeight, color, myRank);
306 Kokkos::parallel_reduce(
"Aggregation Phase 2b: aggregates expansion",
307 Kokkos::RangePolicy<execution_space>(0, numRows),
313 if constexpr (deterministic) {
314 Kokkos::parallel_for(
315 "Aggregation Phase 2b: updating agg penalties",
316 Kokkos::RangePolicy<execution_space>(0, numLocalAggregates),
317 KOKKOS_LAMBDA(
const LO agg) {
318 aggPenalties(agg) += aggPenaltyUpdates(agg);
319 aggPenaltyUpdates(agg) = 0;
323 numNonAggregatedNodes -= numAggregated;
void BuildAggregatesNonKokkos(const ParameterList ¶ms, const LWGraph &graph, Aggregates &aggregates, typename AggregationAlgorithmBase< LocalOrdinal, GlobalOrdinal, Node >::AggStatHostType &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
void BuildAggregates(const ParameterList ¶ms, const LWGraph_kokkos &graph, Aggregates &aggregates, typename AggregationAlgorithmBase< LocalOrdinal, GlobalOrdinal, Node >::AggStatType &aggStat, LO &numNonAggregatedNodes) const
ExpansionFunctor(AggStatType &aggStat_, ProcWinnerType &procWinner_, Vertex2AggType &vertex2AggId_, ColorsType &colors_, LocalGraphType &lclLWGraph_, AggPenaltyType &aggPenalties_, AggPenaltyType &connectWeight_, LO penaltyConnectWeight_, LO color_, LO rank_)
ExpansionFunctor(AggStatType &aggStat_, ProcWinnerType &procWinner_, Vertex2AggType &vertex2AggId_, ColorsType &colors_, LocalGraphType &lclLWGraph_, AggPenaltyType &aggPenalties_, AggPenaltyType &aggPenaltyUpdates_, AggPenaltyType &connectWeight_, LO penaltyConnectWeight_, LO color_, LO rank_)