Skip to content

Commit

Permalink
Fix fm init after rebalancing
Browse files Browse the repository at this point in the history
  • Loading branch information
T3C42 committed Dec 20, 2024
1 parent 5855082 commit 48af000
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions mt-kahypar/dynamic/strategies/localFM.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,20 @@ namespace mt_kahypar::dyn {
void local_fm(ds::StaticHypergraph& hypergraph, Context& context, parallel::scalable_vector<HypernodeID> local_fm_nodes) {

GainCachePtr::resetGainCache(_gain_cache);

mt_kahypar_partitioned_hypergraph_t partitioned_hypergraph = utils::partitioned_hg_cast(*partitioned_hypergraph_s);
_fm->initialize(partitioned_hypergraph);

if (!metrics::isBalanced(*partitioned_hypergraph_s, context)) {
// use rebalancer to rebalance partitioned_hypergraph_s
parallel::scalable_vector<parallel::scalable_vector<Move>> moves_by_part;
Metrics best_Metrics = {mt_kahypar::metrics::quality(*partitioned_hypergraph_s, Objective::km1),
mt_kahypar::metrics::imbalance(*partitioned_hypergraph_s, context)};
_rebalancer->refineAndOutputMoves(partitioned_hypergraph, {}, moves_by_part, best_Metrics, std::numeric_limits<double>::max());
}

//TODO: is second reset after rebalancing necessary?
GainCachePtr::resetGainCache(_gain_cache);

_fm->initialize(partitioned_hypergraph);
//TODO: is second reset after rebalancing necessary?
GainCachePtr::resetGainCache(_gain_cache);
_fm->initialize(partitioned_hypergraph);
}

Metrics best_Metrics = {mt_kahypar::metrics::quality(*partitioned_hypergraph_s, Objective::km1),
mt_kahypar::metrics::imbalance(*partitioned_hypergraph_s, context)};
Expand Down
11 changes: 5 additions & 6 deletions mt-kahypar/dynamic/strategies/localFM_factor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,19 @@ namespace mt_kahypar::dyn {
GainCachePtr::resetGainCache(_gain_cache);

mt_kahypar_partitioned_hypergraph_t partitioned_hypergraph = utils::partitioned_hg_cast(*partitioned_hypergraph_s);
_fm->initialize(partitioned_hypergraph);

if (!metrics::isBalanced(*partitioned_hypergraph_s, context)) {
// use rebalancer to rebalance partitioned_hypergraph_s
parallel::scalable_vector<parallel::scalable_vector<Move>> moves_by_part;
Metrics best_Metrics = {mt_kahypar::metrics::quality(*partitioned_hypergraph_s, Objective::km1),
mt_kahypar::metrics::imbalance(*partitioned_hypergraph_s, context)};
_rebalancer->refineAndOutputMoves(partitioned_hypergraph, {}, moves_by_part, best_Metrics, std::numeric_limits<double>::max());
}

//TODO: is second reset after rebalancing necessary?
GainCachePtr::resetGainCache(_gain_cache);

//TODO does this need to be done prior to rebalancing?
_fm->initialize(partitioned_hypergraph);
//TODO: is second reset after rebalancing necessary?
GainCachePtr::resetGainCache(_gain_cache);
_fm->initialize(partitioned_hypergraph);
}

Metrics best_Metrics = {mt_kahypar::metrics::quality(*partitioned_hypergraph_s, Objective::km1),
mt_kahypar::metrics::imbalance(*partitioned_hypergraph_s, context)};
Expand Down

0 comments on commit 48af000

Please sign in to comment.