From ce2064ca7eeab2aadc87cddf0c9f19eb8caa7ed9 Mon Sep 17 00:00:00 2001 From: Jan Baudisch Date: Wed, 13 Mar 2024 13:54:10 +0100 Subject: [PATCH] feat: change Mt-KaHyPar parameters --- src/Main.cpp | 3 ++- src/config/Config.cpp | 1 + src/config/Config.hpp | 1 + src/config/ConfigConverter.cpp | 1 + src/option.dsc | 1 + src/partitioner/PartitionerKahyparMT.cpp | 13 ++++++++----- src/partitioner/PartitionerKahyparMT.hpp | 6 ++++-- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index bb549d61..2d5f9d82 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -19,8 +19,8 @@ #include #include -#include +#include "partitioner/PartitionerKahyparMT.hpp" #include "src/config/ConfigConverter.hpp" #include "src/methods/MethodManager.hpp" @@ -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; diff --git a/src/config/Config.cpp b/src/config/Config.cpp index 512e6fd3..1b73d751 100644 --- a/src/config/Config.cpp +++ b/src/config/Config.cpp @@ -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; diff --git a/src/config/Config.hpp b/src/config/Config.hpp index 7c4814b0..fb2c6c1d 100644 --- a/src/config/Config.hpp +++ b/src/config/Config.hpp @@ -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; diff --git a/src/config/ConfigConverter.cpp b/src/config/ConfigConverter.cpp index 103f4465..a364226b 100644 --- a/src/config/ConfigConverter.cpp +++ b/src/config/ConfigConverter.cpp @@ -28,6 +28,7 @@ namespace d4 { config.partitioning_heuristic_bipartite_phase_static = vm["partitioning-heuristic-bipartite-phase-static"].as(); config.partitioning_heuristic_simplification_equivalence = vm["partitioning-heuristic-simplification-equivalence"].as(); config.partitioning_heuristic_simplification_hyperedge = vm["partitioning-heuristic-simplification-hyperedge"].as(); + config.partitioning_threads = vm["partitioning-threads"].as(); config.cache_reduction_strategy = vm["cache-reduction-strategy"].as(); config.cache_reduction_strategy_cachet_limit = vm["cache-reduction-strategy-cachet-limit"].as(); config.cache_reduction_strategy_expectation_limit = vm["cache-reduction-strategy-expectation-limit"].as(); diff --git a/src/option.dsc b/src/option.dsc index 5eafbaf3..a906259b 100644 --- a/src/option.dsc +++ b/src/option.dsc @@ -17,6 +17,7 @@ ("partitioning-heuristic-bipartite-phase-static",boost::program_options::value()->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()->default_value(true),"The graph with be simplified by considering literal equivalence.") ("partitioning-heuristic-simplification-hyperedge,phsh",boost::program_options::value()->default_value(true),"The graph with be simplified by reducing the hyper edges.") +("partitioning-threads",boost::program_options::value()->default_value(1),"The number of threads to use for partitioning.") ("cache-reduction-strategy,crs", boost::program_options::value()->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()->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()->default_value(100000), "The frequency in term of number of negative hits used for the expectation reduction strategy allows.") diff --git a/src/partitioner/PartitionerKahyparMT.cpp b/src/partitioner/PartitionerKahyparMT.cpp index c12c5e7b..f8c328e2 100644 --- a/src/partitioner/PartitionerKahyparMT.cpp +++ b/src/partitioner/PartitionerKahyparMT.cpp @@ -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 /** @@ -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. diff --git a/src/partitioner/PartitionerKahyparMT.hpp b/src/partitioner/PartitionerKahyparMT.hpp index 5747aa80..a231bdce 100644 --- a/src/partitioner/PartitionerKahyparMT.hpp +++ b/src/partitioner/PartitionerKahyparMT.hpp @@ -17,11 +17,11 @@ */ #pragma once -#include #include #include +#include -#include "libmtkahypar.h" +#include "src/config/Config.hpp" #include "PartitionerManager.hpp" @@ -43,5 +43,7 @@ class PartitionerKahyparMT : public PartitionerManager { ~PartitionerKahyparMT(); void computePartition(HyperGraph &hypergraph, Level level, std::vector &partition); + + static void initPartitioner(Config &config); }; } // namespace d4