Repository navigation
UCP/CORE: Add shared topology assignment policy #11980
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 2 commits
3f1fa07
8514fbe
e66bc85
8d616a0
e651c57
abc8ac4
9413b2a
fe3025b
173d40f
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 |
|---|---|---|
|
|
@@ -108,6 +108,14 @@ static const char *ucp_fence_modes[] = { | |
| [UCP_FENCE_MODE_LAST] = NULL | ||
| }; | ||
|
|
||
| static const char *ucp_gpu_net_device_modes[] = { | ||
| [UCP_GPU_NET_DEVICE_MODE_NOT_SHARED] = "not_shared", | ||
| [UCP_GPU_NET_DEVICE_MODE_NOT_SHARED_FLIP] = "not_shared_flip", | ||
| [UCP_GPU_NET_DEVICE_MODE_NOT_SHARED_ROUND_ROBIN] = "not_shared_round_robin", | ||
| [UCP_GPU_NET_DEVICE_MODE_SHARED] = "shared", | ||
| [UCP_GPU_NET_DEVICE_MODE_LAST] = NULL | ||
| }; | ||
|
|
||
| static const char *ucp_rndv_modes[] = { | ||
| [UCP_RNDV_MODE_AUTO] = "auto", | ||
| [UCP_RNDV_MODE_GET_ZCOPY] = "get_zcopy", | ||
|
|
@@ -615,6 +623,16 @@ static ucs_config_field_t ucp_context_config_table[] = { | |
| ucs_offsetof(ucp_context_config_t, connect_all_to_all), | ||
| UCS_CONFIG_TYPE_BOOL}, | ||
|
|
||
| {"GPU_NET_DEVICE_MODE", "not_shared", | ||
|
guy-ealey-morag marked this conversation as resolved.
Resolved
|
||
| "Select how network devices are assigned to GPUs.\n" | ||
| " - not_shared : use the default FLIP assignment.\n" | ||
|
guy-ealey-morag marked this conversation as resolved.
Resolved
|
||
| " - not_shared_flip : use the FLIP assignment.\n" | ||
|
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. What's the difference? Why are there two options for this?
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. This is the original design, I'm looking into changing this to something more intuitive
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. @tomerg-nvidia Updated |
||
| " - not_shared_round_robin : use the round-robin assignment.\n" | ||
| " - shared : assign every network device in a topology\n" | ||
| " group to every GPU in that group.", | ||
| ucs_offsetof(ucp_context_config_t, gpu_net_device_mode), | ||
| UCS_CONFIG_TYPE_ENUM(ucp_gpu_net_device_modes)}, | ||
|
|
||
| {"SINGLE_NET_DEVICE", "n", | ||
| "Restrict each protocol's lanes to one network device.\n" | ||
| "The device is picked among the closest eligible network devices using \n" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,22 @@ typedef struct { | |
| } ucp_nics_string_buffers_t; | ||
|
|
||
|
|
||
| ucp_gpu_nic_assignment_policy_t | ||
| ucp_gpu_net_device_mode_get_policy(ucp_gpu_net_device_mode_t mode) | ||
|
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. Is there really a need for both
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. It is required now after the addition of |
||
| { | ||
| switch (mode) { | ||
| case UCP_GPU_NET_DEVICE_MODE_NOT_SHARED: | ||
| case UCP_GPU_NET_DEVICE_MODE_NOT_SHARED_FLIP: | ||
| return UCP_GPU_NIC_ASSIGNMENT_POLICY_FLIP; | ||
| case UCP_GPU_NET_DEVICE_MODE_NOT_SHARED_ROUND_ROBIN: | ||
| return UCP_GPU_NIC_ASSIGNMENT_POLICY_ROUND_ROBIN; | ||
| case UCP_GPU_NET_DEVICE_MODE_SHARED: | ||
| return UCP_GPU_NIC_ASSIGNMENT_POLICY_SHARED; | ||
| default: | ||
| ucs_fatal("invalid gpu network device mode %d", (int)mode); | ||
| } | ||
| } | ||
|
|
||
| static size_t | ||
| ucp_gpu_nic_assignment_get_gpu_idx(ucp_gpu_nic_assignment_policy_t policy, | ||
| size_t num_gpus, size_t nic_idx) | ||
|
|
@@ -327,16 +343,39 @@ ucp_gpu_nic_assignment_init(ucp_gpu_nic_assignment_t *assignment, | |
| } | ||
|
|
||
| static void | ||
| ucp_gpu_nic_assignment_add_group(ucp_gpu_nic_assignment_t *assignment, | ||
| const ucs_topo_group_t *group, | ||
| ucp_gpu_nic_assignment_policy_t policy) | ||
| ucp_gpu_nic_assignment_add_group_shared(ucp_gpu_nic_assignment_t *assignment, | ||
|
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. can we merge add_group_shared() and add_group_not_shared() into a single function either one of the two loop order below so that we have one assignment area? static void
ucp_gpu_nic_assignment_add_group(ucp_gpu_nic_assignment_t *assignment,
const ucs_topo_group_t *group,
ucp_gpu_nic_assignment_policy_t policy)
{
size_t num_gpus = ucs_array_length(&group->gpus);
ucp_gpu_nic_sys_dev_bitmap_t *nic_sys_dev_bitmap;
const ucs_topo_group_element_t *gpu, *nic;
size_t gpu_idx, nic_idx;
ucs_array_for_each_index(gpu, gpu_idx, &group->gpus) {
ucs_assert((gpu->num_sys_devs > 0) &&
(gpu->sys_devs[0] != UCS_SYS_DEVICE_ID_UNKNOWN));
nic_sys_dev_bitmap = ucs_const_cast(
ucp_gpu_nic_sys_dev_bitmap_t*,
ucp_gpu_nic_assignment_lookup(assignment, gpu->sys_devs[0]));
ucs_assert(nic_sys_dev_bitmap != NULL);
ucs_array_for_each_index(nic, nic_idx, &group->nics) {
if ((policy != UCP_GPU_NIC_ASSIGNMENT_POLICY_SHARED) &&
(ucp_gpu_nic_assignment_get_gpu_idx(policy, num_gpus,
nic_idx) != gpu_idx)) {
continue;
}
ucp_gpu_nic_bitmap_add_nic(nic_sys_dev_bitmap, nic);
}
}
}iterating the nics first in the shared case sets the same bits, so the tests should not change: static void
ucp_gpu_nic_assignment_add_group(ucp_gpu_nic_assignment_t *assignment,
const ucs_topo_group_t *group,
ucp_gpu_nic_assignment_mode_t mode)
{
size_t num_gpus = ucs_array_length(&group->gpus);
const ucs_topo_group_element_t *gpu, *nic;
size_t nic_idx, gpu_idx;
ucs_array_for_each_index(nic, nic_idx, &group->nics) {
if (mode == UCP_GPU_NIC_ASSIGNMENT_MODE_SHARED) {
/* Assign the NIC to every GPU in the group. */
ucs_array_for_each(gpu, &group->gpus) {
ucp_gpu_nic_assignment_add_nic_to_gpu(assignment, gpu, nic);
}
} else {
gpu_idx = ucp_gpu_nic_assignment_get_gpu_idx(mode, num_gpus,
nic_idx);
gpu = &ucs_array_elem(&group->gpus, gpu_idx);
ucp_gpu_nic_assignment_add_nic_to_gpu(assignment, gpu, nic);
}
}
} |
||
| const ucs_topo_group_t *group) | ||
| { | ||
| ucp_gpu_nic_sys_dev_bitmap_t *nic_sys_dev_bitmap; | ||
| const ucs_topo_group_element_t *gpu, *nic; | ||
|
|
||
| ucs_array_for_each(gpu, &group->gpus) { | ||
| ucs_assert((gpu->num_sys_devs > 0) && | ||
| (gpu->sys_devs[0] != UCS_SYS_DEVICE_ID_UNKNOWN)); | ||
|
|
||
| nic_sys_dev_bitmap = ucs_const_cast( | ||
|
guy-ealey-morag marked this conversation as resolved.
Resolved
guy-ealey-morag marked this conversation as resolved.
Resolved
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. the gpu bitmap lookup and asserts here are a copy of the block in |
||
| ucp_gpu_nic_sys_dev_bitmap_t*, | ||
| ucp_gpu_nic_assignment_lookup(assignment, gpu->sys_devs[0])); | ||
| ucs_assert(nic_sys_dev_bitmap != NULL); | ||
|
|
||
| /* Assign all NICs in the group to the GPU. */ | ||
| ucs_array_for_each(nic, &group->nics) { | ||
| ucp_gpu_nic_bitmap_add_nic(nic_sys_dev_bitmap, nic); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| static void ucp_gpu_nic_assignment_add_group_not_shared( | ||
| ucp_gpu_nic_assignment_t *assignment, const ucs_topo_group_t *group, | ||
| ucp_gpu_nic_assignment_policy_t policy) | ||
| { | ||
| size_t num_gpus = ucs_array_length(&group->gpus); | ||
| ucp_gpu_nic_sys_dev_bitmap_t *nic_sys_dev_bitmap; | ||
| const ucs_topo_group_element_t *nic; | ||
| const ucs_topo_group_element_t *gpu; | ||
| size_t nic_idx; | ||
| size_t gpu_idx; | ||
| const ucs_topo_group_element_t *gpu, *nic; | ||
| size_t nic_idx, gpu_idx; | ||
|
|
||
| ucs_assertv(policy != UCP_GPU_NIC_ASSIGNMENT_POLICY_SHARED, | ||
| "invalid policy: %d", (int)policy); | ||
|
|
||
| ucs_array_for_each_index(nic, nic_idx, &group->nics) { | ||
| gpu_idx = ucp_gpu_nic_assignment_get_gpu_idx(policy, num_gpus, nic_idx); | ||
|
|
@@ -354,6 +393,18 @@ ucp_gpu_nic_assignment_add_group(ucp_gpu_nic_assignment_t *assignment, | |
| } | ||
| } | ||
|
|
||
| static void | ||
| ucp_gpu_nic_assignment_add_group(ucp_gpu_nic_assignment_t *assignment, | ||
|
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. remove this and inject policy in the called function, implement shared/not shared in one function |
||
| const ucs_topo_group_t *group, | ||
| ucp_gpu_nic_assignment_policy_t policy) | ||
| { | ||
| if (policy == UCP_GPU_NIC_ASSIGNMENT_POLICY_SHARED) { | ||
| ucp_gpu_nic_assignment_add_group_shared(assignment, group); | ||
| } else { | ||
| ucp_gpu_nic_assignment_add_group_not_shared(assignment, group, policy); | ||
| } | ||
| } | ||
|
|
||
| ucs_status_t | ||
| ucp_gpu_nic_assignment_build(const ucs_topo_groups_t *groups, | ||
| ucp_gpu_nic_assignment_policy_t policy, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ | |
| #ifndef UCP_GPU_NIC_ASSIGNMENT_H_ | ||
| #define UCP_GPU_NIC_ASSIGNMENT_H_ | ||
|
|
||
| #include "ucp_types.h" | ||
|
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. maybe define |
||
|
|
||
| #include <ucs/datastruct/static_bitmap.h> | ||
| #include <ucs/sys/topo/base/topo_groups.h> | ||
|
|
||
|
|
@@ -52,10 +54,26 @@ typedef enum { | |
| */ | ||
| UCP_GPU_NIC_ASSIGNMENT_POLICY_ROUND_ROBIN, | ||
|
|
||
| /** | ||
| * Assign every NIC, with all of its ports, to every GPU in the group. | ||
| */ | ||
| UCP_GPU_NIC_ASSIGNMENT_POLICY_SHARED, | ||
|
|
||
| UCP_GPU_NIC_ASSIGNMENT_POLICY_LAST | ||
| } ucp_gpu_nic_assignment_policy_t; | ||
|
|
||
|
|
||
| /** | ||
| * Get the assignment policy of a GPU network device mode. | ||
| * | ||
| * @param [in] mode GPU network device mode. | ||
| * | ||
| * @return Assignment policy corresponding to @a mode. | ||
| */ | ||
| ucp_gpu_nic_assignment_policy_t | ||
| ucp_gpu_net_device_mode_get_policy(ucp_gpu_net_device_mode_t mode); | ||
|
|
||
|
|
||
| /** | ||
| * Build GPU-to-NIC assignments from topology groups. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /** | ||
| * Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2001-2017. ALL RIGHTS RESERVED. | ||
| * Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2001-2026. ALL RIGHTS RESERVED. | ||
| * | ||
| * See file LICENSE for terms. | ||
| */ | ||
|
|
@@ -233,6 +233,18 @@ typedef enum { | |
| } ucp_fence_mode_t; | ||
|
|
||
|
|
||
| /** | ||
| * GPU network device assignment mode. | ||
| */ | ||
| typedef enum { | ||
|
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: these per-value comments repeat the config help string in Rationale: the flip/round_robin/shared semantics are now written out in three places, so they will drift when a policy is added or changed. |
||
| UCP_GPU_NET_DEVICE_MODE_NOT_SHARED, | ||
|
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.
|
||
| UCP_GPU_NET_DEVICE_MODE_NOT_SHARED_FLIP, | ||
|
guy-ealey-morag marked this conversation as resolved.
Resolved
|
||
| UCP_GPU_NET_DEVICE_MODE_NOT_SHARED_ROUND_ROBIN, | ||
| UCP_GPU_NET_DEVICE_MODE_SHARED, | ||
| UCP_GPU_NET_DEVICE_MODE_LAST | ||
| } ucp_gpu_net_device_mode_t; | ||
|
|
||
|
|
||
| /** | ||
| * Communication scheme in RNDV protocol. | ||
| */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.