Skip to content

Commit

Permalink
UCP: fix tl/dev selection to handle float values.
Browse files Browse the repository at this point in the history
- added a small value which would overcome float imprecision in score
  calculations.
- print the lanes configurations in case the tl-dev selection is
  incorrect.

fixes #1534

(cherry picked from commit 4b0dc3e)
  • Loading branch information
alinask committed Jun 15, 2017
1 parent 44ba878 commit 075b7ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/ucp/wireup/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ ucp_wireup_select_transport(ucp_ep_h ep, const ucp_address_entry_t *address_list
int reachable;
int found;
uint8_t priority, best_score_priority;
float epsilon; /* a small value to overcome float imprecision */

found = 0;
best_score = 0.0;
Expand Down Expand Up @@ -257,8 +258,9 @@ ucp_wireup_select_transport(ucp_ep_h ep, const ucp_address_entry_t *address_list

/* First comparing score, if score equals to current best score,
* comparing priority with the priority of best score */
if (!found || (score > best_score) ||
((score == best_score) && (priority > best_score_priority))) {
epsilon = (score + best_score) * (1e-6);
if (!found || (score > (best_score + epsilon)) ||
((fabs(score - best_score) < epsilon) && (priority > best_score_priority))) {
*rsc_index_p = rsc_index;
*dst_addr_index_p = ae - address_list;
*score_p = score;
Expand Down
16 changes: 9 additions & 7 deletions src/ucp/wireup/wireup.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,24 +416,25 @@ static ucs_status_t ucp_wireup_connect_lane(ucp_ep_h ep, ucp_lane_index_t lane,
static void ucp_wireup_print_config(ucp_context_h context,
const ucp_ep_config_key_t *key,
const char *title,
uint8_t *addr_indices)
uint8_t *addr_indices,
ucs_log_level_t log_level)
{
char lane_info[128] = {0};
ucp_lane_index_t lane;

if (!ucs_log_enabled(UCS_LOG_LEVEL_DEBUG)) {
if (!ucs_log_enabled(log_level)) {
return;
}

ucs_debug("%s: am_lane %d wirep_lane %d reachable_mds 0x%lx",
ucs_log(log_level, "%s: am_lane %d wirep_lane %d reachable_mds 0x%lx",
title, key->am_lane, key->wireup_lane,
key->reachable_md_map);

for (lane = 0; lane < key->num_lanes; ++lane) {
ucp_ep_config_lane_info_str(context, key, addr_indices, lane,
UCP_NULL_RESOURCE, lane_info,
sizeof(lane_info));
ucs_debug("%s: %s", title, lane_info);
ucs_log(log_level, "%s: %s", title, lane_info);
}
}

Expand Down Expand Up @@ -477,8 +478,9 @@ ucs_status_t ucp_wireup_init_lanes(ucp_ep_h ep, const ucp_ep_params_t *params,
*/
ucs_debug("cannot reconfigure ep %p from [%d] to [%d]", ep, ep->cfg_index,
new_cfg_index);
ucp_wireup_print_config(worker->context, &ucp_ep_config(ep)->key, "old", NULL);
ucp_wireup_print_config(worker->context, &key, "new", NULL);
ucp_wireup_print_config(worker->context, &ucp_ep_config(ep)->key, "old",
NULL, UCS_LOG_LEVEL_ERROR);
ucp_wireup_print_config(worker->context, &key, "new", NULL, UCS_LOG_LEVEL_ERROR);
ucs_fatal("endpoint reconfiguration not supported yet");
}

Expand All @@ -487,7 +489,7 @@ ucs_status_t ucp_wireup_init_lanes(ucp_ep_h ep, const ucp_ep_params_t *params,

snprintf(str, sizeof(str), "ep %p", ep);
ucp_wireup_print_config(worker->context, &ucp_ep_config(ep)->key, str,
addr_indices);
addr_indices, UCS_LOG_LEVEL_DEBUG);

ucs_trace("ep %p: connect lanes", ep);

Expand Down

0 comments on commit 075b7ba

Please sign in to comment.