Skip to content

Commit

Permalink
UCT/MLX5/UCS: Print error message if SRQ topology is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
yosefe committed Feb 10, 2025
1 parent a281791 commit 859f85f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/ucs/datastruct/string_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
const char **strs, size_t count)
{
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]);
}
}
}

void ucs_string_buffer_append_iovec(ucs_string_buffer_t *strb,
const struct iovec *iov, size_t iovcnt)
{
Expand Down
12 changes: 12 additions & 0 deletions src/ucs/datastruct/string_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* @param [inout] strb String buffer to append to.
* @param [in] sep Use this string as the separator
* @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,
const char **strs, size_t count);


/**
* Append an IO vector representation to the string buffer.
*
Expand Down
8 changes: 8 additions & 0 deletions src/uct/ib/mlx5/rc/rc_mlx5_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ uct_rc_mlx5_iface_parse_srq_topo(uct_ib_mlx5_md_t *md,
((init_attr->qp_type == UCT_IB_QPT_DCI) ?
UCT_IB_MLX5_MD_FLAG_DEVX_DC_SRQ :
UCT_IB_MLX5_MD_FLAG_DEVX_RC_SRQ);
ucs_string_buffer_t strb = UCS_STRING_BUFFER_INITIALIZER;
int i;

for (i = 0; i < config->srq_topo.count; ++i) {
Expand All @@ -403,6 +404,13 @@ uct_rc_mlx5_iface_parse_srq_topo(uct_ib_mlx5_md_t *md,
}
}

ucs_string_buffer_append_list(&strb, ",",
(const char**)config->srq_topo.types,
config->srq_topo.count);
ucs_error("%s: none of the provided SRQ topology modes %s is supported",
uct_ib_device_name(&md->super.dev),
ucs_string_buffer_cstr(&strb));
ucs_string_buffer_cleanup(&strb);
return UCS_ERR_INVALID_PARAM;
}

Expand Down
9 changes: 9 additions & 0 deletions test/gtest/ucs/test_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"};
UCS_STRING_BUFFER_ONSTACK(strb, 128);
/* coverity[overrun-buffer-val] */
ucs_string_buffer_append_list(&strb, " ", str_list,
ucs_static_array_size(str_list));
EXPECT_EQ(std::string("once upon a time"), ucs_string_buffer_cstr(&strb));
}

UCS_TEST_F(test_string_buffer, dump) {
UCS_STRING_BUFFER_ONSTACK(strb, 128);
ucs_string_buffer_appendf(&strb, "hungry\n");
Expand Down

0 comments on commit 859f85f

Please sign in to comment.