1818#include " PartitionerKahyparMT.hpp"
1919
2020#include < iostream>
21- #include < libmtkahypar.h>
2221#include < vector>
2322
23+ #include " mtkahypar.h"
2424#include " src/exceptions/OptionException.hpp"
2525
2626namespace d4 {
@@ -34,6 +34,8 @@ namespace d4 {
3434PartitionerKahyparMT::PartitionerKahyparMT (unsigned maxNodes, unsigned maxEdges,
3535 unsigned maxSumEdgeSize,
3636 std::ostream &out) {
37+ mt_kahypar_error_t error{};
38+
3739 m_pins = std::make_unique<mt_kahypar_hyperedge_id_t []>(maxSumEdgeSize);
3840 m_xpins = std::make_unique<size_t []>(maxEdges + 3 );
3941 m_cwghts = std::make_unique<mt_kahypar_hyperedge_weight_t []>(maxNodes + 3 );
@@ -46,13 +48,13 @@ PartitionerKahyparMT::PartitionerKahyparMT(unsigned maxNodes, unsigned maxEdges,
4648 m_mapNodes.resize (maxNodes + 3 , false );
4749 m_markedNodes.resize (maxNodes + 3 , false );
4850
49- context = mt_kahypar_context_new ( );
51+ mt_kahypar_context_t * context = mt_kahypar_context_from_preset (DEFAULT );
5052 mt_kahypar_set_partitioning_parameters (context, 2 /* number of blocks */ ,
5153 0.05 /* imbalance parameter */ ,
5254 CUT /* objective function */ );
5355
54- mt_kahypar_set_context_parameter (context, VERBOSE, " 0" );
55- mt_kahypar_load_preset (context, mt_kahypar_preset_type_t ::QUALITY );
56+ mt_kahypar_status_t status = mt_kahypar_set_context_parameter (context, VERBOSE, " 0" , &error );
57+ assert (status == SUCCESS );
5658} // constructor
5759
5860/* *
@@ -63,7 +65,7 @@ PartitionerKahyparMT::~PartitionerKahyparMT() {
6365} // destructor
6466
6567void PartitionerKahyparMT::initPartitioner (Config &config) {
66- mt_kahypar_initialize_thread_pool (config.partitioning_threads , true );
68+ mt_kahypar_initialize (config.partitioning_threads , true );
6769}
6870
6971/* *
@@ -74,6 +76,7 @@ void PartitionerKahyparMT::initPartitioner(Config &config) {
7476 */
7577void PartitionerKahyparMT::computePartition (HyperGraph &hypergraph, Level level,
7678 std::vector<int > &partition) {
79+ mt_kahypar_error_t error{};
7780 std::vector<unsigned > elts;
7881
7982 // graph initialization and shift the hypergraph
@@ -109,15 +112,16 @@ void PartitionerKahyparMT::computePartition(HyperGraph &hypergraph, Level level,
109112 const mt_kahypar_hyperedge_id_t num_hyperedges = sizeXpins;
110113
111114 auto hgraph =
112- mt_kahypar_create_hypergraph (DEFAULT , num_vertices, num_hyperedges,
113- m_xpins.get (), m_pins.get (), cost, nullptr );
115+ mt_kahypar_create_hypergraph (context , num_vertices, num_hyperedges,
116+ m_xpins.get (), m_pins.get (), cost, nullptr , &error );
114117
115- auto p = mt_kahypar_partition (hgraph, context);
118+ auto p = mt_kahypar_partition (hgraph, context, &error );
116119
117120 mt_kahypar_get_partition (p, m_partition.data ());
118121
119- mt_kahypar_free_partitioned_hypergraph (p);
120122 mt_kahypar_free_hypergraph (hgraph);
123+ mt_kahypar_free_partitioned_hypergraph (p);
124+
121125 for (unsigned i = 0 ; i < elts.size (); i++)
122126 partition[elts[i]] = m_partition[i];
123127} // computePartition
0 commit comments