DESCRIPTIONhwloc provides command line tools and a C API to obtain the hierarchical map of key computing elements, such as: NUMA memory nodes, shared caches, processor sockets, processor cores, and processor "threads". hwloc also gathers various attributes such as cache and memory information, and is portable across a variety of different operating systems and platforms.
DefinitionsHwloc has some specific definitions for terms that are used in this man page and other hwloc documentation.
- Hwloc CPU set:
- A set of processors included in an hwloc object, expressed as a bitmask indexed by the physical numbers of the CPUs (as announced by the OS). The hwloc definition of "CPU set" does not carry any the same connotations as Linux's "CPU set" (e.g., process affinity, etc.).
- Linux CPU set:
- See http://www.mjmwired.net/kernel/Documentation/cpusets.txt for a discussion of Linux CPU sets. A super-short-ignoring-many-details description (taken from that page) is:
"Cpusets provide a mechanism for assigning a set of CPUs and Memory Nodes to a set of tasks."
- Linux Cgroup:
- See http://www.mjmwired.net/kernel/Documentation/cgroups.txt for a discussion of Linux control groups. A super-short-ignoring-many-details description (taken from that page) is:
"Control Groups provide a mechanism for aggregating/partitioning sets of tasks, and all their future children, into hierarchical groups with specialized behaviour."
To be clear, hwloc supports all of the above concepts. It is simply worth noting that they are 3 different things.
Location SpecificationLocations refer to specific regions within a topology. Before reading the rest of this man page, it may be useful to read lstopo(1) and/or run lstopo on your machine to see the reported topology tree. Seeing and understanding a topology tree will definitely help in understanding the concepts that are discussed below.
Locations can be specified in multiple ways:
- Tuples of hwloc "objects" and associated indexes can be specified in the form object:index. Hwloc objects represent types of mapped items (e.g., sockets, cores, etc.) in a topology tree; indexes are non-negative integers that specify a unique physical object in a topology tree. Both concepts are described in detail, below.
- Chaining multiple tuples together in the more general form object1:index[.object2:index2[...]] is permissable. While the first tuple's object may appear anywhere in the topology, the Nth tuple's object must have a shallower topology depth than the (N+1)th tuple's object. Put simply: as you move right in a tuple chain, objects must go deeper in the topology tree. When using logical indexes (default), indexes specified in chained tuples are relative to the scope of the parent object. For example, "socket:0.core:1" refers to the second core in the first socket. When using OS/physical indexes, the first object matching the given index is used.
- Locations can also be specified as hexidecimal bitmasks prefixed with "0x". Commas must be used to separate the hex digits into blocks of 8, such as "0xffc0140,0x00020110". Leading zeros in each block do not need to be specified. For example, "0xffc0140,0x20110" is equivalent to the prior example, and "0x0000000f" is exactly equivalent to "0xf". Intermediate blocks of 8 digits that are all zeoro can be left empty; "0xff0,,0x13" is equivalent to "0xff0,0x00000000,0x13".
Multiple locations can be specified on the hwloc-bind command line (delimited by whitespace); the first token of the execution command is assumed to either follow "--" (if specified) or the first token that is unrecognized as a location. By default, multiple locations are added, meaning that the binding will be wider in the sense that the process may run on more objects. If prefixed with "~", the given location will be cleared instead of added to the current list of locations. If prefixed with "x", the given location will be and'ed instead of added to the current list. If prefixed with "^", the given location will be xor'ed. More complex operations may be performed by using to compute intermediate values.
Objects can be any of the following strings (listed from "biggest" to "smallest"):
- A set of processors and memory.
- A NUMA node; a set of processors around memory which the processors can directly access.
- Typically a physical package or chip, it is a grouping of one or more processors.
- A single, physical processing unit which may still contain multiple logical processors, such as hardware threads.
- Short for processor (not process!). The smallest physical execution unit that hwloc recognizes. For example, there may be multiple procs on a core (e.g., hardware threads).
The additional system type can be used when several machines form an overall single system image (SSI), such as Kerrighed.
Finally, note that an object can be denoted by its numeric "depth" in the topology graph. See the Examples section for more information.
Hwloc IndexesIndexes are integer values that uniquely specify a given object of a specific type. Indexes can be expressed either as logical values or physical values. While hwloc-bind accepts logical indexes as input by default. Passing --physical switches to physical/OS indexes. Both logical and physical indexes are described on this man page.
Logical indexes are relative to the object order in the output from the lstopo command. They always start with 0 and increment by 1 for each successive object.
Physical indexes are how the operating system refers to objects. Note that while physical indexes are non-negative integer values, the hardware and/or operating system may choose arbitrary values -- they may not start with 0, and successive objects may not have consecutive values.
For example, if the first few lines of lstopo -p output are the following:
Socket#0 + L2(4MB)
L1(32KB) + Core#16 + P#0
L1(32KB) + Core#18 + P#2
Socket#1 + L2(4MB) L1(32KB) + Core#16 + P#1
L1(32KB) + Core#18 + P#3
The first core on the second socket is logically number 2 (i.e., logically the 3rd core, starting from 0). Its physical index is 16, but note that another core also has a physical index of 16. Hence, physical indexes may only be relevant within the scope of their parent (or set of grandparents). In this example, to uniquely identify logical core 2 with physical indexes, you must specify (at a minimum) both a socket and a core: socket 1, core 16.
Index values, regardless of whether they are logical or physical, can be expressed in several different forms (where X, Y, and N are positive integers):
- The object with index value X.
- All the objects with index values >= X and <= Y.
- All the objects with index values >= X.
- N objects starting with index X, possibly wrapping around the end of the level.
- A special index value indicating all valid index values.
- A special index value indicating all valid odd index values.
- A special index value indicating all valid even index values.
REMEMBER: hwloc's command line tools accept logical indexes for location values by default. Use --physical and --logical to switch from one mode to another.