From 86c120545a0c5890180305a9ca388bb003b458c1 Mon Sep 17 00:00:00 2001 From: Daniel Seemaier <17594350+DanielSeemaier@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:31:50 +0100 Subject: [PATCH] refactor: cleanup code for arbitrary block weights (#39) --- kaminpar-shm/coarsening/max_cluster_weights.h | 6 +++--- .../initial_multilevel_bipartitioner.cc | 6 ------ kaminpar-shm/kaminpar.h | 6 +----- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/kaminpar-shm/coarsening/max_cluster_weights.h b/kaminpar-shm/coarsening/max_cluster_weights.h index 5e2683b6..a72c2db2 100644 --- a/kaminpar-shm/coarsening/max_cluster_weights.h +++ b/kaminpar-shm/coarsening/max_cluster_weights.h @@ -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: @@ -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; } diff --git a/kaminpar-shm/initial_partitioning/initial_multilevel_bipartitioner.cc b/kaminpar-shm/initial_partitioning/initial_multilevel_bipartitioner.cc index 8e09c65d..fb3ace98 100644 --- a/kaminpar-shm/initial_partitioning/initial_multilevel_bipartitioner.cc +++ b/kaminpar-shm/initial_partitioning/initial_multilevel_bipartitioner.cc @@ -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() diff --git a/kaminpar-shm/kaminpar.h b/kaminpar-shm/kaminpar.h index e1d6f1bd..79906ab1 100644 --- a/kaminpar-shm/kaminpar.h +++ b/kaminpar-shm/kaminpar.h @@ -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( @@ -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) {