Skip to content

Commit

Permalink
Merge pull request #8 from uulm-janbaudisch/mt-kahypar-parameters
Browse files Browse the repository at this point in the history
feat: change Mt-KaHyPar parameters
  • Loading branch information
SundermannC authored Apr 26, 2024
2 parents 580e46c + ce2064c commit 8cd1816
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

#include <boost/program_options.hpp>
#include <iostream>
#include <vector>

#include "partitioner/PartitionerKahyparMT.hpp"
#include "src/config/ConfigConverter.hpp"
#include "src/methods/MethodManager.hpp"

Expand Down Expand Up @@ -70,6 +70,7 @@ int main(int argc, char **argv) {
}

d4::Config config = d4::ConfigConverter::fromVariablesMap(vm);
d4::PartitionerKahyparMT::initPartitioner(config);
methodRun = d4::MethodManager::makeMethodManager(config, std::cout);
methodRun->run(config);
delete methodRun;
Expand Down
1 change: 1 addition & 0 deletions src/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace d4 {
config.partitioning_heuristic_bipartite_phase_static = 0;
config.partitioning_heuristic_simplification_equivalence = true;
config.partitioning_heuristic_simplification_hyperedge = true;
config.partitioning_threads = 1;
config.cache_reduction_strategy = "expectation";
config.cache_reduction_strategy_cachet_limit = 10UL * (1<<21);
config.cache_reduction_strategy_expectation_limit = 100000;
Expand Down
1 change: 1 addition & 0 deletions src/config/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace d4 {
int partitioning_heuristic_bipartite_phase_static;
bool partitioning_heuristic_simplification_equivalence;
bool partitioning_heuristic_simplification_hyperedge;
unsigned partitioning_threads;
string cache_reduction_strategy;
unsigned long cache_reduction_strategy_cachet_limit;
unsigned long cache_reduction_strategy_expectation_limit;
Expand Down
1 change: 1 addition & 0 deletions src/config/ConfigConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace d4 {
config.partitioning_heuristic_bipartite_phase_static = vm["partitioning-heuristic-bipartite-phase-static"].as<int>();
config.partitioning_heuristic_simplification_equivalence = vm["partitioning-heuristic-simplification-equivalence"].as<bool>();
config.partitioning_heuristic_simplification_hyperedge = vm["partitioning-heuristic-simplification-hyperedge"].as<bool>();
config.partitioning_threads = vm["partitioning-threads"].as<unsigned>();
config.cache_reduction_strategy = vm["cache-reduction-strategy"].as<string>();
config.cache_reduction_strategy_cachet_limit = vm["cache-reduction-strategy-cachet-limit"].as<unsigned long>();
config.cache_reduction_strategy_expectation_limit = vm["cache-reduction-strategy-expectation-limit"].as<unsigned long>();
Expand Down
1 change: 1 addition & 0 deletions src/option.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
("partitioning-heuristic-bipartite-phase-static",boost::program_options::value<int>()->default_value(0),"Use a static decomposition when the number of variable is more than the given parameter. Switch to the dynamic decomposition otherwise. If 0, this option is deactivated.")
("partitioning-heuristic-simplification-equivalence,phse",boost::program_options::value<bool>()->default_value(true),"The graph with be simplified by considering literal equivalence.")
("partitioning-heuristic-simplification-hyperedge,phsh",boost::program_options::value<bool>()->default_value(true),"The graph with be simplified by reducing the hyper edges.")
("partitioning-threads",boost::program_options::value<unsigned>()->default_value(1),"The number of threads to use for partitioning.")
("cache-reduction-strategy,crs", boost::program_options::value<std::string>()->default_value("expectation"), "The strategy used to reduce the cache structure [none, expectation, cache or sharpSAT].")
("cache-reduction-strategy-cachet-limit,crscl", boost::program_options::value<unsigned long>()->default_value(10UL * (1<<21)), "The limit in term of number of entries, the cachet reduction strategy allows.")
("cache-reduction-strategy-expectation-limit,crsel", boost::program_options::value<unsigned long>()->default_value(100000), "The frequency in term of number of negative hits used for the expectation reduction strategy allows.")
Expand Down
13 changes: 8 additions & 5 deletions src/partitioner/PartitionerKahyparMT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ PartitionerKahyparMT::PartitionerKahyparMT(unsigned maxNodes, unsigned maxEdges,

context = mt_kahypar_context_new();
mt_kahypar_set_partitioning_parameters(context, 2 /* number of blocks */,
0.03 /* imbalance parameter */,
CUT /* objective function */);
mt_kahypar_set_context_parameter(context, VERBOSE, "0");
mt_kahypar_load_preset(context, DEFAULT);
mt_kahypar_set_seed(42 /* seed */);
0.05 /* imbalance parameter */,
SOED /* objective function */);

mt_kahypar_set_context_parameter(context, VERBOSE, "0");
mt_kahypar_load_preset(context, mt_kahypar_preset_type_t::QUALITY);
} // constructor

/**
Expand All @@ -63,6 +62,10 @@ PartitionerKahyparMT::~PartitionerKahyparMT() {
mt_kahypar_free_context(context);
} // destructor

void PartitionerKahyparMT::initPartitioner(Config &config) {
mt_kahypar_initialize_thread_pool(config.partitioning_threads, true);
}

/**
Get a partition from the hypergraph.
Expand Down
6 changes: 4 additions & 2 deletions src/partitioner/PartitionerKahyparMT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
*/
#pragma once

#include <functional>
#include <vector>
#include <memory>
#include <libmtkahypar.h>

#include "libmtkahypar.h"
#include "src/config/Config.hpp"

#include "PartitionerManager.hpp"

Expand All @@ -43,5 +43,7 @@ class PartitionerKahyparMT : public PartitionerManager {
~PartitionerKahyparMT();
void computePartition(HyperGraph &hypergraph, Level level,
std::vector<int> &partition);

static void initPartitioner(Config &config);
};
} // namespace d4

0 comments on commit 8cd1816

Please sign in to comment.