Skip to content

Commit

Permalink
CORE: add coll_trace loggger
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei-Lebedev committed Mar 5, 2023
1 parent c7c4375 commit 614c791
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 37 deletions.
26 changes: 14 additions & 12 deletions src/core/ucc_coll.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,23 @@ UCC_CORE_PROFILE_FUNC(ucc_status_t, ucc_collective_init,
}
task->seq_num = team->seq_num++;

if (ucc_global_config.log_component.log_level >= UCC_LOG_LEVEL_INFO) {
if (ucc_global_config.log_component.log_level >= UCC_LOG_LEVEL_DEBUG ||
ucc_global_config.coll_trace) {
char coll_str[256];
ucc_coll_str(task, coll_str, sizeof(coll_str),
ucc_global_config.log_component.log_level);
if (ucc_global_config.log_component.log_level == UCC_LOG_LEVEL_INFO) {
if (team->rank == 0) {
ucc_info("coll_init: %s", coll_str);
}
} else {
ucc_debug("coll_init: %s", coll_str);
if (ucc_global_config.coll_trace.log_level >= UCC_LOG_LEVEL_DIAG) {
char coll_str[256];
ucc_coll_str(task, coll_str, sizeof(coll_str),
ucc_global_config.coll_trace.log_level);
if (ucc_global_config.coll_trace.log_level <= UCC_LOG_LEVEL_DEBUG) {
if (team->rank == 0) {
ucc_log_component_collective_trace(
ucc_global_config.coll_trace.log_level, "coll_init: %s",
coll_str);
}
} else {
ucc_log_component_collective_trace(
ucc_global_config.coll_trace.log_level, "coll_init: %s",
coll_str);
}
}

ucc_assert(task->super.status == UCC_OPERATION_INITIALIZED);
*request = &task->super;

Expand Down
11 changes: 7 additions & 4 deletions src/core/ucc_global_opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ UCC_LIST_HEAD(ucc_config_global_list);

ucc_global_config_t ucc_global_config = {
.log_component = {UCC_LOG_LEVEL_WARN, "UCC"},
.coll_trace = {UCC_LOG_LEVEL_WARN, "UCC_COLL"},
.component_path = NULL,
.install_path = NULL,
.initialized = 0,
Expand All @@ -30,11 +31,13 @@ ucc_config_field_t ucc_global_config_table[] = {
ucc_offsetof(ucc_global_config_t, log_component),
UCC_CONFIG_TYPE_LOG_COMP},

{"COLL_TRACE", "n",
"If UCC logging level is INFO or higher UCC will print info message"
"on each collective.\n",
{"COLL_TRACE", "warn",
"UCC collective logging level. Higher level will result in more verbose "
"collective info. \n "
"Possible values are: fatal, error, warn, info, debug, trace, data, func, "
"poll.",
ucc_offsetof(ucc_global_config_t, coll_trace),
UCC_CONFIG_TYPE_BOOL
UCC_CONFIG_TYPE_LOG_COMP
},

{"PROFILE_MODE", "",
Expand Down
2 changes: 1 addition & 1 deletion src/core/ucc_global_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef struct ucc_global_config {
/* Log level above which log messages will be printed*/
ucc_log_component_config_t log_component;
/* Print collective info for each initialized collective */
int coll_trace;
ucc_log_component_config_t coll_trace;
ucc_component_framework_t cl_framework;
ucc_component_framework_t tl_framework;
ucc_component_framework_t mc_framework;
Expand Down
11 changes: 6 additions & 5 deletions src/schedule/ucc_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ ucc_status_t ucc_schedule_init(ucc_schedule_t *schedule,
{
ucc_status_t status;

status = ucc_coll_task_init(&schedule->super, bargs, team);
schedule->ctx = team->context->ucc_context;
schedule->n_tasks = 0;
status = ucc_coll_task_init(&schedule->super, bargs, team);
schedule->super.flags |= UCC_COLL_TASK_FLAG_IS_SCHEDULE;
schedule->ctx = team->context->ucc_context;
schedule->n_tasks = 0;
return status;
}

Expand All @@ -202,8 +203,8 @@ ucc_status_t ucc_schedule_add_task(ucc_schedule_t *schedule,
ucc_status_t status;

status = ucc_event_manager_subscribe(task, UCC_EVENT_COMPLETED_SCHEDULE,
&schedule->super,
ucc_schedule_completed_handler);
&schedule->super,
ucc_schedule_completed_handler);
task->schedule = schedule;
schedule->tasks[schedule->n_tasks++] = task;
if (task->flags & UCC_COLL_TASK_FLAG_EXECUTOR) {
Expand Down
8 changes: 5 additions & 3 deletions src/schedule/ucc_schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ typedef ucc_status_t (*ucc_task_event_handler_p)(ucc_coll_task_t *parent,
/* triggered post setup function will be launched before starting executor */
typedef ucc_status_t (*ucc_coll_triggered_post_setup_fn_t)(ucc_coll_task_t *task);

typedef ucc_status_t (*ucc_coll_triggered_post_fn_t)(ucc_ee_h ee,
ucc_ev_t *ev,
typedef ucc_status_t (*ucc_coll_triggered_post_fn_t)(ucc_ee_h ee, ucc_ev_t *ev,
ucc_coll_task_t *task);

typedef struct ucc_em_listener {
Expand All @@ -71,6 +70,8 @@ enum {
UCC_COLL_TASK_FLAG_EXECUTOR_STOP = UCC_BIT(3),
/* destroy executor in task complete */
UCC_COLL_TASK_FLAG_EXECUTOR_DESTROY = UCC_BIT(4),
/* if set task can be casted to scheulde */
UCC_COLL_TASK_FLAG_IS_SCHEDULE = UCC_BIT(5),
};

typedef struct ucc_coll_task {
Expand Down Expand Up @@ -146,7 +147,8 @@ ucc_status_t ucc_schedule_init(ucc_schedule_t *schedule,
ucc_base_coll_args_t *bargs,
ucc_base_team_t *team);

ucc_status_t ucc_schedule_add_task(ucc_schedule_t *schedule, ucc_coll_task_t *task);
ucc_status_t ucc_schedule_add_task(ucc_schedule_t *schedule,
ucc_coll_task_t *task);

ucc_status_t ucc_schedule_start(ucc_coll_task_t *task);

Expand Down
66 changes: 54 additions & 12 deletions src/utils/ucc_coll_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,26 +507,68 @@ void ucc_coll_args_str(const ucc_coll_args_t *args, ucc_rank_t trank,
}
}

void ucc_coll_task_components_str(const ucc_coll_task_t *task, char *str,
size_t *len)
{
ucc_schedule_t *schedule;
int i;

if (task->flags & UCC_COLL_TASK_FLAG_IS_SCHEDULE) {
schedule = ucc_derived_of(task, ucc_schedule_t);
for (i = 0; i < schedule->n_tasks; i++) {
ucc_coll_task_components_str(schedule->tasks[i], str, len);
}
} else {
if (!strstr(str, task->team->context->lib->log_component.name)) {
if (*len == 0) {
sprintf(str + *len, "%s",
task->team->context->lib->log_component.name);
*len = strlen(task->team->context->lib->log_component.name) +
*len;
} else {
sprintf(str + *len, ", %s",
task->team->context->lib->log_component.name);
*len = strlen(task->team->context->lib->log_component.name) +
*len + 2;
}
}
}
}

void ucc_coll_str(const ucc_coll_task_t *task, char *str, size_t len,
int verbosity)
{
ucc_team_t *team = task->bargs.team;

if (verbosity >= UCC_LOG_LEVEL_DIAG) {
ucc_coll_args_str(&task->bargs.args, team->rank, team->size, str, len);
}

if (verbosity >= UCC_LOG_LEVEL_INFO) {
char task_info[64];
size_t tl_info_len = 0;
char task_info[64], cl_info[16], tl_info[32];

if (task->team->context->lib->log_component.name[0] == 'C') {
/* it's not CL BASIC task */
strncpy(cl_info, task->team->context->lib->log_component.name, 16);
ucc_coll_task_components_str(task, tl_info, &tl_info_len);
} else {
strncpy(cl_info, "CL_BASIC", 16);
strncpy(tl_info , task->team->context->lib->log_component.name, 16);
}
ucc_coll_args_str(&task->bargs.args, team->rank, team->size, str, len);
ucc_snprintf_safe(task_info, sizeof(task_info), "; %s, team_id %d",
task->team->context->lib->log_component.name,
team->id);
ucc_snprintf_safe(task_info, sizeof(task_info), "; %s {%s}, team_id %d",
cl_info, tl_info, team->id);
strncat(str, task_info, len - strlen(str));
}
if (verbosity >= UCC_LOG_LEVEL_DEBUG) {
char task_info[64];
ucc_snprintf_safe(task_info, sizeof(task_info),
" rank %u, ctx_rank %u, seq_num %d, req %p",
team->rank,
ucc_ep_map_eval(team->ctx_map, team->rank),
task->seq_num, task);
strncat(str, task_info, len - strlen(str));
if (verbosity >= UCC_LOG_LEVEL_DEBUG) {
ucc_snprintf_safe(task_info, sizeof(task_info),
" rank %u, ctx_rank %u, seq_num %d, req %p",
team->rank,
ucc_ep_map_eval(team->ctx_map, team->rank),
task->seq_num, task);
strncat(str, task_info, len - strlen(str));
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/utils/ucc_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
#define ucc_trace_poll(_fmt, ...) \
ucc_log_component_global(UCS_LOG_LEVEL_TRACE_POLL, _fmt, ##__VA_ARGS__)

/* Collective trace logger */
#define ucc_log_component_collective_trace(_level, fmt, ...) \
ucc_log_component(_level, ucc_global_config.coll_trace, fmt, \
##__VA_ARGS__)

#define ucc_coll_trace_info(_fmt, ...) \
ucc_log_component_collective_trace(UCS_LOG_LEVEL_INFO, _fmt, ##__VA_ARGS__)
#define ucc_coll_trace_debug(_fmt, ...) \
ucc_log_component_collective_trace(UCS_LOG_LEVEL_DEBUG, _fmt, ##__VA_ARGS__)


static inline const char* ucc_coll_type_str(ucc_coll_type_t ct)
{
Expand Down

0 comments on commit 614c791

Please sign in to comment.