From 49da0adc9c7518f5559c57e594d3ab80125402b8 Mon Sep 17 00:00:00 2001 From: Robert Krause Date: Tue, 7 Nov 2023 16:22:20 +0100 Subject: [PATCH] fix: accidental overlap between buckets --- .../deterministic/deterministic_jet_refiner.cpp | 2 +- .../rebalancing/deterministic_rebalancer.cpp | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mt-kahypar/partition/refinement/deterministic/deterministic_jet_refiner.cpp b/mt-kahypar/partition/refinement/deterministic/deterministic_jet_refiner.cpp index 8c50bc4e4..c3f4b7b2a 100644 --- a/mt-kahypar/partition/refinement/deterministic/deterministic_jet_refiner.cpp +++ b/mt-kahypar/partition/refinement/deterministic/deterministic_jet_refiner.cpp @@ -128,7 +128,7 @@ bool DeterministicJetRefiner::refineImpl(mt_kahypar_partition return my_gain; }; Gain gain = tbb::parallel_reduce(range, 0, accum, std::plus<>()); - timer.stop_timer("apply moves"); + timer.stop_timer("apply_moves"); current_metrics.quality -= gain; current_metrics.imbalance = metrics::imbalance(phg, _context); diff --git a/mt-kahypar/partition/refinement/deterministic/rebalancing/deterministic_rebalancer.cpp b/mt-kahypar/partition/refinement/deterministic/rebalancing/deterministic_rebalancer.cpp index 22292207a..bb741075c 100644 --- a/mt-kahypar/partition/refinement/deterministic/rebalancing/deterministic_rebalancer.cpp +++ b/mt-kahypar/partition/refinement/deterministic/rebalancing/deterministic_rebalancer.cpp @@ -189,13 +189,13 @@ void DeterministicRebalancer::weakRebalancingRound(Partitione if (b == 0UL) { _moves[i] = tmp_potential_moves[i].copy_parallel(); } - const size_t bucket_size = _moves[i].size() / _context.refinement.deterministic_refinement.jet.num_buckets + 1; - const size_t bucket_start_index = b * bucket_size; - const size_t bucket_end_index = std::min(_moves[i].size(), bucket_start_index + bucket_size); - //timer.stop_timer("copy_moves"); if (_moves[i].size() > 0) { - // sort the moves from each overweight part by priority - //timer.start_timer("sorting", "Sorting"); + const size_t bucket_size = _moves[i].size() / _context.refinement.deterministic_refinement.jet.num_buckets + 1; + const size_t bucket_start_index = b * bucket_size; + const size_t bucket_end_index = std::min(_moves[i].size(), bucket_start_index + bucket_size); + //timer.stop_timer("copy_moves"); + // sort the moves from each overweight part by priority + //timer.start_timer("sorting", "Sorting"); tbb::parallel_sort(_moves[i].begin() + bucket_start_index, _moves[i].end(), [&](const rebalancer::RebalancingMove& a, const rebalancer::RebalancingMove& b) { return a.priority < b.priority || (a.priority == b.priority && a.hn > b.hn); }); @@ -212,7 +212,7 @@ void DeterministicRebalancer::weakRebalancingRound(Partitione // timer.start_timer("exe_moves", "Execute Moves"); //DBG << "exe_moves" << V(bucket_start_index) << ", " << V(last_move_idx) << ", " << V(bucket_end_index) << ", " << V(_moves[i].size()); - tbb::parallel_for(b * bucket_size, std::min(last_move_idx + 1, _moves[i].size()), [&](const size_t j) { + tbb::parallel_for(b * bucket_size, std::min(last_move_idx + 1, bucket_end_index), [&](const size_t j) { const auto move = _moves[i][j]; changeNodePart(phg, move.hn, i, move.to, false); }); @@ -223,12 +223,13 @@ void DeterministicRebalancer::weakRebalancingRound(Partitione } // } }); - + for (size_t i = 0; i < _moves.size(); ++i) { const size_t bucket_size = _moves[i].size() / _context.refinement.deterministic_refinement.jet.num_buckets + 1; const size_t start = (b + 1) * bucket_size; tbb::parallel_for(start, _moves[i].size(), [&](const size_t j) { _moves[i][j] = computeGainAndTargetPart(phg, _moves[i][j].hn, true); + ASSERT(phg.partID(_moves[i][j].hn) == i, V(phg.partID(_moves[i][j].hn)) << V(i) << V(j)); }); } }