Skip to content

Commit

Permalink
fixed deadlock bug caused by bogosity flag getting out of synch betwe…
Browse files Browse the repository at this point in the history
…en processes; thanks to Michael Pippig for the bug report
  • Loading branch information
stevengj committed Nov 25, 2012
1 parent 69aa826 commit 01810ba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions kernel/ifftw.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ struct planner_s {
double (*cost_hook)(const problem *p, double t, cost_kind k);
int (*wisdom_ok_hook)(const problem *p, flags_t flags);
void (*nowisdom_hook)(const problem *p);
wisdom_state_t (*bogosity_hook)(wisdom_state_t state, const problem *p);

/* solver descriptors */
slvdesc *slvdescs;
Expand Down
9 changes: 6 additions & 3 deletions kernel/planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,11 @@ static plan *search(planner *ego, const problem *p, unsigned *slvndx,
return pln;
}

#define CHECK_FOR_BOGOSITY \
if (ego->wisdom_state == WISDOM_IS_BOGUS) \
goto wisdom_is_bogus
#define CHECK_FOR_BOGOSITY \
if ((ego->bogosity_hook ? \
(ego->wisdom_state = ego->bogosity_hook(ego->wisdom_state, p)) \
: ego->wisdom_state) == WISDOM_IS_BOGUS) \
goto wisdom_is_bogus;

static plan *mkplan(planner *ego, const problem *p)
{
Expand Down Expand Up @@ -923,6 +925,7 @@ planner *X(mkplanner)(void)
p->cost_hook = 0;
p->wisdom_ok_hook = 0;
p->nowisdom_hook = 0;
p->bogosity_hook = 0;
p->cur_reg_nam = 0;
p->wisdom_state = WISDOM_NORMAL;

Expand Down
12 changes: 12 additions & 0 deletions mpi/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,25 @@ static void nowisdom_hook(const problem *p)
XM(any_true)(1, comm); /* signal nowisdom to any wisdom_ok_hook */
}

/* needed to synchronize planner bogosity flag, in case non-MPI problems
on a subset of processes encountered bogus wisdom */
static wisdom_state_t bogosity_hook(wisdom_state_t state, const problem *p)
{
MPI_Comm comm = problem_comm(p);
if (comm != MPI_COMM_NULL /* an MPI problem */
&& XM(any_true)(state == WISDOM_IS_BOGUS, comm)) /* bogus somewhere */
return WISDOM_IS_BOGUS;
return state;
}

void XM(init)(void)
{
if (!mpi_inited) {
planner *plnr = X(the_planner)();
plnr->cost_hook = cost_hook;
plnr->wisdom_ok_hook = wisdom_ok_hook;
plnr->nowisdom_hook = nowisdom_hook;
plnr->bogosity_hook = bogosity_hook;
XM(conf_standard)(plnr);
mpi_inited = 1;
}
Expand Down

0 comments on commit 01810ba

Please sign in to comment.