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

Serialize calls to gasnet_AMPoll for IBV/Aries #14912

Merged
merged 2 commits into from
Feb 18, 2020
Merged
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
23 changes: 21 additions & 2 deletions runtime/src/comm/gasnet/comm-gasnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,16 @@ void init_done_obj(done_t* done, int target) {
done->flag = 0;
}

static inline void am_poll_try(void);

static inline
void wait_done_obj(done_t* done, chpl_bool do_yield)
{
#ifndef CHPL_COMM_YIELD_TASK_WHILE_POLLING
GASNET_BLOCKUNTIL(done->flag);
#else
while (!done->flag) {
(void) gasnet_AMPoll();
am_poll_try();
if (do_yield)
chpl_task_yield();
}
Expand Down Expand Up @@ -720,19 +722,36 @@ int32_t chpl_comm_getMaxThreads(void) {
static volatile int pollingRunning;
static volatile int pollingQuit;
static chpl_bool pollingRequired;
static atomic_bool pollingLock;

static inline void am_poll_try(void) {
// Serialize polling for IBV and Aries. Concurrent polling causes contention
// in these configurations. For other configurations that are AM-based
// (udp/amudp, mpi/ammpi) serializing can hurt performance.
#if defined(GASNET_CONDUIT_IBV) || defined(GASNET_CONDUIT_ARIES)
if (!atomic_load_explicit_bool(&pollingLock, memory_order_acquire) &&
!atomic_exchange_explicit_bool(&pollingLock, true, memory_order_acquire)) {
(void) gasnet_AMPoll();
atomic_store_explicit_bool(&pollingLock, false, memory_order_release);
}
#else
(void) gasnet_AMPoll();
#endif
}

static void polling(void* x) {
pollingRunning = 1;

while (!pollingQuit) {
(void) gasnet_AMPoll();
am_poll_try();
chpl_task_yield();
}

pollingRunning = 0;
}

static void setup_polling(void) {
atomic_init_bool(&pollingLock, false);
#if defined(GASNET_CONDUIT_IBV)
pollingRequired = false;
chpl_env_set("GASNET_RCV_THREAD", "1", 1);
Expand Down