Skip to content

Commit

Permalink
[rebalancer] initialize gain cache in initialize method instead of re…
Browse files Browse the repository at this point in the history
…fine

Lazy gain cache initializiation can be invalid in deep multilevel since
it is possible that the wrong k is used (if initialization happens after
changeNumberOfBlocks).

Note: An alternative fix could work by saving both the original and the
current k in the gain cache.
  • Loading branch information
N-Maas committed Oct 13, 2023
1 parent 21a37fb commit 3e9a2a3
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,6 @@ namespace impl {
Metrics& best_metric) {
auto& phg = utils::cast<PartitionedHypergraph>(hypergraph);

if (!_gain_cache.isInitialized()) {
_gain_cache.initializeGainCache(phg);
}

_overloaded_blocks.clear();
_is_overloaded.assign(_context.partition.k, false);
for (PartitionID k = 0; k < _context.partition.k; ++k) {
Expand Down Expand Up @@ -505,7 +501,10 @@ bool AdvancedRebalancer<GraphAndGainTypes>::refineImpl(mt_kahypar_partitioned_hy
template <typename GraphAndGainTypes>
void AdvancedRebalancer<GraphAndGainTypes>::initializeImpl(mt_kahypar_partitioned_hypergraph_t& hypergraph) {
auto& phg = utils::cast<PartitionedHypergraph>(hypergraph);
unused(phg);

if (!_gain_cache.isInitialized()) {
_gain_cache.initializeGainCache(phg);
}
}

template <typename GraphAndGainTypes>
Expand Down

0 comments on commit 3e9a2a3

Please sign in to comment.