Skip to content

Commit

Permalink
UCP/TEST: CR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shasson5 committed Nov 14, 2024
1 parent ae49a49 commit 82e45e2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 47 deletions.
26 changes: 6 additions & 20 deletions src/ucp/core/ucp_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1851,39 +1851,25 @@ ucp_lane_index_t ucp_ep_find_wireup_ep_lane(ucp_ep_h ep)
return UCP_NULL_LANE;
}

static ucp_lane_index_t
ucp_ep_get_reused_lane_source(ucp_ep_h ep, ucp_lane_index_t new_lane,
const ucp_lane_index_t *reuse_lane_map)
{
ucp_lane_index_t lane;

for (lane = 0; lane < ucp_ep_num_lanes(ep); lane++) {
if (reuse_lane_map[lane] == new_lane) {
return lane;
}
}

return UCP_NULL_LANE;
}

ucp_lane_index_t
ucp_ep_find_non_reused_lane(ucp_ep_h ep, const ucp_ep_config_key_t *key,
const ucp_lane_index_t *reuse_lane_map)
{
ucp_lane_map_t lane_bitmap = {0};
ucp_lane_index_t lane;

if (ucp_ep_has_cm_lane(ep)) {
return key->cm_lane;
}

for (lane = 0; lane < key->num_lanes; lane++) {
if (ucp_ep_get_reused_lane_source(ep, lane, reuse_lane_map) ==
UCP_NULL_LANE) {
return lane;
for (lane = 0; lane < ucp_ep_num_lanes(ep); lane++) {
if (reuse_lane_map[lane] != UCP_NULL_LANE) {
lane_bitmap |= UCS_BIT(reuse_lane_map[lane]);
}
}

return UCP_NULL_LANE;
lane = ucs_ffs64_safe(~lane_bitmap);
return (lane < key->num_lanes) ? lane : UCP_NULL_LANE;
}

static int ucp_ep_lane_is_dst_index_match(ucp_rsc_index_t dst_index1,
Expand Down
56 changes: 29 additions & 27 deletions test/gtest/ucp/test_ucp_ep_reconfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,24 @@ class test_ucp_ep_reconfig : public ucp_test {
if (sender().ucph()->num_tls <= 2) {
UCS_TEST_SKIP_R("test requires at least 2 ifaces to work");
}

check_reused_lanes_reconfigurable();
}

static void get_test_variants(std::vector<ucp_test_variant> &variants)
{
add_variant_with_value(variants, UCP_FEATURE_TAG, 0, "");
add_variant_with_value(variants, UCP_FEATURE_TAG, 1, "reuse");
}

void run(bool bidirectional = false, bool reuse_lanes = false);
void run(bool bidirectional = false);
void skip_non_p2p();
bool has_bond_iface();
void check_reused_lanes_reconfigurable();

bool reuse_lanes() const
{
return m_reuse_lanes;
return get_variant_value();
}

void send_message(const ucp_test_base::entity &e1,
Expand Down Expand Up @@ -174,8 +178,6 @@ class test_ucp_ep_reconfig : public ucp_test {
}
}
}

bool m_reuse_lanes;
};

unsigned test_ucp_ep_reconfig::entity::num_paths() const
Expand Down Expand Up @@ -346,9 +348,8 @@ test_ucp_ep_reconfig::entity::get_address(const ucp_tl_bitmap_t &tl_bitmap) cons
return address;
}

void test_ucp_ep_reconfig::run(bool bidirectional, bool reuse_lanes)
void test_ucp_ep_reconfig::run(bool bidirectional)
{
m_reuse_lanes = reuse_lanes;
create_entities_and_connect();
send_recv(bidirectional);

Expand All @@ -368,7 +369,6 @@ void test_ucp_ep_reconfig::skip_non_p2p()
}
}


bool test_ucp_ep_reconfig::has_bond_iface()
{
auto context = sender().ucph();
Expand All @@ -384,9 +384,29 @@ bool test_ucp_ep_reconfig::has_bond_iface()

return false;
}

void test_ucp_ep_reconfig::check_reused_lanes_reconfigurable()
{
if (!reuse_lanes()) {
return;
}

if (has_transport("ud_v") || has_transport("ud_x")) {
UCS_TEST_SKIP_R("the test requires at least 2 lanes, while UD has only "
"1");
}

if (has_transport("tcp") || has_transport("dc_x") || has_transport("shm")) {
UCS_TEST_SKIP_R("non wired-up lanes are not supported yet");
}

if (has_bond_iface()) {
modify_config("IB_NUM_PATHS", "1", SETENV_IF_NOT_EXIST);
}
}

/* TODO: Remove skip condition after next PRs are merged. */
UCS_TEST_SKIP_COND_P(test_ucp_ep_reconfig, basic,
!has_transport("rc_x") || !has_transport("rc_v"))
UCS_TEST_SKIP_COND_P(test_ucp_ep_reconfig, basic, !has_transport("rc"))
{
run();
}
Expand Down Expand Up @@ -415,24 +435,6 @@ UCS_TEST_SKIP_COND_P(test_ucp_ep_reconfig, resolve_remote_id, is_self(),
run(true);
}

UCS_TEST_SKIP_COND_P(test_ucp_ep_reconfig, reuse_lanes, is_self())
{
if (has_transport("ud_v") || has_transport("ud_x")) {
UCS_TEST_SKIP_R("the test requires at least 2 lanes, while UD has only "
"1");
}

if (has_transport("tcp") || has_transport("dc_x") || has_transport("shm")) {
UCS_TEST_SKIP_R("non wired-up lanes are not supported yet");
}

if (has_bond_iface()) {
modify_config("IB_NUM_PATHS", "1", SETENV_IF_NOT_EXIST);
}

run(false, true);
}

UCP_INSTANTIATE_TEST_CASE(test_ucp_ep_reconfig);
UCP_INSTANTIATE_TEST_CASE_TLS(test_ucp_ep_reconfig, rc_x_v, "rc");

Expand Down

0 comments on commit 82e45e2

Please sign in to comment.