-
Notifications
You must be signed in to change notification settings - Fork 930
optionally passive wait when the progress loop is idle for a while #4331
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| * All rights reserved. | ||
| * Copyright (c) 2006-2016 Los Alamos National Security, LLC. All rights | ||
| * reserved. | ||
| * Copyright (c) 2015-2016 Research Organization for Information Science | ||
| * Copyright (c) 2015-2017 Research Organization for Information Science | ||
| * and Technology (RIST). All rights reserved. | ||
| * | ||
| * $COPYRIGHT$ | ||
|
|
@@ -27,6 +27,11 @@ | |
| #ifdef HAVE_SCHED_H | ||
| #include <sched.h> | ||
| #endif | ||
| #if HAVE_POLL_H | ||
| #include <poll.h> | ||
| #elif HAVE_SYS_POLL_H | ||
| #include <sys/poll.h> | ||
| #endif | ||
|
|
||
| #include "opal/runtime/opal_progress.h" | ||
| #include "opal/mca/event/event.h" | ||
|
|
@@ -66,6 +71,9 @@ static size_t callbacks_lp_size = 0; | |
|
|
||
| /* do we want to call sched_yield() if nothing happened */ | ||
| bool opal_progress_yield_when_idle = false; | ||
| /* do we want to sleep if nothing happened for a while */ | ||
| int opal_progress_sleep_when_idle_threshold = -1; | ||
| static int yield_count = 0; | ||
|
|
||
| #if OPAL_PROGRESS_USE_TIMERS | ||
| static opal_timer_t event_progress_last_time = 0; | ||
|
|
@@ -229,16 +237,25 @@ opal_progress(void) | |
| } | ||
| } | ||
|
|
||
| if (OPAL_UNLIKELY(opal_progress_yield_when_idle)) { | ||
| if (events <= 0) { | ||
| if (opal_progress_sleep_when_idle_threshold < 0 || yield_count < opal_progress_sleep_when_idle_threshold) { | ||
| yield_count++; | ||
| #if OPAL_HAVE_SCHED_YIELD | ||
| if (opal_progress_yield_when_idle && events <= 0) { | ||
| /* If there is nothing to do - yield the processor - otherwise | ||
| * we could consume the processor for the entire time slice. If | ||
| * the processor is oversubscribed - this will result in a best-case | ||
| * latency equivalent to the time-slice. | ||
| */ | ||
| sched_yield(); | ||
| } | ||
| /* If there is nothing to do - yield the processor - otherwise | ||
| * we could consume the processor for the entire time slice. If | ||
| * the processor is oversubscribed - this will result in a best-case | ||
| * latency equivalent to the time-slice. | ||
| */ | ||
| sched_yield(); | ||
| #endif /* defined(HAVE_SCHED_YIELD) */ | ||
| } else { | ||
| poll(NULL, 0, 1); | ||
| } | ||
| } else { | ||
| yield_count = 0; | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If, per the comment above, we end up squashing both mechanisms into the same MCA variable, you should probably squash these two blocks together (i.e., the |
||
| } | ||
|
|
||
|
|
||
|
|
@@ -310,6 +327,20 @@ opal_progress_set_yield_when_idle(bool yieldopt) | |
| } | ||
|
|
||
|
|
||
| int | ||
| opal_progress_set_sleep_when_idle_threshold(int thresholdopt) | ||
| { | ||
| int tmp = opal_progress_sleep_when_idle_threshold; | ||
|
|
||
| opal_progress_sleep_when_idle_threshold = thresholdopt; | ||
|
|
||
| OPAL_OUTPUT((debug_output, "progress: progress_set_sleep_threshold to %d", | ||
| thresholdopt)); | ||
|
|
||
| return tmp; | ||
| } | ||
|
|
||
|
|
||
| void | ||
| opal_progress_set_event_poll_rate(int polltime) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still mention MPI in here, and also mention oversubscription (but the code doesn't check for oversubscription (per comments, we're still discussing what the default should be -- I just want to make sure that we don't forget to update the help message when a decision is made).