Skip to content

Commit 17f034d

Browse files
committed
make metis fail when >256 procs
- metis/apfMETIS.h: add APF_METIS_MAXRANKS macro. - metis/apfMETISbalancer.cc: fail with error message when more than 256 peers. - metis/apfMETISsplitter.cc: fail when more than 256 peers. - metis/apfMETIScommon.h: add STRINGIFY macro for error messages. - ma/maBalance.cc: fallback to Parma when PUMI_HAS_METIS but more than 256 peers to avoid failure. Signed-off-by: Aiden Woodruff <[email protected]>
1 parent 67bb47c commit 17f034d

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

ma/maBalance.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ void preBalance(Adapt* a)
184184
return;
185185
}
186186
#elif defined(PUMI_HAS_METIS)
187-
runMETIS(a);
187+
if (a->mesh->getPCU()->Peers() < APF_METIS_MAXRANKS) runMETIS(a);
188+
else runParma(a);
189+
return;
188190
#else
189191
runParma(a);
190192
return;
@@ -230,7 +232,8 @@ void midBalance(Adapt* a)
230232
return;
231233
}
232234
#elif defined(PUMI_HAS_METIS)
233-
runMETIS(a);
235+
if (a->mesh->getPCU()->Peers() < APF_METIS_MAXRANKS) runMETIS(a);
236+
else runParma(a);
234237
return;
235238
#else
236239
runParma(a);
@@ -288,7 +291,8 @@ void postBalance(Adapt* a)
288291
return;
289292
}
290293
#elif defined(PUMI_HAS_METIS)
291-
runMETIS(a);
294+
if (a->mesh->getPCU()->Peers() < APF_METIS_MAXRANKS) runMETIS(a);
295+
else runParma(a);
292296
printEntityImbalance(a->mesh);
293297
#else
294298
runParma(a);

metis/apfMETIS.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef APF_METIS_H
88
#define APF_METIS_H
99

10+
#define APF_METIS_MAXRANKS 256
11+
1012
/**
1113
* \file apfMETIS.h
1214
* \brief METIS partitioning for apf::Mesh objects.

metis/apfMETISbalancer.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <apfShape.h>
1717
#include <lionPrint.h>
1818
#include <pcu_util.h>
19+
#include "apfMETIS.h"
1920

2021
#include <metis.h>
2122

@@ -170,6 +171,12 @@ static void remapPart(int nparts, std::vector<idx_t>& part, const std::vector<in
170171

171172
void MetisBalancer::balance(MeshTag* weights, double tolerance) {
172173
PCU_ALWAYS_ASSERT(tolerance > 1.0);
174+
if (mesh_->getPCU()->Peers() > APF_METIS_MAXRANKS) {
175+
fail(
176+
"METIS called with > " STRINGIFY(APF_METIS_MAXRANKS)
177+
" procs, which is unsupported due to memory requirements\n"
178+
);
179+
}
173180
if (weights != nullptr) {
174181
if (mesh_->getPCU()->Self() == 0)
175182
lion_oprint(1, "METIS: weights are not supported\n");

metis/apfMETIScommon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#ifndef APF_METIS_COMMON_H
99
#define APF_METIS_COMMON_H
1010

11+
#define STRINGIFY(arg) #arg
12+
1113
#include <vector>
1214

1315
namespace apf {

metis/apfMETISsplitter.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <apfShape.h>
44
#include <lionPrint.h>
55
#include <pcu_util.h>
6+
#include "apfMETIS.h"
67

78
#include <metis.h>
89

@@ -18,6 +19,12 @@ Migration* MetisSplitter::split(
1819
) {
1920
PCU_ALWAYS_ASSERT(tolerance > 1.0);
2021
PCU_ALWAYS_ASSERT(multiple > 1);
22+
if (mesh_->getPCU()->Peers() > APF_METIS_MAXRANKS) {
23+
fail(
24+
"METIS called with > " STRINGIFY(APF_METIS_MAXRANKS)
25+
" procs, which is unsupported due to memory requirements\n"
26+
);
27+
}
2128
auto t0 = pcu::Time();
2229
if (weights != nullptr) {
2330
lion_oprint(1, "METIS: weights are not supported\n");

0 commit comments

Comments
 (0)