ucs_status_t uct_mm_ep_atomic_cswap64(uct_ep_h tl_ep, uint64_t compare, uint64_t swap, uint64_t remote_addr, uct_rkey_t rkey, uint64_t *result, uct_completion_t *comp) { uint64_t *ptr = (uint64_t *)(rkey + remote_addr); *result = ucs_atomic_cswap64(ptr, compare, swap); uct_mm_trace_data(remote_addr, rkey, "ATOMIC_CSWAP64 [compare %"PRIu64" swap %"PRIu64" result %"PRIu64"]", compare, swap, *result); return UCS_OK; }
static inline ucs_status_t uct_mm_ep_get_remote_elem(uct_mm_ep_t *ep, uint64_t head, uct_mm_fifo_element_t **elem) { uct_mm_iface_t *iface = ucs_derived_of(ep->super.super.iface, uct_mm_iface_t); uint64_t elem_index; /* the fifo elem's index in the fifo. */ /* must be smaller than fifo size */ uint64_t returned_val; elem_index = ep->fifo_ctl->head & iface->fifo_mask; *elem = UCT_MM_IFACE_GET_FIFO_ELEM(iface, ep->fifo, elem_index); /* try to get ownership of the head element */ returned_val = ucs_atomic_cswap64(&ep->fifo_ctl->head, head, head+1); if (returned_val != head) { return UCS_ERR_NO_RESOURCE; } return UCS_OK; }