HWLOC-DISTRIB(1) | hwloc | HWLOC-DISTRIB(1) |
hwloc-distrib - Build a number of cpu masks distributed on the system
hwloc-distrib [options] <integer>
hwloc-distrib generates a series of CPU masks corresponding to a distribution of a given number of elements over the topology of the machine. The distribution is done recursively from the top of the hierarchy (or from the level specified by option --from) down to the bottom of the hierarchy (or down to the level specified by option --to, or until only one element remains), splitting the number of elements at each encountered hierarchy level not ignored by options --ignore.
This can e.g. be used to distribute a set of processes hierarchically according to the topology of a machine. These masks can be used with hwloc-bind(1).
NOTE: It is highly recommended that you read the hwloc(7) overview page before reading this man page. Most of the concepts described in hwloc(7) directly apply to the hwloc-bind utility.
hwloc-distrib's operation is best described through several examples.
If 4 processes have to be distributed across a machine, their CPU masks may be obtained with:
$ hwloc-distrib 4
0x0000000f
0x00000f00
0x000000f0
0x0000f000
To distribute only among the second package, the topology should be restricted:
$ hwloc-distrib --restrict $(hwloc-calc package:1) 4
0x00000010
0x00000020
0x00000040
0x00000080
To get a single processor of each CPU masks (prevent migration in case of binding)
$ hwloc-distrib 4 --single
0x00000001
0x00000100
0x00000010
0x00001000
Each output line may be converted independently with hwloc-calc:
$ hwloc-distrib 4 --single | hwloc-calc --taskset
0x1
0x100
0x10
0x1000
To convert the output into a list of processors that may be passed to dplace -c inside a mpirun command line:
$ hwloc-distrib 4 --single | xargs hwloc-calc --pulist
0,8,4,16
Upon successful execution, hwloc-distrib displays one or more CPU mask strings. The return value is 0.
hwloc-distrib will return nonzero if any kind of error occurs, such as (but not limited to) failure to parse the command line.
December 13, 2018 | 1.11.12 |