Skip to content

osc/ucx: flush all the outstanding transfers before cleaning up the thread local context #10238

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
Apr 8, 2022
Merged
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
10 changes: 10 additions & 0 deletions opal/mca/common/ucx/common_ucx_wpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,16 @@ static void _tlocal_ctx_rec_cleanup(_ctx_record_t *ctx_rec)
opal_common_ucx_winfo_t *winfo = ctx_rec->winfo;
opal_common_ucx_wpool_t *wpool = ctx_rec->gctx->wpool;

opal_mutex_lock(&winfo->mutex);
int rc = opal_common_ucx_winfo_flush(winfo, 0, OPAL_COMMON_UCX_FLUSH_B, OPAL_COMMON_UCX_SCOPE_WORKER, NULL);
winfo->global_inflight_ops = 0;
memset(winfo->inflight_ops, 0, winfo->comm_size * sizeof(short));
opal_mutex_unlock(&winfo->mutex);
if (rc != OPAL_SUCCESS) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to move the check for failure inside of the mutex (but of course remember to unloc before returning).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rc is a local variable, so it is immune to being changed by another thread for what it is worth.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I was going to ask - why move it inside the mutex?

MCA_COMMON_UCX_ERROR("opal_common_ucx_flush failed: %d", rc);
return;
}

/* Remove worker from active and return to idle list. */
_wpool_put_winfo(wpool, winfo);

Expand Down