void ucp_ep_destroy(ucp_ep_h ep) { ucp_worker_h worker = ep->worker; ucs_debug("destroy ep %p", ep); UCS_ASYNC_BLOCK(&worker->async); sglib_hashed_ucp_ep_t_delete(worker->ep_hash, ep); ucp_ep_destory_uct_eps(ep); UCS_ASYNC_UNBLOCK(&worker->async); ucs_free(ep); }
void ucp_ep_wireup_stop(ucp_ep_h ep) { ucp_worker_h worker = ep->worker; ucs_trace_func("ep=%p", ep); if (ep->uct.next_ep != NULL) { while (uct_ep_flush(ep->uct.next_ep) != UCS_OK) { ucp_worker_progress(ep->worker); } uct_ep_destroy(ep->uct.next_ep); } if (ep->wireup_ep != NULL) { while (uct_ep_flush(ep->wireup_ep) != UCS_OK) { ucp_worker_progress(ep->worker); } uct_ep_destroy(ep->wireup_ep); } UCS_ASYNC_BLOCK(&worker->async); sglib_hashed_ucp_ep_t_delete(worker->ep_hash, ep); UCS_ASYNC_UNBLOCK(&worker->async); }
ucs_status_t ucp_ep_wireup_start(ucp_ep_h ep, ucp_address_t *address) { ucp_worker_h worker = ep->worker; struct sockaddr *am_short_addr; ucp_rsc_index_t wireup_rsc_index; struct sockaddr *wireup_addr; uct_iface_attr_t *iface_attr; uct_iface_h iface; ucp_rsc_index_t dst_rsc_index, wireup_dst_rsc_index; ucp_rsc_index_t wireup_dst_pd_index; ucs_status_t status; UCS_ASYNC_BLOCK(&worker->async); ep->dest_uuid = ucp_address_uuid(address); sglib_hashed_ucp_ep_t_add(worker->ep_hash, ep); ucs_debug("connecting 0x%"PRIx64"->0x%"PRIx64, worker->uuid, ep->dest_uuid); /* * Select best transport for active messages */ status = ucp_pick_best_wireup(worker, address, ucp_am_short_score_func, &ep->uct.rsc_index, &dst_rsc_index, &ep->uct.dst_pd_index, &am_short_addr, &ep->uct.reachable_pds, "short_am"); if (status != UCS_OK) { ucs_error("No transport for short active message"); goto err; } iface = worker->ifaces[ep->uct.rsc_index]; iface_attr = &worker->iface_attrs[ep->uct.rsc_index]; /* * If the selected transport can be connected directly, do it. */ if (iface_attr->cap.flags & UCT_IFACE_FLAG_CONNECT_TO_IFACE) { status = uct_ep_create_connected(iface, am_short_addr, &ep->uct.next_ep); if (status != UCS_OK) { ucs_debug("failed to create ep"); goto err; } ep->state |= UCP_EP_STATE_LOCAL_CONNECTED; ucp_ep_remote_connected(ep); goto out; } /* * If we cannot connect the selected transport directly, select another * transport for doing the wireup. */ status = ucp_pick_best_wireup(worker, address, ucp_wireup_score_func, &wireup_rsc_index, &wireup_dst_rsc_index, &wireup_dst_pd_index, &wireup_addr, &ep->uct.reachable_pds, "wireup"); if (status != UCS_OK) { goto err; } status = uct_ep_create_connected(worker->ifaces[wireup_rsc_index], wireup_addr, &ep->wireup_ep); if (status != UCS_OK) { goto err; } if (!(iface_attr->cap.flags & UCT_IFACE_FLAG_CONNECT_TO_EP)) { status = UCS_ERR_UNREACHABLE; goto err_destroy_wireup_ep; } /* * Until the transport is connected, send operations should return NO_RESOURCE. * Plant a dummy endpoint object which will do it. */ status = UCS_CLASS_NEW(ucp_dummy_ep_t, &ep->uct.ep, ep); if (status != UCS_OK) { goto err_destroy_wireup_ep; } /* * Create endpoint for the transport we need to wire-up. */ status = uct_ep_create(iface, &ep->uct.next_ep); if (status != UCS_OK) { goto err_destroy_uct_ep; } /* * Send initial connection request for wiring-up the transport. */ status = ucp_ep_wireup_send(ep, ep->wireup_ep, UCP_AM_ID_CONN_REQ, dst_rsc_index); if (status != UCS_OK) { goto err_destroy_next_ep; } out: UCS_ASYNC_UNBLOCK(&worker->async); return UCS_OK; err_destroy_next_ep: uct_ep_destroy(ep->uct.next_ep); err_destroy_uct_ep: uct_ep_destroy(ep->uct.ep); err_destroy_wireup_ep: uct_ep_destroy(ep->wireup_ep); err: sglib_hashed_ucp_ep_t_delete(worker->ep_hash, ep); UCS_ASYNC_UNBLOCK(&worker->async); return status; }
static void ucp_ep_delete(ucp_ep_h ep) { sglib_hashed_ucp_ep_t_delete(ep->worker->ep_hash, ep); ucs_free(ep); }