Skip to content

Commit

Permalink
utils/bind: accept input locations as nodeset=0xfff
Browse files Browse the repository at this point in the history
Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Sep 21, 2020
1 parent c978f9a commit 3c9cf6b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions utils/hwloc/hwloc-bind.1in
Expand Up @@ -117,6 +117,10 @@ cpuset is empty while their nodeset is correct.
.TP
\
Also parse input bitmasks as nodesets instead of cpusets.
.TP
\
When this option is not passed, individual input bitmasks may
still be parsed as nodesets if they are prefixed with \fInodeset=\fR.

.TP
\fB\-e\fR \fB\-\-get-last-cpu-location\fR
Expand Down Expand Up @@ -199,6 +203,10 @@ Upon successful execution, hwloc-bind simply sets bindings and then execs
the executable over itself.
.
.PP
If a bitmask location is given with prefix \fInodeset=\fR, then it
is considered a nodeset instead of a CPU set. See also \fB\-\-nodeset\fR.
.
.PP
If multiple locations are given, they are combined in the sense that
the binding will be wider. The process will be allowed to run on every
location inside the combination.
Expand Down
14 changes: 12 additions & 2 deletions utils/hwloc/hwloc-bind.c
Expand Up @@ -193,6 +193,9 @@ int main(int argc, char *argv[])
depth = hwloc_topology_get_depth(topology);

while (argc >= 1) {
char *location;
int nodeset_location;

if (!strcmp(argv[0], "--")) {
argc--;
argv++;
Expand Down Expand Up @@ -309,15 +312,22 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}

location = argv[0];
nodeset_location = 0;
if (!strncmp(location, "nodeset=", 8)) {
location += 8;
nodeset_location = 1;
}

lcontext.topology = topology;
lcontext.topodepth = depth;
lcontext.only_hbm = only_hbm;
lcontext.logical = logical;
lcontext.verbose = verbose;
scontext.nodeset_input = use_nodeset;
scontext.nodeset_input = use_nodeset || nodeset_location;
scontext.nodeset_output = working_on_cpubind ? 0 : 1;
scontext.output_set = working_on_cpubind ? cpubind_set : membind_set;
ret = hwloc_calc_process_location_as_set(&lcontext, &scontext, argv[0]);
ret = hwloc_calc_process_location_as_set(&lcontext, &scontext, location);
if (ret < 0) {
if (verbose > 0)
fprintf(stderr, "assuming the command starts at %s\n", argv[0]);
Expand Down

0 comments on commit 3c9cf6b

Please sign in to comment.