Skip to content

Commit

Permalink
[temporary] parameter for changing bucket size
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Maas committed Sep 4, 2023
1 parent f423340 commit d1e7aef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions mt-kahypar/io/command_line_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ namespace mt_kahypar {
po::value<double>((initial_partitioning ? &context.initial_partitioning.refinement.fm.unconstrained_min_improvement :
&context.refinement.fm.unconstrained_min_improvement))->value_name("<double>")->default_value(-1.0),
"Switch to constrained FM if relative improvement of unconstrained FM is below this treshold.")
((initial_partitioning ? "i-r-fm-unconstrained-bucket-factor" : "r-fm-unconstrained-bucket-factor"),
po::value<double>((initial_partitioning ? &context.initial_partitioning.refinement.fm.bucket_factor :
&context.refinement.fm.bucket_factor))->value_name("<double>")->default_value(1.5),
"Base for exponential scaling of buckets which are used for the estimation of imbalance penalties.")
((initial_partitioning ? "i-r-fm-obey-minimal-parallelism" : "r-fm-obey-minimal-parallelism"),
po::value<bool>(
(initial_partitioning ? &context.initial_partitioning.refinement.fm.obey_minimal_parallelism :
Expand Down
1 change: 1 addition & 0 deletions mt-kahypar/partition/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ struct FMParameters {
bool activate_unconstrained_dynamically = false;
double penalty_for_activation_test = 0.5;
double unconstrained_min_improvement = -1.0;
double bucket_factor = 1.5;
};

std::ostream& operator<<(std::ostream& out, const FMParameters& params);
Expand Down
1 change: 1 addition & 0 deletions mt-kahypar/partition/refinement/fm/fm_commons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace mt_kahypar {

template<typename PartitionedHypergraphT>
void UnconstrainedFMData::initialize(const Context& context, const PartitionedHypergraphT& phg) {
bucket_factor = context.refinement.fm.bucket_factor;
changeNumberOfBlocks(context.partition.k);
reset();

Expand Down
10 changes: 6 additions & 4 deletions mt-kahypar/partition/refinement/fm/fm_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ struct UnconstrainedFMData {

// TODO(maas): in weighted graphs the constant number of buckets might be problematic
static constexpr BucketID NUM_BUCKETS = 16;
static constexpr double BUCKET_FACTOR = 1.5;
// static constexpr double BUCKET_FACTOR = 1.5;
static constexpr double FALLBACK_TRESHOLD = 0.75;

bool initialized = false;
Expand All @@ -167,14 +167,16 @@ struct UnconstrainedFMData {
tbb::enumerable_thread_specific<parallel::scalable_vector<HypernodeWeight>> local_bucket_weights;
parallel::scalable_vector<parallel::scalable_vector<HypernodeWeight>> fallback_bucket_weights;
kahypar::ds::FastResetFlagArray<> rebalancing_nodes;
double bucket_factor;

explicit UnconstrainedFMData():
initialized(false),
current_k(0),
bucket_weights(),
virtual_weight_delta(),
local_bucket_weights(),
rebalancing_nodes() { }
rebalancing_nodes(),
bucket_factor(2.0) { }

template<typename PartitionedHypergraphT>
void initialize(const Context& context, const PartitionedHypergraphT& phg);
Expand Down Expand Up @@ -205,7 +207,7 @@ struct UnconstrainedFMData {
double gainPerWeightForBucket(BucketID bucketId) const {
// TODO: test other value than 1.5
if (bucketId > 1) {
return std::pow(BUCKET_FACTOR, bucketId - 2);
return std::pow(bucket_factor, bucketId - 2);
} else if (bucketId == 1) {
return 0.5;
} else {
Expand All @@ -215,7 +217,7 @@ struct UnconstrainedFMData {

BucketID bucketForGainPerWeight(double gainPerWeight) const {
if (gainPerWeight >= 1) {
return 2 + std::ceil(std::log(gainPerWeight) / std::log(BUCKET_FACTOR));
return 2 + std::ceil(std::log(gainPerWeight) / std::log(bucket_factor));
} else if (gainPerWeight > 0.5) {
return 2;
} else if (gainPerWeight > 0) {
Expand Down

0 comments on commit d1e7aef

Please sign in to comment.