Skip to content

Commit

Permalink
lstopo/x11+windows: add shortcuts for dumping cli options for the cur…
Browse files Browse the repository at this point in the history
…rent tweaks

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Aug 29, 2018
1 parent 274519b commit f866d85
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -32,6 +32,7 @@ Version 2.1.0
- The X11 interactive output has additional keyboard shortcuts to
dynamically change the displaying of indexes, attributes and text.
- Add --linespacing and change default margins and linespacing.
- Add keyboard shortcuts to tweak the graphical output interactively.
+ Add --nodeset options to hwloc-calc for converting between cpusets and
nodesets.
+ hwloc-annotate may annotate multiple locations at once.
Expand Down
7 changes: 6 additions & 1 deletion utils/lstopo/lstopo-cairo.c
Expand Up @@ -339,11 +339,13 @@ output_x11(struct lstopo_output *loutput, const char *dummy __hwloc_attribute_un
printf(" Scroll horizontally ................. Left Right Ctrl+PageUp/Down\n");
printf(" Scroll to the top-left corner ....... Home\n");
printf(" Scroll to the bottom-right corner ... End\n");
printf(" Exit ................................ q Q Esc\n");
printf("Configuration tweaks:\n");
printf(" Toggle color for disallowed objects . d\n");
printf(" Toggle color for binding objects .... b\n");
printf(" Show/Hide Attributes/Indexes/Text ... A/I/T\n");
printf(" Show Physical/Logical/Both indexes .. P/L/B\n");
printf(" Exit ................................ q Q Esc\n");
printf(" Command-line options for tweaks ..... c\n");
printf("\n\n");

/* ready */
Expand Down Expand Up @@ -536,6 +538,9 @@ output_x11(struct lstopo_output *loutput, const char *dummy __hwloc_attribute_un
disp->needs_redraw = 1;
move_x11(disp);
break;
case XK_c:
lstopo_show_interactive_cli_options(loutput);
break;
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion utils/lstopo/lstopo-windows.c
Expand Up @@ -112,6 +112,9 @@ WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
loutput->show_binding ^= 1;
redraw = 1;
break;
case 'c':
lstopo_show_interactive_cli_options(loutput);
break;
case 'q':
case 'Q':
finish = 1;
Expand Down Expand Up @@ -402,11 +405,13 @@ output_windows (struct lstopo_output *loutput, const char *dummy __hwloc_attribu
printf(" Scroll horizontally ................. Left Right Ctrl+PageUp/Down\n");
printf(" Scroll to the top-left corner ....... Home\n");
printf(" Scroll to the bottom-right corner ... End\n");
printf(" Exit ................................ q Q Esc\n");
printf("Configuration tweaks:\n");
printf(" Toggle color for disallowed objects . d\n");
printf(" Toggle color for binding objects .... b\n");
printf(" Show/Hide Attributes/Indexes/Text ... A/I/T\n");
printf(" Show Physical/Logical/Both indexes .. P/L/B\n");
printf(" Exit ................................ q Q Esc\n");
printf(" Command-line options for tweaks ..... c\n");
printf("\n\n");

/* ready */
Expand Down
45 changes: 45 additions & 0 deletions utils/lstopo/lstopo.c
Expand Up @@ -528,6 +528,51 @@ void usage(const char *name, FILE *where)
fprintf (where, " --version Report version and exit\n");
}

static void lstopo_show_interactive_cli_options_array(const int *array, const char *name)
{
int enabled = 0, disabled = 0, i;
for(i=HWLOC_OBJ_TYPE_MIN; i<HWLOC_OBJ_TYPE_MAX; i++) {
if (array[i])
enabled++;
else
disabled++;
}
if (!enabled)
printf(" --no-%s", name);
else if (!disabled)
printf(" --%s", name);
else {
printf(" --%s --no-%s=", name, name);
for(i=HWLOC_OBJ_TYPE_MIN; i<HWLOC_OBJ_TYPE_MAX; i++) {
if (!array[i]) {
printf("%s%s", hwloc_obj_type_string(i), disabled > 1 ? "," : "");
disabled--;
}
}
}
}

void lstopo_show_interactive_cli_options(const struct lstopo_output *loutput)
{
printf("Command-line options for the current configuration tweaks:\n");

if (loutput->index_type == LSTOPO_INDEX_TYPE_PHYSICAL)
printf(" -p");
else if (loutput->index_type == LSTOPO_INDEX_TYPE_LOGICAL)
printf(" -l");

lstopo_show_interactive_cli_options_array(loutput->show_indexes, "index");
lstopo_show_interactive_cli_options_array(loutput->show_attrs, "attrs");
lstopo_show_interactive_cli_options_array(loutput->show_text, "text");

if (!loutput->show_binding)
printf(" --binding-color=none");
if (!loutput->show_disallowed)
printf(" --disallowed-color=none");

printf("\n\n");
}

enum output_format {
LSTOPO_OUTPUT_DEFAULT,
LSTOPO_OUTPUT_CONSOLE,
Expand Down
2 changes: 2 additions & 0 deletions utils/lstopo/lstopo.h
Expand Up @@ -261,4 +261,6 @@ static __hwloc_inline int lstopo_busid_snprintf(char *text, size_t textlen, hwlo
lastobj->attr->pcidev.func);
}

extern void lstopo_show_interactive_cli_options(const struct lstopo_output *loutput);

#endif /* UTILS_LSTOPO_H */

0 comments on commit f866d85

Please sign in to comment.