Skip to content

Commit

Permalink
refactor: cleanup code for arbitrary block weights (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSeemaier authored Dec 2, 2024
1 parent 0434537 commit 86c1205
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
6 changes: 3 additions & 3 deletions kaminpar-shm/coarsening/max_cluster_weights.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ NodeWeight compute_max_cluster_weight(
break;

case ClusterWeightLimit::BLOCK_WEIGHT:
max_cluster_weight = (1.0 + p_ctx.epsilon()) * total_node_weight / p_ctx.k;
max_cluster_weight = (1.0 + p_ctx.inferred_epsilon()) * total_node_weight / p_ctx.k;
break;

case ClusterWeightLimit::ONE:
Expand Down Expand Up @@ -61,8 +61,8 @@ NodeWeight compute_max_cluster_weight(
break;

case ClusterWeightLimit::BLOCK_WEIGHT:
if constexpr (requires { p_ctx.epsilon(); }) {
max_cluster_weight = (1.0 + p_ctx.epsilon()) * total_node_weight / p_ctx.k;
if constexpr (requires { p_ctx.inferred_epsilon(); }) {
max_cluster_weight = (1.0 + p_ctx.inferred_epsilon()) * total_node_weight / p_ctx.k;
} else {
max_cluster_weight = (1.0 + p_ctx.epsilon) * total_node_weight / p_ctx.k;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ void InitialMultilevelBipartitioner::initialize(
<< ", will be relaxed with parameters max node weight " << graph.max_node_weight();

_p_ctx.setup(graph, std::move(max_block_weights), true);

// @todo: we need this for the max cluster weight computation, where inferred epsilon might give
// slightly different values otherwise
// For now, only for testing, but keep in mind to update max_cluster_weight() to use
// inferred_epsilon() before removing this!
_p_ctx.set_epsilon(adapted_eps);
} else {
DBG << "[" << current_block << "/" << current_k
<< "]j-> using original epsilon: " << _ctx.partition.epsilon()
Expand Down
6 changes: 1 addition & 5 deletions kaminpar-shm/kaminpar.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,7 @@ struct PartitionContext {
[[nodiscard]] BlockWeight
total_unrelaxed_max_block_weights(const BlockID begin, const BlockID end) const {
if (_uniform_block_weights) {
const double max =
(1.0 + inferred_epsilon()) * std::ceil(1.0 * (end - begin) * total_node_weight / k);
return max;
// return _unrelaxed_max_block_weights[begin] * (end - begin);
return (1.0 + inferred_epsilon()) * std::ceil(1.0 * (end - begin) * total_node_weight / k);
}

return std::accumulate(
Expand All @@ -409,7 +406,6 @@ struct PartitionContext {

[[nodiscard]] double inferred_epsilon() const {
return infer_epsilon(total_node_weight);
// return 1.0 * _total_max_block_weights / total_node_weight - 1.0;
}

void set_epsilon(const double eps) {
Expand Down

0 comments on commit 86c1205

Please sign in to comment.