void uct_iface_mem_free(const uct_allocated_memory_t *mem) { if (mem->method != UCT_ALLOC_METHOD_PD) { uct_pd_mem_dereg(mem->pd, mem->memh); } uct_mem_free(mem); }
/** * Unregister memory from all protection domains. * Save in *alloc_pd_memh_p the memory handle of the allocating PD, if such exists. */ static ucs_status_t ucp_memh_dereg_pds(ucp_context_h context, ucp_mem_h memh, uct_mem_h* alloc_pd_memh_p) { unsigned pd_index, uct_index; ucs_status_t status; uct_index = 0; *alloc_pd_memh_p = UCT_INVALID_MEM_HANDLE; for (pd_index = 0; pd_index < context->num_pds; ++pd_index) { if (!(memh->pd_map & UCS_BIT(pd_index))) { /* PD not present in the array */ continue; } if (memh->alloc_pd == context->pds[pd_index]) { /* If we used a pd to register the memory, remember the memh - for * releasing the memory later. We cannot release the memory at this * point because we have to unregister it from other PDs first. */ ucs_assert(memh->alloc_method == UCT_ALLOC_METHOD_PD); *alloc_pd_memh_p = memh->uct[uct_index]; } else { status = uct_pd_mem_dereg(context->pds[pd_index], memh->uct[uct_index]); if (status != UCS_OK) { ucs_error("Failed to dereg address %p with pd %s", memh->address, context->pd_rscs[pd_index].pd_name); return status; } } ++uct_index; } return UCS_OK; }