Skip to content

Commit ebb6dbf

Browse files
Valentin Hoyetbgoglin
authored andcommitted
utils: add support for --restrict nodeset=<nodeset>
This was already support in lstopo --allow Signed-off-by: Valentin Hoyet <[email protected]> Signed-off-by: Brice Goglin <[email protected]>
1 parent d01d10d commit ebb6dbf

File tree

10 files changed

+68
-20
lines changed

10 files changed

+68
-20
lines changed

utils/hwloc/hwloc-bind.1in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ both formats are always accepted.
130130
\fB\-\-restrict\fR <cpuset>
131131
Restrict the topology to the given cpuset.
132132
.TP
133+
\fB\-\-restrict\fR nodeset=<nodeset>
134+
Restrict the topology to the given nodeset, unless --restrict-flags specifies something different.
135+
.TP
133136
\fB\-\-disallowed\fR
134137
Include objects disallowed by administrative limitations.
135138
.TP

utils/hwloc/hwloc-bind.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright © 2009 CNRS
3-
* Copyright © 2009-2019 Inria. All rights reserved.
3+
* Copyright © 2009-2020 Inria. All rights reserved.
44
* Copyright © 2009-2010, 2012 Université Bordeaux
55
* Copyright © 2009-2018 Cisco Systems, Inc. All rights reserved.
66
* See COPYING in top-level directory.
@@ -51,7 +51,8 @@ void usage(const char *name, FILE *where)
5151
fprintf(where, " --taskset Use taskset-specific format when displaying cpuset strings\n");
5252
fprintf(where, "Input topology options:\n");
5353
fprintf(where, " --no-smt Only keep a single PU per core\n");
54-
fprintf(where, " --restrict <set> Restrict the topology to processors listed in <set>\n");
54+
fprintf(where, " --restrict [nodeset=]<bitmap>\n");
55+
fprintf(where, " Restrict the topology to some processors or NUMA nodes.\n");
5556
fprintf(where, " --disallowed Include objects disallowed by administrative limitations\n");
5657
fprintf(where, " --hbm Only consider high bandwidth memory nodes\n");
5758
fprintf(where, " --no-hbm Ignore high-bandwidth memory nodes\n");
@@ -74,6 +75,7 @@ int main(int argc, char *argv[])
7475
int use_nodeset = 0;
7576
int get_last_cpu_location = 0;
7677
unsigned long flags = 0;
78+
unsigned long restrict_flags = 0;
7779
int force = 0;
7880
int single = 0;
7981
int verbose = 0;
@@ -261,9 +263,14 @@ int main(int argc, char *argv[])
261263
exit(EXIT_FAILURE);
262264
}
263265
restrictset = hwloc_bitmap_alloc();
264-
hwloc_bitmap_sscanf(restrictset, argv[1]);
266+
if(strncmp(argv[1], "nodeset=", 8)) {
267+
hwloc_bitmap_sscanf(restrictset, argv[1]);
268+
} else {
269+
hwloc_bitmap_sscanf(restrictset, argv[1]+8);
270+
restrict_flags |= HWLOC_RESTRICT_FLAG_BYNODESET;
271+
}
265272
ENSURE_LOADED();
266-
err = hwloc_topology_restrict (topology, restrictset, 0);
273+
err = hwloc_topology_restrict (topology, restrictset, restrict_flags);
267274
if (err) {
268275
perror("Restricting the topology");
269276
/* FALLTHRU */

utils/hwloc/hwloc-calc.1in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ both formats are always accepted.
118118
\fB\-\-restrict\fR <cpuset>
119119
Restrict the topology to the given cpuset.
120120
.TP
121+
\fB\-\-restrict\fR nodeset=<nodeset>
122+
Restrict the topology to the given nodeset, unless --restrict-flags specifies something different.
123+
.TP
121124
\fB\-\-disallowed\fR
122125
Include objects disallowed by administrative limitations.
123126
.TP

utils/hwloc/hwloc-calc.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ void usage(const char *callname __hwloc_attribute_unused, FILE *where)
4747
fprintf(where, " --single Singlify the output to a single CPU\n");
4848
fprintf(where, "Input topology options:\n");
4949
fprintf(where, " --no-smt Only keep a single PU per core\n");
50-
fprintf(where, " --restrict <cpuset> Restrict the topology to processors listed in <cpuset>\n");
50+
fprintf(where, " --restrict [nodeset=]<bitmap>\n");
51+
fprintf(where, " Restrict the topology to some processors or NUMA nodes.\n");
5152
fprintf(where, " --disallowed Include objects disallowed by administrative limitations\n");
5253
hwloc_utils_input_format_usage(where, 10);
5354
fprintf(where, "Miscellaneous options:\n");
@@ -231,6 +232,7 @@ int main(int argc, char *argv[])
231232
hwloc_topology_t topology;
232233
int loaded = 0;
233234
unsigned long flags = 0;
235+
unsigned long restrict_flags = 0;
234236
char *input = NULL;
235237
enum hwloc_utils_input_format input_format = HWLOC_UTILS_INPUT_DEFAULT;
236238
int depth = 0;
@@ -317,9 +319,14 @@ int main(int argc, char *argv[])
317319
exit(EXIT_FAILURE);
318320
}
319321
restrictset = hwloc_bitmap_alloc();
320-
hwloc_bitmap_sscanf(restrictset, argv[1]);
322+
if(strncmp(argv[1], "nodeset=", 8)) {
323+
hwloc_bitmap_sscanf(restrictset, argv[1]);
324+
} else {
325+
hwloc_bitmap_sscanf(restrictset, argv[1]+8);
326+
restrict_flags |= HWLOC_RESTRICT_FLAG_BYNODESET;
327+
}
321328
ENSURE_LOADED();
322-
err = hwloc_topology_restrict (topology, restrictset, 0);
329+
err = hwloc_topology_restrict (topology, restrictset, restrict_flags);
323330
if (err) {
324331
perror("Restricting the topology");
325332
/* FALLTHRU */
@@ -519,7 +526,6 @@ int main(int argc, char *argv[])
519526
#define HWLOC_CALC_LINE_LEN 64
520527
size_t len = HWLOC_CALC_LINE_LEN;
521528
char * line = malloc(len);
522-
523529
while (1) {
524530
char *current, *tmpline;
525531

utils/hwloc/hwloc-distrib.1in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.\" -*- nroff -*-
2-
.\" Copyright © 2010-2018 Inria. All rights reserved.
2+
.\" Copyright © 2010-2020 Inria. All rights reserved.
33
.\" Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
44
.\" See COPYING in top-level directory.
55
.TH HWLOC-DISTRIB "1" "%HWLOC_DATE%" "%PACKAGE_VERSION%" "%PACKAGE_NAME%"
@@ -82,6 +82,9 @@ and singlify CPU sets by keeping the last bit (instead of the first bit).
8282
\fB\-\-restrict\fR <cpuset>
8383
Restrict the topology to the given cpuset.
8484
.TP
85+
\fB\-\-restrict\fR nodeset=<nodeset>
86+
Restrict the topology to the given nodeset, unless --restrict-flags specifies something different.
87+
.TP
8588
\fB\-\-disallowed\fR
8689
Include objects disallowed by administrative limitations.
8790
.TP

utils/hwloc/hwloc-distrib.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright © 2009 CNRS
3-
* Copyright © 2009-2019 Inria. All rights reserved.
3+
* Copyright © 2009-2020 Inria. All rights reserved.
44
* Copyright © 2009-2010 Université Bordeaux
55
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
66
* See COPYING in top-level directory.
@@ -24,7 +24,8 @@ void usage(const char *callname __hwloc_attribute_unused, FILE *where)
2424
fprintf(where, " --at <type> Distribute among objects of the given type\n");
2525
fprintf(where, " --reverse Distribute by starting from last objects\n");
2626
fprintf(where, "Input topology options:\n");
27-
fprintf(where, " --restrict <set> Restrict the topology to processors listed in <set>\n");
27+
fprintf(where, " --restrict [nodeset=]<bitmap>\n");
28+
fprintf(where, " Restrict the topology to some processors or NUMA nodes.\n");
2829
fprintf(where, " --disallowed Include objects disallowed by administrative limitations\n");
2930
hwloc_utils_input_format_usage(where, 0);
3031
fprintf(where, "Formatting options:\n");
@@ -48,6 +49,7 @@ int main(int argc, char *argv[])
4849
const char *from_type = NULL, *to_type = NULL;
4950
hwloc_topology_t topology;
5051
unsigned long flags = 0;
52+
unsigned long restrict_flags = 0;
5153
unsigned long dflags = 0;
5254
int opt;
5355
int err;
@@ -155,7 +157,12 @@ int main(int argc, char *argv[])
155157
usage (callname, stdout);
156158
exit(EXIT_FAILURE);
157159
}
158-
restrictstring = strdup(argv[1]);
160+
if(strncmp(argv[1], "nodeset=", 8)) {
161+
restrictstring = strdup(argv[1]);
162+
} else {
163+
restrictstring = strdup(argv[1]+8);
164+
restrict_flags |= HWLOC_RESTRICT_FLAG_BYNODESET;
165+
}
159166
argc--;
160167
argv++;
161168
goto next;
@@ -216,7 +223,7 @@ int main(int argc, char *argv[])
216223
if (restrictstring) {
217224
hwloc_bitmap_t restrictset = hwloc_bitmap_alloc();
218225
hwloc_bitmap_sscanf(restrictset, restrictstring);
219-
err = hwloc_topology_restrict (topology, restrictset, 0);
226+
err = hwloc_topology_restrict (topology, restrictset, restrict_flags);
220227
if (err) {
221228
perror("Restricting the topology");
222229
/* FALLTHRU */

utils/hwloc/hwloc-info.1in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.\" -*- nroff -*-
2-
.\" Copyright © 2009-2018 Inria. All rights reserved.
2+
.\" Copyright © 2009-2020 Inria. All rights reserved.
33
.\" Copyright © 2009-2010 Université of Bordeaux
44
.\" Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
55
.\" See COPYING in top-level directory.
@@ -104,6 +104,9 @@ Include objects disallowed by administrative limitations.
104104
\fB\-\-restrict\fR <cpuset>
105105
Restrict the topology to the given cpuset.
106106
.TP
107+
\fB\-\-restrict\fR nodeset=<nodeset>
108+
Restrict the topology to the given nodeset, unless --restrict-flags specifies something different.
109+
.TP
107110
\fB\-\-restrict\fR binding
108111
Restrict the topology to the current process binding.
109112
This option requires the use of the actual current machine topology

utils/hwloc/hwloc-info.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright © 2009 CNRS
3-
* Copyright © 2009-2019 Inria. All rights reserved.
3+
* Copyright © 2009-2020 Inria. All rights reserved.
44
* Copyright © 2009-2012 Université Bordeaux
55
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
66
* See COPYING in top-level directory.
@@ -44,7 +44,8 @@ void usage(const char *name, FILE *where)
4444
fprintf (where, " --descendants <type> Only display descendants of the given type\n");
4545
fprintf (where, " -n Prefix each line with the index of the considered object\n");
4646
fprintf (where, "Object filtering options:\n");
47-
fprintf (where, " --restrict <cpuset> Restrict the topology to processors listed in <cpuset>\n");
47+
fprintf (where, " --restrict [nodeset=]<bitmap>\n");
48+
fprintf (where, " Restrict the topology to some processors or NUMA nodes.\n");
4849
fprintf (where, " --restrict binding Restrict the topology to the current process binding\n");
4950
fprintf (where, " --filter <type>:<knd> Filter objects of the given type, or all.\n");
5051
fprintf (where, " <knd> may be `all' (keep all), `none' (remove all), `structure' or `important'\n");
@@ -339,6 +340,7 @@ main (int argc, char *argv[])
339340
hwloc_topology_t topology;
340341
int topodepth;
341342
unsigned long flags = 0;
343+
unsigned long restrict_flags = 0;
342344
char * callname;
343345
char * input = NULL;
344346
enum hwloc_utils_input_format input_format = HWLOC_UTILS_INPUT_DEFAULT;
@@ -484,7 +486,12 @@ main (int argc, char *argv[])
484486
usage (callname, stderr);
485487
exit(EXIT_FAILURE);
486488
}
487-
restrictstring = strdup(argv[1]);
489+
if(strncmp(argv[1], "nodeset=", 8)) {
490+
restrictstring = strdup(argv[1]);
491+
} else {
492+
restrictstring = strdup(argv[1]+8);
493+
restrict_flags |= HWLOC_RESTRICT_FLAG_BYNODESET;
494+
}
488495
opt = 1;
489496
}
490497

@@ -588,7 +595,7 @@ main (int argc, char *argv[])
588595
} else {
589596
hwloc_bitmap_sscanf(restrictset, restrictstring);
590597
}
591-
err = hwloc_topology_restrict (topology, restrictset, 0);
598+
err = hwloc_topology_restrict (topology, restrictset, restrict_flags);
592599
if (err) {
593600
perror("Restricting the topology");
594601
/* FALLTHRU */

utils/lstopo/lstopo-no-graphics.1in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ inside a single physical device) are collapsed.
203203
\fB\-\-restrict\fR <cpuset>
204204
Restrict the topology to the given cpuset.
205205
.TP
206+
\fB\-\-restrict\fR nodeset=<nodeset>
207+
Restrict the topology to the given nodeset, unless --restrict-flags specifies something different.
208+
.TP
206209
\fB\-\-restrict\fR binding
207210
Restrict the topology to the current process binding.
208211
This option requires the use of the actual current machine topology

utils/lstopo/lstopo.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ void usage(const char *name, FILE *where)
384384
fprintf (where, " --merge Do not show levels that do not have a hierarchical\n"
385385
" impact\n");
386386
fprintf (where, " --no-collapse Do not collapse identical PCI devices\n");
387-
fprintf (where, " --restrict <cpuset> Restrict the topology to processors listed in <cpuset>\n");
387+
fprintf (where, " --restrict [nodeset=]<bitmap>\n");
388+
fprintf (where, " Restrict the topology to some processors or NUMA nodes.\n");
388389
fprintf (where, " --restrict binding Restrict the topology to the current process binding\n");
389390
fprintf (where, " --restrict-flags <n> Set the flags to be used during restrict\n");
390391
fprintf (where, " --no-io Do not show any I/O device or bridge\n");
@@ -914,7 +915,12 @@ main (int argc, char *argv[])
914915
else if (!strcmp (argv[0], "--restrict")) {
915916
if (argc < 2)
916917
goto out_usagefailure;
917-
restrictstring = strdup(argv[1]);
918+
if(strncmp(argv[1], "nodeset=", 8)) {
919+
restrictstring = strdup(argv[1]);
920+
} else {
921+
restrictstring = strdup(argv[1]+8);
922+
restrict_flags |= HWLOC_RESTRICT_FLAG_BYNODESET;
923+
}
918924
opt = 1;
919925
}
920926
else if (!strcmp (argv[0], "--restrict-flags")) {

0 commit comments

Comments
 (0)