Skip to content

Commit

Permalink
dbg: add progress output to FM
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSeemaier committed May 13, 2024
1 parent 36a266e commit 804166c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
27 changes: 25 additions & 2 deletions kaminpar-shm/refinement/fm/fm_refiner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,14 @@ bool FMRefiner<GainCache, DeltaPartitionedGraph>::refine(
} else {
START_TIMER("Localized searches, coarse level");
}

std::atomic<int> active_workers = 0;
std::atomic<std::size_t> finished_batches = 0;
const std::size_t finished_batch_output_interval = 1'000;

tbb::parallel_for<int>(0, _ctx.parallel.num_threads, [&](int) {
++active_workers;

EdgeWeight &expected_gain = expected_gain_ets.local();
LocalizedFMRefiner<GainCache, DeltaPartitionedGraph> &localized_refiner =
*localized_fm_refiner_ets.local();
Expand All @@ -208,8 +215,24 @@ bool FMRefiner<GainCache, DeltaPartitionedGraph>::refine(
localized_refiner.last_batch_seed_nodes(), localized_refiner.last_batch_moves()
)
);

if (active_workers > 2) {
if ((++finished_batches) % finished_batch_output_interval == 0) {
LOG << "FM status: " << active_workers << " workers, " << finished_batches
<< " batches, " << _shared->border_nodes.remaining() << " remaining border nodes";
}
} else {
if ((++finished_batches) % (finished_batch_output_interval / 100) == 0) {
LOG << "FM status: " << active_workers << " workers, " << finished_batches
<< " batches, " << _shared->border_nodes.remaining() << " remaining border nodes";
}
}
}

--active_workers;
});
LOG << "~~~ FM status: " << active_workers << " workers, " << finished_batches << " batches, "
<< _shared->border_nodes.remaining() << " remaining border nodes";
STOP_TIMER();

IFSTATSC(_fm_ctx.dbg_compute_batch_stats, batch_stats.next_iteration());
Expand Down Expand Up @@ -551,12 +574,12 @@ LocalizedFMRefiner<GainCache, DeltaPartitionedGraph>::best_gain(
const NodeWeight block_weight_gap = max_block_weight - target_block_weight;
if (block_weight_gap < std::min<EdgeWeight>(best_target_block_weight_gap, 0)) {
return;
} // loop could not be vectorized
}

const EdgeWeight gain = compute_gain();
if (gain > best_gain ||
(gain == best_gain && block_weight_gap > best_target_block_weight_gap)) {
best_gain = gain; // SLOW: hoisting getelementptr
best_gain = gain;
best_target_block = to;
best_target_block_weight_gap = block_weight_gap;
}
Expand Down
5 changes: 5 additions & 0 deletions kaminpar-shm/refinement/fm/fm_refiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ template <typename GainCache> class BorderNodes {
return _border_nodes.size();
}

[[nodiscard]] std::size_t remaining() const {
const std::size_t rem = _border_nodes.size() - _next_border_node;
return has_more() ? rem : 0;
}

void shuffle() {
Random::instance().shuffle(_border_nodes.begin(), _border_nodes.end());
}
Expand Down

0 comments on commit 804166c

Please sign in to comment.