-
Notifications
You must be signed in to change notification settings - Fork 423
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
UCP: tm offload rndv support #1549
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5fb5269
UCP: tm offload rndv support
alex-mikheev eb0a6a0
UCP: tm rndv coverity fix
alex-mikheev c647f8a
UCP: tm offload rndv fixes p1
alex-mikheev bd9c7b8
UCP: tm offload rndv fixes p2
alex-mikheev 2ba0e9a
UCP: tm offload rndv fixes p3
alex-mikheev 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,66 @@ void ucp_tag_offload_completed(uct_tag_context_t *self, uct_tag_t stag, | |
ucp_request_complete_recv(req, status); | ||
} | ||
|
||
/* RNDV request matched by the transport. Need to proceed with AM based RNDV */ | ||
void ucp_tag_offload_rndv_cb(uct_tag_context_t *self, uct_tag_t stag, | ||
const void *header, unsigned header_length, | ||
ucs_status_t status) | ||
{ | ||
ucp_request_t *req = ucs_container_of(self, ucp_request_t, recv.uct_ctx); | ||
ucp_context_t *ctx = req->recv.worker->context; | ||
ucp_sw_rndv_hdr_t *sreq = (ucp_sw_rndv_hdr_t*)header; | ||
ucp_worker_iface_t *iface = ucs_queue_head_elem_non_empty(&ctx->tm.offload_ifaces, | ||
ucp_worker_iface_t, queue); | ||
ucp_rndv_rts_hdr_t rts; | ||
|
||
rts.sreq = sreq->super; | ||
rts.super.tag = stag; | ||
rts.flags = 0; | ||
rts.address = 0; /* RNDV needs to be completed in SW */ | ||
rts.size = sreq->length; | ||
|
||
ucp_request_memory_dereg(ctx, iface->rsc_index, req->recv.datatype, | ||
&req->recv.state); | ||
/* coverity[address_of] */ | ||
ucp_rndv_matched(req->recv.worker, req, &rts); | ||
} | ||
|
||
ucs_status_t ucp_tag_offload_unexp_rndv(void *arg, unsigned flags, | ||
uint64_t stag, const void *hdr, | ||
unsigned hdr_length, | ||
uint64_t remote_addr, size_t length, | ||
const void *rkey_buf) | ||
{ | ||
ucp_rndv_rts_hdr_t *rts = (ucp_rndv_rts_hdr_t*)(((ucp_tag_hdr_t*)hdr) - 1); | ||
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. isn't this illegal to access memory before 'hdr'? |
||
ucp_worker_t *worker = arg; | ||
void *rkey = rts + 1; | ||
size_t len = sizeof(*rts); | ||
ucp_ep_t *ep = ucp_worker_get_reply_ep(worker, rts->sreq.sender_uuid); | ||
const uct_md_attr_t *md_attrs; | ||
size_t rkey_size; | ||
|
||
/* rts.req should be alredy in place - it is sent by the sender. | ||
* Fill the rest of rts header and pass to common rts handler */ | ||
if (rkey_buf) { | ||
/* Copy rkey before to fill rts, to avoid overriding rkey */ | ||
md_attrs = ucp_ep_md_attr(ep, ucp_ep_get_tag_lane(ep)); | ||
rkey_size = md_attrs->rkey_packed_size; | ||
memcpy(rkey, rkey_buf, rkey_size); | ||
len += rkey_size; | ||
rts->flags = UCP_RNDV_RTS_FLAG_PACKED_RKEY | UCP_RNDV_RTS_FLAG_OFFLOAD; | ||
rts->size = length; | ||
} else { | ||
ucs_assert(remote_addr == 0ul); | ||
/* This must be SW RNDV request. Take length from its header. */ | ||
rts->size = ((ucp_sw_rndv_hdr_t*)hdr)->length; | ||
} | ||
|
||
rts->super.tag = stag; | ||
rts->address = remote_addr; | ||
|
||
return ucp_rndv_rts_handler(arg, rts, len, flags, UCP_RECV_DESC_FLAG_OFFLOAD); | ||
} | ||
|
||
void ucp_tag_offload_cancel(ucp_context_t *ctx, ucp_request_t *req, int force) | ||
{ | ||
ucp_worker_iface_t *ucp_iface; | ||
|
@@ -99,6 +159,7 @@ int ucp_tag_offload_post(ucp_context_t *ctx, ucp_request_t *req) | |
|
||
req->recv.uct_ctx.tag_consumed_cb = ucp_tag_offload_tag_consumed; | ||
req->recv.uct_ctx.completed_cb = ucp_tag_offload_completed; | ||
req->recv.uct_ctx.rndv_cb = ucp_tag_offload_rndv_cb; | ||
|
||
iov.buffer = (void*)req->recv.buffer; | ||
iov.length = length; | ||
|
@@ -213,6 +274,81 @@ static ucs_status_t ucp_tag_offload_eager_zcopy(uct_pending_req_t *self) | |
return ucp_do_tag_offload_zcopy(self, 0ul, ucp_tag_eager_zcopy_req_complete); | ||
} | ||
|
||
ucs_status_t ucp_tag_offload_sw_rndv(uct_pending_req_t *self) | ||
{ | ||
ucp_request_t *req = ucs_container_of(self, ucp_request_t, send.uct); | ||
ucp_ep_t *ep = req->send.ep; | ||
ucp_sw_rndv_hdr_t rndv_hdr = { | ||
.super.sender_uuid = req->send.ep->worker->uuid, | ||
.super.reqptr = (uintptr_t)req, | ||
.length = req->send.length | ||
}; | ||
|
||
return uct_ep_tag_rndv_request(ep->uct_eps[req->send.lane], req->send.tag, | ||
&rndv_hdr, sizeof(rndv_hdr)); | ||
} | ||
|
||
ucs_status_t ucp_tag_offload_rndv_zcopy(uct_pending_req_t *self) | ||
{ | ||
void *rndv_op; | ||
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. pls move this variable to be last, so variables with initializers are first |
||
ucp_request_t *req = ucs_container_of(self, ucp_request_t, send.uct); | ||
ucp_ep_t *ep = req->send.ep; | ||
size_t max_iov = ucp_ep_config(ep)->tag.eager.max_iov; | ||
uct_iov_t *iov = ucs_alloca(max_iov * sizeof(uct_iov_t)); | ||
size_t iovcnt = 0; | ||
ucp_request_hdr_t rndv_hdr = { | ||
.sender_uuid = ep->worker->uuid, | ||
.reqptr = (uintptr_t)req | ||
}; | ||
|
||
req->send.uct_comp.count = 1; | ||
req->send.uct_comp.func = ucp_tag_eager_zcopy_completion; | ||
|
||
ucs_assert_always(UCP_DT_IS_CONTIG(req->send.datatype)); | ||
ucp_dt_iov_copy_uct(iov, &iovcnt, max_iov, &req->send.state, req->send.buffer, | ||
req->send.datatype, req->send.length); | ||
|
||
rndv_op = uct_ep_tag_rndv_zcopy(ep->uct_eps[req->send.lane], req->send.tag, | ||
&rndv_hdr, sizeof(rndv_hdr), iov, iovcnt, | ||
&req->send.uct_comp); | ||
if (UCS_PTR_IS_ERR(rndv_op)) { | ||
return UCS_PTR_STATUS(rndv_op); | ||
} | ||
req->flags |= UCP_REQUEST_FLAG_OFFLOADED; | ||
req->send.tag_offload.rndv_op = rndv_op; | ||
return UCS_OK; | ||
} | ||
|
||
void ucp_tag_offload_cancel_rndv(ucp_request_t *req) | ||
{ | ||
ucp_ep_t *ep = req->send.ep; | ||
ucs_status_t status; | ||
|
||
status = uct_ep_tag_rndv_cancel(ep->uct_eps[ucp_ep_get_tag_lane(ep)], | ||
req->send.tag_offload.rndv_op); | ||
if (status != UCS_OK) { | ||
ucs_error("Failed to cancel tag rndv op %s", ucs_status_string(status)); | ||
} | ||
} | ||
|
||
ucs_status_t ucp_tag_offload_start_rndv(ucp_request_t *sreq) | ||
{ | ||
ucs_status_t status; | ||
ucp_lane_index_t lane = ucp_ep_get_tag_lane(sreq->send.ep); | ||
|
||
sreq->send.lane = lane; | ||
if (UCP_DT_IS_CONTIG(sreq->send.datatype)) { | ||
status = ucp_request_send_buffer_reg(sreq, lane); | ||
if (status != UCS_OK) { | ||
return status; | ||
} | ||
sreq->send.uct.func = ucp_tag_offload_rndv_zcopy; | ||
} else { | ||
sreq->send.uct.func = ucp_tag_offload_sw_rndv; | ||
} | ||
return UCS_OK; | ||
} | ||
|
||
const ucp_proto_t ucp_tag_offload_proto = { | ||
.contig_short = ucp_tag_offload_eager_short, | ||
.bcopy_single = ucp_tag_offload_eager_bcopy, | ||
|
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
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.
pls add comment like "emulate rts without key"