-
Notifications
You must be signed in to change notification settings - Fork 900
Move yield capability to opal thread component #8037
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
Conversation
The IBM CI (GNU/Scale) build failed! Please review the log, linked below. Gist: https://gist.github.com/a2564f8c8ba9bdb2332b6d1fe978e3b7 |
The IBM CI (PGI) build failed! Please review the log, linked below. Gist: https://gist.github.com/949782597258de0c7ad48b8833f04858 |
The IBM CI (XL) build failed! Please review the log, linked below. Gist: https://gist.github.com/6fd4bdb517db3a0833ed3c590fa23024 |
49fb30c
to
ae8b5f9
Compare
@devreal I suspect you are aware of this, but just as a reminder: calling something via an MCA interface costs about 5ns. So doing that to execute a 1ns |
I think it boils down to a direct function call. Given that all pthread options either require a syscall or at least activate some low-level user-space thread scheduler the added function call should be negligible. I agree that a 1ns sleep is unrealistic but I wasn't sure what a good value actually is so this was the conservative choice. In part that is why it's configurable :) For Argobots and Qthreads the calls to |
c5f3e3d
to
6610871
Compare
I moved some around some of the pthread-specific code to reduce the number of non-static symbols and address the comments above. I also made the |
We end up doing a function call into a function call, for nothing. Why not having opal_thread_yield the function pointer that gets called only if non NULL, and then the threading layer set it to whatever it needs ? |
I think we should avoid function pointers where possible because indirect calls are more costly and prevent some optimizations (sibling call optimization and LTO, for example). Right now, |
OMPI embraced function pointers long ago, we evaluated the approach and it was well performing. |
It would be cheaper to have an empty function than an if and a call... function pointers are cheap(ish). Branches in front of function pointers, not so much. |
Is there a good reason to have both usleep and nanosleep? From what I remember nanosleep is considered superior to usleep in most respects. |
None in particular, other than giving people options to experiment with. After looking around the internet it looks like |
I removed the |
Can one of the admins verify this patch? |
Ping :) Could someone please review and let me know if this needs more changes? |
This adds two new mca parameters for the pthreads component: threads_pthreads_yield_strategy to choose the strategy (valid values: sched_yield or nanosleep), threads_pthreads_nanosleep_time (time passed to nanosleep) A thread component may also signal that yield-when-idle should be the default (used for Argobots and Qthreads) Signed-off-by: Joseph Schuchart <[email protected]>
f7b5408
to
45bfe03
Compare
Oops, I realized that the Argobots integration is not part of 4.1.x. We don't need to port this one back then. |
Looks like some results from IBM CI failed to report back. Let's re-run. |
👍 We can probably replace the release CPU function in opal_lifo (https://github.com/open-mpi/ompi/blob/master/opal/class/opal_lifo.h#L92) with this. |
Any objections to merging this PR? |
Can we get this merged? We really want this feature in |
This PR is based on a discussion at #6433 and aims to introduce alternative yielding mechanisms using
usleep
andnanosleep
, to be chosen at runtime through MCA parameters. In doing so, it moves the yielding implementation into the opal thread components and thus provide the correct yielding capabilities for Argobots/Qthreads.This adds two new mca parameters:
threads_pthreads_yield_strategy to choose the strategy (sched_yield and nanosleep, pthreads only), and
threads_pthreads_nanosleep_time (time passed to nanosleep, pthreads only)
A thread component may also signal that yield-when-idle should be the default. This is true for Argobots/Qhtreads because they are cooperatively scheduled and thus have to rely on MPI to yield the underlying thread and allow for all communication operations to be initiated eventually.
Marking this as WIP as I am unable to properly test the Argobots/Qthreads integration at this time, see #8036. I still wanted to put it out for people to comment and in case someone else was following the discussion linked above.
Fixes #7702
Signed-off-by: Joseph Schuchart [email protected]