Skip to content

Commit

Permalink
Merge pull request #9747 from cgcgcg/phase2a
Browse files Browse the repository at this point in the history
MueLu: Make Phase2a do the same as ML
  • Loading branch information
cgcgcg authored Dec 15, 2021
2 parents edc1c65 + f9ff7f7 commit d961612
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 955 deletions.
928 changes: 0 additions & 928 deletions packages/muelu/doc/UsersGuide/MueLu_MasterList.cpp

This file was deleted.

6 changes: 3 additions & 3 deletions packages/muelu/doc/UsersGuide/masterList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,10 @@
</parameter>

<parameter>
<name>aggregation: phase2a include root</name>
<name>aggregation: match ML phase2a</name>
<type>bool</type>
<default>true</default>
<description>Whether the root node should be included in the aggregates formed in phase 2a.</description>
<default>false</default>
<description>Match ML's phase 2a. In particular, setting this to true will include the root node into the tentative aggregates in phase 2a.</description>
<visible>false</visible>
<comment-ML>parameter not existing in ML</comment-ML>
</parameter>
Expand Down
2 changes: 1 addition & 1 deletion packages/muelu/doc/UsersGuide/paramlist_hidden.tex
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@

\cbb{aggregation: enable phase 3}{bool}{true}{Turn on/off phase 3 of aggregation}

\cbb{aggregation: phase2a include root}{bool}{true}{Whether the root node should be included in the aggregates formed in phase 2a.}
\cbb{aggregation: match ML phase2a}{bool}{false}{Match ML's phase 2a. In particular, setting this to true will include the root node into the tentative aggregates in phase 2a.}

\cbb{aggregation: phase2a agg factor}{double}{0.5}{Agg factor for Phase 2a sizes}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace MueLu {
SET_VALID_ENTRY("aggregation: preserve Dirichlet points");
SET_VALID_ENTRY("aggregation: allow user-specified singletons");
SET_VALID_ENTRY("aggregation: error on nodes with no on-rank neighbors");
SET_VALID_ENTRY("aggregation: phase2a include root");
SET_VALID_ENTRY("aggregation: match ML phase2a");
SET_VALID_ENTRY("aggregation: phase2a agg factor");
SET_VALID_ENTRY("aggregation: phase3 avoid singletons");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace MueLu {

int minNodesPerAggregate = params.get<int>("aggregation: min agg size");
int maxNodesPerAggregate = params.get<int>("aggregation: max agg size");
bool includeRootInAgg = params.get<bool>("aggregation: phase2a include root");
bool matchMLbehavior = params.get<bool>("aggregation: match ML phase2a");

const LO numRows = graph.GetNodeNumVertices();
const int myRank = graph.GetComm()->getRank();
Expand All @@ -92,13 +92,16 @@ namespace MueLu {
if (aggStat[rootCandidate] != READY)
continue;

LO numNeighbors = 0;
aggSize = 0;
if (includeRootInAgg)
if (matchMLbehavior) {
aggList[aggSize++] = rootCandidate;
numNeighbors++;
}

ArrayView<const LocalOrdinal> neighOfINode = graph.getNeighborVertices(rootCandidate);

LO numNeighbors = 0;

for (int j = 0; j < neighOfINode.size(); j++) {
LO neigh = neighOfINode[j];

Expand All @@ -119,8 +122,7 @@ namespace MueLu {

// NOTE: ML uses a hardcoded value 3 instead of MinNodesPerAggregate
if (aggSize > as<size_t>(minNodesPerAggregate) &&
((includeRootInAgg && aggSize-1 > factor*numNeighbors) ||
(!includeRootInAgg && aggSize > factor*numNeighbors))) {
(aggSize > factor*numNeighbors)) {
// Accept new aggregate
// rootCandidate becomes the root of the newly formed aggregate
aggregates.SetIsRoot(rootCandidate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace MueLu {
{
const int minNodesPerAggregate = params.get<int>("aggregation: min agg size");
const int maxNodesPerAggregate = params.get<int>("aggregation: max agg size");
bool includeRootInAgg = params.get<bool>("aggregation: phase2a include root");
bool matchMLbehavior = params.get<bool>("aggregation: match ML phase2a");

const LO numRows = graph.GetNodeNumVertices();
const int myRank = graph.GetComm()->getRank();
Expand Down Expand Up @@ -129,17 +129,18 @@ namespace MueLu {
if(aggStat(rootCandidate) == READY &&
colors(rootCandidate) == color) {

LO aggSize;
if (includeRootInAgg)
aggSize = 1;
else
aggSize = 0;
LO numNeighbors = 0;
LO aggSize = 0;
if (matchMLbehavior) {
aggSize += 1;
numNeighbors +=1;
}

auto neighbors = graph.getNeighborVertices(rootCandidate);

// Loop over neighbors to count how many nodes could join
// the new aggregate
LO numNeighbors = 0;

for(int j = 0; j < neighbors.length; ++j) {
LO neigh = neighbors(j);
if(neigh != rootCandidate) {
Expand All @@ -155,16 +156,15 @@ namespace MueLu {
// If a sufficient number of nodes can join the new aggregate
// then we actually create the aggregate.
if(aggSize > minNodesPerAggregate &&
((includeRootInAgg && aggSize-1 > factor*numNeighbors) ||
(!includeRootInAgg && aggSize > factor*numNeighbors))) {
(aggSize > factor*numNeighbors)) {

// aggregates.SetIsRoot(rootCandidate);
LO aggIndex = Kokkos::
atomic_fetch_add(&numLocalAggregates(), 1);

LO numAggregated = 0;

if (includeRootInAgg) {
if (matchMLbehavior) {
// Add the root.
aggStat(rootCandidate) = AGGREGATED;
vertex2AggId(rootCandidate, 0) = aggIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace MueLu {
SET_VALID_ENTRY("aggregation: enable phase 2a");
SET_VALID_ENTRY("aggregation: enable phase 2b");
SET_VALID_ENTRY("aggregation: enable phase 3");
SET_VALID_ENTRY("aggregation: phase2a include root");
SET_VALID_ENTRY("aggregation: match ML phase2a");
SET_VALID_ENTRY("aggregation: phase2a agg factor");
SET_VALID_ENTRY("aggregation: preserve Dirichlet points");
SET_VALID_ENTRY("aggregation: allow user-specified singletons");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace MueLu {
SET_VALID_ENTRY("aggregation: enable phase 2a");
SET_VALID_ENTRY("aggregation: enable phase 2b");
SET_VALID_ENTRY("aggregation: enable phase 3");
SET_VALID_ENTRY("aggregation: phase2a include root");
SET_VALID_ENTRY("aggregation: match ML phase2a");
SET_VALID_ENTRY("aggregation: phase3 avoid singletons");
SET_VALID_ENTRY("aggregation: error on nodes with no on-rank neighbors");
SET_VALID_ENTRY("aggregation: preserve Dirichlet points");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ namespace MueLu {
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: enable phase 2a", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: enable phase 2b", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: enable phase 3", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: phase2a include root", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: match ML phase2a", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: phase2a agg factor", double, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: preserve Dirichlet points", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: error on nodes with no on-rank neighbors", bool, aggParams);
Expand Down
4 changes: 2 additions & 2 deletions packages/muelu/src/MueCentral/MueLu_MasterList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ namespace MueLu {
"<Parameter name=\"aggregation: enable phase 2a\" type=\"bool\" value=\"true\"/>"
"<Parameter name=\"aggregation: enable phase 2b\" type=\"bool\" value=\"true\"/>"
"<Parameter name=\"aggregation: enable phase 3\" type=\"bool\" value=\"true\"/>"
"<Parameter name=\"aggregation: phase2a include root\" type=\"bool\" value=\"true\"/>"
"<Parameter name=\"aggregation: match ML phase2a\" type=\"bool\" value=\"false\"/>"
"<Parameter name=\"aggregation: phase2a agg factor\" type=\"double\" value=\"0.5\"/>"
"<Parameter name=\"aggregation: error on nodes with no on-rank neighbors\" type=\"bool\" value=\"false\"/>"
"<Parameter name=\"aggregation: phase3 avoid singletons\" type=\"bool\" value=\"false\"/>"
Expand Down Expand Up @@ -682,7 +682,7 @@ namespace MueLu {

("aggregation: enable phase 3","aggregation: enable phase 3")

("aggregation: phase2a include root","aggregation: phase2a include root")
("aggregation: match ML phase2a","aggregation: match ML phase2a")

("aggregation: phase2a agg factor","aggregation: phase2a agg factor")

Expand Down
2 changes: 1 addition & 1 deletion packages/muelu/test/unit_tests/Aggregates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class AggregateGenerator {
aggFact->SetParameter("aggregation: enable phase 2b", Teuchos::ParameterEntry(true));
aggFact->SetParameter("aggregation: enable phase 3", Teuchos::ParameterEntry(true));

aggFact->SetParameter("aggregation: phase2a include root", Teuchos::ParameterEntry(true));
aggFact->SetParameter("aggregation: match ML phase2a", Teuchos::ParameterEntry(true));

// Hybrid
level.Set("aggregationRegionType", regionType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace MueLuTests {
params.set<int> ("aggregation: max agg size", 3);
params.set<bool>("aggregation: deterministic", false);

params.set<bool>("aggregation: phase2a include root", true);
params.set<bool>("aggregation: match ML phase2a", true);
params.set<bool>("aggregation: error on nodes with no on-rank neighbors", false);
params.set<bool>("aggregation: phase3 avoid singletons", false);

Expand Down

0 comments on commit d961612

Please sign in to comment.