Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/uct/cuda/cuda_ipc/cuda_ipc.inl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2025. ALL RIGHTS RESERVED.
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2025-2026. ALL RIGHTS RESERVED.
* See file LICENSE for terms.
*/

Expand Down Expand Up @@ -83,16 +83,16 @@ uct_cuda_ipc_check_and_pop_ctx(int is_ctx_pushed)
}

static UCS_F_ALWAYS_INLINE int
uct_cuda_ipc_is_rkey_local(const uct_cuda_ipc_extended_rkey_t *rkey)
uct_cuda_ipc_is_rkey_local(pid_t rkey_pid, ucs_sys_ns_t rkey_pid_ns)
{
static pid_t pid = 0;

if (ucs_unlikely(pid == 0)) {
pid = getpid();
}

return (pid == rkey->super.pid) &&
(ucs_sys_get_ns(UCS_SYS_NS_TYPE_PID) == rkey->pid_ns);
return (pid == rkey_pid) &&
(ucs_sys_get_ns(UCS_SYS_NS_TYPE_PID) == rkey_pid_ns);
Comment on lines +94 to +95

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how does it work if 2 processes on different machines happen to have same pid?

@rakhmets rakhmets Mar 30, 2026 •

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.

well... it may not work after this #10933 was merged...
it's a corner case for now, since this is a MNNVL case, and the uuids of the GPUs used must also match.

}

static UCS_F_ALWAYS_INLINE ucs_status_t uct_cuda_ipc_get_remote_address(
Expand Down
7 changes: 4 additions & 3 deletions src/uct/cuda/cuda_ipc/cuda_ipc_cache.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2018. ALL RIGHTS RESERVED.
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2018-2026. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/
Expand Down Expand Up @@ -569,7 +569,8 @@ ucs_status_t uct_cuda_ipc_unmap_memhandle(pid_t pid, ucs_sys_ns_t pid_ns,
/* checking if the mapped address is the same as the d_bptr
* this is true for the case of single process memory mapping
* see uct_cuda_ipc_map_memhandle for more details */
if (d_bptr == (uintptr_t)mapped_addr) {
if ((d_bptr == (uintptr_t)mapped_addr) &&
uct_cuda_ipc_is_rkey_local(pid, pid_ns)) {
return UCS_OK;
}

Expand Down Expand Up @@ -620,7 +621,7 @@ UCS_PROFILE_FUNC(ucs_status_t, uct_cuda_ipc_map_memhandle,
return status;
}

if (uct_cuda_ipc_is_rkey_local(ext_key) &&
if (uct_cuda_ipc_is_rkey_local(key->pid, ext_key->pid_ns) &&
(memcmp(uuid.bytes, key->uuid.bytes, sizeof(uuid.bytes)) == 0)) {
/* TODO: added for test purpose to enable cuda_ipc tests in gtest
* mapped addrr is set to be same as d_bptr avoiding any calls to
Expand Down
4 changes: 2 additions & 2 deletions src/uct/cuda/cuda_ipc/cuda_ipc_md.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2018-2019. ALL RIGHTS RESERVED.
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2018-2026. ALL RIGHTS RESERVED.
* See file LICENSE for terms.
*/

Expand Down Expand Up @@ -96,7 +96,7 @@ uct_cuda_ipc_get_dev_cache(uct_cuda_ipc_component_t *component,

key.uuid = rkey->uuid;
key.type = rkey->ph.handle_type;
key.is_local = uct_cuda_ipc_is_rkey_local(ext_rkey);
key.is_local = uct_cuda_ipc_is_rkey_local(rkey->pid, ext_rkey->pid_ns);

iter = kh_put(cuda_ipc_uuid_hash, hash, key, &ret);
if (ret == UCS_KH_PUT_KEY_PRESENT) {
Expand Down
Loading