Skip to content

Commit

Permalink
CORE: Add fn name to score print
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarkauskas authored and nsarkauskas committed Feb 26, 2025
1 parent 9be1ac7 commit 70b9a6b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/coll_score/ucc_coll_score.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ ucc_status_t ucc_coll_score_dup(const ucc_coll_score_t *in,
void ucc_coll_score_set(ucc_coll_score_t *score,
ucc_score_t value);

void ucc_coll_score_map_print_info(const ucc_score_map_t *score);
void ucc_coll_score_map_print_info(const ucc_score_map_t *score, int verbosity);

ucc_status_t ucc_coll_score_update(ucc_coll_score_t *score,
ucc_coll_score_t *update,
Expand Down
32 changes: 27 additions & 5 deletions src/coll_score/ucc_coll_score_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "utils/ucc_string.h"
#include "schedule/ucc_schedule.h"

#include <dlfcn.h>

typedef struct ucc_score_map {
ucc_coll_score_t *score;
/* Size, rank of the process in the base_team associated with that
Expand Down Expand Up @@ -157,7 +159,19 @@ ucc_status_t ucc_coll_init(ucc_score_map_t *map,
} \
}

void ucc_coll_score_map_print_info(const ucc_score_map_t *map)
static const char *get_fn_name(ucc_base_coll_init_fn_t init_fn)
{
int status;
Dl_info info;
const char *fn_ptr_str = "?";
status = dladdr(init_fn, &info);
if (status && info.dli_sname != NULL) {
fn_ptr_str = info.dli_sname;
}
return fn_ptr_str;
}

void ucc_coll_score_map_print_info(const ucc_score_map_t *map, int verbosity)
{
size_t left;
ucc_msg_range_t *range;
Expand Down Expand Up @@ -193,10 +207,18 @@ void ucc_coll_score_map_print_info(const ucc_score_map_t *map)
sizeof(range_str));
ucc_score_to_str(range->super.score, score_str,
sizeof(score_str));
STR_APPEND(coll_str, left, 256, "{%s}:%s:%s ",
range_str,
range->super.team->context->lib->log_component.name,
score_str);
if (verbosity >= UCC_LOG_LEVEL_DEBUG) {
// Get the name of the init function through dladdr
STR_APPEND(coll_str, left, 256, "{%s}:%s:%s=%s ",
range_str,
range->super.team->context->lib->log_component.name,
score_str, get_fn_name(range->super.init));
} else {
STR_APPEND(coll_str, left, 256, "{%s}:%s:%s ",
range_str,
range->super.team->context->lib->log_component.name,
score_str);
}
}
STR_APPEND(coll_str, left, 4, "\n");
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/ucc_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ ucc_status_t ucc_team_create_test_single(ucc_context_t *context,
team->rank == 0) {
ucc_info("===== COLL_SCORE_MAP (team_id %d, size %u) =====",
team->id, team->size);
ucc_coll_score_map_print_info(team->score_map);
ucc_coll_score_map_print_info(team->score_map,
ucc_global_config.log_component.log_level);
ucc_info("================================================");
}
/* TODO: add team/coll selection and check if some teams are never
Expand Down

0 comments on commit 70b9a6b

Please sign in to comment.