Skip to content

Commit d775119

Browse files
authored
Merge pull request #1613 from alinask/topic/ucp-wireup-float-handle
UCP: fix tl/dev selection to handle float values.
2 parents 2eafed2 + 4b0dc3e commit d775119

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/ucp/wireup/select.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ ucp_wireup_select_transport(ucp_ep_h ep, const ucp_address_entry_t *address_list
146146
int reachable;
147147
int found;
148148
uint8_t priority, best_score_priority;
149+
float epsilon; /* a small value to overcome float imprecision */
149150

150151
found = 0;
151152
best_score = 0.0;
@@ -250,8 +251,9 @@ ucp_wireup_select_transport(ucp_ep_h ep, const ucp_address_entry_t *address_list
250251

251252
/* First comparing score, if score equals to current best score,
252253
* comparing priority with the priority of best score */
253-
if (!found || (score > best_score) ||
254-
((score == best_score) && (priority > best_score_priority))) {
254+
epsilon = (score + best_score) * (1e-6);
255+
if (!found || (score > (best_score + epsilon)) ||
256+
((fabs(score - best_score) < epsilon) && (priority > best_score_priority))) {
255257
*rsc_index_p = rsc_index;
256258
*dst_addr_index_p = ae - address_list;
257259
*score_p = score;

src/ucp/wireup/wireup.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,24 +408,25 @@ static ucs_status_t ucp_wireup_connect_lane(ucp_ep_h ep, ucp_lane_index_t lane,
408408
static void ucp_wireup_print_config(ucp_context_h context,
409409
const ucp_ep_config_key_t *key,
410410
const char *title,
411-
uint8_t *addr_indices)
411+
uint8_t *addr_indices,
412+
ucs_log_level_t log_level)
412413
{
413414
char lane_info[128] = {0};
414415
ucp_lane_index_t lane;
415416

416-
if (!ucs_log_enabled(UCS_LOG_LEVEL_DEBUG)) {
417+
if (!ucs_log_enabled(log_level)) {
417418
return;
418419
}
419420

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

424425
for (lane = 0; lane < key->num_lanes; ++lane) {
425426
ucp_ep_config_lane_info_str(context, key, addr_indices, lane,
426427
UCP_NULL_RESOURCE, lane_info,
427428
sizeof(lane_info));
428-
ucs_debug("%s: %s", title, lane_info);
429+
ucs_log(log_level, "%s: %s", title, lane_info);
429430
}
430431
}
431432

@@ -468,8 +469,9 @@ ucs_status_t ucp_wireup_init_lanes(ucp_ep_h ep, unsigned address_count,
468469
*/
469470
ucs_debug("cannot reconfigure ep %p from [%d] to [%d]", ep, ep->cfg_index,
470471
new_cfg_index);
471-
ucp_wireup_print_config(worker->context, &ucp_ep_config(ep)->key, "old", NULL);
472-
ucp_wireup_print_config(worker->context, &key, "new", NULL);
472+
ucp_wireup_print_config(worker->context, &ucp_ep_config(ep)->key, "old",
473+
NULL, UCS_LOG_LEVEL_ERROR);
474+
ucp_wireup_print_config(worker->context, &key, "new", NULL, UCS_LOG_LEVEL_ERROR);
473475
ucs_fatal("endpoint reconfiguration not supported yet");
474476
}
475477

@@ -478,7 +480,7 @@ ucs_status_t ucp_wireup_init_lanes(ucp_ep_h ep, unsigned address_count,
478480

479481
snprintf(str, sizeof(str), "ep %p", ep);
480482
ucp_wireup_print_config(worker->context, &ucp_ep_config(ep)->key, str,
481-
addr_indices);
483+
addr_indices, UCS_LOG_LEVEL_DEBUG);
482484

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

0 commit comments

Comments
 (0)