Skip to content
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

UCT/MLX5/UCS: Print error message if SRQ topology is invalid #10479

Merged

Conversation

yosefe
Copy link
Contributor

@yosefe yosefe commented Feb 10, 2025

Why

Without this fix, if the none of the SRQ topologies provided in the configuration is supported, there is a failure to create the uct_iface without an indicative error message.

@yosefe yosefe requested a review from roiedanino February 10, 2025 19:14
@yosefe yosefe force-pushed the topic/uct-mlx5-ucs-print-error-message-if branch from 859f85f to 7ba8a42 Compare February 10, 2025 19:15
Comment on lines 141 to 149
size_t i;

for (i = 0; i < count; ++i) {
if (i > 0) {
ucs_string_buffer_appendf(strb, "%s%s", sep, strs[i]);
} else {
ucs_string_buffer_appendf(strb, "%s", strs[i]);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: we can remove branch in the loop:

Suggested change
size_t i;
for (i = 0; i < count; ++i) {
if (i > 0) {
ucs_string_buffer_appendf(strb, "%s%s", sep, strs[i]);
} else {
ucs_string_buffer_appendf(strb, "%s", strs[i]);
}
}
size_t i;
if (count > 0) {
ucs_string_buffer_appendf(strb, "%s", strs[0]);
}
for (i = 1; i < count; ++i) {
ucs_string_buffer_appendf(strb, "%s%s", sep, strs[i]);
}

@@ -179,6 +179,18 @@ void ucs_string_buffer_append_flags(ucs_string_buffer_t *strb, uint64_t mask,
const char **flag_names);


/**
* Append a list of strings separated by a custom token.
Copy link
Contributor

Choose a reason for hiding this comment

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

list -> array?

@@ -135,6 +135,20 @@ void ucs_string_buffer_append_flags(ucs_string_buffer_t *strb, uint64_t mask,
ucs_string_buffer_rtrim(strb, ",|");
}

void ucs_string_buffer_append_list(ucs_string_buffer_t *strb, const char *sep,
Copy link
Contributor

Choose a reason for hiding this comment

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

_append_array?

Copy link
Contributor

Choose a reason for hiding this comment

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

or _strings?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or ucs_string_buffer_append_all which is quite common in some libraries

* @param [in] strs Array of strings to append.
* @param [in] count Number of strings in the array.
*/
void ucs_string_buffer_append_list(ucs_string_buffer_t *strb, const char *sep,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to make a generic append_array instead, that would accept any type of array?
Something like:

#define UCS_SB_APPEND_ARRAY(_strb, _array, _fmt, _sep) \
    ucs_array_for_each(_elem, _array) { \
        ucs_string_buffer_appendf(_strb, "%s"_fmt, _sep, _elem); \
    }

Copy link
Contributor

@tvegas1 tvegas1 left a comment

Choose a reason for hiding this comment

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

minor comments

src/uct/ib/mlx5/rc/rc_mlx5_iface.c Outdated Show resolved Hide resolved
@@ -135,6 +135,20 @@ void ucs_string_buffer_append_flags(ucs_string_buffer_t *strb, uint64_t mask,
ucs_string_buffer_rtrim(strb, ",|");
}

void ucs_string_buffer_append_list(ucs_string_buffer_t *strb, const char *sep,
Copy link
Contributor

Choose a reason for hiding this comment

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

or _strings?

test/gtest/ucs/test_string.cc Outdated Show resolved Hide resolved
@@ -311,6 +311,15 @@ UCS_TEST_F(test_string_buffer, flags) {
EXPECT_EQ(std::string("one|three"), ucs_string_buffer_cstr(&strb));
}

UCS_TEST_F(test_string_buffer, list) {
static const char *str_list[] = {"once", "upon", "a", "time"};
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: str_list -> str_arr

@@ -135,6 +135,20 @@ void ucs_string_buffer_append_flags(ucs_string_buffer_t *strb, uint64_t mask,
ucs_string_buffer_rtrim(strb, ",|");
}

void ucs_string_buffer_append_list(ucs_string_buffer_t *strb, const char *sep,
Copy link
Contributor

Choose a reason for hiding this comment

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

Or ucs_string_buffer_append_all which is quite common in some libraries

roiedanino
roiedanino previously approved these changes Feb 11, 2025
src/ucs/datastruct/string_buffer.h Outdated Show resolved Hide resolved
src/ucs/datastruct/string_buffer.h Show resolved Hide resolved
* @param _array Array of elements to append.
* @param _count Number of elements in the array.
*/
#define ucs_string_buffer_append_array(_strb, _sep, _fmt, _array, _count) \
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, now it's cool
Just one minor thing: currently this is suitable for C arrays, maybe it makes sense to have an "overload" for ucs_array?

// C array
#define ucs_string_buffer_append_carray(_strb, _sep, _fmt, _array, _count)  << current impl

#define ucs_string_buffer_append_array(_strb, _sep, _fmt, _array) \  << overload for UCS array
    ucs_string_buffer_append_carray(_strb, _sep, _fmt, _array.buffer, _array.length)

Up to you, not really critical

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Today we don't have a place we use it for ucs_array so IMO it's not needed

@yosefe yosefe force-pushed the topic/uct-mlx5-ucs-print-error-message-if branch from ae2834d to c6e568b Compare February 12, 2025 09:24
@yosefe yosefe enabled auto-merge February 12, 2025 12:07
@yosefe yosefe merged commit 87d8a47 into openucx:master Feb 12, 2025
151 checks passed
@yosefe yosefe deleted the topic/uct-mlx5-ucs-print-error-message-if branch February 12, 2025 17:47
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