Skip to content

Commit 60703e5

Browse files
fix(partitioner): update usage of mt-kahypar
1 parent 4023ada commit 60703e5

File tree

4 files changed

+17
-67
lines changed

4 files changed

+17
-67
lines changed

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.27)
1+
cmake_minimum_required(VERSION 3.30)
22

33
project(d4 VERSION 2.0.0 LANGUAGES CXX)
44

@@ -35,7 +35,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/glucose-3.0)
3535
include_directories(${GMP_INCLUDE_DIRS})
3636
include_directories(${GMPXX_INCLUDE_DIRS})
3737
include_directories(${Boost_INCLUDE_DIRS})
38-
include_directories(${MtKaHyPar_INCLUDE_DIR})
3938
include_directories(${arjun_INCLUDE_DIR})
4039
include_directories(${GMPC_INCLUDE_DIR})
4140
include_directories(${glucose_INCLUDE_DIRS})
@@ -156,7 +155,7 @@ add_library(core STATIC
156155
$<TARGET_OBJECTS:utils>
157156
)
158157

159-
target_link_libraries(core MtKaHyPar::MtKaHyPar GPMC::GPMC arjun glucose::glucose GMP::GMPXX GMP::GMP cadiback cadical)
158+
target_link_libraries(core MtKaHyPar::mtkahypar GPMC::GPMC arjun glucose::glucose GMP::GMPXX GMP::GMP cadiback cadical)
160159

161160
if(USE_GLUCOSE)
162161
target_link_libraries(core glucose::glucose)

cmake/FindMtKaHyPar.cmake

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/partitioner/PartitionerKahyparMT.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
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

2626
namespace d4 {
@@ -34,6 +34,8 @@ namespace d4 {
3434
PartitionerKahyparMT::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

6567
void 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
*/
7577
void 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

src/partitioner/PartitionerKahyparMT.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include <vector>
2121
#include <memory>
22-
#include <libmtkahypar.h>
22+
#include <mtkahypar.h>
2323

2424
#include "src/config/Config.hpp"
2525

@@ -35,6 +35,7 @@ class PartitionerKahyparMT : public PartitionerManager {
3535
std::unique_ptr<mt_kahypar_hyperedge_id_t[]> m_pins;
3636
std::vector<mt_kahypar_partition_id_t> m_partition;
3737
mt_kahypar_context_s *context;
38+
mt_kahypar_error_t error;
3839

3940
public:
4041
PartitionerKahyparMT(unsigned maxNodes, unsigned maxEdges,

0 commit comments

Comments
 (0)