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; ucp_lane_index_t lane; uct_rkey_t uct_rkey; ucs_status_t status; UCP_RMA_CHECK_PARAMS(buffer, length); UCP_EP_RESOLVE_RKEY_RMA(ep, rkey, lane, uct_rkey, rma_config); if (length <= rma_config->max_get_bcopy) { status = uct_ep_get_bcopy(ep->uct_eps[lane], (uct_unpack_callback_t)memcpy, (void*)buffer, length, remote_addr, uct_rkey, NULL); if (ucs_likely(status != UCS_ERR_NO_RESOURCE)) { /* Return on error or success */ return status; } } ucp_rma_start_nbi(ep, buffer, length, remote_addr, rkey, ucp_progress_get_nbi); return UCS_INPROGRESS; }
ucs_status_t ucp_rma_get(ucp_ep_h ep, void *buffer, size_t length, uint64_t remote_addr, ucp_rkey_h rkey) { uct_completion_t comp; ucs_status_t status; uct_rkey_t uct_rkey; size_t frag_length; if (length == 0) { return UCS_OK; } uct_rkey = UCP_RMA_RKEY_LOOKUP(ep, rkey); comp.count = 1; for (;;) { /* Push out all fragments, and request completion only for the last * fragment. */ frag_length = ucs_min(ep->config.max_bcopy_get, length); status = uct_ep_get_bcopy(ep->uct.ep, (uct_unpack_callback_t)memcpy, (void*)buffer, frag_length, remote_addr, uct_rkey, &comp); if (ucs_likely(status == UCS_OK)) { goto posted; } else if (status == UCS_INPROGRESS) { ++comp.count; goto posted; } else if (status == UCS_ERR_NO_RESOURCE) { goto retry; } else { return status; } posted: length -= frag_length; if (length == 0) { break; } buffer += frag_length; remote_addr += frag_length; retry: ucp_worker_progress(ep->worker); } /* coverity[loop_condition] */ while (comp.count > 1) { ucp_worker_progress(ep->worker); }; return UCS_OK; }
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; }
static ucs_status_t ucp_progress_get_nbi(uct_pending_req_t *self) { ucp_request_t *req = ucs_container_of(self, ucp_request_t, send.uct); ucp_rkey_h rkey = req->send.rma.rkey; ucp_ep_t *ep = req->send.ep; 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_EP_RESOLVE_RKEY_RMA(ep, rkey, uct_ep, uct_rkey, rma_config); for (;;) { frag_length = ucs_min(rma_config->max_get_bcopy, req->send.length); status = uct_ep_get_bcopy(uct_ep, (uct_unpack_callback_t)memcpy, (void*)req->send.buffer, frag_length, req->send.rma.remote_addr, uct_rkey, NULL); if (ucs_likely(status == UCS_OK || status == UCS_INPROGRESS)) { /* Get was initiated */ req->send.length -= frag_length; req->send.buffer += frag_length; req->send.rma.remote_addr += frag_length; if (req->send.length == 0) { /* Get was posted */ ucp_request_complete(req, void); status = UCS_OK; break; } } else { /* Error - abort */ break; } } return status; }
static ucs_status_t ucp_progress_get_nbi(uct_pending_req_t *self) { ucp_request_t *req = ucs_container_of(self, ucp_request_t, send.uct); ucp_rkey_h rkey = req->send.rma.rkey; ucp_ep_t *ep = req->send.ep; ucp_ep_rma_config_t *rma_config; ucs_status_t status; uct_rkey_t uct_rkey; size_t frag_length; UCP_EP_RESOLVE_RKEY_RMA(ep, rkey, req->send.lane, uct_rkey, rma_config); frag_length = ucs_min(rma_config->max_get_bcopy, req->send.length); status = uct_ep_get_bcopy(ep->uct_eps[req->send.lane], (uct_unpack_callback_t)memcpy, (void*)req->send.buffer, frag_length, req->send.rma.remote_addr, uct_rkey, NULL); if ((status == UCS_OK) || (status == UCS_INPROGRESS)) { /* Get was initiated */ req->send.length -= frag_length; req->send.buffer += frag_length; req->send.rma.remote_addr += frag_length; if (req->send.length == 0) { /* Get was posted */ ucp_request_put(req, UCS_OK); return UCS_OK; } else { return UCS_INPROGRESS; } } else { return status; } }