Skip to content

Commit 8294bc1

Browse files
committed
PABLO: fix parallel 2:1 balance
The first 2:1 balancing was only checking internal octants, however the balancing algortihm uses marker information from the neighbours of the checked octants and the neighbours could be ghosts octants. It is therefore necessary to exchange the adaption markers before starting balancing a partitioned tree.
1 parent 23ef12d commit 8294bc1

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

src/PABLO/ParaTree.cpp

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5791,38 +5791,49 @@ namespace bitpit {
57915791
(*m_log) << " " << endl;
57925792
}
57935793

5794-
// Process internal octants
5795-
if (verbose){
5796-
(*m_log) << " Processing internal octants" << endl;
5797-
}
5798-
5799-
m_octree.localBalance(balanceNewOctants, true, false);
5800-
5794+
bool initialStep = true;
5795+
while (true) {
58015796
#if BITPIT_ENABLE_MPI==1
5802-
// Propagate marker changes across processes
5803-
if (!m_serial) {
5804-
if (verbose){
5805-
(*m_log) << " Propagating marker changes across processes" << endl;
5806-
}
5807-
5808-
while (true) {
5809-
// Exchange markers across processes
5797+
// Exchange markers across processes
5798+
if (!m_serial) {
58105799
bool markersUpdated = commMarker();
5811-
MPI_Allreduce(MPI_IN_PLACE, &markersUpdated, 1, MPI_C_BOOL, MPI_LOR, m_comm);
5812-
if (!markersUpdated) {
5813-
break;
5800+
if (!initialStep) {
5801+
MPI_Allreduce(MPI_IN_PLACE, &markersUpdated, 1, MPI_C_BOOL, MPI_LOR, m_comm);
5802+
if (!markersUpdated) {
5803+
break;
5804+
}
58145805
}
5806+
}
5807+
#endif
5808+
5809+
// Balance 2:1 the tree
5810+
//
5811+
// After the first step only ghost octants are checked for balance, that's because
5812+
// starting from the second step we only need to propagate marker information across
5813+
// the processes.
5814+
bool checkInterior = initialStep;
5815+
bool checkGhosts = true;
58155816

5816-
// Process ghost octants to propagate marker changes applied by other processes
5817-
bool balanceUpdated = m_octree.localBalance(balanceNewOctants, false, true);
5817+
bool balanceUpdated = m_octree.localBalance(balanceNewOctants, checkInterior, checkGhosts);
5818+
#if BITPIT_ENABLE_MPI==1
5819+
if (!m_serial) {
58185820
MPI_Allreduce(MPI_IN_PLACE, &balanceUpdated, 1, MPI_C_BOOL, MPI_LOR, m_comm);
58195821
if (!balanceUpdated) {
58205822
break;
58215823
}
5824+
} else {
5825+
break;
58225826
}
5823-
}
5827+
#else
5828+
BITPIT_UNUSED(balanceUpdated);
5829+
break;
58245830
#endif
58255831

5832+
// This is not anymore the first balance step
5833+
initialStep = false;
5834+
5835+
}
5836+
58265837
// Print footer
58275838
if (verbose){
58285839
(*m_log) << " 2:1 Balancing reached " << endl;

0 commit comments

Comments
 (0)