diff --git a/NEWS b/NEWS index c41135dea..21f0ee4ae 100644 --- a/NEWS +++ b/NEWS @@ -30,6 +30,8 @@ Version 2.11.0 + hwloc-info has a new --get-attr option to get a single attribute. + hwloc-info now supports "levels", "support" and "topology" special keywords for backward compatibility for hwloc 3.0. + + The --taskset command-line option is superseded by the new + --cpuset-output-format which also allows to export as list. Version 2.10.0 diff --git a/contrib/completion/bash/hwloc b/contrib/completion/bash/hwloc index 85dad037d..605fa1581 100644 --- a/contrib/completion/bash/hwloc +++ b/contrib/completion/bash/hwloc @@ -31,7 +31,7 @@ _lstopo() { --windows-processor-groups -c --cpuset -C --cpuset-only - --taskset + --cpuset-output-format --cof --filter --ignore --no-caches --no-useless-caches @@ -146,6 +146,9 @@ _lstopo() { --distances-transform) COMPREPLY=( `compgen -W "links merge-switch-ports transitive-closure" -- "$cur"` ) ;; + --cpuset-output-format | --cof) + COMPREPLY=( "hwloc" "list" taskset" ) + ;; esac fi } @@ -250,7 +253,7 @@ _hwloc_bind(){ --nodeset --pid --tid - --taskset + --cpuset-output-format --cof --restrict --restrict-flags --disallowed --whole-system @@ -288,6 +291,9 @@ _hwloc_bind(){ --best-memattr) COMPREPLY=( "" "" ) ;; + --cpuset-output-format | --cof) + COMPREPLY=( "hwloc" "list" taskset" ) + ;; esac fi } @@ -314,7 +320,7 @@ _hwloc_calc(){ --no --nodeset-output --oo --object-output --sep - --taskset + --cpuset-output-format --cof --single --restrict --restrict-flags @@ -365,6 +371,9 @@ _hwloc_calc(){ --cpukind) COMPREPLY=( "=" "" "" ) ;; + --cpuset-output-format | --cof) + COMPREPLY=( "hwloc" "list" taskset" ) + ;; esac fi } @@ -450,7 +459,7 @@ _hwloc_distrib(){ --input -i --input-format --if --single - --taskset + --cpuset-output-format --cof -v --verbose --version -h --help @@ -477,6 +486,9 @@ _hwloc_distrib(){ --restrict-flags) COMPREPLY=( "" "" ) ;; + --cpuset-output-format | --cof) + COMPREPLY=( "hwloc" "list" taskset" ) + ;; esac fi } diff --git a/doc/hwloc.doxy b/doc/hwloc.doxy index 0f77de883..c73d3112e 100644 --- a/doc/hwloc.doxy +++ b/doc/hwloc.doxy @@ -3050,8 +3050,9 @@ enabled for the current topology. See for instance hwloc_bitmap_taskset_snprintf() in \ref hwlocality_bitmap(). - Most hwloc command-line tools also support the \--taskset - option to manipulate taskset-specific strings. + Most hwloc command-line tools also support the option + \--cpuset-output-format taskset + to manipulate taskset-specific strings. diff --git a/utils/hwloc/hwloc-bind.1in b/utils/hwloc/hwloc-bind.1in index c8094d672..40becd748 100644 --- a/utils/hwloc/hwloc-bind.1in +++ b/utils/hwloc/hwloc-bind.1in @@ -213,11 +213,16 @@ This option does not apply to the output, see \fB\-\-get\fR above. Interpret input locations with logical indexes instead of physical/OS indexes (default). This option does not apply to the output, see \fB\-\-get\fR above. .TP -\fB\-\-taskset\fR -Display CPU set strings in the format recognized by the taskset command-line -program instead of hwloc-specific CPU set string format. +\fB\-\-cpuset\-output\-format\fR \fB\-\-cof\fR +Change the format of CPUset or nodeset strings displayed by \fB\-\-get\fR, \fB\-e\fR, etc. +By default, the hwloc-specific format is used. +If \fIlist\fR is given, the output is a comma-separated of numbers or ranges, +e.g. 2,4-5,8 . +If \fItaskset\fR is given, the output is compatible with the taskset program +(replaces the former \fB--taskset\fR option). + This option has no impact on the format of input CPU set strings, -both formats are always accepted. +both hwloc and taskset formats are always accepted. .TP \fB\-f\fR \fB\-\-force\fR Launch the executable even if binding failed. diff --git a/utils/hwloc/hwloc-bind.c b/utils/hwloc/hwloc-bind.c index df0c16596..edba278e0 100644 --- a/utils/hwloc/hwloc-bind.c +++ b/utils/hwloc/hwloc-bind.c @@ -58,7 +58,9 @@ void usage(const char *name, FILE *where) #ifdef HWLOC_LINUX_SYS fprintf(where, " --tid Operate on thread \n"); #endif - fprintf(where, " --taskset Use taskset-specific format when displaying cpuset strings\n"); + fprintf(where, " --cpuset-output-format \n" + " --cof \n" + " Change the format of cpuset outputs\n"); fprintf(where, "Miscellaneous options:\n"); fprintf(where, " -f --force Launch the command even if binding failed\n"); fprintf(where, " -q --quiet Hide non-fatal error messages\n"); @@ -85,7 +87,7 @@ int main(int argc, char *argv[]) int no_smt = -1; int only_hbm = -1; int logical = 1; - int taskset = 0; + enum hwloc_utils_cpuset_format_e cpuset_output_format = HWLOC_UTILS_CPUSET_FORMAT_HWLOC; unsigned cpubind_flags = 0; hwloc_membind_policy_t membind_policy = HWLOC_MEMBIND_BIND; int got_mempolicy = 0; @@ -270,8 +272,21 @@ int main(int argc, char *argv[]) logical = 0; goto next; } + if (!strcmp(argv[0], "--cpuset-output-format") || !strcmp(argv[0], "--cof")) { + if (argc < 2) { + usage (callname, stderr); + exit(EXIT_FAILURE); + } + cpuset_output_format = hwloc_utils_parse_cpuset_format(argv[1]); + if (HWLOC_UTILS_CPUSET_FORMAT_UNKNOWN == cpuset_output_format) { + fprintf(stderr, "Unrecognized %s argument %s\n", argv[0], argv[1]); + exit(EXIT_FAILURE); + } + opt = 1; + goto next; + } if (!strcmp(argv[0], "--taskset")) { - taskset = 1; + cpuset_output_format = HWLOC_UTILS_CPUSET_FORMAT_TASKSET; goto next; } if (!strcmp (argv[0], "-e") || !strncmp (argv[0], "--get-last-cpu-location", 10)) { @@ -417,16 +432,10 @@ int main(int argc, char *argv[]) if (use_nodeset) { hwloc_bitmap_t nset = hwloc_bitmap_alloc(); hwloc_cpuset_to_nodeset(topology, cpubind_set, nset); - if (taskset) - hwloc_bitmap_taskset_asprintf(&s, nset); - else - hwloc_bitmap_asprintf(&s, nset); + hwloc_utils_cpuset_format_asprintf(&s, nset, cpuset_output_format); hwloc_bitmap_free(nset); } else { - if (taskset) - hwloc_bitmap_taskset_asprintf(&s, cpubind_set); - else - hwloc_bitmap_asprintf(&s, cpubind_set); + hwloc_utils_cpuset_format_asprintf(&s, cpubind_set, cpuset_output_format); } } else { @@ -446,10 +455,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "hwloc_get_membind failed (errno %d %s)\n", errno, errmsg); return EXIT_FAILURE; } - if (taskset) - hwloc_bitmap_taskset_asprintf(&s, membind_set); - else - hwloc_bitmap_asprintf(&s, membind_set); + hwloc_utils_cpuset_format_asprintf(&s, membind_set, cpuset_output_format); switch (policy) { case HWLOC_MEMBIND_FIRSTTOUCH: policystr = "firsttouch"; break; case HWLOC_MEMBIND_BIND: policystr = "bind"; break; diff --git a/utils/hwloc/hwloc-calc.1in b/utils/hwloc/hwloc-calc.1in index 815d6865f..16d4de7d2 100644 --- a/utils/hwloc/hwloc-calc.1in +++ b/utils/hwloc/hwloc-calc.1in @@ -282,11 +282,16 @@ while a comma is used to separate indexes \fB\-\-single\fR Singlify the output to a single CPU. .TP -\fB\-\-taskset\fR -Display CPU set strings in the format recognized by the taskset command-line -program instead of hwloc-specific CPU set string format. +\fB\-\-cpuset\-output\-format\fR \fB\-\-cof\fR +Change the format of displayed CPU set strings. +By default, the hwloc-specific format is used. +If \fIlist\fR is given, the output is a comma-separated of numbers or ranges, +e.g. 2,4-5,8 . +If \fItaskset\fR is given, the output is compatible with the taskset program +(replaces the former \fB--taskset\fR option). + This option has no impact on the format of input CPU set strings, -both formats are always accepted. +both hwloc and taskset formats are always accepted. .TP \fB\-q\fR \fB\-\-quiet\fR Hide non-fatal error messages. diff --git a/utils/hwloc/hwloc-calc.c b/utils/hwloc/hwloc-calc.c index c5a2c46e7..d6012e3f1 100644 --- a/utils/hwloc/hwloc-calc.c +++ b/utils/hwloc/hwloc-calc.c @@ -57,7 +57,9 @@ void usage(const char *callname __hwloc_attribute_unused, FILE *where) fprintf(where, " --no --nodeset-output Manipulate nodesets instead of cpusets for outputs\n"); fprintf(where, " --oo --object-output Report objects instead of object indexes\n"); fprintf(where, " --sep Use separator in the output\n"); - fprintf(where, " --taskset Use taskset-specific format when displaying cpuset strings\n"); + fprintf(where, " --cpuset-output-format \n" + " --cof \n" + " Change the format of cpuset outputs\n"); fprintf(where, " --single Singlify the output to a single CPU\n"); fprintf(where, "Miscellaneous options:\n"); fprintf(where, " -q --quiet Hide non-fatal error messages\n"); @@ -83,7 +85,7 @@ static unsigned long best_node_flags = 0; static int showobjs = 0; static int no_smt = -1; static int singlify = 0; -static int taskset = 0; +static enum hwloc_utils_cpuset_format_e cpuset_output_format = HWLOC_UTILS_CPUSET_FORMAT_HWLOC; static hwloc_bitmap_t cpukind_cpuset = NULL; static int @@ -276,10 +278,7 @@ hwloc_calc_output(hwloc_topology_t topology, const char *sep, hwloc_bitmap_t set } else { char *string = NULL; - if (taskset) - hwloc_bitmap_taskset_asprintf(&string, set); - else - hwloc_bitmap_asprintf(&string, set); + hwloc_utils_cpuset_format_asprintf(&string, set, cpuset_output_format); printf("%s\n", string); free(string); } @@ -603,10 +602,23 @@ int main(int argc, char *argv[]) singlify = 1; goto next; } - if (!strcmp(argv[0], "--taskset")) { - taskset = 1; + if (!strcmp(argv[0], "--cpuset-output-format") || !strcmp(argv[0], "--cof")) { + if (argc < 2) { + usage (callname, stderr); + exit(EXIT_FAILURE); + } + cpuset_output_format = hwloc_utils_parse_cpuset_format(argv[1]); + if (HWLOC_UTILS_CPUSET_FORMAT_UNKNOWN == cpuset_output_format) { + fprintf(stderr, "Unrecognized %s argument %s\n", argv[0], argv[1]); + exit(EXIT_FAILURE); + } + opt = 1; goto next; } + if (!strcmp(argv[0], "--taskset")) { + cpuset_output_format = HWLOC_UTILS_CPUSET_FORMAT_TASKSET; + goto next; + } fprintf (stderr, "Unrecognized option: %s\n", argv[0]); usage(callname, stderr); diff --git a/utils/hwloc/hwloc-distrib.1in b/utils/hwloc/hwloc-distrib.1in index adad97e94..5c3709aa2 100644 --- a/utils/hwloc/hwloc-distrib.1in +++ b/utils/hwloc/hwloc-distrib.1in @@ -21,9 +21,13 @@ hwloc-distrib \- Build a number of cpu masks distributed on the system \fB\-\-single\fR Singlify each output to a single CPU. .TP -\fB\-\-taskset\fR -Show CPU set strings in the format recognized by the taskset command-line -program instead of hwloc-specific CPU set string format. +\fB\-\-cpuset\-output\-format\fR \fB\-\-cof\fR +Change the format of displayed CPU set strings. +By default, the hwloc-specific format is used. +If \fIlist\fR is given, the output is a comma-separated of numbers or ranges, +e.g. 2,4-5,8 . +If \fItaskset\fR is given, the output is compatible with the taskset program +(replaces the former \fB--taskset\fR option). .TP \fB\-v\fR \fB\-\-verbose\fR Verbose messages. diff --git a/utils/hwloc/hwloc-distrib.c b/utils/hwloc/hwloc-distrib.c index 386c3b02c..10b6ec27a 100644 --- a/utils/hwloc/hwloc-distrib.c +++ b/utils/hwloc/hwloc-distrib.c @@ -1,6 +1,6 @@ /* * Copyright © 2009 CNRS - * Copyright © 2009-2021 Inria. All rights reserved. + * Copyright © 2009-2024 Inria. All rights reserved. * Copyright © 2009-2010 Université Bordeaux * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved. * Copyright © 2023 Université de Reims Champagne-Ardenne. All rights reserved. @@ -33,6 +33,9 @@ void usage(const char *callname __hwloc_attribute_unused, FILE *where) fprintf(where, "Formatting options:\n"); fprintf(where, " --single Singlify each output to a single CPU\n"); fprintf(where, " --taskset Show taskset-specific cpuset strings\n"); + fprintf(where, " --cpuset-output-format \n" + " --cof \n" + " Change the format of cpuset outputs\n"); fprintf(where, "Miscellaneous options:\n"); fprintf(where, " -v --verbose Show verbose messages\n"); fprintf(where, " --version Report version and exit\n"); @@ -45,7 +48,7 @@ int main(int argc, char *argv[]) char *callname; char *input = NULL; struct hwloc_utils_input_format_s input_format = HWLOC_UTILS_INPUT_FORMAT_DEFAULT; - int taskset = 0; + enum hwloc_utils_cpuset_format_e cpuset_output_format = HWLOC_UTILS_CPUSET_FORMAT_HWLOC; int singlify = 0; int verbose = 0; char *restrictstring = NULL; @@ -91,8 +94,21 @@ int main(int argc, char *argv[]) singlify = 1; goto next; } + if (!strcmp(argv[0], "--cpuset-output-format") || !strcmp(argv[0], "--cof")) { + if (argc < 2) { + usage (callname, stderr); + exit(EXIT_FAILURE); + } + cpuset_output_format = hwloc_utils_parse_cpuset_format(argv[1]); + if (HWLOC_UTILS_CPUSET_FORMAT_UNKNOWN == cpuset_output_format) { + fprintf(stderr, "Unrecognized %s argument %s\n", argv[0], argv[1]); + exit(EXIT_FAILURE); + } + opt = 1; + goto next; + } if (!strcmp(argv[0], "--taskset")) { - taskset = 1; + cpuset_output_format = HWLOC_UTILS_CPUSET_FORMAT_TASKSET; goto next; } if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "--verbose")) { @@ -286,10 +302,7 @@ int main(int argc, char *argv[]) hwloc_bitmap_singlify(cpuset[i]); } } - if (taskset) - hwloc_bitmap_taskset_asprintf(&str, cpuset[i]); - else - hwloc_bitmap_asprintf(&str, cpuset[i]); + hwloc_utils_cpuset_format_asprintf(&str, cpuset[i], cpuset_output_format); printf("%s\n", str); free(str); hwloc_bitmap_free(cpuset[i]); diff --git a/utils/hwloc/misc.h b/utils/hwloc/misc.h index a80c3b7a5..534538624 100644 --- a/utils/hwloc/misc.h +++ b/utils/hwloc/misc.h @@ -965,6 +965,38 @@ hwloc_utils_get_best_node_in_array_by_memattr(hwloc_topology_t topology, hwloc_m return -1; } +enum hwloc_utils_cpuset_format_e { + HWLOC_UTILS_CPUSET_FORMAT_UNKNOWN, + HWLOC_UTILS_CPUSET_FORMAT_HWLOC, + HWLOC_UTILS_CPUSET_FORMAT_TASKSET, + HWLOC_UTILS_CPUSET_FORMAT_LIST +}; + +static __hwloc_inline enum hwloc_utils_cpuset_format_e +hwloc_utils_parse_cpuset_format(const char *string) +{ + if (!strcmp(string, "hwloc")) + return HWLOC_UTILS_CPUSET_FORMAT_HWLOC; + else if (!strcmp(string, "list")) + return HWLOC_UTILS_CPUSET_FORMAT_LIST; + else if (!strcmp(string, "taskset")) + return HWLOC_UTILS_CPUSET_FORMAT_TASKSET; + else + return HWLOC_UTILS_CPUSET_FORMAT_UNKNOWN; +} + +static __hwloc_inline int +hwloc_utils_cpuset_format_asprintf(char **string, hwloc_const_bitmap_t set, + enum hwloc_utils_cpuset_format_e cpuset_output_format) +{ + switch (cpuset_output_format) { + case HWLOC_UTILS_CPUSET_FORMAT_HWLOC: return hwloc_bitmap_asprintf(string, set); + case HWLOC_UTILS_CPUSET_FORMAT_TASKSET: return hwloc_bitmap_taskset_asprintf(string, set); + case HWLOC_UTILS_CPUSET_FORMAT_LIST: return hwloc_bitmap_list_asprintf(string, set); + default: abort(); + } +} + static __hwloc_inline unsigned long hwloc_utils_parse_restrict_flags(char * str){ struct hwloc_utils_parsing_flag possible_flags[] = { diff --git a/utils/hwloc/test-hwloc-calc.output b/utils/hwloc/test-hwloc-calc.output index 385869dc9..4f4f88432 100644 --- a/utils/hwloc/test-hwloc-calc.output +++ b/utils/hwloc/test-hwloc-calc.output @@ -1,7 +1,10 @@ -# root +# root --cpuset-output-format hwloc 0xffffffff,0xffffffff -# all --taskset +# all --cof list +0-63 + +# all --cpuset-output-format taskset 0xffffffffffffffff # hex diff --git a/utils/hwloc/test-hwloc-calc.sh.in b/utils/hwloc/test-hwloc-calc.sh.in index d79fb8bba..a1ccce60a 100644 --- a/utils/hwloc/test-hwloc-calc.sh.in +++ b/utils/hwloc/test-hwloc-calc.sh.in @@ -37,11 +37,14 @@ file="$tmp/test-hwloc-calc.output" set -e ( - echo "# root" - $calc --if synthetic --input "node:4 core:4 pu:4" root + echo "# root --cpuset-output-format hwloc" + $calc --if synthetic --input "node:4 core:4 pu:4" root --cpuset-output-format hwloc echo - echo "# all --taskset" - $calc --if synthetic --input "node:4 core:4 pu:4" all --taskset + echo "# all --cof list" + $calc --if synthetic --input "node:4 core:4 pu:4" all --cof list + echo + echo "# all --cpuset-output-format taskset" + $calc --if synthetic --input "node:4 core:4 pu:4" all --cpuset-output-format taskset echo echo "# hex" @@ -296,7 +299,7 @@ EOF EOF echo echo "# Reading infinite cpusets from stdin and exporting to taskset" - cat << EOF | $calc --if synthetic --input "node:4 core:4 pu:4" --taskset + cat << EOF | $calc --if synthetic --input "node:4 core:4 pu:4" --cpuset-output-format taskset 0xf...f 0xf...f,abcd00 0xf...f,abcd,ef00 diff --git a/utils/hwloc/test-hwloc-distrib.output b/utils/hwloc/test-hwloc-distrib.output index c064942c0..b2dcd3f99 100644 --- a/utils/hwloc/test-hwloc-distrib.output +++ b/utils/hwloc/test-hwloc-distrib.output @@ -2,11 +2,11 @@ 0x0000000f 0x000000f0 -# 4 sets out of 2 2 2 -0x00000003 -0x0000000c -0x00000030 -0x000000c0 +# 4 sets out of 2 2 2, as lists +0-1 +2-3 +4-5 +6-7 # 8 sets out of 2 2 2 0x00000001 diff --git a/utils/hwloc/test-hwloc-distrib.sh.in b/utils/hwloc/test-hwloc-distrib.sh.in index a42a17464..b343d3974 100644 --- a/utils/hwloc/test-hwloc-distrib.sh.in +++ b/utils/hwloc/test-hwloc-distrib.sh.in @@ -3,7 +3,7 @@ # # Copyright © 2009 CNRS -# Copyright © 2009-2020 Inria. All rights reserved. +# Copyright © 2009-2024 Inria. All rights reserved. # Copyright © 2009 Université Bordeaux # Copyright © 2014 Cisco Systems, Inc. All rights reserved. # See COPYING in top-level directory. @@ -38,8 +38,8 @@ set -e echo "# 2 sets out of 2 2 2" $distrib --if synthetic --input "2 2 2" 2 echo - echo "# 4 sets out of 2 2 2" - $distrib --if synthetic --input "2 2 2" 4 + echo "# 4 sets out of 2 2 2, as lists" + $distrib --if synthetic --input "2 2 2" --cof list 4 echo echo "# 8 sets out of 2 2 2" $distrib --if synthetic --input "2 2 2" 8 diff --git a/utils/lstopo/lstopo-no-graphics.1in b/utils/lstopo/lstopo-no-graphics.1in index edde1f977..e4a563fcd 100644 --- a/utils/lstopo/lstopo-no-graphics.1in +++ b/utils/lstopo/lstopo-no-graphics.1in @@ -1,5 +1,5 @@ .\" -*- nroff -*- -.\" Copyright © 2009-2023 Inria. All rights reserved. +.\" Copyright © 2009-2024 Inria. All rights reserved. .\" Copyright © 2009-2010 Université of Bordeaux .\" Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved. .\" Copyright © 2020 Hewlett Packard Enterprise. All rights reserved. @@ -141,9 +141,14 @@ Display the cpuset of each object. Only display the cpuset of each object; do not display anything else about the object. .TP -\fB\-\-taskset\fR -Show CPU set strings in the format recognized by the taskset command-line -program instead of hwloc-specific CPU set string format. +\fB\-\-cpuset\-output\-format\fR \fB\-\-cof\fR +Change the format of displayed CPU set strings. +By default, the hwloc-specific format is used. +If \fIlist\fR is given, the output is a comma-separated of numbers or ranges, +e.g. 2,4-5,8 . +If \fItaskset\fR is given, output cpusets are compatible with the taskset program +(replaces the former \fB--taskset\fR option). + This option should be combined with \fB\-\-cpuset\fR or \fB\-\-cpuset\-only\fR, otherwise it will imply \fB\-\-cpuset\fR. .TP diff --git a/utils/lstopo/lstopo-text.c b/utils/lstopo/lstopo-text.c index acd7ec930..dc22fa051 100644 --- a/utils/lstopo/lstopo-text.c +++ b/utils/lstopo/lstopo-text.c @@ -1,6 +1,6 @@ /* * Copyright © 2009 CNRS - * Copyright © 2009-2022 Inria. All rights reserved. + * Copyright © 2009-2024 Inria. All rights reserved. * Copyright © 2009-2012 Université Bordeaux * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved. * See COPYING in top-level directory. @@ -116,10 +116,7 @@ output_console_obj (struct lstopo_output *loutput, hwloc_obj_t l, int collapse) fprintf(output, " cpuset="); if (loutput->show_cpuset) { char *cpusetstr; - if (loutput->show_taskset) - hwloc_bitmap_taskset_asprintf(&cpusetstr, l->cpuset); - else - hwloc_bitmap_asprintf(&cpusetstr, l->cpuset); + hwloc_utils_cpuset_format_asprintf(&cpusetstr, l->cpuset, loutput->cpuset_output_format); fprintf(output, "%s", cpusetstr); free(cpusetstr); } diff --git a/utils/lstopo/lstopo.c b/utils/lstopo/lstopo.c index 32bae61ab..136d5c992 100644 --- a/utils/lstopo/lstopo.c +++ b/utils/lstopo/lstopo.c @@ -1,6 +1,6 @@ /* * Copyright © 2009 CNRS - * Copyright © 2009-2023 Inria. All rights reserved. + * Copyright © 2009-2024 Inria. All rights reserved. * Copyright © 2009-2012, 2015, 2017 Université Bordeaux * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved. * Copyright © 2020 Hewlett Packard Enterprise. All rights reserved. @@ -573,7 +573,9 @@ void usage(const char *name, FILE *where) #endif fprintf (where, " -c --cpuset Show the cpuset of each object\n"); fprintf (where, " -C --cpuset-only Only show the cpuset of each object\n"); - fprintf (where, " --taskset Show taskset-specific cpuset strings\n"); + fprintf (where, " --cpuset-output-format \n" + " --cof \n" + " Change the format of cpuset outputs\n"); fprintf (where, "Object filtering options:\n"); fprintf (where, " --filter : Filter objects of the given type, or all.\n"); fprintf (where, " may be `all' (keep all), `none' (remove all), `structure' or `important'\n"); @@ -952,7 +954,7 @@ main (int argc, char *argv[]) loutput.show_cpukinds_only = 0; loutput.show_windows_processor_groups_only = 0; loutput.show_cpuset = 0; - loutput.show_taskset = 0; + loutput.cpuset_output_format = HWLOC_UTILS_CPUSET_FORMAT_HWLOC; loutput.transform_distances = -1; loutput.nr_cpukind_styles = 0; @@ -1063,8 +1065,22 @@ main (int argc, char *argv[]) loutput.show_cpuset = 1; else if (!strcmp (argv[0], "-C") || !strcmp (argv[0], "--cpuset-only")) loutput.show_cpuset = 2; + else if (!strcmp(argv[0], "--cpuset-output-format") || !strcmp(argv[0], "--cof")) { + if (argc < 2) { + usage (callname, stderr); + exit(EXIT_FAILURE); + } + loutput.cpuset_output_format = hwloc_utils_parse_cpuset_format(argv[1]); + if (HWLOC_UTILS_CPUSET_FORMAT_UNKNOWN == loutput.cpuset_output_format) { + fprintf(stderr, "Unrecognized %s argument %s\n", argv[0], argv[1]); + goto out_usagefailure; + } + if (!loutput.show_cpuset) + loutput.show_cpuset = 1; + opt = 1; + } else if (!strcmp (argv[0], "--taskset")) { - loutput.show_taskset = 1; + loutput.cpuset_output_format = HWLOC_UTILS_CPUSET_FORMAT_TASKSET; if (!loutput.show_cpuset) loutput.show_cpuset = 1; } else if (!strcmp (argv[0], "--only")) { diff --git a/utils/lstopo/lstopo.h b/utils/lstopo/lstopo.h index ba9e38b37..dd9758223 100644 --- a/utils/lstopo/lstopo.h +++ b/utils/lstopo/lstopo.h @@ -1,6 +1,6 @@ /* * Copyright © 2009 CNRS - * Copyright © 2009-2023 Inria. All rights reserved. + * Copyright © 2009-2024 Inria. All rights reserved. * Copyright © 2009-2010, 2012, 2015 Université Bordeaux * Copyright © 2011 Cisco Systems, Inc. All rights reserved. * Copyright © 2020 Hewlett Packard Enterprise. All rights reserved. @@ -103,7 +103,7 @@ struct lstopo_output { int show_windows_processor_groups_only; struct hwloc_calc_level show_only; int show_cpuset; - int show_taskset; + enum hwloc_utils_cpuset_format_e cpuset_output_format; int transform_distances; /* draw config */ diff --git a/utils/lstopo/test-lstopo.sh.in b/utils/lstopo/test-lstopo.sh.in index 637310be7..251f01d87 100644 --- a/utils/lstopo/test-lstopo.sh.in +++ b/utils/lstopo/test-lstopo.sh.in @@ -3,7 +3,7 @@ # # Copyright © 2009 CNRS -# Copyright © 2009-2022 Inria. All rights reserved. +# Copyright © 2009-2024 Inria. All rights reserved. # Copyright © 2009, 2011 Université Bordeaux # Copyright © 2020 Hewlett Packard Enterprise. All rights reserved. # See COPYING in top-level directory. @@ -51,7 +51,7 @@ $ls -v > $tmp/test.console_verbose echo "** Verbose with cpusets in $tmp/test.cpuset_verbose ..." $ls -c -v > $tmp/test.cpuset_verbose echo "** Verbose with taskset sets in $tmp/test.taskset ..." -$ls --taskset -v > $tmp/test.taskset +$ls --cpuset-output-format taskset -v > $tmp/test.taskset echo "** Merged topology in $tmp/test.merge ..." $ls --merge > $tmp/test.merge