static UCS_F_NOINLINE ucs_status_ptr_t ucp_tag_send_slow(ucp_ep_h ep, const void *buffer, size_t count, uintptr_t datatype, ucp_tag_t tag, ucp_send_callback_t cb) { ucp_request_t *req; ucs_status_t status; req = ucs_mpool_get_inline(&ep->worker->req_mp); if (req == NULL) { return UCS_STATUS_PTR(UCS_ERR_NO_MEMORY); } VALGRIND_MAKE_MEM_DEFINED(req + 1, ep->worker->context->config.request.size); req->flags = 0; req->cb.send = cb; status = ucp_tag_send_start_req(ep, buffer, count, datatype, tag, req); if (status != UCS_OK) { return UCS_STATUS_PTR(status); /* UCS_OK also goes here */ } if (!(req->flags & UCP_REQUEST_FLAG_COMPLETED)) { ucp_ep_add_pending(ep, ep->uct_ep, req); ucp_worker_progress(ep->worker); } ucs_trace_req("send_nb returning request %p", req); return req + 1; }
ucs_status_t ucp_get_nbi(ucp_ep_h ep, void *buffer, size_t length, uint64_t remote_addr, ucp_rkey_h rkey) { ucp_ep_rma_config_t *rma_config; ucs_status_t status; uct_rkey_t uct_rkey; size_t frag_length; uct_ep_h uct_ep; UCP_RMA_CHECK_PARAMS(buffer, length); for (;;) { UCP_EP_RESOLVE_RKEY_RMA(ep, rkey, uct_ep, uct_rkey, rma_config); frag_length = ucs_min(rma_config->max_get_bcopy, length); status = uct_ep_get_bcopy(uct_ep, (uct_unpack_callback_t)memcpy, (void*)buffer, frag_length, remote_addr, uct_rkey, NULL); if (ucs_likely(status == UCS_OK || status == UCS_INPROGRESS)) { /* Get was initiated */ length -= frag_length; buffer += frag_length; remote_addr += frag_length; if (length == 0) { break; } } else if (ucs_unlikely(status == UCS_ERR_NO_RESOURCE)) { /* Out of resources - adding request for later schedule */ ucp_request_t *req; req = ucs_mpool_get_inline(&ep->worker->req_mp); if (req == NULL) { /* can't allocate memory for request - abort */ status = UCS_ERR_NO_MEMORY; break; } ucp_add_pending_rma(req, ep, uct_ep, buffer, length, remote_addr, rkey, ucp_progress_get_nbi); /* Mark it as in progress */ status = UCS_INPROGRESS; break; } else { /* Error */ break; } } return status; }
void *ucs_mpool_get(ucs_mpool_t *mp) { return ucs_mpool_get_inline(mp); }
ucs_status_t ucp_put_nbi(ucp_ep_h ep, const void *buffer, size_t length, uint64_t remote_addr, ucp_rkey_h rkey) { ucp_ep_rma_config_t *rma_config; ucs_status_t status; uct_rkey_t uct_rkey; ssize_t packed_len; ucp_request_t *req; uct_ep_h uct_ep; UCP_RMA_CHECK_PARAMS(buffer, length); for (;;) { UCP_EP_RESOLVE_RKEY_RMA(ep, rkey, uct_ep, uct_rkey, rma_config); if (length <= rma_config->max_put_short) { /* Fast path for a single short message */ status = uct_ep_put_short(uct_ep, buffer, length, remote_addr, uct_rkey); if (ucs_likely(status != UCS_ERR_NO_RESOURCE)) { /* Return on error or success */ break; } else { /* Out of resources - adding request for later schedule */ req = ucs_mpool_get_inline(&ep->worker->req_mp); if (req == NULL) { status = UCS_ERR_NO_MEMORY; break; } ucp_add_pending_rma(req, ep, uct_ep, buffer, length, remote_addr, rkey, ucp_progress_put_nbi); status = UCS_INPROGRESS; break; } } else { /* Fragmented put */ if (length <= ucp_ep_config(ep)->bcopy_thresh) { /* TBD: Should be replaced with bcopy */ packed_len = ucs_min(length, rma_config->max_put_short); status = uct_ep_put_short(uct_ep, buffer, packed_len, remote_addr, uct_rkey); } else { /* TBD: Use z-copy */ ucp_memcpy_pack_context_t pack_ctx; pack_ctx.src = buffer; pack_ctx.length = ucs_min(length, rma_config->max_put_bcopy); packed_len = uct_ep_put_bcopy(uct_ep, ucp_memcpy_pack, &pack_ctx, remote_addr, uct_rkey); status = (packed_len > 0) ? UCS_OK : (ucs_status_t)packed_len; } if (ucs_likely(status == UCS_OK || status == UCS_INPROGRESS)) { length -= packed_len; if (length == 0) { /* Put is completed - return success */ break; } buffer += packed_len; remote_addr += packed_len; } else if (status == UCS_ERR_NO_RESOURCE) { /* Out of resources - adding request for later schedule */ req = ucs_mpool_get_inline(&ep->worker->req_mp); if (req == NULL) { status = UCS_ERR_NO_MEMORY; break; } ucp_add_pending_rma(req, ep, uct_ep, buffer, length, remote_addr, rkey, ucp_progress_put_nbi); status = UCS_INPROGRESS; break; } else { /* Return - Error occured */ break; } } } return status; }