Skip to content

Commit

Permalink
test: add scheduling point in threads/idup_deadlock
Browse files Browse the repository at this point in the history
When underlying threads are nonpreemptive (e.g., Argobots threads), a busy loop
can cause a deadlock.  This patch fixes a busy loop in threads/idup_deadlock by
adding MTest_thread_yield(), a new function that is translated into yield when
threads are nonpreemptive.
  • Loading branch information
shintaro-iwasaki committed Mar 30, 2020
1 parent 720e943 commit d0d2e59
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/mpi/threads/comm/idup_deadlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ MTEST_THREAD_RETURN_TYPE test_comm_dup(void *arg)
wait = 0;
for (i = 0; i < NUM_THREADS; i++)
wait += start_idup[i];
MTest_thread_yield();
} while (wait > NUM_THREADS / 2);
}

Expand Down
8 changes: 8 additions & 0 deletions test/mpi/util/mtest_thread_abt.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ int MTest_thread_lock_free(MTEST_THREAD_LOCK_TYPE * lock)
return 0;
}

int MTest_thread_yield(void)
{
int ret;
ret = ABT_thread_yield();
MTEST_ABT_ERROR(ret, "ABT_thread_yield");
return 0;
}

/* -------------------------------------------- */
#define HAVE_MTEST_THREAD_BARRIER 1

Expand Down
5 changes: 5 additions & 0 deletions test/mpi/util/mtest_thread_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ int MTest_thread_lock_free(MTEST_THREAD_LOCK_TYPE * lock)
return err;
}

int MTest_thread_yield(void)
{
return 0;
}

/*----------------------------------------------------------------*/
#if defined(HAVE_PTHREAD_BARRIER_INIT)

Expand Down
5 changes: 5 additions & 0 deletions test/mpi/util/mtest_thread_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@ int MTest_thread_lock_free(MTEST_THREAD_LOCK_TYPE * lock)
}
return MTestReturnValue(errs);
}

int MTest_thread_yield(void)
{
return 0;
}

0 comments on commit d0d2e59

Please sign in to comment.