Repository navigation
UCT/UD: Add generation ID to dest_id to make it unique #11800
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
Changes from 7 commits
bd3e0a3
aaa19cc
26fec45
eb524eb
2a3aa84
8a7f223
1de55a1
b204b9c
0a7188b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -525,6 +525,7 @@ UCS_CLASS_INIT_FUNC(uct_ud_iface_t, uct_ud_iface_ops_t *ops, | |
| UCT_UD_IFACE_HOOK_INIT(self); | ||
|
|
||
| ucs_ptr_array_init(&self->eps, "ud_eps"); | ||
| ucs_array_init_dynamic(&self->ep_gen); | ||
|
|
||
| status = uct_ud_iface_create_qp(self, config); | ||
| if (status != UCS_OK) { | ||
|
|
@@ -594,6 +595,7 @@ UCS_CLASS_INIT_FUNC(uct_ud_iface_t, uct_ud_iface_ops_t *ops, | |
| err_qp: | ||
| uct_ud_iface_destroy_qp(self); | ||
| err_eps_array: | ||
| ucs_array_cleanup_dynamic(&self->ep_gen); | ||
| ucs_ptr_array_cleanup(&self->eps, 1); | ||
| return status; | ||
| } | ||
|
|
@@ -635,6 +637,7 @@ static UCS_CLASS_CLEANUP_FUNC(uct_ud_iface_t) | |
| ucs_mpool_cleanup(&self->rx.mp, 0); | ||
|
|
||
| ucs_debug("iface(%p): ptr_array cleanup", self); | ||
| ucs_array_cleanup_dynamic(&self->ep_gen); | ||
| ucs_ptr_array_cleanup(&self->eps, 1); | ||
| ucs_arbiter_cleanup(&self->tx.pending_q); | ||
| UCS_STATS_NODE_FREE(self->stats); | ||
|
|
@@ -820,16 +823,41 @@ ucs_status_t uct_ud_iface_flush(uct_iface_h tl_iface, unsigned flags, | |
| return UCS_OK; | ||
| } | ||
|
|
||
| void uct_ud_iface_add_ep(uct_ud_iface_t *iface, uct_ud_ep_t *ep) | ||
| ucs_status_t uct_ud_iface_add_ep(uct_ud_iface_t *iface, uct_ud_ep_t *ep) | ||
| { | ||
| ep->ep_id = ucs_ptr_array_insert(&iface->eps, ep); | ||
| unsigned max_index = iface->eps.size; | ||
| unsigned ep_index; | ||
| uint32_t ep_gen; | ||
|
|
||
| if (max_index > UCT_UD_EP_INDEX_MAX) { | ||
| ucs_error("iface %p: reached the maximal number of endpoints (%lu)", | ||
| iface, UCT_UD_EP_INDEX_MAX + 1); | ||
| return UCS_ERR_EXCEEDS_LIMIT; | ||
| } | ||
|
|
||
| if (max_index >= ucs_array_length(&iface->ep_gen)) { | ||
| ucs_array_resize(&iface->ep_gen, max_index + 1, 0, | ||
| return UCS_ERR_NO_MEMORY); | ||
| } | ||
|
|
||
| ep_index = ucs_ptr_array_insert(&iface->eps, ep); | ||
| ep_gen = ucs_array_elem(&iface->ep_gen, ep_index); | ||
| ep->ep_id = (ep_gen << UCT_UD_EP_INDEX_BITS) | ep_index; | ||
|
Contributor
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. minor: since we have one liner helper
Contributor
Author
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. I had it initially, but then removed. It is used in just one place, so I preferred to have an explicit assignment |
||
| return UCS_OK; | ||
| } | ||
|
|
||
| void uct_ud_iface_remove_ep(uct_ud_iface_t *iface, uct_ud_ep_t *ep) | ||
| { | ||
| unsigned ep_index; | ||
| uint8_t *gen; | ||
|
|
||
| if (ep->ep_id != UCT_UD_EP_NULL_ID) { | ||
| ucs_trace("iface(%p) remove ep: %p id %d", iface, ep, ep->ep_id); | ||
| ucs_ptr_array_remove(&iface->eps, ep->ep_id); | ||
| ep_index = uct_ud_ep_id_index(ep->ep_id); | ||
| ucs_trace("iface(%p) remove " UCT_UD_EP_FMT, iface, UCT_UD_EP_ARG(ep)); | ||
| /* Increment generation for the next iteration. */ | ||
| gen = &ucs_array_elem(&iface->ep_gen, ep_index); | ||
| *gen = (*gen + 1) & UCT_UD_EP_GEN_MASK; | ||
| ucs_ptr_array_remove(&iface->eps, ep_index); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.