Skip to content

Commit f9de4ea

Browse files
feat(partitioner): print mt-kahypar errors
1 parent 1225249 commit f9de4ea

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/partitioner/PartitionerKahyparMT.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ namespace d4 {
3434
PartitionerKahyparMT::PartitionerKahyparMT(unsigned maxNodes, unsigned maxEdges,
3535
unsigned maxSumEdgeSize,
3636
std::ostream &out) {
37-
mt_kahypar_error_t error{};
38-
3937
m_pins = std::make_unique<mt_kahypar_hyperedge_id_t[]>(maxSumEdgeSize);
4038
m_xpins = std::make_unique<size_t[]>(maxEdges + 3);
4139
m_cwghts = std::make_unique<mt_kahypar_hyperedge_weight_t[]>(maxNodes + 3);
4240
m_partition = std::vector<mt_kahypar_partition_id_t>(maxNodes + 3);
41+
mt_kahypar_error_t error{};
4342

4443
// set all weight to 1
4544
for (unsigned i = 0; i < (maxNodes + 3); i++)
@@ -48,13 +47,16 @@ PartitionerKahyparMT::PartitionerKahyparMT(unsigned maxNodes, unsigned maxEdges,
4847
m_mapNodes.resize(maxNodes + 3, false);
4948
m_markedNodes.resize(maxNodes + 3, false);
5049

51-
mt_kahypar_context_t* context = mt_kahypar_context_from_preset(DEFAULT);
50+
context = mt_kahypar_context_from_preset(DEFAULT);
5251
mt_kahypar_set_partitioning_parameters(context, 2 /* number of blocks */,
5352
0.05 /* imbalance parameter */,
5453
CUT /* objective function */);
5554

56-
mt_kahypar_status_t status = mt_kahypar_set_context_parameter(context, VERBOSE, "0", &error);
57-
assert(status == SUCCESS);
55+
mt_kahypar_set_context_parameter(context, VERBOSE, "0", &error);
56+
if (error.status != SUCCESS) {
57+
std::cerr << error.msg << std::endl;
58+
std::exit(1);
59+
}
5860
} // constructor
5961

6062
/**
@@ -76,8 +78,8 @@ void PartitionerKahyparMT::initPartitioner(Config &config) {
7678
*/
7779
void PartitionerKahyparMT::computePartition(HyperGraph &hypergraph, Level level,
7880
std::vector<int> &partition) {
79-
mt_kahypar_error_t error{};
8081
std::vector<unsigned> elts;
82+
mt_kahypar_error_t error{};
8183

8284
// graph initialization and shift the hypergraph
8385
unsigned sizeXpins = 0;
@@ -115,8 +117,18 @@ void PartitionerKahyparMT::computePartition(HyperGraph &hypergraph, Level level,
115117
mt_kahypar_create_hypergraph(context, num_vertices, num_hyperedges,
116118
m_xpins.get(), m_pins.get(), cost, nullptr, &error);
117119

120+
if (error.status != SUCCESS) {
121+
std::cerr << error.msg << std::endl;
122+
std::exit(1);
123+
}
124+
118125
auto p = mt_kahypar_partition(hgraph, context, &error);
119126

127+
if (error.status != SUCCESS) {
128+
std::cerr << error.msg << std::endl;
129+
std::exit(1);
130+
}
131+
120132
mt_kahypar_get_partition(p, m_partition.data());
121133

122134
mt_kahypar_free_hypergraph(hgraph);

0 commit comments

Comments
 (0)