-
Notifications
You must be signed in to change notification settings - Fork 435
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
UCT/MLX5/UCS: Print error message if SRQ topology is invalid #10479
Conversation
859f85f
to
7ba8a42
Compare
src/ucs/datastruct/string_buffer.c
Outdated
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]); | ||
} | ||
} |
There was a problem hiding this comment.
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:
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]); | |
} |
src/ucs/datastruct/string_buffer.h
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list -> array?
src/ucs/datastruct/string_buffer.c
Outdated
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_append_array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or _strings?
There was a problem hiding this comment.
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
src/ucs/datastruct/string_buffer.h
Outdated
* @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, |
There was a problem hiding this comment.
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); \
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments
src/ucs/datastruct/string_buffer.c
Outdated
@@ -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, |
There was a problem hiding this comment.
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
@@ -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"}; |
There was a problem hiding this comment.
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
src/ucs/datastruct/string_buffer.c
Outdated
@@ -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, |
There was a problem hiding this comment.
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 _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) \ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
ae2834d
to
c6e568b
Compare
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.