-
Notifications
You must be signed in to change notification settings - Fork 52
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
add blocking_fifo pool type #46
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
24355f1
skip redundant pool size check and pop
carns 96b7c48
clean up superfluous definition
carns 4c235b2
implement BLOCKING_FIFO pool
carns f6e31bc
bug fix
carns bed2316
test program for blocking_fifo pool
carns 7cab4b5
bug fix
carns c473210
tune basic scheduler for use with blocking fifo
carns File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,8 +95,7 @@ static void sched_run(ABT_sched sched) | |
for (i = 0; i < num_pools; i++) { | ||
ABT_pool pool = p_pools[i]; | ||
ABTI_pool *p_pool = ABTI_pool_get_ptr(pool); | ||
size_t size = ABTI_pool_get_size(p_pool); | ||
if (size > 0) { | ||
if (num_pools == 1 || ABTI_pool_get_size(p_pool) > 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. same comment as above |
||
ABT_unit unit = ABTI_pool_pop(p_pool); | ||
if (unit != ABT_UNIT_NULL) { | ||
ABTI_xstream_run_unit(p_xstream, unit, p_pool); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,8 +82,7 @@ static void sched_run(ABT_sched sched) | |
/* Execute one work unit from the scheduler's pool */ | ||
ABT_pool pool = p_pools[0]; | ||
ABTI_pool *p_pool = ABTI_pool_get_ptr(pool); | ||
size_t size = ABTI_pool_get_size(p_pool); | ||
if (size > 0) { | ||
if (num_pools == 1 || ABTI_pool_get_size(p_pool) > 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. same comment as above with a slight variation. |
||
unit = ABTI_pool_pop(p_pool); | ||
if (unit != ABT_UNIT_NULL) { | ||
ABTI_xstream_run_unit(p_xstream, unit, p_pool); | ||
|
@@ -94,7 +93,7 @@ static void sched_run(ABT_sched sched) | |
target = (num_pools == 2) ? 1 : (rand_r(&seed) % (num_pools-1) + 1); | ||
pool = p_pools[target]; | ||
p_pool = ABTI_pool_get_ptr(pool); | ||
size = ABTI_pool_get_size(p_pool); | ||
size_t size = ABTI_pool_get_size(p_pool); | ||
if (size > 0) { | ||
unit = ABTI_pool_pop(p_pool); | ||
LOG_EVENT_POOL_POP(p_pool, unit); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't think acquiring the lock here is necessary. The pool push operation should be thread safe and
cond_signal
does not need a lockThere 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.
I agree cond_signal() itself doesn't need a lock, but the lock in this specific example is to prevent a race between the waiter checking for the pool being empty and this function adding something to the pool. Without the mutex the you could theoretically get this order of operations, with thread a calling pop() and thread b calling push():
thread a: lock
thread a: check if pool is empty
thread b: insert into pool queue
thread b: cond_signal
thread a: cond_wait
Thread a will block in this case even though there is work in the pool when it hits the cond_wait() call.
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.
the timeout != infinite avoids deadlocks in this PR, so I think it's still correct. Performance wise, my suggestion allows push() to be on a fast path and pop() on empty (including false positives) on a slow path. But I agree that if we change the semantic of the pool to include infinite wait on pop() (which I think is a likely API extension in the future), then keeping the lock for correctness is a must