Skip to content

Commit 1ace8ff

Browse files
UCP/CORE: Fix PR comments
1 parent e3be8e9 commit 1ace8ff

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

src/ucp/core/ucp_context.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <ucs/type/init_once.h>
2727
#include <ucs/vfs/base/vfs_cb.h>
2828
#include <ucs/vfs/base/vfs_obj.h>
29+
#include <uct/ib/base/ib_device.h>
2930
#include <string.h>
3031
#include <dlfcn.h>
3132

@@ -72,9 +73,6 @@
7273
/* Factor to multiply with in order to get infinite latency */
7374
#define UCP_CONTEXT_INFINITE_LAT_FACTOR 100
7475

75-
#define UCP_MLX_PREFIX "mlx"
76-
#define UCP_MLX_DEFAULT_PORT "1"
77-
7876
typedef enum ucp_transports_list_search_result {
7977
UCP_TRANSPORTS_LIST_SEARCH_RESULT_PRIMARY = UCS_BIT(0),
8078
UCP_TRANSPORTS_LIST_SEARCH_RESULT_AUX_IN_MAIN = UCS_BIT(1),
@@ -1080,7 +1078,7 @@ ucp_config_is_tl_name_present(const ucs_config_names_array_t *tl_array,
10801078
tl_cfg_mask));
10811079
}
10821080

1083-
/* Return a pointer to the suffix of the device name,
1081+
/* Return a pointer to the suffix of the device name,
10841082
* or the end of the string if no suffix is found. */
10851083
static const char *ucp_get_dev_name_suffix(const char *dev_name)
10861084
{
@@ -1091,13 +1089,6 @@ static const char *ucp_get_dev_name_suffix(const char *dev_name)
10911089
return colon + 1;
10921090
}
10931091

1094-
static inline int
1095-
ucp_is_dev_mlx_default_port(const char *dev_name, const char *dev_name_suffix)
1096-
{
1097-
return (!strncmp(dev_name, UCP_MLX_PREFIX, strlen(UCP_MLX_PREFIX))) &&
1098-
(!strcmp(dev_name_suffix, UCP_MLX_DEFAULT_PORT));
1099-
}
1100-
11011092
static int ucp_is_resource_in_device_list(const uct_tl_resource_desc_t *resource,
11021093
const ucs_config_names_array_t *devices,
11031094
uint64_t *dev_cfg_mask,
@@ -1117,7 +1108,8 @@ static int ucp_is_resource_in_device_list(const uct_tl_resource_desc_t *resource
11171108
if (dev_type == UCT_DEVICE_TYPE_NET) {
11181109
dev_name_suffix = ucp_get_dev_name_suffix(resource->dev_name);
11191110

1120-
if (ucp_is_dev_mlx_default_port(resource->dev_name, dev_name_suffix)) {
1111+
if (uct_ib_device_is_mlx_default_port(resource->dev_name,
1112+
dev_name_suffix)) {
11211113
ucs_strncpy_zero(dev_name_base, resource->dev_name,
11221114
(size_t)(dev_name_suffix - resource->dev_name));
11231115

src/uct/ib/base/ib_device.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
#define UCT_IB_DEVICE_ROUTABLE_FLID_GID_INDEX 1 /* The gid index used by default
7676
with FLID based IB routing */
7777

78+
#define UCT_IB_MLX_DEV_NAME_PREFIX "mlx"
79+
#define UCT_IB_MLX_DEFAULT_PORT "1"
7880

7981
enum {
8082
UCT_IB_DEVICE_STAT_ASYNC_EVENT,
@@ -521,4 +523,20 @@ void uct_ib_handle_async_event(uct_ib_device_t *dev, uct_ib_async_event_t *event
521523

522524
int uct_ib_device_is_smi(struct ibv_device *ibv_device);
523525

526+
/**
527+
* Check if the device is a Mellanox device with the default port.
528+
*
529+
* @param dev_name Device name
530+
* @param dev_name_suffix Device name suffix (following the colon)
531+
*
532+
* @return Non-zero if the device is an MLX device with default port.
533+
*/
534+
static inline int uct_ib_device_is_mlx_default_port(const char *dev_name,
535+
const char *dev_name_suffix)
536+
{
537+
return (strncmp(dev_name, UCT_IB_MLX_DEV_NAME_PREFIX,
538+
strlen(UCT_IB_MLX_DEV_NAME_PREFIX)) == 0) &&
539+
(strcmp(dev_name_suffix, UCT_IB_MLX_DEFAULT_PORT) == 0);
540+
}
541+
524542
#endif

test/gtest/ucp/test_ucp_context.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ class test_ucp_net_devices_config : public ucp_test {
146146
static std::set<std::string> get_mlx5_device_names(const entity &e) {
147147
std::set<std::string> device_names;
148148
for_each_net_device(e, [&](const uct_tl_resource_desc_t *rsc) {
149-
if (strncmp(rsc->dev_name, "mlx5_", 5) == 0) {
149+
std::string dev_name(rsc->dev_name);
150+
if (dev_name.compare(0, 5, "mlx5_") == 0) {
150151
device_names.insert(rsc->dev_name);
151152
}
152153
});

0 commit comments

Comments
 (0)