Skip to content

coll/libnbc: demote progress_lock to regular flag #3901

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 1 commit into from
Jul 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ompi/mca/coll/libnbc/coll_libnbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ struct ompi_coll_libnbc_component_t {
opal_free_list_t requests;
opal_list_t active_requests;
int32_t active_comms;
opal_atomic_lock_t progress_lock; /* protect from recursive calls */
opal_mutex_t lock; /* protect access to the active_requests list */
};
typedef struct ompi_coll_libnbc_component_t ompi_coll_libnbc_component_t;
Expand Down
48 changes: 24 additions & 24 deletions ompi/mca/coll/libnbc/coll_libnbc_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const char *mca_coll_libnbc_component_version_string =


static int libnbc_priority = 10;
static bool libnbc_in_progress = false; /* protect from recursive calls */
bool libnbc_ibcast_skip_dt_decision = true;


Expand Down Expand Up @@ -102,8 +103,6 @@ libnbc_open(void)
a non-blocking collective started */
mca_coll_libnbc_component.active_comms = 0;

opal_atomic_init(&mca_coll_libnbc_component.progress_lock, OPAL_ATOMIC_UNLOCKED);

return OMPI_SUCCESS;
}

Expand Down Expand Up @@ -263,37 +262,38 @@ ompi_coll_libnbc_progress(void)
ompi_coll_libnbc_request_t* request, *next;
int res;

/* return if invoked recursively */
if (opal_atomic_trylock(&mca_coll_libnbc_component.progress_lock)) return 0;

/* process active requests, and use mca_coll_libnbc_component.lock to access the
* mca_coll_libnbc_component.active_requests list */
OPAL_THREAD_LOCK(&mca_coll_libnbc_component.lock);
OPAL_LIST_FOREACH_SAFE(request, next, &mca_coll_libnbc_component.active_requests,
ompi_coll_libnbc_request_t) {
OPAL_THREAD_UNLOCK(&mca_coll_libnbc_component.lock);
res = NBC_Progress(request);
if( NBC_CONTINUE != res ) {
/* done, remove and complete */
OPAL_THREAD_LOCK(&mca_coll_libnbc_component.lock);
opal_list_remove_item(&mca_coll_libnbc_component.active_requests,
&request->super.super.super);
OPAL_THREAD_UNLOCK(&mca_coll_libnbc_component.lock);
/* return if invoked recursively */
if (!libnbc_in_progress) {
libnbc_in_progress = true;

if( OMPI_SUCCESS == res || NBC_OK == res || NBC_SUCCESS == res ) {
request->super.req_status.MPI_ERROR = OMPI_SUCCESS;
}
else {
request->super.req_status.MPI_ERROR = res;
OPAL_LIST_FOREACH_SAFE(request, next, &mca_coll_libnbc_component.active_requests,
ompi_coll_libnbc_request_t) {
OPAL_THREAD_UNLOCK(&mca_coll_libnbc_component.lock);
res = NBC_Progress(request);
if( NBC_CONTINUE != res ) {
/* done, remove and complete */
OPAL_THREAD_LOCK(&mca_coll_libnbc_component.lock);
opal_list_remove_item(&mca_coll_libnbc_component.active_requests,
&request->super.super.super);
OPAL_THREAD_UNLOCK(&mca_coll_libnbc_component.lock);

if( OMPI_SUCCESS == res || NBC_OK == res || NBC_SUCCESS == res ) {
request->super.req_status.MPI_ERROR = OMPI_SUCCESS;
}
else {
request->super.req_status.MPI_ERROR = res;
}
ompi_request_complete(&request->super, true);
}
ompi_request_complete(&request->super, true);
OPAL_THREAD_LOCK(&mca_coll_libnbc_component.lock);
}
OPAL_THREAD_LOCK(&mca_coll_libnbc_component.lock);
libnbc_in_progress = false;
}
OPAL_THREAD_UNLOCK(&mca_coll_libnbc_component.lock);

opal_atomic_unlock(&mca_coll_libnbc_component.progress_lock);

return 0;
}

Expand Down