Skip to content

Commit 0335732

Browse files
UCP/CORE: Remove device range logic
1 parent 795b01b commit 0335732

File tree

2 files changed

+3
-138
lines changed

2 files changed

+3
-138
lines changed

src/ucp/core/ucp_context.c

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -993,52 +993,6 @@ static uint64_t ucp_str_array_search(const char **array, unsigned array_len,
993993
return result;
994994
}
995995

996-
/* Search str in the ranges that are specified in the array.
997-
* Ranges are a prefix followed by a [range_start-range_end] suffix. (ex: mlx5_[0-2])
998-
* @return bitmap of indexes in which the string appears in the array.
999-
*/
1000-
static uint64_t ucp_str_array_search_in_ranges(const char **array,
1001-
unsigned array_len,
1002-
const char *str)
1003-
{
1004-
unsigned long range_start, range_end, str_id;
1005-
size_t prefix_len;
1006-
uint64_t result;
1007-
const char *p;
1008-
char *endptr;
1009-
unsigned i;
1010-
int n;
1011-
1012-
result = 0;
1013-
for (i = 0; i < array_len; ++i) {
1014-
p = strchr(array[i], '[');
1015-
if (p == NULL) {
1016-
continue; /* Not a range */
1017-
}
1018-
1019-
prefix_len = (size_t)(p - array[i]);
1020-
if (strncmp(array[i], str, prefix_len)) {
1021-
continue; /* Prefix does not match */
1022-
}
1023-
1024-
n = 0;
1025-
if ((sscanf(p, "[%lu-%lu]%n", &range_start, &range_end, &n) != 2) ||
1026-
(n == 0) || (p[n] != '\0') || (range_start > range_end)) {
1027-
continue; /* Invalid range */
1028-
}
1029-
1030-
str_id = strtoul(str + prefix_len, &endptr, 10);
1031-
if ((endptr == str + prefix_len) || (*endptr != '\0') ||
1032-
(str_id < range_start) || (str_id > range_end)) {
1033-
continue; /* Mismatch */
1034-
}
1035-
1036-
result |= UCS_BIT(i);
1037-
}
1038-
1039-
return result;
1040-
}
1041-
1042996
static unsigned ucp_tl_alias_count(ucp_tl_alias_t *alias)
1043997
{
1044998
unsigned count;
@@ -1108,9 +1062,6 @@ static int ucp_is_resource_in_device_list(const uct_tl_resource_desc_t *resource
11081062
mask = ucp_str_array_search((const char**)devices[dev_type].names,
11091063
devices[dev_type].count, resource->dev_name,
11101064
NULL);
1111-
mask |= ucp_str_array_search_in_ranges((const char**)devices[dev_type].names,
1112-
devices[dev_type].count,
1113-
resource->dev_name);
11141065

11151066
/* for network devices, also search for the base name (before the delimiter) */
11161067
if (dev_type == UCT_DEVICE_TYPE_NET) {
@@ -1119,9 +1070,6 @@ static int ucp_is_resource_in_device_list(const uct_tl_resource_desc_t *resource
11191070
mask |= ucp_str_array_search((const char**)devices[dev_type].names,
11201071
devices[dev_type].count, dev_basename,
11211072
NULL);
1122-
mask |= ucp_str_array_search_in_ranges(
1123-
(const char**)devices[dev_type].names,
1124-
devices[dev_type].count, dev_basename);
11251073
}
11261074
}
11271075

test/gtest/ucp/test_ucp_context.cc

Lines changed: 3 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,9 @@ class test_ucp_net_devices_config : public ucp_test {
221221
EXPECT_EQ(m_warnings.size() - warn_count, 1)
222222
<< "Expected exactly one warning";
223223

224-
// print all warnings
225-
for (const std::string &warn : m_warnings) {
226-
std::cout << warn << std::endl;
227-
}
228-
229224
/* Check that a warning about duplicate device was printed */
230225
std::string expected_warn = "device '" + duplicate_dev_name +
231-
"' was selected multiple times";
226+
"' is specified multiple times";
232227
bool found_warning = false;
233228
for (size_t i = warn_count; i < m_warnings.size(); ++i) {
234229
if (m_warnings[i].find(expected_warn) != std::string::npos) {
@@ -311,73 +306,6 @@ UCS_TEST_P(test_ucp_net_devices_config, explicit_port_suffix)
311306
<< "Device '" << test_dev_name << "' should be selected";
312307
}
313308

314-
/*
315-
* Test that device name range specification works with base names.
316-
* E.g., "mlx5_[0-1]" should match mlx5_0:1 and mlx5_1:1
317-
*/
318-
UCS_TEST_P(test_ucp_net_devices_config, range_with_base_names)
319-
{
320-
entity *e = create_entity();
321-
322-
std::set<std::string> mlx5_devices = get_mlx5_device_names(*e);
323-
if (mlx5_devices.empty()) {
324-
UCS_TEST_SKIP_R("No mlx5 network device available");
325-
}
326-
327-
size_t num_mlx5_devices = mlx5_devices.size();
328-
if (num_mlx5_devices < 2) {
329-
UCS_TEST_SKIP_R("Need at least 2 mlx5 devices for range test");
330-
}
331-
332-
m_entities.clear();
333-
334-
/* Use a range that should match all mlx devices */
335-
modify_config("NET_DEVICES", "mlx5_[0-99]");
336-
e = create_entity();
337-
338-
/* Verify that mlx5 devices were selected */
339-
std::set<std::string> selected_devices = get_mlx5_device_names(*e);
340-
EXPECT_EQ(selected_devices.size(), num_mlx5_devices)
341-
<< "Expected " << num_mlx5_devices
342-
<< " mlx5 devices to be selected with range";
343-
}
344-
345-
/*
346-
* Test that a range not covering all devices only selects matching devices.
347-
* E.g., "mlx5_[1-2]" should match mlx5_1 and mlx5_2, but not mlx5_0.
348-
*/
349-
UCS_TEST_P(test_ucp_net_devices_config, partial_range_selection)
350-
{
351-
entity *e = create_entity();
352-
353-
std::set<std::string> mlx5_devices = get_mlx5_device_names(*e);
354-
if (mlx5_devices.empty()) {
355-
UCS_TEST_SKIP_R("No mlx5 network device available");
356-
}
357-
358-
std::set<std::string> base_names = get_mlx5_base_names(mlx5_devices);
359-
360-
if (!has_device(base_names, "mlx5_0") ||
361-
!has_device(base_names, "mlx5_1") ||
362-
!has_device(base_names, "mlx5_2")) {
363-
UCS_TEST_SKIP_R(
364-
"Need mlx5_0, mlx5_1, and mlx5_2 devices for this test");
365-
}
366-
367-
m_entities.clear();
368-
369-
modify_config("NET_DEVICES", "mlx5_[1-2]");
370-
e = create_entity();
371-
372-
std::set<std::string> selected_devices = get_mlx5_device_names(*e);
373-
374-
std::set<std::string> selected_base_names = get_mlx5_base_names(
375-
selected_devices);
376-
377-
std::set<std::string> expected_base_names = {"mlx5_1", "mlx5_2"};
378-
EXPECT_EQ(selected_base_names, expected_base_names);
379-
}
380-
381309
/*
382310
* Test that specifying a device multiple times produces a warning
383311
*/
@@ -388,23 +316,12 @@ UCS_TEST_P(test_ucp_net_devices_config, duplicate_device_warning_simple)
388316

389317
UCS_TEST_P(test_ucp_net_devices_config, duplicate_device_warning_base_name)
390318
{
391-
test_duplicate_device_warning("mlx5_0:1,mlx5_0", "mlx5_0:1");
319+
test_duplicate_device_warning("mlx5_0:1,mlx5_0", "mlx5_0");
392320
}
393321

394322
UCS_TEST_P(test_ucp_net_devices_config, duplicate_device_warning_two_base_name)
395323
{
396-
test_duplicate_device_warning("mlx5_0,mlx5_0", "mlx5_0:1");
397-
}
398-
399-
UCS_TEST_P(test_ucp_net_devices_config, duplicate_device_warning_range)
400-
{
401-
test_duplicate_device_warning("mlx5_[0-99],mlx5_0", "mlx5_0:1");
402-
}
403-
404-
UCS_TEST_P(test_ucp_net_devices_config, duplicate_device_warning_two_ranges)
405-
{
406-
test_duplicate_device_warning("mlx5_[0-1],mlx5_[1-2]", "mlx5_1:1");
324+
test_duplicate_device_warning("mlx5_0,mlx5_0", "mlx5_0");
407325
}
408326

409-
410327
UCP_INSTANTIATE_TEST_CASE_TLS(test_ucp_net_devices_config, ib, "ib")

0 commit comments

Comments
 (0)