Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return an error when initial partitionning fails because trying to partition a graph into too many parts #94

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ graphs/*.npart.*
GKlib
.svn/

# VSCode things
.vscode/

28 changes: 14 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ endif(SHARED)
include(./conf/gkbuild.cmake)

# METIS' custom options
#option(IDX64 "enable 64 bit ints" OFF)
#option(REAL64 "enable 64 bit floats (i.e., double)" OFF)
#if(IDX64)
# set(METIS_COPTIONS "${METIS_COPTIONS} -DIDXTYPEWIDTH=64")
#else()
# set(METIS_COPTIONS "${METIS_COPTIONS} -DIDXTYPEWIDTH=32")
#endif(IDX64)
#if(REAL64)
# set(METIS_COPTIONS "${METIS_COPTIONS} -DREALTYPEWIDTH=64")
#else()
# set(METIS_COPTIONS "${METIS_COPTIONS} -DREALTYPEWIDTH=32")
#endif(REAL64)
#
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${METIS_COPTIONS}")
option(IDX64 "enable 64 bit ints" OFF)
option(REAL64 "enable 64 bit floats (i.e., double)" OFF)
if(IDX64)
set(METIS_COPTIONS "${METIS_COPTIONS} -DIDXTYPEWIDTH=64")
else()
set(METIS_COPTIONS "${METIS_COPTIONS} -DIDXTYPEWIDTH=32")
endif(IDX64)
if(REAL64)
set(METIS_COPTIONS "${METIS_COPTIONS} -DREALTYPEWIDTH=64")
else()
set(METIS_COPTIONS "${METIS_COPTIONS} -DREALTYPEWIDTH=32")
endif(REAL64)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${METIS_COPTIONS}")


# Add include directories.
Expand Down
3 changes: 3 additions & 0 deletions libmetis/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,7 @@
#define KMETIS_DEFAULT_UFACTOR 30
#define OMETIS_DEFAULT_UFACTOR 200

/* Metis error during recursive bisection */
#define METIS_ERR_INVALID_BISECTION -999999

#endif
23 changes: 19 additions & 4 deletions libmetis/pmetis.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ int METIS_PartGraphRecursive(idx_t *nvtxs, idx_t *ncon, idx_t *xadj,
iset(*nvtxs, 0, part);
*objval = (*nparts == 1 ? 0 : MlevelRecursiveBisection(ctrl, graph, *nparts, part, ctrl->tpwgts, 0));

if (*objval == METIS_ERR_INVALID_BISECTION)
return metis_rcode(METIS_ERR_INVALID_BISECTION);

IFSET(ctrl->dbglvl, METIS_DBG_TIME, gk_stopcputimer(ctrl->TotalTmr));
IFSET(ctrl->dbglvl, METIS_DBG_TIME, PrintTimers(ctrl));

Expand Down Expand Up @@ -165,7 +168,7 @@ idx_t MlevelRecursiveBisection(ctrl_t *ctrl, graph_t *graph, idx_t nparts,
if ((nvtxs = graph->nvtxs) == 0) {
printf("\t***Cannot bisect a graph with 0 vertices!\n"
"\t***You are trying to partition a graph into too many parts!\n");
return 0;
return METIS_ERR_INVALID_BISECTION;
}

ncon = graph->ncon;
Expand Down Expand Up @@ -203,16 +206,28 @@ idx_t MlevelRecursiveBisection(ctrl_t *ctrl, graph_t *graph, idx_t nparts,
}

/* Do the recursive call */
idx_t lobjval, robjval;
if (nparts > 3) {
objval += MlevelRecursiveBisection(ctrl, lgraph, (nparts>>1), part,
lobjval = MlevelRecursiveBisection(ctrl, lgraph, (nparts>>1), part,
tpwgts, fpart);
objval += MlevelRecursiveBisection(ctrl, rgraph, nparts-(nparts>>1), part,
robjval = MlevelRecursiveBisection(ctrl, rgraph, nparts-(nparts>>1), part,
tpwgts+(nparts>>1)*ncon, fpart+(nparts>>1));

if (lobjval != METIS_ERR_INVALID_BISECTION && robjval != METIS_ERR_INVALID_BISECTION) {
objval += lobjval + robjval;
}
else
objval = METIS_ERR_INVALID_BISECTION;
}
else if (nparts == 3) {
FreeGraph(&lgraph);
objval += MlevelRecursiveBisection(ctrl, rgraph, nparts-(nparts>>1), part,
robjval = MlevelRecursiveBisection(ctrl, rgraph, nparts-(nparts>>1), part,
tpwgts+(nparts>>1)*ncon, fpart+(nparts>>1));
if (robjval != METIS_ERR_INVALID_BISECTION) {
objval += robjval;
}
else
objval = METIS_ERR_INVALID_BISECTION;
}


Expand Down