-
Notifications
You must be signed in to change notification settings - Fork 934
Improve request/progress performance #1810
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |
| * Copyright (c) 2014-2016 The University of Tennessee and The University | ||
| * of Tennessee Research Foundation. All rights | ||
| * reserved. | ||
| * Copyright (c) 2016 Los Alamos National Security, LLC. All rights | ||
| * reserved. | ||
| * $COPYRIGHT$ | ||
| * | ||
| * Additional copyrights may follow | ||
|
|
@@ -27,50 +29,44 @@ typedef struct ompi_wait_sync_t { | |
| #define REQUEST_PENDING (void*)0L | ||
| #define REQUEST_COMPLETED (void*)1L | ||
|
|
||
| #if OPAL_ENABLE_MULTI_THREADS | ||
|
|
||
| #define OPAL_ATOMIC_ADD_32(a,b) opal_atomic_add_32(a,b) | ||
| #define OPAL_ATOMIC_SWP_PTR(a,b) opal_atomic_swap_ptr(a,b) | ||
| #define SYNC_WAIT(sync) sync_wait_mt(sync) | ||
| #define PTHREAD_COND_INIT(a,b) pthread_cond_init(a,b) | ||
| #define PTHREAD_MUTEX_INIT(a,b) pthread_mutex_init(a,b) | ||
| #define SYNC_WAIT(sync) (opal_using_threads() ? sync_wait_mt (sync) : sync_wait_st (sync)) | ||
| #define PTHREAD_COND_INIT(a,b) (opal_using_threads() ? pthread_cond_init (a,b) : 0) | ||
| #define PTHREAD_MUTEX_INIT(a,b) (opal_using_threads() ? pthread_mutex_init (a,b) : 0) | ||
|
|
||
| #define WAIT_SYNC_RELEASE(sync) \ | ||
| do { \ | ||
| if (opal_using_threads()) { \ | ||
| pthread_cond_destroy(&(sync)->condition); \ | ||
| pthread_mutex_destroy(&(sync)->lock); \ | ||
| } while(0) | ||
| } | ||
|
|
||
| #define WAIT_SYNC_SIGNAL(sync) \ | ||
| do { \ | ||
| if (opal_using_threads()) { \ | ||
| pthread_mutex_lock(&(sync->lock)); \ | ||
| pthread_cond_signal(&sync->condition); \ | ||
| pthread_mutex_unlock(&(sync->lock)); \ | ||
| } while(0) | ||
|
|
||
| #else | ||
| } | ||
|
|
||
| #define OPAL_ATOMIC_ADD_32(a,b) (*(a) += (b)) | ||
| #define OPAL_ATOMIC_SWP_PTR(a,b) *(a) = (b) | ||
| #define PTHREAD_COND_INIT(a,b) | ||
| #define PTHREAD_MUTEX_INIT(a,b) | ||
| #define SYNC_WAIT(sync) sync_wait_st(sync) | ||
| #define WAIT_SYNC_RELEASE(sync) | ||
| #define WAIT_SYNC_SIGNAL(sync) | ||
| OPAL_DECLSPEC int sync_wait_mt(ompi_wait_sync_t *sync); | ||
| static inline int sync_wait_st (ompi_wait_sync_t *sync) | ||
| { | ||
| while (sync->count > 0) { | ||
| opal_progress(); | ||
| } | ||
|
|
||
| #endif /* OPAL_ENABLE_MULTI_THREADS */ | ||
| return sync->status; | ||
| } | ||
|
|
||
| OPAL_DECLSPEC int sync_wait_mt(ompi_wait_sync_t *sync); | ||
| OPAL_DECLSPEC int sync_wait_st(ompi_wait_sync_t *sync); | ||
|
|
||
| #define WAIT_SYNC_INIT(sync,c) \ | ||
| do { \ | ||
| (sync)->count = c; \ | ||
| (sync)->next = NULL; \ | ||
| (sync)->prev = NULL; \ | ||
| (sync)->status = 0; \ | ||
| PTHREAD_COND_INIT(&(sync)->condition, NULL); \ | ||
| PTHREAD_MUTEX_INIT(&(sync)->lock, NULL); \ | ||
| #define WAIT_SYNC_INIT(sync,c) \ | ||
| do { \ | ||
| (sync)->count = c; \ | ||
| (sync)->next = NULL; \ | ||
| (sync)->prev = NULL; \ | ||
| (sync)->status = 0; \ | ||
| if (opal_using_threads()) { \ | ||
| PTHREAD_COND_INIT(&(sync)->condition, NULL); \ | ||
| PTHREAD_MUTEX_INIT(&(sync)->lock, NULL); \ | ||
| } \ | ||
| } while(0) | ||
|
|
||
| /** | ||
|
|
@@ -82,12 +78,13 @@ OPAL_DECLSPEC int sync_wait_st(ompi_wait_sync_t *sync); | |
| static inline void wait_sync_update(ompi_wait_sync_t *sync, int updates, int status) | ||
| { | ||
| if( OPAL_LIKELY(OPAL_SUCCESS == status) ) { | ||
| if( 0 != (OPAL_ATOMIC_ADD_32(&sync->count, -updates)) ) { | ||
| if( 0 != (OPAL_THREAD_ADD32(&sync->count, -updates)) ) { | ||
| return; | ||
| } | ||
| } else { | ||
| OPAL_ATOMIC_CMPSET_32(&(sync->count), 0, 0); | ||
| sync->status = -1; | ||
| /* this is an error path so just use the atomic */ | ||
|
Member
Author
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. Want to point out this error path was wrong. |
||
| opal_atomic_swap_32 (&sync->count, 0); | ||
| sync->status = OPAL_ERROR; | ||
| } | ||
| WAIT_SYNC_SIGNAL(sync); | ||
| } | ||
|
|
||
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.
Since PTHREAD_COND_INIT and PTHREAD_MUTEX_INIT already check for opal_using_threads(), this branch might be redundant ?
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.
Indeed. I didn't think to check what those macro did. Will clean it up in a bit.
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.
Unless you want to do it. I can add your commit to the 2.x PR.
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.
Didn't see your comment until later, timezone issues. I see that you already have a PR to fix it - #1811
Thanks 👍