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

simplify algorithms of synchronization objects #268

Merged
merged 5 commits into from Dec 2, 2020

Conversation

shintaro-iwasaki
Copy link
Collaborator

Problem

The implementations of synchronization objects are overlapped but differently written in each file. Specifically, the core algorithm of synchronization objects is managing a queue of waiting threads, but ABT_cond, ABT_barrier, ABT_future, and ABT_eventual use similar but different code. ABT_mutex uses an incorrect queue implementation (see #14, #41, and #102).

Solution

To avoid code duplication, this PR implements ABTI_waitlist. ABT_mutex will use this when --disable-simple-mutex is passed; by default the existing yield-based implementation is used. Better ABT_mutex implementation is our future work.

Expected impact

This change significantly affects the performance of ABT_mutex with --disable-simple-mutex. The new implementation is correct but slower in some cases. This PR should not affect the performance of the other synchronization objects (including ABT_mutex without --disable-simple-mutex) much -- this PR should make them faster.

ABTI_waitlist is a helper to suspend and resume multiple threads, which is
useful to implement synchronization objects.  The next commit will change the
implementation of existing synchronization objects.
This patch uses ABTI_waitlist for synchronization objects including ABT_barrier,
ABT_cond, ABT_eventual, and ABT_future.  This can reduce the common code that
manages a queue of waiting threads.
The mutex logic that uses ABTI_thread_htable is broken and hard to fix.  This
patch removes this implementation.  Note that this algorithm is disabled by
default (which can be turned on by passing --disable-simple-mutex).
The current busy-yield-based implementation can easily make pools full of
waiting threads, which is inefficient.  ABTI_waitlist-based implementation can
avoid such a case.

Note that by default ABT_mutex will use busy-yield-based implementation in order
not to change the default performance of ABT_mutex.  For example, the original
implementation performs better if there is no contention.  ABTI_waitlist-based
implementation can be enabled by passing --disable-simple-mutex at configuration
time.
@shintaro-iwasaki
Copy link
Collaborator Author

test:argobots/all
test:argobots/freebsd
test:argobots/osx
test:argobots/solaris

@shintaro-iwasaki shintaro-iwasaki merged commit eeae7fe into pmodels:main Dec 2, 2020
@shintaro-iwasaki shintaro-iwasaki deleted the pr/waitlist branch December 2, 2020 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant