Skip to content

Device API V2 Improvements #11150

Merged
yosefe merged 18 commits intoopenucx:masterfrom
ofirfarjun7:topic/device-api-v2-followup
Mar 4, 2026
Merged

Device API V2 Improvements #11150
yosefe merged 18 commits intoopenucx:masterfrom
ofirfarjun7:topic/device-api-v2-followup

Conversation

@ofirfarjun7
Copy link
Copy Markdown
Contributor

What?

Fix comments and improve implementation

Why?

Address open comments from #11123

Comment thread src/ucp/core/ucp_device.c
/* Migrate the constructed handle header to device memory */
ucp_mem_type_unpack(ep->worker, mem->address, &handle, sizeof(handle),
ucp_mem_type_unpack(ep->worker, mem->address, handle, handle_size,
mem_type);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

free handle

Comment thread src/uct/api/device/uct_device_types.h Outdated
uct_cuda_ipc_device_mem_element_t cuda_ipc_mem_element;
};

/* Base structure for all device memory elements */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment

Comment thread src/ucp/core/ucp_device.c
@@ -772,16 +767,13 @@ static ucs_status_t ucp_device_remote_mem_list_element_pack(
uct_rkey = ucp_rkey_get_tl_rkey(rkey, rkey_index);
ucs_assert(uct_rkey != UCT_INVALID_RKEY);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spare line

@ofirfarjun7 ofirfarjun7 requested a review from tvegas1 January 29, 2026 13:49
Comment thread src/ucp/core/ucp_device.c Outdated
Comment thread src/ucp/core/ucp_device.c Outdated
Comment thread src/ucp/core/ucp_device.c Outdated
Comment thread src/ucp/core/ucp_device.c Outdated
Comment thread src/ucp/core/ucp_device.c Outdated
Comment thread src/uct/ib/mlx5/dv/ib_mlx5dv_md.c Outdated
tvegas1
tvegas1 previously approved these changes Feb 4, 2026
Comment thread src/ucp/api/device/ucp_device_impl.h
tvegas1
tvegas1 previously approved these changes Feb 10, 2026
Comment thread src/ucp/api/device/ucp_device_impl.h Outdated
UCS_F_DEVICE ucs_status_t ucp_device_check_params(const T mem_list_h,
unsigned index)
{
if (DEVICE_ENABLE_PARAMS_CHECK) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this macro should have UCP_ prefix since it's compiled as part of user's code

Comment thread src/ucp/api/device/ucp_device_impl.h Outdated
Comment on lines +57 to +58
if (((mem_list_h)->version != UCP_DEVICE_MEM_LIST_VERSION_V1) ||
((index) >= (mem_list_h)->length)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra () not needed it's not a macro

Comment thread src/ucp/api/device/ucp_device_impl.h Outdated
if (DEVICE_ENABLE_PARAMS_CHECK) {
if (((mem_list_h)->version != UCP_DEVICE_MEM_LIST_VERSION_V1) ||
((index) >= (mem_list_h)->length)) {
printf("Invalid parameters for %p\n", mem_list_h);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ucs_device_error

Comment thread src/ucs/sys/device_code.h Outdated
#define UCS_F_DEVICE static inline
#endif /* __NVCC__ */

#ifndef DEVICE_ENABLE_PARAMS_CHECK
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more space line before

uint32_t lkey;
uint32_t rkey;
} uct_rc_gdaki_device_mem_element_t;
} uct_ib_md_device_mem_element_t;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we move these structs to ib/cuda_ipc and not have them in uct common code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will move in next PR after revert to query size from transport.

Comment thread src/uct/ib/mlx5/dv/ib_mlx5dv_md.c Outdated
}

static ucs_status_t
uct_ib_md_mlx5_devx_mem_elem_pack(uct_md_h md, uct_mem_h memh, uct_rkey_t rkey,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uct_ib_md_mlx5_devx_md_mem_elem_pack

Comment thread src/ucp/core/ucp_device.c
{
size_t handle_size = 0;
size_t uct_elem_size[UCP_DEVICE_MEM_LIST_MAX_EPS];
const size_t uct_elem_size = sizeof(uct_device_mem_element_t);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems redundant var

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to touch code we plan to remove?

Comment thread src/ucp/core/ucp_device.c Outdated
return UCS_ERR_NO_DEVICE;
}

handle_size *= params->num_elements;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add variable like num_lanes, that we increment in line 381, and then
handle_size = sizeof(*handle) + (num_lanes * params->num_elements)

it's better that use same variable with different meanings over time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to touch code we plan to remove?

Comment thread src/ucp/core/ucp_device.c
Comment on lines +490 to +494
handle->local_addrs = (void**)UCS_PTR_BYTE_OFFSET(
mem->address, UCS_PTR_BYTE_DIFF(handle, local_addresses));
handle->remote_addrs = (uint64_t*)UCS_PTR_BYTE_OFFSET(
mem->address, UCS_PTR_BYTE_DIFF(handle, remote_addresses));
handle->lengths = (size_t*)UCS_PTR_BYTE_OFFSET(mem->address,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess we could remove these after removing v1 device api from ucx?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Comment thread src/ucp/core/ucp_device.c Outdated
Comment on lines +868 to +880
status = ucp_mem_do_alloc(context, NULL, handle_size,
UCT_MD_MEM_ACCESS_LOCAL_READ |
UCT_MD_MEM_ACCESS_LOCAL_WRITE,
mem_type, local_sys_dev,
"ucp_device_remote_mem_list_handle_t", mem);
if (status != UCS_OK) {
ucs_error("failed to allocate ucp_device_remote_mem_list_handle_t: %s",
ucs_status_string(status));
goto out;
}

return UCS_OK;
ucp_mem_type_unpack(ep->worker, mem->address, handle, handle_size,
mem_type);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can unite common code with create local mem list handle?

Comment thread src/uct/api/device/uct_device_types.h Outdated
tvegas1
tvegas1 previously approved these changes Feb 25, 2026
Comment thread src/ucp/core/ucp_device.c Outdated
Comment thread src/ucp/core/ucp_device.c Outdated
@yosefe yosefe merged commit 6da563a into openucx:master Mar 4, 2026
152 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants