Hwloc A4
Hwloc A4
2.11.2
1 Hardware Locality 1
1.1 Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 hwloc Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Command-line Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Programming Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4.1 Portability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4.2 API Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 Questions and Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.6 History / Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Installation 11
2.1 Basic Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Optional Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 Installing from a Git clone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5 Command-Line Tools 19
5.1 lstopo and lstopo-no-graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.2 hwloc-bind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.3 hwloc-calc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.4 hwloc-info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.5 hwloc-distrib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.6 hwloc-ps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.7 hwloc-annotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.8 hwloc-diff, hwloc-patch and hwloc-compress-dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.9 hwloc-dump-hwdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.10 hwloc-gather-topology and hwloc-gather-cpuid . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
6 Environment Variables 23
8 I/O Devices 29
8.1 Enabling and requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Generated by Doxygen
ii
9 Miscellaneous objects 35
9.1 Misc objects added by hwloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
9.2 Annotating topologies with Misc objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
10 Object attributes 37
10.1 Normal attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
10.2 Custom string infos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
10.2.1 Hardware Platform Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
10.2.2 Operating System Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
10.2.3 hwloc Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
10.2.4 CPU Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
10.2.5 OS Device Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
10.2.6 Other Object-specific Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
10.2.7 User-Given Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
12 Heterogeneous Memory 47
12.1 Memory Tiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
12.2 Using Heterogeneous Memory from the command-line . . . . . . . . . . . . . . . . . . . . . . . . 48
12.3 Using Heterogeneous Memory from the C API . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
12.3.1 Iterating over the list of (heterogeneous) NUMA nodes . . . . . . . . . . . . . . . . . . . . 48
12.3.2 Iterating over local (heterogeneous) NUMA nodes . . . . . . . . . . . . . . . . . . . . . . 49
14 Synthetic topologies 53
14.1 Synthetic description string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
14.2 Loading a synthetic topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
14.3 Exporting a topology as a synthetic string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
16 Thread Safety 57
Generated by Doxygen
iii
Generated by Doxygen
iv
21 Topic Index 85
21.1 Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
23 Topic Documentation 89
23.1 Error reporting in the API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
23.2 API version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
23.2.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
23.2.2 Macro Definition Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
23.2.2.1 HWLOC_API_VERSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
23.2.2.2 HWLOC_COMPONENT_ABI . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
23.2.3 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
23.2.3.1 hwloc_get_api_version() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
23.3 Object Sets (hwloc_cpuset_t and hwloc_nodeset_t) . . . . . . . . . . . . . . . . . . . . . . . . . . 90
23.3.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Generated by Doxygen
v
Generated by Doxygen
vi
23.7.3.3 hwloc_get_nbobjs_by_depth() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
23.7.3.4 hwloc_get_nbobjs_by_type() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
23.7.3.5 hwloc_get_next_obj_by_depth() . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
23.7.3.6 hwloc_get_next_obj_by_type() . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
23.7.3.7 hwloc_get_obj_by_depth() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
23.7.3.8 hwloc_get_obj_by_type() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
23.7.3.9 hwloc_get_root_obj() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
23.7.3.10 hwloc_get_type_depth() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
23.7.3.11 hwloc_get_type_or_above_depth() . . . . . . . . . . . . . . . . . . . . . . . . 101
23.7.3.12 hwloc_get_type_or_below_depth() . . . . . . . . . . . . . . . . . . . . . . . . . 101
23.7.3.13 hwloc_topology_get_depth() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
23.8 Converting between Object Types and Attributes, and Strings . . . . . . . . . . . . . . . . . . . . 102
23.8.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
23.8.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
23.8.2.1 hwloc_obj_attr_snprintf() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
23.8.2.2 hwloc_obj_type_snprintf() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
23.8.2.3 hwloc_obj_type_string() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
23.8.2.4 hwloc_type_sscanf() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
23.8.2.5 hwloc_type_sscanf_as_depth() . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
23.9 Consulting and Adding Info Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
23.9.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
23.9.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
23.9.2.1 hwloc_obj_add_info() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
23.9.2.2 hwloc_obj_get_info_by_name() . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
23.9.2.3 hwloc_obj_set_subtype() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
23.10 CPU binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
23.10.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
23.10.2 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
23.10.2.1 hwloc_cpubind_flags_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
23.10.3 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
23.10.3.1 hwloc_get_cpubind() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
23.10.3.2 hwloc_get_last_cpu_location() . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
23.10.3.3 hwloc_get_proc_cpubind() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
23.10.3.4 hwloc_get_proc_last_cpu_location() . . . . . . . . . . . . . . . . . . . . . . . . 107
23.10.3.5 hwloc_get_thread_cpubind() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
23.10.3.6 hwloc_set_cpubind() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
23.10.3.7 hwloc_set_proc_cpubind() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
23.10.3.8 hwloc_set_thread_cpubind() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
23.11 Memory binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
23.11.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
23.11.2 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
23.11.2.1 hwloc_membind_flags_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Generated by Doxygen
vii
Generated by Doxygen
viii
Generated by Doxygen
ix
Generated by Doxygen
x
Generated by Doxygen
xi
Generated by Doxygen
xii
Generated by Doxygen
xiii
Generated by Doxygen
xiv
Generated by Doxygen
xv
Generated by Doxygen
xvi
Generated by Doxygen
xvii
Generated by Doxygen
xviii
Generated by Doxygen
xix
Generated by Doxygen
xx
Generated by Doxygen
xxi
Generated by Doxygen
xxii
Generated by Doxygen
xxiii
Generated by Doxygen
xxiv
Generated by Doxygen
Chapter 1
Hardware Locality
– hwloc Overview
– Command-line Examples
– Programming Interface
– Questions and Bugs
– History / Credits
• Chapters
– Installation
– Compiling software on top of hwloc's C API
– Terms and Definitions
– Command-Line Tools
– Environment Variables
– CPU and Memory Binding Overview
– I/O Devices
– Miscellaneous objects
– Object attributes
– Topology Attributes: Distances, Memory Attributes and CPU Kinds
– Heterogeneous Memory
– Importing and exporting topologies from/to XML files
– Synthetic topologies
– Interoperability With Other Software
– Thread Safety
– Components and plugins
– Embedding hwloc in Other Software
– Frequently Asked Questions (FAQ)
– Upgrading to the hwloc 2.0 API
Generated by Doxygen
2 Hardware Locality
• Linux (with knowledge of cgroups and cpusets, memory targets/initiators, etc.) on all supported hardware,
including Intel Xeon Phi, ScaleMP vSMP, and NumaScale NumaConnect.
• AIX
• Darwin / OS X
• NetBSD
• HP-UX
• Microsoft Windows
Since it uses standard Operating System information, hwloc's support is mostly independant from the processor
type (x86, powerpc, ...) and just relies on the Operating System support. The main exception is BSD operating
systems (NetBSD, FreeBSD, etc.) because they do not provide support topology information, hence hwloc uses an
x86-only CPUID-based backend (which can be used for other OSes too, see the Components and plugins section).
To check whether hwloc works on a particular machine, just try to build it and run lstopo or lstopo-no-graphics.
If some things do not look right (e.g. bogus or missing cache information), see Questions and Bugs.
hwloc only reports the number of processors on unsupported operating systems; no topology information is avail-
able.
For development and debugging purposes, hwloc also offers the ability to work on "fake" topologies:
• Symmetrical tree of resources generated from a list of level arities, see Synthetic topologies.
• Remote machine simulation through the gathering of topology as XML files, see Importing and exporting topologies from/to XML
hwloc can display the topology in a human-readable format, either in graphical mode (X11), or by exporting in one of
several different formats, including: plain text, LaTeX tikzpicture, PDF, PNG, and FIG (see Command-line Examples
below). Note that some of the export formats require additional support libraries.
hwloc offers a programming interface for manipulating topologies and objects. It also brings a powerful CPU bitmap
API that is used to describe topology objects location on physical/logical processors. See the Programming Interface
below. It may also be used to binding applications onto certain cores or memory nodes. Several utility programs
are also provided to ease command-line manipulation of topology objects, binding of processes, and so on.
Bindings for several other languages are available from the project website.
Generated by Doxygen
1.3 Command-line Examples 3
Machine
NUMANode L#0 (P#0)
Package L#0 + L3 L#0 (4096KB)
L2 L#0 (1024KB) + L1 L#0 (16KB) + Core L#0
PU L#0 (P#0)
PU L#1 (P#8)
L2 L#1 (1024KB) + L1 L#1 (16KB) + Core L#1
PU L#2 (P#4)
PU L#3 (P#12)
Package L#1 + L3 L#1 (4096KB)
L2 L#2 (1024KB) + L1 L#2 (16KB) + Core L#2
PU L#4 (P#1)
PU L#5 (P#9)
L2 L#3 (1024KB) + L1 L#3 (16KB) + Core L#3
PU L#6 (P#5)
PU L#7 (P#13)
Package L#2 + L3 L#2 (4096KB)
L2 L#4 (1024KB) + L1 L#4 (16KB) + Core L#4
PU L#8 (P#2)
PU L#9 (P#10)
L2 L#5 (1024KB) + L1 L#5 (16KB) + Core L#5
PU L#10 (P#6)
PU L#11 (P#14)
Package L#3 + L3 L#3 (4096KB)
L2 L#6 (1024KB) + L1 L#6 (16KB) + Core L#6
PU L#12 (P#3)
PU L#13 (P#11)
L2 L#7 (1024KB) + L1 L#7 (16KB) + Core L#7
PU L#14 (P#7)
PU L#15 (P#15)
Note that there is also an equivalent output in XML that is meant for exporting/importing topologies but it is hardly
readable to human-beings (see Importing and exporting topologies from/to XML files for details).
On a 4-package 2-core Opteron NUMA machine (with two core cores disallowed by the administrator), the lstopo
tool may show the following graphical output (with --disallowed for displaying disallowed objects):
Generated by Doxygen
4 Hardware Locality
On a 2-package quad-core Xeon (pre-Nehalem, with 2 dual-core dies into each package):
Generated by Doxygen
1.4 Programming Interface 5
Each hwloc object contains a cpuset describing the list of processing units that it contains. These bitmaps
may be used for CPU binding and Memory binding. hwloc offers an extensive bitmap manipulation interface in
hwloc/bitmap.h.
Moreover, hwloc also comes with additional helpers for interoperability with several commonly used environments.
See the Interoperability With Other Software section for details.
The complete API documentation is available in a full set of HTML pages, man pages, and self-contained PDF files
(formatted for both both US letter and A4 formats) in the source tarball in doc/doxygen-doc/.
NOTE: If you are building the documentation from a Git clone, you will need to have Doxygen and pdflatex installed
– the documentation will be built during the normal "make" process. The documentation is installed during "make
install" to $prefix/share/doc/hwloc/ and your systems default man page tree (under $prefix, of course).
1.4.1 Portability
Operating System have varying support for CPU and memory binding, e.g. while some Operating Systems provide
interfaces for all kinds of CPU and memory bindings, some others provide only interfaces for a limited number of
kinds of CPU and memory binding, and some do not provide any binding interface at all. Hwloc's binding functions
would then simply return the ENOSYS error (Function not implemented), meaning that the underlying Operating
System does not provide any interface for them. CPU binding and Memory binding provide more information on
which hwloc binding functions should be preferred because interfaces for them are usually available on the sup-
ported Operating Systems.
Similarly, the ability of reporting topology information varies from one platform to another. As shown in
Command-line Examples, hwloc can obtain information on a wide variety of hardware topologies. However,
some platforms and/or operating system versions will only report a subset of this information. For example, on
an PPC64-based system with 8 cores (each with 2 hardware threads) running a default 2.6.18-based kernel from
RHEL 5.4, hwloc is only able to glean information about NUMA nodes and processor units (PUs). No information
about caches, packages, or cores is available.
Here's the graphical output from lstopo on this platform when Simultaneous Multi-Threading (SMT) is enabled:
And here's the graphical output from lstopo on this platform when SMT is disabled:
Notice that hwloc only sees half the PUs when SMT is disabled. PU L#6, for example, seems to change location
from NUMA node #0 to #1. In reality, no PUs "moved" – they were simply re-numbered when hwloc only saw
half as many (see also Logical index in Indexes and Sets). Hence, PU L#6 in the SMT-disabled picture probably
corresponds to PU L#12 in the SMT-enabled picture.
This same "PUs have disappeared" effect can be seen on other platforms – even platforms / OSs that provide much
more information than the above PPC64 system. This is an unfortunate side-effect of how operating systems report
information to hwloc.
Note that upgrading the Linux kernel on the same PPC64 system mentioned above to 2.6.34, hwloc is able to
discover all the topology information. The following picture shows the entire topology layout when SMT is enabled:
Generated by Doxygen
6 Hardware Locality
Developers using the hwloc API or XML output for portable applications should therefore be extremely careful to
not make any assumptions about the structure of data that is returned. For example, per the above reported PPC
topology, it is not safe to assume that PUs will always be descendants of cores.
Additionally, future hardware may insert new topology elements that are not available in this version of hwloc. Long-
lived applications that are meant to span multiple different hardware platforms should also be careful about making
structure assumptions. For example, a new element may someday exist between a core and a PU.
#include "hwloc.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
int depth;
unsigned i, n;
unsigned long size;
int levels;
char string[128];
int topodepth;
void *m;
hwloc_topology_t topology;
hwloc_cpuset_t cpuset;
hwloc_obj_t obj;
/*****************************************************************
* First example:
Generated by Doxygen
1.4 Programming Interface 7
/*****************************************************************
* Second example:
* Walk the topology with a tree style.
*****************************************************************/
printf("*** Printing overall tree\n");
print_children(topology, hwloc_get_root_obj(topology), 0);
/*****************************************************************
* Third example:
* Print the number of packages.
*****************************************************************/
depth = hwloc_get_type_depth(topology, HWLOC_OBJ_PACKAGE);
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN) {
printf("*** The number of packages is unknown\n");
} else {
printf("*** %u package(s)\n",
hwloc_get_nbobjs_by_depth(topology, depth));
}
/*****************************************************************
* Fourth example:
* Compute the amount of cache that the first logical processor
* has above it.
*****************************************************************/
levels = 0;
size = 0;
for (obj = hwloc_get_obj_by_type(topology, HWLOC_OBJ_PU, 0);
obj;
obj = obj->parent)
if (hwloc_obj_type_is_cache(obj->type)) {
levels++;
size += obj->attr->cache.size;
}
printf("*** Logical processor 0 has %d caches totaling %luKB\n",
levels, size / 1024);
/*****************************************************************
* Fifth example:
* Bind to only one thread of the last core of the machine.
*
* First find out where cores are, or else smaller sets of CPUs if
* the OS doesn’t have the notion of a "core".
*****************************************************************/
depth = hwloc_get_type_or_below_depth(topology, HWLOC_OBJ_CORE);
/*****************************************************************
* Sixth example:
* Allocate some memory on the last NUMA node, bind some existing
* memory to the last NUMA node.
*****************************************************************/
Generated by Doxygen
8 Hardware Locality
size = 1024*1024;
m = hwloc_alloc_membind(topology, size, obj->nodeset,
HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_BYNODESET);
hwloc_free(topology, m, size);
m = malloc(size);
hwloc_set_area_membind(topology, m, size, obj->nodeset,
HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_BYNODESET);
free(m);
return 0;
}
hwloc provides a pkg-config executable to obtain relevant compiler and linker flags. See Compiling software on top of hwloc's C AP
for details on building program on top of hwloc's API using GNU Make or CMake.
On a machine 2 processor packages – each package of which has two processing cores – the output from running
hwloc-hello could be something like the following:
shell$ ./hwloc-hello
*** Objects at level 0
Index 0: Machine
*** Objects at level 1
Index 0: Package#0
Index 1: Package#1
*** Objects at level 2
Index 0: Core#0
Index 1: Core#1
Index 2: Core#3
Index 3: Core#2
*** Objects at level 3
Index 0: PU#0
Index 1: PU#1
Index 2: PU#2
Index 3: PU#3
*** Printing overall tree
Machine
Package#0
Core#0
PU#0
Core#1
PU#1
Package#1
Core#3
PU#2
Core#2
PU#3
*** 2 package(s)
*** Logical processor 0 has 0 caches totaling 0KB
shell$
Generated by Doxygen
1.6 History / Credits 9
libtopology was initially developed by the Inria Runtime Team-Project. PLPA was initially developed by the Open
MPI development team as a sub-project. Both are now deprecated in favor of hwloc, which is distributed as an Open
MPI sub-project.
Generated by Doxygen
10 Hardware Locality
Generated by Doxygen
Chapter 2
Installation
The hwloc command-line tool "lstopo" produces human-readable topology maps, as mentioned above. Running the
"lstopo" tool is a good way to check as a graphical output whether hwloc properly detected the architecture of your
node.
The hwloc core may also benefit from the following development packages:
• the NVIDIA CUDA Toolkit for CUDA device discovery. See How do I enable CUDA and select which CUDA version to use?.
• the NVIDIA Management Library (NVML) for NVML device discovery. It is included in CUDA since ver-
sion 8.0. Older NVML releases were available within the NVIDIA GPU Deployment Kit from https←-
://developer.nvidia.com/gpu-deployment-kit .
• the NV-CONTROL X extension library (NVCtrl) for NVIDIA display discovery. The relevant development pack-
age is usually libXNVCtrl-devel or libxnvctrl-dev. It is also available within nvidia-settings from
ftp://download.nvidia.com/XFree86/nvidia-settings/ and https://github.←-
com/NVIDIA/nvidia-settings/ .
• the AMD ROCm SMI library for RSMI device discovery. The relevant development package is usually
rocm-smi-lib64 or librocm-smi-dev. See How do I enable ROCm SMI and select which version to use?.
Generated by Doxygen
12 Installation
• the oneAPI Level Zero library. The relevant development package is usually level-zero-dev or
level-zero-devel.
• libxml2 for full XML import/export support (otherwise, the internal minimalistic parser will only be able to import
XML files that were exported by the same hwloc release). See Importing and exporting topologies from/to XML files
for details. The relevant development package is usually libxml2-devel or libxml2-dev.
• libudev on Linux for easier discovery of OS device information (otherwise hwloc will try to manually parse
udev raw files). The relevant development package is usually libudev-devel or libudev-dev.
• libtool's ltdl library for dynamic plugin loading if the native dlopen cannot be used. The relevant development
package is usually libtool-ltdl-devel or libltdl-dev.
PCI and XML support may be statically built inside the main hwloc library, or as separate dynamically-loaded plugins
(see the Components and plugins section).
Also note that if you install supplemental libraries in non-standard locations, hwloc's configure script may not be able
to find them without some help. You may need to specify additional CPPFLAGS, LDFLAGS, or PKG_CONFIG_PATH
values on the configure command line.
For example, if libpciaccess was installed into /opt/pciaccess, hwloc's configure script may not find it by default. Try
adding PKG_CONFIG_PATH to the ./configure command line, like this:
Note that because of the possibility of GPL taint, the pciutils library libpci will not be used (remember that
hwloc is BSD-licensed).
Note that GNU Autoconf >=2.63, Automake >=1.11 and Libtool >=2.2.6 are required when building from a Git
clone.
Nightly development snapshots are available on the web site, they can be configured and built without any need for
Git or GNU Autotools.
Generated by Doxygen
Chapter 3
A program using the hwloc C API (for instance with hwloc-hello.c presented in API Example) may be built
with standard development tools. pkg-config provides easy ways to retrieve the required compiler and linker
flags as described below, but it is not mandatory.
hwloc-hello: hwloc-hello.c
$(CC) hwloc-hello.c $(CFLAGS) -o hwloc-hello $(LDLIBS)
add_executable(hwloc-hello hwloc-hello.c)
target_include_directories(hwloc-hello PRIVATE ${HWLOC_INCLUDE_DIRS})
target_compile_options(hwloc-hello PRIVATE ${HWLOC_CFLAGS})
target_link_libraries(hwloc-hello PRIVATE ${HWLOC_LINK_LIBRARIES})
target_link_options(hwloc-hello PRIVATE ${HWLOC_LDFLAGS})
Generated by Doxygen
14 Compiling software on top of hwloc's C API
cmake -B build
cmake --build build --verbose
Generated by Doxygen
Chapter 4
4.1 Objects
Object Interesting kind of part of the system, such as a Core, a L2Cache, a NUMA memory node, etc. The
different types detected by hwloc are detailed in the hwloc_obj_type_t enumeration.
Objects are topologically sorted by locality (CPU and node sets) into a tree (see Hierarchy, Tree and Levels).
Object Kind There are four kinds of Objects: Memory (NUMA nodes and Memory-side caches), I/O (Bridges,
PCI and OS devices), Misc, and Normal (everything else, including Machine, Package, Die, Core, PU, CPU
Caches, etc.). Normal and Memory objects have (non-NULL) CPU sets and nodesets, while I/O and Misc
don't.
See also
Processing Unit (PU) The smallest processing element that can be represented by a hwloc object. It may be a
single-core processor, a core of a multicore processor, or a single thread in a SMT processor (also sometimes
called "Logical processor", not to be confused with "Logical index of a processor"). hwloc's PU acronym
stands for Processing Unit.
Package A processor Package is the physical package that usually gets inserted into a socket on the motherboard.
It is also often called a physical processor or a CPU even if these names bring confusion with respect to cores
and processing units. A processor package usually contains multiple cores (and may also be composed of
multiple dies). hwloc Package objects were called Sockets up to hwloc 1.10.
NUMA Node An object that contains memory that is directly and byte-accessible to the host processors. It
is usually close to some cores as specified by its CPU set. Hence it is attached as a memory child
of the object that groups those cores together, for instance a Package objects with 4 Core children (see
Hierarchy, Tree and Levels).
Memory-side Cache A cache in front of a specific memory region (e.g. a range of physical addresses). It caches
all accesses to that region without caring about which core issued the request. This is the opposite of usual
CPU caches where only accesses from the local cores are cached, without caring about the target memory.
In hwloc, memory-side caches are memory objects placed between their local CPU objects (parent) and the
target NUMA node memory (child).
Logical index Index to uniquely identify objects of the same type and depth, automatically computed by hwloc
according to the topology. It expresses logical proximity in a generic way, i.e. objects which have adjacent
Generated by Doxygen
16 Terms and Definitions
logical indexes are adjacent in the topology. That is why hwloc almost always uses it in its API, since it
expresses logical proximity. They can be shown (as L#x) by lstopo thanks to the -l option. This index
is always linear and in the range [0, num_objs_same_type_same_level-1]. Think of it as ``cousin rank.'' The
ordering is based on topology first, and then on OS CPU numbers, so it is stable across everything except
firmware CPU renumbering. "Logical index" should not be confused with "Logical processor". A "Logical
processor" (which in hwloc we rather call "processing unit" to avoid the confusion) has both a physical index
(as chosen arbitrarily by BIOS/OS) and a logical index (as computed according to logical proximity by hwloc).
See also Should I use logical or physical/OS indexes? and how?.
CPU set The set of processing units (PU) logically included in an object (if it makes sense). They are always
expressed using physical processor numbers (as announced by the OS). They are implemented as the
hwloc_bitmap_t opaque structure. hwloc CPU sets are just masks, they do not have any relation with an
operating system actual binding notion like Linux' cpusets. I/O and Misc objects do not have CPU sets while
all Normal and Memory objects have non-NULL CPU sets.
Node set The set of NUMA memory nodes logically included in an object (if it makes sense). They are al-
ways expressed using physical node numbers (as announced by the OS). They are implemented with the
hwloc_bitmap_t opaque structure. as bitmaps. I/O and Misc objects do not have Node sets while all Normal
and Memory objects have non-NULL nodesets.
Bitmap A possibly-infinite set of bits used for describing sets of objects such as CPUs (CPU sets) or memory
nodes (Node sets). They are implemented with the hwloc_bitmap_t opaque structure.
Ancestor object The parent object, or its own parent, and so on.
Children object(s) The object (or objects) contained in the current object because their CPU set is included in the
CPU set of the current object. Each object may also contain separated lists for Memory, I/O and Misc object
children.
Arity The number of normal children of an object. There are also specific arities for Memory, I/O and Misc children.
Sibling objects Objects in the same children list, which all of them are normal children of the same parent, or all
of them are Memory children of the same parent, or I/O children, or Misc. They usually have the same type
(and hence are cousins, as well). But they may not if the topology is asymmetric.
Sibling rank Index to uniquely identify objects which have the same parent, and is always in the range [0, arity-1]
(respectively memory_arity, io_arity or misc_arity for Memory, I/O and Misc children of a parent).
Cousin objects Objects of the same type (and depth) as the current object, even if they do not have the same
parent.
Level Set of objects of the same type and depth. All these objects are cousins.
Memory, I/O and Misc objects also have their own specific levels and (virtual) depth.
Depth Nesting level in the object tree, starting from the root object. If the topology is symmetric, the depth of a
child is equal to the parent depth plus one, and an object depth is also equal to the number of parent/child
links between the root object and the given object. If the topology is asymmetric, the difference between
some parent and child depths may be larger than one when some intermediate levels (for instance groups)
are missing in only some parts of the machine.
The depth of the Machine object is always 0 since it is always the root of the topology. The depth of PU
objects is equal to the number of levels in the topology minus one.
Memory, I/O and Misc objects also have their own specific levels and depth.
Generated by Doxygen
4.3 Hierarchy, Tree and Levels 17
The following diagram can help to understand the vocabulary of the relationships by showing the example of a
machine with two dual core packages (with no hardware threads); thus, a topology with 5 levels. Each box with
rounded corner corresponds to one hwloc_obj_t, containing the values of the different integer fields (depth, logical←-
_index, etc.), and arrows show to which other hwloc_obj_t pointers point to (first_child, parent, etc.).
The topology always starts with a Machine object as root (depth 0) and ends with PU objects at the bottom (depth
4 here).
Objects of the same level (cousins) are listed in red boxes and linked with red arrows. Children of the same parent
(siblings) are linked with blue arrows.
The L2 cache of the last core is intentionally missing to show how asymmetric topologies are handled. See
What happens if my topology is asymmetric? for more information about such strange topologies.
Machine
Machine .depth = 0
level .logical_index = 0
depth=0 .os_index = -1
.sibling_rank=0
.arity=2 NUMA Node
.memory_arity=1 memory_first_child .depth = -3
.logical_index = 0
children[0] children[1] parent .os_index = 0
first_child last_child .sibling_rank = 0
parent parent
Package Package Package
level .depth = 1 next_sibling .depth = 1
depth=1 .logical_index =0 .logical_index = 1
.os_index = 0 next_cousin prev_sibling .os_index = 1
.sibling_rank=0 .sibling_rank=1
.arity=2 prev_cousin .arity=2
It should be noted that for PU objects, the logical index – as computed linearly by hwloc – is not the same as the
OS index.
The NUMA node is on the side because it is not part of the main tree but rather attached to the object that corre-
sponds to its locality (the entire machine here, hence the root object). It is attached as a Memory child (in green)
and has a virtual depth (negative). It could also have siblings if there were multiple local NUMA nodes, or cousins if
other NUMA nodes were attached somewhere else in the machine.
I/O or Misc objects could be attached in a similar manner.
Generated by Doxygen
18 Terms and Definitions
Generated by Doxygen
Chapter 5
Command-Line Tools
hwloc comes with an extensive C programming interface and several command line utilities. Each of them is fully
documented in its own manual page; the following is a summary of the available command line tools.
5.2 hwloc-bind
hwloc-bind binds processes to specific hardware objects through a flexible syntax. A simple example is binding an
executable to specific cores (or packages or bitmaps or ...). The hwloc-bind(1) man page provides much more detail
on what is possible.
hwloc-bind can also be used to retrieve the current process' binding, or retrieve the last CPU(s) where a process
ran, or operate on memory binding.
Just like hwloc-calc, the input locations given to hwloc-bind may be either objects or cpusets (bitmaps as reported
by hwloc-calc or hwloc-distrib).
5.3 hwloc-calc
hwloc-calc is hwloc's Swiss Army Knife command-line tool for converting things. The input may be either objects or
cpusets (bitmaps as reported by another hwloc-calc instance or by hwloc-distrib), that may be combined by addition,
intersection or subtraction. The output may be expressed as:
• a cpuset bitmap: This compact opaque representation of objects is useful for shell scripts etc. It may passed
to hwloc command-line tools such as hwloc-calc or hwloc-bind, or to hwloc command-line options such as
lstopo --restrict.
• a nodeset bitmap: Another opaque representation that represents memory locality more precisely, especially
if some NUMA nodes are CPU less or if multiple NUMA nodes are local to the same CPUs.
• the amount of the equivalent hwloc objects from a specific type, or the list of their indexes. This is useful for
iterating over all similar objects (for instance all cores) within a given part of a platform.
Generated by Doxygen
20 Command-Line Tools
• a hierarchical description of objects, for instance a thread index within a core within a package. This gives a
better view of the actual location of an object.
Moreover, input and/or output may be use either physical/OS object indexes or as hwloc's logical object indexes.
It eases cooperation with external tools such as taskset or numactl by exporting hwloc specifications into list of
processor or NUMA node physical indexes. See also Should I use logical or physical/OS indexes? and how?.
5.4 hwloc-info
hwloc-info dumps information about the given objects, as well as all its specific attributes. It is intended to be used
with tools such as grep for filtering certain attribute lines. When no object is specified, or when --topology is
passed, hwloc-info prints a summary of the topology. When --support is passed, hwloc-info lists the supported
features for the topology.
5.5 hwloc-distrib
hwloc-distrib generates a set of cpuset bitmaps that are uniformly distributed across the machine for the given
number of processes. These strings may be used with hwloc-bind to run processes to maximize their memory
bandwidth by properly distributing them across the machine.
5.6 hwloc-ps
hwloc-ps is a tool to display the bindings of processes that are currently running on the local machine. By default,
hwloc-ps only lists processes that are bound; unbound process (and Linux kernel threads) are not displayed.
5.7 hwloc-annotate
hwloc-annotate may modify object (and topology) attributes such as string information (see Custom string infos for
details) or Misc children objects. It may also add distances, memory attributes, etc. to the topology. It reads an
input topology from a XML file and outputs the annotated topology as another XML file.
5.9 hwloc-dump-hwdata
hwloc-dump-hwdata is a Linux and x86-specific tool that dumps (during boot, privileged) some topology and locality
information from raw hardware files (SMBIOS and ACPI tables) to human-readable and world-accessible files that
the hwloc library will later reuse.
Currently only used on Intel Xeon Phi processor platforms. See Why do I need hwloc-dump-hwdata for memory on Intel Xeon Phi proc
See HWLOC_DUMPED_HWDATA_DIR in Environment Variables for details about the location of dumped files.
Generated by Doxygen
5.10 hwloc-gather-topology and hwloc-gather-cpuid 21
These files may be used later (possibly offline) for simulating or debugging a machine without actually running on
it.
Generated by Doxygen
22 Command-Line Tools
Generated by Doxygen
Chapter 6
Environment Variables
The behavior of the hwloc library and tools may be tuned thanks to the following environment variables.
HWLOC_XMLFILE=/path/to/file.xml enforces the discovery from the given XML file as if hwloc_topology_set_xml()
had been called. This file may have been generated earlier with lstopo file.xml. For convenience, this backend
provides empty binding hooks which just return success. To have hwloc still actually call OS-specific hooks,
HWLOC_THISSYSTEM should be set 1 in the environment too, to assert that the loaded file is really the
underlying system. See also Importing and exporting topologies from/to XML files.
HWLOC_XML_VERBOSE=1
HWLOC_ALLOW=all Totally ignore administrative restrictions such as Linux Cgroups and consider all resources
(PUs and NUMA nodes) as allowed. This is different from setting HWLOC_TOPOLOGY_FLAG_INCLUDE←-
_DISALLOWED which gathers all resources but marks the unavailable ones as disallowed.
HWLOC_HIDE_ERRORS=1 enables or disables verbose reporting of errors. The hwloc library may issue warn-
ings to the standard error stream when it detects a problem during topology discovery, for instance if the
operating system (or user) gives contradictory topology information.
By default (1), hwloc only shows critical errors such as invalid hardware topology information or invalid con-
figuration. If set to 0 (default in lstopo), more errors are displayed, for instance a failure to initialize CUDA or
NVML. If set to 2, no hwloc error messages are shown.
Generated by Doxygen
24 Environment Variables
Note that additional verbose messages may be enabled with other variables such as HWLOC_GROUPING←-
_VERBOSE.
HWLOC_USE_NUMA_DISTANCES=7 enables or disables the use of NUMA distances. NUMA distances and
memory target/initiator information may be used to improve the locality of NUMA nodes, especially CPU-less
nodes. Bits in the value of this environment variable enable different features: Bit 0 enables the gathering of
NUMA distances from the operating system. Bit 1 further enables the use of NUMA distances to improve the
locality of CPU-less nodes. Bit 2 enables the use of target/initiator information.
HWLOC_MEMTIERS_GUESS=none
HWLOC_MEMTIERS_GUESS=all Disable or enable all heuristics to guess memory subtypes and tiers. By de-
fault, hwloc only uses heuristics that are likely correct and disables those that are unlikely.
HWLOC_MEMTIERS=0x0f=HBM;0xf=DRAM Enforce the memory tiers from the given semi-colon separated list.
Each entry specifies a bitmask (nodeset) of NUMA nodes and their subtype. Nodes not listed in any entry
are not placed in any tier.
If an empty value or none is given, tiers are entirely disabled.
HWLOC_MEMTIERS_REFRESH=1 Force the rebuilding of memory tiers. This is mostly useful when importing a
XML topology from an old hwloc version which was not able to guess memory subtypes and tiers.
HWLOC_GROUPING=1 enables or disables objects grouping based on distances. By default, hwloc uses dis-
tance matrices between objects (either read from the OS or given by the user) to find groups of close objects.
These groups are described by adding intermediate Group objects in the topology. Setting this environ-
ment variable to 0 will disable this grouping. This variable supersedes the obsolete HWLOC_IGNORE_←-
DISTANCES variable.
HWLOC_GROUPING_VERBOSE=0 enables or disables some verbose messages during grouping. If this variable
is set to 1, some debug messages will be displayed during distance-based grouping of objects even if debug
was not specific at configure time. This is useful when trying to find an interesting distance grouping accuracy.
HWLOC_CPUKINDS_RANKING=default change the ranking policy for CPU kinds. hwloc tries to rank CPU kinds
that are energy efficiency first, and then CPUs that are rather high-performance and power hungry.
By default, if available, the OS-provided efficiency is used for ranking. Otherwise, the frequency and/or core
types are used when available.
This environment variable may be set to coretype+frequency, coretype+frequency_strict,
coretype, frequency, frequency_base, frequency_max, forced_efficiency, no_←-
forced_efficiency, default, or none.
HWLOC_CPUKINDS_MAXFREQ=adjust=10 change the use of the max frequency in the Linux backend. hwloc
tries to read the base and max frequencies of each core on Linux. Some hardware features such as Intel Turbo
Boost Max 3.0 make some cores report slightly higher max frequencies than others in the same CPU package.
Despite having slightly different frequencies, these cores are considered identical instead of exposing an
hybrid CPU. Hence, by default, hwloc uniformizes the max frequencies of cores that have the same base
frequency (higher values are downgraded by up to 10%).
If this environment variable is set to adjust=X, the 10% threshold is replaced with X. If set to 1, max
frequencies are not adjusted anymore, some homogeneous processors may appear hybrid because of this.
If set to 0, max frequencies are entirely ignored.
HWLOC_CPUKINDS_HOMOGENEOUS=0 uniformize max frequency, base frequency and Linux capacity to force
a single homogeneous kind of CPUs. This is enabled by default on NVIDIA Grace but may be disabled if set
to 0 (or enabled on other platforms if set to 1).
Generated by Doxygen
25
HWLOC_PCI_LOCALITY=<domain/bus> <cpuset>;...
HWLOC_PCI_LOCALITY=/path/to/pci/locality/file changes the locality of I/O devices behing the specified PCI
buses. If no I/O locality information is available or if the BIOS reports incorrect information, it is possible to
move a I/O device tree (OS and/or PCI devices with optional bridges) near a custom set of processors.
Localities are given either inside the environment variable itself, or in the pointed file. They may be separated
either by semi-colons or by line-breaks. Invalid localities are silently ignored, hence it is possible to insert
comments between actual localities.
Each locality contains a domain/bus specification (in hexadecimal numbers as usual) followed by a whitespace
and a cpuset:
• 0001 <cpuset> specifies the locality of all buses in PCI domain 0000.
• 0000:0f <cpuset> specifies only PCI bus 0f in domain 0000.
• 0002:04-0a <cpuset> specifies a range of buses (from 04 to 0a) within domain 0002.
Domain/bus specifications should usually match entire hierarchies of buses behind a bridge (including pri-
mary, secondary and subordinate buses). For instance, if hostbridge 0000:00 is above other bridges/switches
with buses 0000:01 to 0000:09, the variable should be HWLOC_PCI_LOCALITY="0000:00-09 <cpuset>".
It supersedes the old HWLOC_PCI_0000_00_LOCALCPUS=<cpuset> which only works when hostbridges
exist in the topology.
If the variable is defined to empty or invalid, no forced PCI locality is applied but hwloc's internal automatic
locality quirks are disabled, which means the exact PCI locality reported by the platform is used.
HWLOC_X86_TOPOEXT_NUMANODES=0 use AMD topoext CPUID leaf in the x86 backend to detect NUMA
nodes. When using the x86 backend, setting this variable to 1 enables the building of NUMA nodes from
AMD processor CPUID instructions. However this strategy does not always reflect BIOS configuration such
as NUMA interleaving. And node indexes may be different from those of the operating system. Hence this
should only be used when OS backends are wrong and the user is sure that CPUID returns correct NUMA
information.
HWLOC_KNL_MSCACHE_L3=0 Expose the KNL MCDRAM in cache mode as a Memory-side Cache instead of a
L3. hwloc releases prior to 2.1 exposed the MCDRAM cache as a CPU-side L3 cache. Now that Memory-side
caches are supported by hwloc, it is still exposed as a L3 by default to avoid breaking existing applications.
Setting this environment variable to 1 will expose it as a proper Memory-side cache.
Generated by Doxygen
26 Environment Variables
Not using the main file-system root causes hwloc_topology_is_thissystem() to return 0. For convenience, this
backend provides empty binding hooks which just return success. To have hwloc still actually call OS-specific
hooks, HWLOC_THISSYSTEM should be set 1 in the environment too, to assert that the loaded file is really
the underlying system.
HWLOC_CPUID_PATH=/path/to/cpuid/ forces the x86 backend to read dumped CPUIDs from the given directory
instead of executing actual x86 CPUID instructions. This directory may have been saved previously from
another machine with hwloc-gather-cpuid.
One should likely also set HWLOC_COMPONENTS=x86,stop so that non-x86 backends are disabled (the
-i option of command-line tools takes care of both).
It causes hwloc_topology_is_thissystem() to return 0. For convenience, this backend provides empty binding
hooks which just return success. To have hwloc still actually call OS-specific hooks, HWLOC_THISSYSTEM
should be set 1 in the environment too, to assert that the loaded CPUID dump is really the underlying system.
HWLOC_PLUGINS_VERBOSE=1 displays verbose information about plugins. List which directories are scanned,
which files are loaded, and which components are successfully loaded.
HWLOC_DEBUG_VERBOSE=0 disables all verbose messages that are enabled by default when -enable-debug
is passed to configure. When set to more than 1, even more verbose messages are displayed. The default is
1.
Generated by Doxygen
Chapter 7
Binding tasks and data buffers is hwloc's second main goal after discovering and exposing the hardware topology.
hwloc defines APIs to bind threads and processes to cores and processing units (see CPU binding), and to bind
memory buffers to NUMA nodes (see Memory binding). Some examples are available under doc/examples/ in the
source tree.
Sections below provide high-level insights on how these APIs work.
Generated by Doxygen
28 CPU and Memory Binding Overview
• functions that set/get the current memory binding policies (if supported): hwloc_set_membind(),
hwloc_get_membind(), hwloc_set_proc_membind() and hwloc_get_proc_membind()
• a function that allocates memory bound to specific node set without changing the current memory binding
policy (if supported): hwloc_alloc_membind().
• a helper which, if needed, changes the current memory binding policy of the process in order to obtain
memory binding: hwloc_alloc_membind_policy().
An application can thus use the two first sets of functions if it wants to manage separately the global process binding
policy and directed allocation, or use the third set of functions if it does not care about the process memory binding
policy. Again, reading Memory binding is strongly recommended.
Generated by Doxygen
Chapter 8
I/O Devices
hwloc usually manipulates processing units and memory but it can also discover I/O devices and report their locality
as well. This is useful for placing I/O intensive applications on cores near the I/O devices they use, or for gathering
information about all platform components.
• HWLOC_OBJ_OS_DEVICE describes an operating-system-specific handle such as the sda drive or the eth0
network interface. See OS devices.
8.3 OS devices
Although each PCI device is uniquely identified by its bus ID (e.g. 0000:01:02.3), a user-space application can
hardly find out which PCI device it is actually using. Applications rather use software handles (such as the eth0
Generated by Doxygen
30 I/O Devices
network interface, the sda hard drive, or the mlx4_0 OpenFabrics HCA). Therefore hwloc tries to add software
devices (HWLOC_OBJ_OS_DEVICE, also known as OS devices).
OS devices may be attached below PCI devices, but they may also be attached directly to normal objects. Indeed
some OS devices are not related to PCI. For instance, NVDIMM block devices (such as pmem0s on Linux) are
directly attached near their NUMA node (I/O child of the parent whose memory child is the NUMA node). Also,
if hwloc could not discover PCI for some reason, PCI-related OS devices may also be attached directly to normal
objects.
Finally, OS subdevices may be exposed as OS devices children of another OS device. This is the case of LevelZero
subdevices for instance.
hwloc first tries to discover OS devices from the operating system, e.g. eth0, sda or mlx4_0. However, this ability is
currently only available on Linux for some classes of devices.
hwloc then tries to discover software devices through additional I/O components using external libraries. For in-
stance proprietary graphics drivers do not expose any named OS device, but hwloc may still create one OS object
per software handle when supported. For instance the opencl and cuda components may add some opencl0d0
and cuda0 OS device objects.
Here is a list of OS device objects commonly created by hwloc components when I/O discovery is enabled and
supported.
• GPUs (HWLOC_OBJ_OSDEV_GPU)
– rsmi0 for the first RSMI device ("RSMI" subtype, from the RSMI component, using the AMD ROCm SMI
library)
– nvml0 for the first NVML device ("NVML" subtype, from the NVML component, using the NVIDIA Man-
agement Library)
– :0.0 for the first display ("Display" subtype, from the GL component, using the NV-CONTROL X extension
library, NVCtrl)
– card0 and renderD128 for DRM device files (from the Linux component, filtered-out by default because
considered non-important)
• Co-Processors (HWLOC_OBJ_OSDEV_COPROC)
– opencl0d0 for the first device of the first OpenCL platform, opencl1d3 for the fourth device of the second
OpenCL platform ("OpenCL" subtype, from the OpenCL component)
– ze0 for the first Level Zero device ("LevelZero" subtype, from the levelzero component, using the oneAPI
Level Zero library), and ze0.1 for its second subdevice (if any).
– cuda0 for the first NVIDIA CUDA device ("CUDA" subtype, from the CUDA component, using the NVIDIA
CUDA Library)
– ve0 for the first NEC Vector Engine device ("VectorEngine" subtype, from the Linux component)
Note that some PCI devices may contain multiple software devices (see the example below).
See also Interoperability With Other Software for managing these devices without considering them as hwloc ob-
jects.
Generated by Doxygen
8.4 PCI devices and bridges 31
• pci=0000:02:03.0 is replaced by the set of CPUs that are close to the PCI device whose bus ID is
given.
• os=eth0 is replaced by CPUs that are close to the I/O device whose software handle is called eth0.
This enables easy binding of I/O-intensive applications near the device they use.
8.6 Examples
The following picture shows a dual-package dual-core host whose PCI bus is connected to the first package and
NUMA node.
Generated by Doxygen
32 I/O Devices
Six interesting PCI devices were discovered (dark green boxes). However, hwloc found some corresponding soft-
ware devices (eth0, eth1, sda, mlx4_0, ib0, and ib1 light grey boxes) for only four of these physical devices. The
other ones (PCI 04:03.0 and PCI 00:1f.2) are an unused IDE controller (no disk attached) and a graphic card (no
corresponding software device reported to the user by the operating system).
On the contrary, it should be noted that three different software devices were found for the last PCI device (PCI
51:00.0). Indeed this OpenFabrics HCA PCI device object contains one OpenFabrics software device (mlx4_0) and
two virtual network interfaces (ib0 and ib1).
Here is the corresponding textual output:
Generated by Doxygen
8.6 Examples 33
Package L#1
NUMANode L#1 (P#1 12GB)
L3 L#1 (8192KB)
L2 L#2 (256KB) + L1 L#2 (32KB) + Core L#2 + PU L#2 (P#1)
L2 L#3 (256KB) + L1 L#3 (32KB) + Core L#3 + PU L#3 (P#3)
Generated by Doxygen
34 I/O Devices
Generated by Doxygen
Chapter 9
Miscellaneous objects
hwloc topologies may be annotated with Misc objects (of type HWLOC_OBJ_MISC) either automatically or by the
user. This is a flexible way to annotate topologies with large sets of information since Misc objects may be inserted
anywhere in the topology (to annotate specific objects or parts of the topology), even below other Misc objects, and
each of them may contain multiple attributes (see also How do I annotate the topology with private notes?).
These Misc objects may have a subtype field to replace Misc with something else in the lstopo output.
• Memory modules (DIMMs), on Linux when privileged and when dmi-sysfs is supported by the kernel.
These objects have a subtype field of value MemoryModule. They are currently always attached to the
root object. Their attributes describe the DIMM vendor, model, etc. lstopo -v displays them as:
Misc(MemoryModule) (P#1 DeviceLocation="Bottom-Slot 2(right)" BankLocation="BANK 2" Vendor=Elpida
SerialNumber=21733667 AssetTag=9876543210 PartNumber="EBJ81UG8EFU0-GN-F ")
• Displaying process binding in lstopo --top. These objects have a subtype field of value Process
and a name attribute made of their PID and program name. They are attached below the object they are
bound to. The textual lstopo displays them as:
PU L#0 (P#0)
Misc(Process) 4445 myprogram
Generated by Doxygen
36 Miscellaneous objects
Generated by Doxygen
Chapter 10
Object attributes
• NUMA nodes: subtype DRAM (for usual main memory), HBM (high-bandwidth memory), SPM (specific-
purpose memory, usually reserved for some custom applications), NVM (non-volatile memory when used
as main memory), MCDRAM (on KNL), GPUMemory (on POWER architecture with NVIDIA GPU memory
shared over NVLink), CXL-DRAM or CXL-NVM for CXL DRAM or non-volatile memory. Note that some of
these subtypes are guessed by the library, they might be missing or slightly wrong in some corner cases.
See Heterogeneous Memory for details, and HWLOC_MEMTIERS and HWLOC_MEMTIERS_GUESS in
Environment Variables for tuning these.
• Groups: subtype Cluster, Module, Tile, Compute Unit, Book or Drawer for different
architecture-specific groups of CPUs (see also What are these Group objects in my topology?).
• L3 Caches: subtype MemorySideCache when hwloc is configured to expose the KNL MCDRAM in Cache
mode as a L3.
• PCI devices: subtype NVSwitch for NVLink switches (see also NVLinkBandwidth in Distances).
• Misc devices: subtype MemoryModule (see also Misc objects added by hwloc)
Each object also contains an attr field that, if non NULL, points to a union hwloc_obj_attr_u of type-
specific attribute structures. For instance, a L2Cache object obj contains cache-specific information in
obj->attr->cache, such as its size and associativity, cache type. See hwloc_obj_attr_u for details.
Generated by Doxygen
38 Object attributes
array field) or using the hwloc_obj_get_info_by_name(). The user may additionally add new name-value pairs to
any object using hwloc_obj_add_info() or the hwloc-annotate program.
Here is a non-exhaustive list of attributes that may be automatically added by hwloc. Note that these attributes
heavily depend on the ability of the operating system to report them. Many of them will therefore be missing on
some OS.
DMIBoardVendor, DMIBoardName, etc. DMI hardware information such as the motherboard and chassis models
and vendors, the BIOS revision, etc., as reported by Linux under /sys/class/dmi/id/.
SoC0ID, SoC0Family, SoC1Revision, etc. The ID, family and revision of the first system-on-chip (SoC0), second
(SoC1), etc.
MemoryMode, ClusterMode Intel Xeon Phi processor configuration modes. Available if hwloc-dump-hwdata was
used (see Why do I need hwloc-dump-hwdata for memory on Intel Xeon Phi processor?) or if hwloc man-
aged to guess them from the NUMA configuration.
The memory mode may be Cache, Flat, Hybrid50 (half the MCDRAM is used as a cache) or Hybrid25 (25%
of MCDRAM as cache). The cluster mode may be Quadrant, Hemisphere, All2All, SNC2 or SNC4. See
doc/examples/get-knl-modes.c in the source directory for an example of retrieving these attributes.
OSName, OSRelease, OSVersion, HostName, Architecture The operating system name, release, version, the
hostname and the architecture name, as reported by the Unix uname command.
LinuxCgroup The name the Linux control group where the calling process is placed.
WindowsBuildEnvironment Either MinGW or Cygwin when one of these environments was used during build.
Backend (topology root, or specific object added by that backend) The name of the hwloc backend/component
that filled the topology. If several components were combined, multiple Backend pairs may exist, with different
values, for instance x86 and Linux in the root object and CUDA in CUDA OS device objects.
MemoryTiersNr The number of different memory tiers in the topology, if any. See Heterogeneous Memory.
SyntheticDescription The description string that was given to hwloc to build this synthetic topology.
hwlocVersion The version number of the hwloc library that was used to generate the topology. If the topology was
loaded from XML, this is not the hwloc version that loaded it, but rather the first hwloc instance that exported
the topology to XML earlier.
ProcessName The name of the process that contains the hwloc library that was used to generate the topology.
If the topology was from XML, this is not the hwloc process that loaded it, but rather the first process that
exported the topology to XML earlier.
Generated by Doxygen
10.2 Custom string infos 39
CPUVendor, CPUModelNumber, CPUFamilyNumber, CPUStepping The processor vendor name, model num-
ber, family number, and stepping number. Currently available for x86 and Xeon Phi processors on most
systems, and for ia64 processors on Linux (except CPUStepping).
CPUFamily The family of the CPU, currently only available on Linux on LoongArch platforms.
CPURevision A POWER/PowerPC-specific general processor revision number, currently only available on Linux.
Vendor, Model, Revision, Size, SectorSize (Block OS devices) The vendor and model names, revision, size (in
KiB = 1024 bytes) and SectorSize (in bytes).
LinuxDeviceID (Block OS devices) The major/minor device number such as 8:0 of Linux device.
SerialNumber (Block and CXL Memory OS devices) The serial number of the device.
CXLRAMSize, CXLPMEMSize (CXL Memory Block OS devices) The size of the volatile (RAM) or persistent
(PMEM) memory in a CXL Type-3 device. Sizes are in KiB (1024 bytes).
GPUVendor, GPUModel (GPU or Co-Processor OS devices) The vendor and model names of the GPU device.
OpenCLDeviceType, OpenCLPlatformIndex,
LevelZeroSubdeviceID (LevelZero OS subdevices) The index of this subdevice within its parent.
LevelZeroDeviceType (LevelZero OS devices or subdevices) A string describing the type of device, for in-
stance "GPU", "CPU", "FPGA", etc.
LevelZeroNumSlices, LevelZeroNumSubslicesPerSlice,
Generated by Doxygen
40 Object attributes
AMDUUID, AMDSerial (RSMI GPU OS devices) The UUID and serial number of AMD GPUs.
RSMIVRAMSize, RSMIVisibleVRAMSize, RSMIGTTSize (RSMI GPU OS devices) The amount of GPU mem-
ory (VRAM), of GPU memory that is visible from the host (Visible VRAM), and of system memory that is
usable by the GPU (Graphics Translation Table). Sizes are in KiB (1024 bytes).
XGMIHiveID (RSMI GPU OS devices) The ID of the group of GPUs (Hive) interconnected by XGMI links
XGMIPeers (RSMI GPU OS devices) The list of RSMI OS devices that are directly connected to the current device
through XGMI links. They are given as a space-separated list of object names, for instance rsmi2 rsmi3.
NVIDIAUUID, NVIDIASerial (NVML GPU OS devices) The UUID and serial number of NVIDIA GPUs.
CUDAMultiProcessors, CUDACoresPerMP,
Address, Port (Network interface OS devices) The MAC address and the port number of a software network
interface, such as eth4 on Linux.
MemoryTier (NUMA Nodes) The rank of the memory tier of this node. Ranks start from 0 for highest bandwidth
nodes. The attribute is only set if multiple tiers are found. See Heterogeneous Memory.
CXLDevice (NUMA Nodes or DAX Memory OS devices) The PCI/CXL bus ID of a device whose CXL Type-3
memory is exposed here. If multiple devices are interleaved, their bus IDs are separated by commas, and the
number of devices in reported in CXLDeviceInterleaveWays.
CXLDeviceInterleaveWays (NUMA Nodes or DAX Memory OS devices) If multiple CXL devices are inter-
leaved, this attribute shows the number of devices (and the number of bus IDs in the CXLDevice attributes).
DAXDevice (NUMA Nodes) The name of the Linux DAX device that was used to expose a non-volatile memory
region as a volatile NUMA node.
DAXType (NUMA Nodes or DAX OS devices) The type of memory exposed in a Linux DAX device or in the cor-
responding NUMA node, either "NVM" (non-volatile memory) or "SPM" (specific-purpose memory).
Generated by Doxygen
10.2 Custom string infos 41
DAXParent (NUMA Nodes or DAX OS devices) A string describing the Linux sysfs hierarchy that exposes the
DAX device, for instance containing "hmem1" for specific-purpose memory or "ndbus0" for NVDIMMs.
PCIBusID (GPUMemory NUMA Nodes) The PCI bus ID of the GPU whose memory is exposed in this NUMA
node.
Inclusive (Caches) The inclusiveness of a cache (1 if inclusive, 0 otherwise). Currently only available on x86
processors.
SolarisProcessorGroup (Group) The Solaris kstat processor group name that was used to build this Group ob-
ject.
PCIVendor, PCIDevice (PCI devices and bridges) The vendor and device names of the PCI device.
PCISlot (PCI devices or Bridges) The name/number of the physical slot where the device is plugged. If the
physical device contains PCI bridges above the actual PCI device, the attribute may be attached to the
highest bridge (i.e. the first object that actually appears below the physical slot).
Vendor, AssetTag, PartNumber, DeviceLocation, BankLocation, FormFactor, Type, Size, Rank (MemoryModule Misc objects)
Information about memory modules (DIMMs) extracted from SMBIOS. Size is in KiB.
lstopoStyle Enforces the style of an object (background and text colors) in the graphical output of lstopo. See
CUSTOM COLORS in the lstopo(1) manpage for details.
Generated by Doxygen
42 Object attributes
Generated by Doxygen
Chapter 11
Besides the hierarchy of objects and individual object attributes (see Object attributes), hwloc may also expose finer
information about the hardware organization.
11.1 Distances
A machine with 4 CPUs may have identical links between every pairs of CPUs, or those CPUs could also only be
connected through a ring. In the ring case, accessing the memory of nearby CPUs is slower than local memory, but
it is also faster than accessing the memory of CPU on the opposite side of the ring. These deep details cannot be
exposed in the hwloc hierarchy, that is why hwloc also exposes distances.
Distances are matrices of values between sets of objects, usually latencies or bandwidths. By default, hwloc tries
to get a matrix of relative latencies between NUMA nodes when exposed by the hardware.
In the aforementioned ring case, the matrix could report 10 for latency between a NUMA node and itself, 20 for
nearby nodes, and 30 for nodes that are opposites on the ring. Those are theoretical values exposed by hardware
vendors (in the System Locality Distance Information Table (SLIT) in the ACPI) rather than physical latencies. They
are mostly meant for comparing node relative distances.
Distances structures currently created by hwloc are:
NUMALatency (Linux, Solaris, FreeBSD) This is the matrix of theoretical latencies described above.
XGMIBandwidth (RSMI) This is the matrix of unidirectional XGMI bandwidths between AMD GPUs (in MB/s). It
contains 0 when there is no direct XGMI link between objects. Values on the diagonal are artificially set to
very high so that local access always appears faster than remote access.
GPUs are identified by RSMI OS devices such as "rsmi0". They may be converted into the corresponding
OpenCL or PCI devices using hwloc_get_obj_with_same_locality() or the hwloc-annotate tool.
hwloc_distances_transform() or hwloc-annotate may also be used to transform this matrix into something
more convenient, for instance by replacing bandwidths with numbers of links between peers.
XGMIHops (RSMI) This matrix lists the number of XGMI hops between AMD GPUs. It reports 1 when there is a
direct link between two distinct GPUs. If there is no XGMI route between them, the value is 0. The number of
hops between a GPU and itself (on the diagonal) is 0 as well.
XeLinkBandwidth (LevelZero) This is the matrix of unidirectional XeLink bandwidths between Intel GPUs (in
MB/s). It contains 0 when there is no direct XeLink between objects. When there are multiple links, their
bandwidth is aggregated.
Values on the diagonal are artificially set to very high so that local access always appears faster than remote
access. This includes bandwidths between a (sub)device and itself, between a subdevice and its parent
device, or between two subdevices of the same parent.
The matrix interconnects all LevelZero devices and subdevices (if any), even if some of them may have no
link at all.
The bandwidths of links between subdevices are accumulated in the bandwidth between their parents.
Generated by Doxygen
44 Topology Attributes: Distances, Memory Attributes and CPU Kinds
NVLinkBandwidth (NVML) This is the matrix of unidirectional NVLink bandwidths between NVIDIA GPUs (in
MB/s). It contains 0 when there is no direct NVLink between objects. When there are multiple links, their
bandwidth is aggregated. Values on the diagonal are artificially set to very high so that local access always
appears faster than remote access.
On POWER platforms, NVLinks may also connects GPUs to CPUs. On NVIDIA platforms such as DGX-2,
a NVSwitch may interconnect GPUs through NVLinks. In these cases, the distances structure is heteroge-
neous. GPUs always appear first in the matrix (as NVML OS devices such as "nvml0"), and non-GPU objects
may appear at the end (Package for POWER processors, PCI device for NVSwitch).
NVML OS devices may be converted into the corresponding CUDA, OpenCL or PCI devices using
hwloc_get_obj_with_same_locality() or the hwloc-annotate tool.
hwloc_distances_transform() or hwloc-annotate may also be used to transform this matrix into something
more convenient, for instance by removing switches or CPU ports, or by replacing bandwidths with numbers
of links between peers.
When a NVSwitch interconnects GPUs, only links between one GPU and different NVSwitch ports are re-
ported. They may be merged into a single switch port with hwloc_distances_transform() or hwloc-annotate.
Or a transitive closure may also be applied to report the bandwidth between GPUs across the NVSwitch.
Users may also specify their own matrices between any set of objects, even if these objects are of different types
(e.g. bandwidths between GPUs and CPUs).
The entire API is located in hwloc/distances.h. See also Retrieve distances between objects, as well as
Helpers for consulting distance matrices and Add distances between objects.
FrequencyMaxMHz (Linux) The maximal operating frequency of the core, as reported by cpufreq drivers on
Linux.
FrequencyBaseMHz (Linux) The base/nominal operating frequency of the core, as reported by some cpufreq
or ACPI drivers on Linux (e.g. cpufreq_cppc or intel_pstate).
CoreType (x86) A string describing the kind of core, currently IntelAtom or IntelCore, as reported by the
x86 CPUID instruction and Linux PMU on some Intel processors.
Generated by Doxygen
11.3 CPU Kinds 45
LinuxCapacity (Linux) The Linux-specific CPU capacity found in sysfs, as reported by the Linux kernel on
some recent platforms. Higher values usually mean that the Linux scheduler considers the core as high-
performance rather than energy-efficient.
LinuxCPUType (Linux) The Linux-specific CPU type found in sysfs, such as intel_atom_0, as reported by
future Linux kernels on some Intel processors.
DarwinCompatible (Darwin / Mac OS X) The compatibility attribute of the CPUs as found in the IO reg-
istry on Darwin / Mac OS X. For instance apple,icestorm;ARM,v8 for energy-efficient cores and
apple,firestorm;ARM,v8 on performance cores on Apple M1 CPU.
Generated by Doxygen
46 Topology Attributes: Distances, Memory Attributes and CPU Kinds
Generated by Doxygen
Chapter 12
Heterogeneous Memory
Heterogeneous memory hardware exposes different NUMA nodes for different memory technologies. On the image
below, a dual-socket server has both HBM (high bandwidth memory) and usual DRAM connected to each socket,
as well as some CXL memory connected to the entire machine.
The hardware usually exposes "normal" memory first because it is where "normal" data buffers should be allocated
by default. However there is no guarantee about whether HBM, NVM, CXL will appear second. Hence there is a
need to explicit memory technologies and performance to help users decide where to allocate.
• Each node object has its subtype field set to HBM, DRAM or CXL-DRAM (see other possible values in
Normal attributes).
• Each node also has a string info attribute with name MemoryTier and value 0 for the first tier, 1 for the
second, etc.
• First hwloc looks into operating system information to find out whether a node is non-volatile, CXL, special-
purpose, etc.
• Then it combines that knowledge with performance metrics exposed by the hardware to guess what's actually
DRAM, HBM, etc. These metrics are also exposed in hwloc Memory Attributes, for instance bandwidth and la-
tency, for read and write. See Memory Attributes and Comparing memory node attributes for finding where to allocate on
for more details.
Once nodes with similar or different characteristics are identified, they are placed in tiers. Tiers are then sorted by
bandwidth so that the highest bandwidth is ranked first, etc.
If hwloc fails to build tiers properly, see HWLOC_MEMTIERS and HWLOC_MEMTIERS_GUESS in Environment Variables.
Generated by Doxygen
48 Heterogeneous Memory
To list all the physical indexes of Tier-0 NUMA nodes (HBM P#2 and P#3 not shown on the figure):
The number of tiers may be retrieved by looking at topology attributes in the root object:
hwloc-calc and hwloc-bind also have options such as --local-memory and --best-memattr to select the
best NUMA node among the local ones. For instance, the following command-lines say that, among nodes near
node:0 (DRAM L#0), the best one for latency is itself while the best one for bandwidth is node:1 (HBM L#1).
• First, there may be multiple memory children attached at the same place. For instance, each Package in the
above image has two memory children, one for the DRAM NUMA node, and another one for the HBM node.
• Second, memory children may be attached at different levels. In the above image, CXL memory is attached
to the root Machine object instead of below a Package.
Hence, one may have to rethink the way it selects NUMA nodes.
It is also possible to iterate over the memory parents (e.g. Packages in our example) and select only one mem-
ory child for each of them. hwloc_get_memory_parents_depth() may be used to find the depth of these parents.
However this method only works if all memory parents are at the same level. It would fail in our example: the
root Machine object also has a memory child (CXL), hence hwloc_get_memory_parents_depth() would returns
HWLOC_TYPE_DEPTH_MULTIPLE.
Generated by Doxygen
12.3 Using Heterogeneous Memory from the C API 49
hwloc_memattr_get_best_target() is also a convenient way to select the best local NUMA node according to perfor-
mance metrics. See also Comparing memory node attributes for finding where to allocate on.
Generated by Doxygen
50 Heterogeneous Memory
Generated by Doxygen
Chapter 13
hwloc offers the ability to export topologies to XML files and reload them later. This is for instance useful for loading
topologies faster (see I do not want hwloc to rediscover my enormous machine topology every time I rerun a process),
manipulating other nodes' topology, or avoiding the need for privileged processes (see Does hwloc require privileged access?).
Topologies may be exported to XML files thanks to hwloc_topology_export_xml(), or to a XML memory buffer with
hwloc_topology_export_xmlbuffer(). The lstopo program can also serve as a XML topology export tool.
XML topologies may then be reloaded later with hwloc_topology_set_xml() and hwloc_topology_set_xmlbuffer().
The HWLOC_XMLFILE environment variable also tells hwloc to load the topology from the given XML file (see
Environment Variables).
Note
Loading XML topologies disables binding because the loaded topology may not correspond to the
physical machine that loads it. This behavior may be reverted by asserting that loaded file re-
ally matches the underlying system with the HWLOC_THISSYSTEM environment variable or the
HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM topology flag.
The topology flag HWLOC_TOPOLOGY_FLAG_THISSYSTEM_ALLOWED_RESOURCES may be used to
load a XML topology that contains the entire machine and restrict it to the part that is actually available to the
current process (e.g. when Linux Cgroup/Cpuset are used to restrict the set of resources).
hwloc also offers the ability to export/import Topology differences.
XML topology files are not localized. They use a dot as a decimal separator. Therefore any exported topology
can be reloaded on any other machine without requiring to change the locale.
XML exports contain all details about the platform. It means that two very similar nodes still have different
XML exports (e.g. some serial numbers or MAC addresses are different). If a less precise exporting/importing
is required, one may want to look at Synthetic topologies instead.
Generated by Doxygen
52 Importing and exporting topologies from/to XML files
Generated by Doxygen
Chapter 14
Synthetic topologies
hwloc may load fake or remote topologies so as to consult them without having the underlying hardware available.
Aside from loading XML topologies, hwloc also enables the building of synthetic topologies that are described by a
single string listing the arity of each levels.
For instance, lstopo may create a topology made of 2 packages, containing a single NUMA node and a L2 cache
above two single-threaded cores:
Replacing - with file.xml in this command line will export this topology to XML as usual.
Note
Synthetic topologies offer a very basic way to export a topology and reimport it on another machine. It is a lot
less precise than XML but may still be enough when only the hierarchy of resources matters.
NUMA nodes are handled in a special way since they are not part of the main CPU hierarchy but rather attached
below it as memory children. Thus, NUMANode:3 actually means Group:3 where one NUMA node is attached
below each group. These groups are merged back into the parent when possible (typically when a single NUMA
node is requested below each parent).
It is also possible the explicitly attach NUMA nodes to specific levels. For instance, a topology similar to a Intel Xeon
Phi processor (with 2 NUMA nodes per 16-core group) may be created with:
Generated by Doxygen
54 Synthetic topologies
The root object does not appear in the synthetic description string since it is always a Machine object. Therefore
the Machine type is disallowed in the description as well.
A NUMA level (with a single NUMA node) is automatically added if needed.
Each item may be followed parentheses containing a list of space-separated attributes. For instance:
• L2iCache:2(size=32kB) specifies 2 children of 32kB level-2 instruction caches. The size may be
specified in bytes (without any unit suffix) or as kB, KiB, MB, MiB, etc.
• NUMANode:3(memory=16MB) specifies 3 NUMA nodes with 16MB each. The size may be specified in
bytes (without any unit suffix) or as GB, GiB, TB, TiB, etc.
• PU:2(indexes=0,2,1,3) specifies 2 PU children and the full list of OS indexes among the entire set of
4 PU objects.
• Attributes in parentheses at the very beginning of the description apply to the root object.
hwloc command-line tools may modify a synthetic topology, for instance to customize object attributes, or
to remove some objects to make the topology heterogeneous or asymmetric. See many examples in
How do I create a custom heterogeneous and asymmetric topology?.
The exported string may be passed back to hwloc for recreating another similar topology (see also
Are synthetic strings compatible between hwloc releases?). The entire tree will be similar, but some attributes
such as the processor model will be missing.
Such an export is only possible if the topology is totally symmetric. It means that the symmetric_subtree
field of the root object is set. Also memory children should be attached in a symmetric way (e.g. the same number
of memory children below each Package object, etc.). However, I/O devices and Misc objects are ignored when
looking at symmetry and exporting the string.
Generated by Doxygen
Chapter 15
Although hwloc offers its own portable interface, it still may have to interoperate with specific or non-portable li-
braries that manipulate similar kinds of objects. hwloc therefore offers several specific "helpers" to assist converting
between those specific interfaces and hwloc.
Some external libraries may be specific to a particular OS; others may not always be available. The hwloc core
therefore generally does not explicitly depend on these types of libraries. However, when a custom application uses
or otherwise depends on such a library, it may optionally include the corresponding hwloc helper to extend the hwloc
interface with dedicated helpers.
Most of these helpers use structures that are specific to these external libraries and only meaningful on the local
machine. If so, the helper requires the input topology to match the current machine. Some helpers also require I/O
device discovery to be supported and enabled for the current topology.
Linux specific features hwloc/linux.h offers Linux-specific helpers that utilize some non-portable features of the
Linux system, such as binding threads through their thread ID ("tid") or parsing kernel CPU mask files. See
Linux-specific helpers.
Windows specific features hwloc/windows.h offers Windows-specific helpers to query information about Win-
dows processor groups. See Windows-specific helpers.
Linux libnuma hwloc/linux-libnuma.h provides conversion helpers between hwloc CPU sets and libnuma-specific
types, such as bitmasks. It helps you use libnuma memory-binding functions with hwloc CPU sets. See
Interoperability with Linux libnuma bitmask and Interoperability with Linux libnuma unsigned long masks.
Glibc hwloc/glibc-sched.h offers conversion routines between Glibc and hwloc CPU sets in order to use hwloc with
functions such as sched_getaffinity() or pthread_attr_setaffinity_np(). See Interoperability with glibc sched affinity.
OpenFabrics Verbs hwloc/openfabrics-verbs.h helps interoperability with the OpenFabrics Verbs interface. For
example, it can return a list of processors near an OpenFabrics device. It may also return the cor-
responding OS device hwloc object for further information (if I/O device discovery is enabled). See
Interoperability with OpenFabrics.
OpenCL hwloc/opencl.h enables interoperability with the OpenCL interface. Only the AMD and NVIDIA imple-
mentations currently offer locality information. It may return the list of processors near a GPU given as a
cl_device_id. It may also return the corresponding OS device hwloc object for further information (if I/O
device discovery is enabled). See Interoperability with OpenCL.
oneAPI Level Zero hwloc/levelzero.h enables interoperability with the oneAPI Level Zero interface. It
may return the list of processors near an accelerator or GPU. It may also return the correspond-
ing OS device hwloc object for further information (if I/O device discovery is enabled). See
Interoperability with the oneAPI Level Zero interface..
AMD ROCm SMI Library (RSMI) hwloc/rsmi.h enables interoperability with the AMD ROCm SMI inter-
face. It may return the list of processors near an AMD GPU. It may also return the corre-
sponding OS device hwloc object for further information (if I/O device discovery is enabled). See
Interoperability with the ROCm SMI Management Library.
NVIDIA CUDA hwloc/cuda.h and hwloc/cudart.h enable interoperability with NVIDIA CUDA Driver and Runtime
interfaces. For instance, it may return the list of processors near NVIDIA GPUs. It may also return the
Generated by Doxygen
56 Interoperability With Other Software
corresponding OS device hwloc object for further information (if I/O device discovery is enabled). See
Interoperability with the CUDA Driver API and Interoperability with the CUDA Runtime API.
NVIDIA Management Library (NVML) hwloc/nvml.h enables interoperability with the NVIDIA NVML interface. It
may return the list of processors near a NVIDIA GPU given as a nvmlDevice_t. It may also return
the corresponding OS device hwloc object for further information (if I/O device discovery is enabled). See
Interoperability with the NVIDIA Management Library.
NVIDIA displays hwloc/gl.h enables interoperability with NVIDIA displays using the NV-CONTROL X extension
(NVCtrl library). If I/O device discovery is enabled, it may return the OS device hwloc object that cor-
responds to a display given as a name such as :0.0 or given as a port/device pair (server/screen). See
Interoperability with OpenGL displays.
Taskset command-line tool The taskset command-line tool is widely used for binding processes. It manipulates
CPU set strings in a format that is slightly different from hwloc's one (it does not divide the string in fixed-
size subsets and separates them with commas). To ease interoperability, hwloc offers routines to convert
hwloc CPU sets from/to taskset-specific string format. See for instance hwloc_bitmap_taskset_snprintf() in
The bitmap API.
Most hwloc command-line tools also support the option --cpuset-output-format taskset to ma-
nipulate taskset-specific strings.
Generated by Doxygen
Chapter 16
Thread Safety
Like most libraries that mainly fill data structures, hwloc is not thread safe but rather reentrant: all state is held in a
hwloc_topology_t instance without mutex protection. That means, for example, that two threads can safely operate
on and modify two different hwloc_topology_t instances, but they should not simultaneously invoke functions that
modify the same instance. Similarly, one thread should not modify a hwloc_topology_t instance while another thread
is reading or traversing it. However, two threads can safely read or traverse the same hwloc_topology_t instance
concurrently.
When running in multiprocessor environments, be aware that proper thread synchronization and/or memory co-
herency protection is needed to pass hwloc data (such as hwloc_topology_t pointers) from one processor to another
(e.g., a mutex, semaphore, or a memory barrier). Note that this is not a hwloc-specific requirement, but it is worth
mentioning.
For reference, hwloc_topology_t modification operations include (but may not be limited to):
Consulting distances hwloc_distances_get() and its variants are thread-safe except if the topology was
recently modified (because distances may involve objects that were removed).
Whenever the topology is modified (see above), hwloc_topology_refresh() should be called
in the same thread-safe context to force the refresh of internal distances structures. A call to
hwloc_distances_get() may also refresh distances-related structures.
Once this refresh has been performed, multiple hwloc_distances_get() may then be performed con-
currently by multiple threads.
Consulting memory attributes Functions consulting memory attributes in hwloc/memattrs.h are thread-safe ex-
cept if the topology was recently modified (because memory attributes may involve objects that were re-
moved).
Whenever the topology is modified (see above), hwloc_topology_refresh() should be called in
the same thread-safe context to force the refresh of internal memory attribute structures. A call to
Generated by Doxygen
58 Thread Safety
Locating topologies hwloc_topology_set_∗ (see Topology Detection Configuration and Query) do not
modify the topology directly, but they do modify internal structures describing the behavior of the upcoming
invocation of hwloc_topology_load(). Hence, all of these functions should not be used concurrently.
Generated by Doxygen
Chapter 17
hwloc is organized in components that are responsible for discovering objects. Depending on the topology config-
uration, some components will be used (once enabled, they create a backend), some will be ignored.
The usual default is to enable the native operating system component, (e.g. linux or solaris) and the pci one.
If available, an architecture-specific component (such as x86) may also improve the topology detection. Finally,
some hardware-specific components (such as cuda or rsmi) may add information about GPUs, accelerators, etc.
If a XML topology is loaded, the xml discovery component will be used instead of all other components.
Generated by Doxygen
60 Components and plugins
instead of only completing what the native OS information. This may be useful if the native component is buggy on
some platforms.
It is possible to prevent some components from being loaded by prefixing their name with - in the list. For instance
x86,-pci will load the x86 component, then let hwloc load all the usual components except pci. A single
component phase may also be blacklisted, for instance with -linux:io.
It is possible to prevent all remaining components from being loaded by placing stop in the environment variable.
Only the components listed before this keyword will be enabled.
hwloc_topology_set_components() may also be used inside the program to prevent the loading of a specific com-
ponent (or phases) for the target topology.
linux The official component for discovering CPU, memory and I/O devices on Linux. It discovers PCI devices
without the help of external libraries such as libpciaccess, but requires the pci component for adding ven-
dor/device names to PCI objects. It also discovers many kinds of Linux-specific OS devices.
aix, darwin, freebsd, hpux, netbsd, solaris, windows Each officially supported operating system has its own
native component, which is statically built when supported, and which is used by default.
x86 The x86 architecture (either 32 or 64 bits) has its own component that may complete or replace the previously-
found CPU information. It is statically built when supported.
bgq This component is specific to IBM BlueGene/Q compute node (running CNK). It is built and enabled by default
when --host=powerpc64-bgq-linux is passed to configure (see How do I build hwloc for BlueGene/Q?).
no_os A basic component that just tries to detect the number of processing units in the system. It mostly serves
on operating systems that are not natively supported. It is always statically built.
pci PCI object discovery uses the external libpciaccess library; see I/O Devices. It may also annotate existing PCI
devices with vendor and device names. It may be built as a plugin.
opencl The OpenCL component creates co-processor OS device objects such as opencl0d0 (first device of the
first OpenCL platform) or opencl1d3 (fourth device of the second platform). Only the AMD and NVIDIA
OpenCL implementations currently offer locality information. It may be built as a plugin.
rsmi This component creates GPU OS device objects such as rsmi0 for describing AMD GPUs. It may be built
as a plugin.
levelzero This component creates co-processor OS device objects such as ze0 for describing oneAPI Level Zero
devices. It may also create sub-OS-devices such as ze0.0 inside those devices. It may be built as a plugin.
Generated by Doxygen
17.4 Existing components and plugins 61
cuda This component creates co-processor OS device objects such as cuda0 that correspond to NVIDIA GPUs
used with CUDA library. It may be built as a plugin.
nvml Probing the NVIDIA Management Library creates OS device objects such as nvml0 that are useful for batch
schedulers. It also detects the actual PCIe link bandwidth without depending on power management state
and without requiring administrator privileges. It may be built as a plugin.
gl Probing the NV-CONTROL X extension (NVCtrl library) creates OS device objects such as :0.0 corresponding
to NVIDIA displays. They are useful for graphical applications that need to place computation and/or data
near a rendering GPU. It may be built as a plugin.
synthetic Synthetic topology support (see Synthetic topologies) is always built statically.
xml XML topology import (see Importing and exporting topologies from/to XML files) is always built stati-
cally. It internally uses a specific class of components for the actual XML import/export routines (see
libxml2 and minimalistic XML backends for details).
fake A dummy plugin that does nothing but is used for debugging plugin support.
Generated by Doxygen
62 Components and plugins
Generated by Doxygen
Chapter 18
It can be desirable to include hwloc in a larger software package (be sure to check out the LICENSE file) so that
users don't have to separately download and install it before installing your software. This can be advantageous to
ensure that your software uses a known-tested/good version of hwloc, or for use on systems that do not have hwloc
pre-installed.
When used in "embedded" mode, hwloc will:
There are two ways to put hwloc into "embedded" mode. The first is directly from the configure command line:
The second requires that your software project uses the GNU Autoconf / Automake / Libtool tool chain to build your
software. If you do this, you can directly integrate hwloc's m4 configure macro into your configure script. You can
then invoke hwloc's configuration tests and build setup by calling a m4 macro (see below).
Although hwloc dynamic shared object plugins may be used in embedded mode, the embedder project will have to
manually setup dlopen or libltdl in its build system so that hwloc can load its plugins at run time. Also, embedders
should be aware of complications that can arise due to public and private linker namespaces (e.g., if the embedder
project is loaded into a private namespace and then hwloc tries to dynamically load its plugins, such loading may
fail since the hwloc plugins can't find the hwloc symbols they need). The embedder project is strongly advised not
to use hwloc's dynamically loading plugins / dlopen / libltdl capability.
Generated by Doxygen
64 Embedding hwloc in Other Software
embedded hwloc is located in the source tree at contrib/hwloc, you should pass [contrib/hwloc] as
the first argument. If HWLOC_SETUP_CORE and the rest of configure completes successfully, then
"make" traversals of the hwloc tree with standard Automake targets (all, clean, install, etc.) should behave
as expected. For example, it is safe to list the hwloc directory in the SUBDIRS of a higher-level Makefile.am.
The last argument, if not empty, will cause the macro to display an announcement banner that it is starting
the hwloc core configuration tests.
HWLOC_SETUP_CORE will set the following environment variables and AC_SUBST them: HWLOC_←-
EMBEDDED_CFLAGS, HWLOC_EMBEDDED_CPPFLAGS, and HWLOC_EMBEDDED_LIBS. These flags
are filled with the values discovered in the hwloc-specific m4 tests, and can be used in your build process as
relevant. The _CFLAGS, _CPPFLAGS, and _LIBS variables are necessary to build libhwloc (or libhwloc_←-
embedded) itself.
HWLOC_SETUP_CORE also sets HWLOC_EMBEDDED_LDADD environment variable (and AC_SUBSTs
it) to contain the location of the libhwloc_embedded.la convenience Libtool archive. It can be used in your
build process to link an application or other library against the embedded hwloc library.
NOTE: If the HWLOC_SET_SYMBOL_PREFIX macro is used, it must be invoked before HWLOC_←-
SETUP_CORE.
• HWLOC_SET_SYMBOL_PREFIX(foo_): Tells the hwloc to prefix all of hwloc's types and public symbols
with "foo_"; meaning that function hwloc_init() becomes foo_hwloc_init(). Enum values are prefixed with an
upper-case translation if the prefix supplied; HWLOC_OBJ_CORE becomes FOO_hwloc_OBJ_CORE. This
is recommended behavior if you are including hwloc in middleware – it is possible that your software will be
combined with other software that links to another copy of hwloc. If both uses of hwloc utilize different symbol
prefixes, there will be no type/symbol clashes, and everything will compile, link, and run successfully. If you
both embed hwloc without changing the symbol prefix and also link against an external hwloc, you may get
multiple symbol definitions when linking your final library or application.
• HWLOC_DO_AM_CONDITIONALS: If you embed hwloc in a larger project and build it conditionally with Au-
tomake (e.g., if HWLOC_SETUP_CORE is invoked conditionally), you must unconditionally invoke HWLOC←-
_DO_AM_CONDITIONALS to avoid warnings from Automake (for the cases where hwloc is not selected to
be built). This macro is necessary because hwloc uses some AM_CONDITIONALs to build itself, and AM←-
_CONDITIONALs cannot be defined conditionally. Note that it is safe (but unnecessary) to call HWLOC←-
_DO_AM_CONDITIONALS even if HWLOC_SETUP_CORE is invoked unconditionally. If you are not using
Automake to build hwloc, this macro is unnecessary (and will actually cause errors because it invoked AM_∗
macros that will be undefined).
NOTE: When using the HWLOC_SETUP_CORE m4 macro, it may be necessary to explicitly invoke AC_←-
CANONICAL_TARGET (which requires config.sub and config.guess) and/or AC_USE_SYSTEM_EXTENSIONS
macros early in the configure script (e.g., after AC_INIT but before AM_INIT_AUTOMAKE). See the Autoconf doc-
umentation for further information.
Also note that hwloc's top-level configure.ac script uses exactly the macros described above to build hwloc in a
standalone mode (by default). You may want to examine it for one example of how these macros are used.
Generated by Doxygen
18.2 Example Embedding hwloc 65
Now you can bootstrap, configure, build, and run the sandbox as normal – all calls to "sandbox_hwloc_∗" will use
the embedded hwloc rather than any system-provided copy of hwloc.
Generated by Doxygen
66 Embedding hwloc in Other Software
Generated by Doxygen
Chapter 19
19.1 Concepts
19.1.1 I only need binding, or the number of cores, why should I use hwloc ?
hwloc is its portable API that works on a variety of operating systems. It supports binding of threads, processes
and memory buffers (see CPU binding and Memory binding). Even if some features are not supported on some
systems, using hwloc is much easier than reimplementing your own portability layer.
Moreover, hwloc provides knowledge of cores and hardware threads. It offers easy ways to bind tasks to individual
hardware threads, or to entire multithreaded cores, etc. See How may I ignore symmetric multithreading, hyper-threading, etc. in hwloc
Most alternative software for binding do not even know whether each core is single-threaded, multithreaded or
hyper-threaded. They would bind to individual threads without any way to know whether multiple tasks are in the
same physical core.
However, using hwloc comes with an overhead since a topology must be loaded before gathering information
and binding tasks or memory. Fortunately this overhead may be significantly reduced by filtering non-interesting
information out of the topology, see What may I disable to make hwloc faster? below.
The following code tells hwloc to build a much smaller topology that only contains Cores (explicitly filtered-in below),
hardware threads (PUs, cannot be filtered-out), NUMA nodes (cannot be filtered-out), and the root object (usually a
Machine; the root cannot be removed without breaking the tree):
hwloc_topology_t topology;
hwloc_topology_init(&topology);
/* filter everything out */
hwloc_topology_set_all_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_NONE);
/* filter Cores back in */
hwloc_topology_set_type_filter(topology, HWLOC_OBJ_CORE, HWLOC_TYPE_FILTER_KEEP_ALL);
hwloc_topology_load(topology);
However, one should remember that filtering such objects out removes locality information from the hwloc tree. For
instance, we may not know anymore which PU is close to which NUMA node. This would be useful to applications
that explicitly want to place specific memory buffers close to specific tasks. To ignore useless objects but keep
those that bring locality/hierarchy information, applications may replace HWLOC_TYPE_FILTER_KEEP_NONE with
HWLOC_TYPE_FILTER_KEEP_STRUCTURE above.
Starting with hwloc 2.8, it is also possible to ignore distances between objects, memory performance attributes, and
Generated by Doxygen
68 Frequently Asked Questions (FAQ)
[...]
/* disable distances, memory attributes and CPU kinds */
hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_NO_DISTANCES
|HWLOC_TOPOLOGY_FLAG_NO_MEMATTRS
|HWLOC_TOPOLOGY_FLAG_NO_CPUKINDS);
[...]
hwloc_topology_load(topology);
Finally it is possible to prevent some hwloc components from being loaded and queried. If you are sure that
the Linux (or x86) component is enough to discover everything you need, you may ask hwloc to disable all
other components by setting something like HWLOC_COMPONENTS=linux,stop in the environment. See
Components and plugins for details.
Generated by Doxygen
19.1 Concepts 69
19.1.5 hwloc only has a one-dimensional view of the architecture, it ignores distances?
hwloc places all objects in a tree. Each level is a one-dimensional view of a set of similar objects. All children of the
same object (siblings) are assumed to be equally interconnected (same distance between any of them), while the
distance between children of different objects (cousins) is supposed to be larger.
Modern machines exhibit complex hardware interconnects, so this tree may miss some information about the actual
physical distances between objects. The hwloc topology may therefore be annotated with distance information that
may be used to build a more realistic representation (multi-dimensional) of each level. For instance, there can be
a distance matrix that representing the latencies between any pair of NUMA nodes if the BIOS and/or operating
system reports them.
For more information about the hwloc distances, see Distances.
• NUMA parents when memory locality does not match any existing object.
• I/O parents when I/O locality does not match any existing object.
• AMD Core Complex (CCX) (subtype is Complex, in the x86 backend), but these objects are usually
merged with the L3 caches or Dies.
• AMD Bulldozer dual-core compute units (subtype is ComputeUnit, in the x86 backend), but these ob-
jects are usually merged with the L2 caches.
• Linux Clusters of CPUs (subtype is Cluster), for instance for ARM cores sharing of some internal cache
or bus, or x86 cores sharing a L2 cache (since Linux kernel 5.16). HWLOC_DONT_MERGE_CLUSTER_←-
GROUPS=1 may be set in the environment to disable the automerging of these groups with identical caches,
etc.
hwloc Groups are only kept if no other object has the same locality information. It means that a Group containing
a single child is merged into that child. And a Group is merged into its parent if it is its only child. For instance a
Windows processor group containing a single NUMA node would be merged with that NUMA node since it already
contains the relevant hierarchy information.
When inserting a custom Group with hwloc_hwloc_topology_insert_group_object(), this merging may be disabled
by setting its dont_merge attribute.
• Intermediate groups may added for I/O affinity: on a 4-package machine, an I/O bus may be connected to 2
packages. These packages are below an additional Group object, while the other packages are not (see also
What are these Group objects in my topology?).
Generated by Doxygen
70 Frequently Asked Questions (FAQ)
• If only part of a node is available to the current process, for instance because the resource manager uses
Linux Cgroups to restrict process resources, some cores (or NUMA nodes) will disappear from the topology
(unless flag HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED was passed). On a 32-core machine
where 12 cores were allocated to the process, this may lead to one CPU package with 8 cores, another one
with only 4 cores, and two missing packages.
To understand how hwloc manages such cases, one should first remember the meaning of levels and cousin objects.
All objects of the same type are gathered as horizontal levels with a given depth. They are also connected through
the cousin pointers of the hwloc_obj structure. Object attribute (cache depth and type, group depth) are also taken
in account when gathering objects as horizontal levels. To be clear: there will be one level for L1i caches, another
level for L1d caches, another one for L2, etc.
If the topology is asymmetric (e.g., if a group is missing above some processors), a given horizontal level will still
exist if there exist any objects of that type. However, some branches of the overall tree may not have an object
located in that horizontal level. Note that this specific hole within one horizontal level does not imply anything for
other levels. All objects of the same type are gathered in horizontal levels even if their parents or children have
different depths and types.
See the diagram in Terms and Definitions for a graphical representation of such topologies.
Moreover, it is important to understand that a same parent object may have children of different types (and therefore,
different depths). These children are therefore siblings (because they have the same parent), but they are
not cousins (because they do not belong to the same horizontal level).
x86 machines usually offer the ability to disable hyper-threading in the BIOS. Or it can be disabled on the Linux
kernel command-line at boot time, or later by writing in sysfs virtual files.
If you do so, the hwloc topology structure does not significantly change, but some PU objects will not appear
anymore. No level will disappear, you will see the same number of Core objects, but each of them will contain a
single PU now. The PU level does not disappear either (remember that hwloc topologies always contain a PU level
at the bottom of the topology) even if there is a single PU object per Core parent.
$ lstopo -
...
Core L#0
PU L#0 (P#0)
Core L#1
PU L#1 (P#1)
Generated by Doxygen
19.2 Advanced 71
Whenever you want to bind a process or thread to a core, make sure you singlify its cpuset first, so that the task is
actually bound to a single thread within this core (to avoid useless migrations).
/* bind on the second core */
hwloc_obj_t core = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 1);
hwloc_cpuset_t set = hwloc_bitmap_dup(core->cpuset);
hwloc_bitmap_singlify(set);
hwloc_set_cpubind(topology, set, 0);
hwloc_bitmap_free(set);
With hwloc-calc or hwloc-bind command-line tools, you may specify that you only want a single-thread within each
core by asking for their first PU object:
$ hwloc-calc core:4-7
0x0000ff00
$ hwloc-calc core:4-7.pu:0
0x00005500
When binding a process on the command-line, you may either specify the exact thread that you want to use, or ask
hwloc-bind to singlify the cpuset before binding
$ hwloc-bind core:3.pu:0 -- echo "hello from first thread on core #3"
hello from first thread on core #3
...
$ hwloc-bind core:3 --single -- echo "hello from a single thread on core #3"
hello from a single thread on core #3
19.2 Advanced
19.2.1 I do not want hwloc to rediscover my enormous machine topology every time I
rerun a process
Although the topology discovery is not expensive on common machines, its overhead may become significant when
multiple processes repeat the discovery on large machines (for instance when starting one process per core in a
parallel application). The machine topology usually does not vary much, except if some cores are stopped/restarted
or if the administrator restrictions are modified. Thus rediscovering the whole topology again and again may look
useless.
For this purpose, hwloc offers XML import/export and shared memory features.
XML lets you save the discovered topology to a file (for instance with the lstopo program) and reload it later by setting
the HWLOC_XMLFILE environment variable. The HWLOC_THISSYSTEM environment variable should also be set
to 1 to assert that loaded file is really the underlying system.
Loading a XML topology is usually much faster than querying multiple files or calling multiple functions of the
operating system. It is also possible to manipulate such XML files with the C programming interface, and the
import/export may also be directed to memory buffer (that may for instance be transmitted between applications
through a package). See also Importing and exporting topologies from/to XML files.
Note
Generated by Doxygen
72 Frequently Asked Questions (FAQ)
19.2.3 How to avoid memory waste when manipulating multiple similar topologies?
hwloc does not share information between topologies. If multiple similar topologies are loaded in memory, for
instance the topologies of different identical nodes of a cluster, lots of information will be duplicated.
hwloc/diff.h (see also Topology differences) offers the ability to compute topology differences, apply or unapply them,
or export/import to/from XML. However, this feature is limited to basic differences such as attribute changes. It does
not support complex modifications such as adding or removing some objects.
Assuming we want two packages, one with 4 dual-threaded cores, and one with 8 single-threaded cores, first we
create a topology with two identical packages, each with 8 dual-threaded cores:
Then create the bitmask representing the PUs that we wish to keep and pass it to lstopo's restrict option:
To mark the cores of first package as Big (power hungry) and those of second package as Little (energy efficient),
define CPU kinds:
$ hwloc-annotate topo.xml topo.xml -- none -- cpukind $(hwloc-calc -i topo.xml pack:0) 1 0 CoreType Big
$ hwloc-annotate topo.xml topo.xml -- none -- cpukind $(hwloc-calc -i topo.xml pack:1) 0 0 CoreType Little
A similar method may be used for heterogeneous memory. First we specify 2 NUMA nodes per package in our
synthetic description:
Generated by Doxygen
19.3 Caveats 73
Next we may specify that the small NUMA node (second of second package) is HBM while the large ones are
DRAM:
Finally we may define memory performance attributes to specify that the HBM bandwidth (200GB/s) from local cores
is higher than the DRAM bandwidth (50GB/s):
There is currently no way to create or modify I/O devices attached to such fake topologies. There is also no way to
have some partial levels, e.g. a L3 cache in one package but not in the other.
More changes may obviously be performed by manually modifying the XML export file. Simple operations such as
modifying object attributes (cache size, memory size, name-value info attributes, etc.), moving I/O subtrees, moving
Misc objects, or removing objects are easy to perform.
However, modifying CPU and Memory objects requires care since cpusets and nodesets are supposed to remain
consistent between parents and children. Similarly, PCI bus IDs should remain consistent between bridges and
children within an I/O subtree.
19.3 Caveats
19.3.1 Why is lstopo slow?
lstopo enables most hwloc objects and discovery flags by default so that the output topology is as precise as possible
(while hwloc disables many of them by default). This includes I/O device discovery through PCI libraries as well
as external libraries such as NVML. To speed up lstopo, you may disable such features with command-line options
such as --no-io.
When NVIDIA GPU probing is enabled (e.g. with CUDA or NVML), one may enable the Persistent mode (with
nvidia-smi -pm 1) to avoid significant GPU wakeup and initialization overhead.
When AMD GPU discovery is enabled with OpenCL and hwloc is used remotely over ssh, some spurious round-
trips on the network may significantly increase the discovery time. Forcing the DISPLAY environment variable to
the remote X server display (usually :0) instead of only setting the COMPUTE variable may avoid this.
Also remember that these hwloc components may be disabled. At build-time, one may pass configure
flags such as --disable-opencl, --disable-cuda, --disable-nvml, --disable-rsmi, and
--disable-levelzero. At runtime, one may set the environment variable HWLOC_COMPONENTS=-opencl,-cuda,-nvml
or call hwloc_topology_set_components().
Remember that these backends are disabled by default, except in lstopo. If hwloc itself is still too slow even after
disabling all the I/O devices as explained above, see also What may I disable to make hwloc faster? for disabling
even more features.
Generated by Doxygen
74 Frequently Asked Questions (FAQ)
discovery on Solaris and BSDs requires access to some special files that are usually restricted to root (/dev/pci∗ or
/devices/pci∗).
To workaround this limitation, it is recommended to export the topology as a XML file generated by the administrator
(with the lstopo program) and make it available to all users (see Importing and exporting topologies from/to XML files).
It will offer all discovery information to any application without requiring any privileged access anymore. Only the
necessary hardware characteristics will be exported, no sensitive information will be disclosed through this XML
export.
This XML-based model also has the advantage of speeding up the discovery because reading a XML topology is
usually much faster than querying the operating system again.
The utility hwloc-dump-hwdata is also involved in gathering privileged information at boot time and making it
available to non-privileged users (note that this may require a specific SELinux MLS policy module). However, it only
applies to Intel Xeon Phi processors for now (see Why do I need hwloc-dump-hwdata for memory on Intel Xeon Phi processor?).
See also HWLOC_DUMPED_HWDATA_DIR in Environment Variables for details about the location of dumped files.
****************************************************************************
* hwloc received invalid information from the operating system.
*
* L3 (cpuset 0x000003f0) intersects with NUMANode (P#0 cpuset 0x0000003f) without inclusion!
* Error occurred in topology.c line 940
*
* Please report this error message to the hwloc user’s mailing list,
* along with the files generated by the hwloc-gather-topology script.
*
* hwloc will now ignore this invalid topology information and continue.
****************************************************************************
These errors are common on large AMD platforms because of BIOS and/or Linux kernel bugs causing invalid L3
cache information. In the above example, the hardware reports a L3 cache that is shared by 2 cores in the first
NUMA node and 4 cores in the second NUMA node. That's wrong, it should actually be shared by all 6 cores in a
single NUMA node. The resulting topology will miss some L3 caches.
If your application does not care about cache sharing, or if you do not plan to request cache-aware binding in
your process launcher, you may likely ignore this error (and hide it by setting HWLOC_HIDE_ERRORS=1 in your
environment).
Some platforms report similar warnings about conflicting Packages and NUMANodes.
On x86 hosts, passing HWLOC_COMPONENTS=x86 in the environment may workaround some of these issues by
switching to a different way to discover the topology.
Upgrading the BIOS and/or the operating system may help. Otherwise, as explained in the message, reporting this
issue to the hwloc developers (by sending the tarball that is generated by the hwloc-gather-topology script on this
platform) is a good way to make sure that this is a software (operating system) or hardware bug (BIOS, etc).
See also Questions and Bugs. Opening an issue on GitHub automatically displays hints on what information you
should provide when reporting such bugs.
--suppressions=/path/to/hwloc-valgrind.supp
Generated by Doxygen
19.4 Platform-specific 75
19.4 Platform-specific
19.4.1 How do I enable ROCm SMI and select which version to use?
hwloc enables ROCm SMI as soon as it finds its development headers and libraries on the system.
This detection consists in looking in /opt/rocm by default. If a ROCm version was specified with
--with-rocm-version=4.4.0 or in the ROCM_VERSION environment variable, then /opt/rocm-<version>
is used instead. Finally, a specific installation path may be specified with --with-rocm=/path/to/rocm.
As usual, developer header and library paths may also be set through environment variables such as LIBRARY←-
_PATH and C_INCLUDE_PATH.
To find out whether ROCm SMI was detected and enabled, look in Probe / display I/O devices at the end of the
configure script output. Passing --enable-rsmi will also cause configure to fail if RSMI could not be found and
enabled in hwloc.
19.4.2 How do I enable CUDA and select which CUDA version to use?
hwloc enables CUDA as soon as it finds CUDA development headers and libraries on the system. This detection
may be performed thanks to pkg-config but it requires hwloc to know which CUDA version to look for. This may
be done by passing --with-cuda-version=11.0 to the configure script. Otherwise hwloc will also look for
the CUDA_VERSION environment variable.
If pkg-config does not work, passing --with-cuda=/path/to/cuda to the configure script is another
way to define the corresponding library and header paths. Finally, these paths may also be set through environment
variables such as LIBRARY_PATH and C_INCLUDE_PATH.
These paths, either detected by pkg-config or given manually, will also be used to detect NVML and OpenCL
libraries and enable their hwloc backends.
To find out whether CUDA was detected and enabled, look in Probe / display I/O devices at the end of the configure
script output. Passing --enable-cuda will also cause configure to fail if CUDA could not be found and enabled
in hwloc.
Note that --with-cuda=/nonexisting may be used to disable all dependencies that are installed by CUDA,
i.e. the CUDA, NVML and NVIDIA OpenCL backends, since the given directory does not exist.
19.4.3 How do I find the local MCDRAM NUMA node on Intel Xeon Phi processor?
Intel Xeon Phi processors introduced a new memory architecture by possibly having two distinct local memories←-
: some normal memory (DDR) and some high-bandwidth on-package memory (MCDRAM). Processors can
be configured in various clustering modes to have up to 4 Clusters. Moreover, each Cluster (quarter, half or
whole processor) of the processor may have its own local parts of the DDR and of the MCDRAM. This mem-
ory and clustering configuration may be probed by looking at MemoryMode and ClusterMode attributes, see
Hardware Platform Information and doc/examples/get-knl-modes.c in the source directory.
Starting with version 2.0, hwloc properly exposes this memory configuration. DDR and MCDRAM are attached as
two memory children of the same parent, DDR first, and MCDRAM second if any. Depending on the processor
configuration, that parent may be a Package, a Cache, or a Group object of type Cluster.
Hence cores may have one or two local NUMA nodes, listed by the core nodeset. An application may allocate local
memory from a core by using that nodeset. The operating system will actually allocate from the DDR when possible,
or fallback to the MCDRAM.
To allocate specifically on one of these memories, one should walk up the parent pointers until finding an object with
some memory children. Looking at these memory children will give the DDR first, then the MCDRAM if any. Their
nodeset may then be used for allocating or binding memory buffers.
One may also traverse the list of NUMA nodes until finding some whose cpuset matches the target core or PUs.
The MCDRAM NUMA nodes may be identified thanks to the subtype field which is set to MCDRAM.
Command-line tools such as hwloc-bind may bind memory on the MCDRAM by using the hbm keyword. For
instance, to bind on the first MCDRAM NUMA node:
$ hwloc-bind --membind --hbm numa:0 -- myprogram
$ hwloc-bind --membind numa:0 -- myprogram
19.4.4 Why do I need hwloc-dump-hwdata for memory on Intel Xeon Phi processor?
Intel Xeon Phi processors may use the on-package memory (MCDRAM) as either memory or a memory-side cache
(reported as a L3 cache by hwloc by default, see HWLOC_KNL_MSCACHE_L3 in Environment Variables). There
Generated by Doxygen
76 Frequently Asked Questions (FAQ)
are also several clustering modes that significantly affect the memory organization (see How do I find the local MCDRAM NUMA node
for more information about these modes). Details about these are currently only available to privileged users. With-
out them, hwloc relies on a heuristic for guessing the modes.
The hwloc-dump-hwdata utility may be used to dump this privileged binary information into human-readable and
world-accessible files that the hwloc library will later load. The utility should usually run as root once during boot,
in order to update dumped information (stored under /var/run/hwloc by default) in case the MCDRAM or clustering
configuration changed between reboots.
When SELinux MLS policy is enabled, a specific hwloc policy module may be required so that all users get access to
the dumped files (in /var/run/hwloc by default). One may use hwloc policy files from the SELinux Reference Policy at
https://github.com/TresysTechnology/refpolicy-contrib (see also the documentation at
https://github.com/TresysTechnology/refpolicy/wiki/GettingStarted).
hwloc-dump-hwdata requires dmi-sysfs kernel module loaded.
The utility is currently unneeded on platforms without Intel Xeon Phi processors.
See HWLOC_DUMPED_HWDATA_DIR in Environment Variables for details about the location of dumped files.
CPPFLAGS may have to be updated if your platform headers are installed in a different directory.
• hwloc also supports such Unix-like builds in Cygwin (environment for porting Unix code to Windows).
• Windows build is also possible with CMake (CMakeLists.txt available under contrib/windows-cmake/).
• hwloc also comes with an example of Microsoft Visual Studio solution (under contrib/windows/)
that may serve as a base for custom builds.
Generated by Doxygen
19.5 Compatibility between hwloc versions 77
#include <hwloc.h>
#if HWLOC_API_VERSION >= 0x00020000
...
#endif
To check for the API of release X.Y.Z at build time, you may compare HWLOC_API_VERSION with
(X<<16)+(Y<<8)+Z.
For supporting older releases that do not have HWLOC_OBJ_NUMANODE and HWLOC_OBJ_PACKAGE yet, you
may use:
#include <hwloc.h>
#if HWLOC_API_VERSION < 0x00010b00
#define HWLOC_OBJ_NUMANODE HWLOC_OBJ_NODE
#define HWLOC_OBJ_PACKAGE HWLOC_OBJ_SOCKET
#endif
Once a program is built against a hwloc library, it may also dynamically link with compatible libraries from other
hwloc releases. The version of that runtime library may be queried with hwloc_get_api_version(). For instance, the
following code enables the topology flag HWLOC_TOPOLOGY_FLAG_NO_DISTANCES when compiling on hwloc
2.8 or later, but it disables it at runtime if running on an older hwloc (otherwise hwloc_topology_set_flags() would
fail).
unsigned long topology_flags = ...; /* wanted flags that were supported before 2.8 */
#if HWLOC_API_VERSION >= 0x20800
if (hwloc_get_api_version() >= 0x20800)
topology_flags |= HWLOC_TOPOLOGY_FLAG_NO_DISTANCES; /* wanted flags only supported in 2.8+ */
#endif
hwloc_topology_set_flags(topology, topology_flags);
See also How do I handle ABI breaks? for using hwloc_get_api_version() for testing ABI compatibility.
19.5.2 What is the difference between API and library version numbers?
HWLOC_API_VERSION is the version of the API. It changes when functions are added, modified, etc. However it
does not necessarily change from one release to another. For instance, two releases of the same series (e.g. 2.0.3
and 2.0.4) usually have the same HWLOC_API_VERSION (0x00020000). However their HWLOC_VERSION
strings are different ("2.0.3" and "2.0.4" respectively).
#include <hwloc.h>
unsigned version = hwloc_get_api_version();
if ((version >> 16) != (HWLOC_API_VERSION >> 16)) {
fprintf(stderr,
"%s compiled for hwloc API 0x%x but running on library API 0x%x.\n"
"You may need to point LD_LIBRARY_PATH to the right hwloc library.\n"
"Aborting since the new ABI is not backward compatible.\n",
callname, HWLOC_API_VERSION, version);
exit(EXIT_FAILURE);
}
Generated by Doxygen
78 Frequently Asked Questions (FAQ)
#include <hwloc.h>
#if HWLOC_API_VERSION >= 0x00020000
/* headers are recent */
if (hwloc_get_api_version() < 0x20000)
... error out, the hwloc runtime library is older than 2.0 ...
#else
/* headers are pre-2.0 */
if (hwloc_get_api_version() >= 0x20000)
... error out, the hwloc runtime library is more recent than 2.0 ...
#endif
In theory, library sonames prevent linking with incompatible libraries. However custom hwloc installations or improp-
erly configured build environments may still lead to such issues. Hence running one of the above (cheap) checks
before initializing hwloc topology may be useful.
Generated by Doxygen
Chapter 20
See Compatibility between hwloc versions for detecting the hwloc version that you are compiling and/or running
against.
20.1.2 Examples
• a UMA machine with 2 packages and a single NUMA node is now modeled as a "Machine" object with two
"Package" children and one "NUMANode" memory children (displayed first in lstopo below):
• a machine with 2 packages with one NUMA node and 2 cores in each is now:
• if there are two NUMA nodes per package, a Group object may be added to keep cores together with their
local NUMA node:
Generated by Doxygen
80 Upgrading to the hwloc 2.0 API
• if the platform has L3 caches whose localities are identical to NUMA nodes, Groups aren't needed:
The NUMA depth should not be compared with others. An unmodified code that still compares NUMA and Package
depths (to find out whether Packages contain NUMA or the contrary) would now always assume Packages contain
NUMA (because the NUMA depth is negative).
However, the depth of the Normal parents of NUMA nodes may be used instead. In the last example above, NUMA
nodes are attached to L3 caches, hence one may compare the depth of Packages and L3 to find out that NUMA
nodes are contained in Packages. This depth of parents may be retrieved with hwloc_get_memory_parents_depth().
However, this function may return HWLOC_TYPE_DEPTH_MULTIPLE on future platforms if NUMA nodes are at-
tached to different levels.
20.1.4 Finding Local NUMA nodes and looking at Children and Parents
Applications that walked up/down to find NUMANode parent/children must now be updated. Instead of looking
directly for a NUMA node, one should now look for an object that has some memory children. NUMA node(s) will
be attached there. For instance, when looking for a NUMA node above a given core core:
The list of local NUMA nodes (usually a single one) is also described by the nodeset attribute of each object
(which contains the physical indexes of these nodes). Iterating over the NUMA level is also an easy way to find local
NUMA nodes:
Generated by Doxygen
20.2 4 Kinds of Objects and Children 81
if (hwloc_bitmap_isset(obj->nodeset, tmp->os_index))
/* tmp is a NUMA node local to obj, use it */
}
Similarly finding objects that are close to a given NUMA nodes should be updated too. Instead of looking at the
NUMA node parents/children, one should now find a Normal parent above that NUMA node, and then look at its
parents/children as usual:
hwloc_obj_t tmp = obj->parent;
while (hwloc_obj_type_is_memory(tmp))
tmp = tmp->parent;
/* now use tmp instead of obj */
To avoid such hwloc v2.x-specific and NUMA-specific cases in the code, a generic lookup for any kind of object,
including NUMA nodes, might also be implemented by iterating over a level. For instance finding an object of type
type which either contains or is included in object obj can be performed by traversing the level of that type and
comparing CPU sets:
hwloc_obj_t tmp = NULL;
while ((tmp = hwloc_get_next_obj_by_type(topology, type, tmp)) != NULL) {
if (hwloc_bitmap_intersects(tmp->cpuset, obj->cpuset))
/* tmp matches, use it */
}
This generic lookup works whenever type or obj are Normal or Memory objects since both have CPU
sets. Moreover, it is compatible with the hwloc v1.x API.
• Memory (currently NUMA nodes or Memory-side Caches), attached to parents as Memory children;
Generated by Doxygen
82 Upgrading to the hwloc 2.0 API
hwloc_bitmap_intersects(obj->cpuset, hwloc_topology_get_allowed_cpuset(topology))
Replace cpusets with nodesets for NUMA nodes. To find out which ones, replace intersects() with and() to get the
actual intersection.
Also, the meaning of KEEP_STRUCTURE has changed (only entire levels may be ignored, instead of single
objects), the old behavior is not available anymore.
• HWLOC_TOPOLOGY_FLAG_ICACHES is superseded by
hwloc_topology_set_icache_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_ALL);
hwloc_topology_set_io_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_ALL);
To only keep important devices (Bridges with children, common PCI devices and OS devices):
hwloc_topology_set_io_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_IMPORTANT);
Generated by Doxygen
20.8 XML changes 83
• When the importer uses hwloc 1.x, export with HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1. Otherwise
the importer will fail to import.
• When the exporter uses hwloc 1.x, it cannot pass any flag, and a 2.0 importer can import without problem.
#if HWLOC_API_VERSION >= 0x20000
if (need 1.x compatible XML export)
hwloc_topology_export_xml(...., HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1);
else /* need 2.x compatible XML export */
hwloc_topology_export_xml(...., 0);
#else
hwloc_topology_export_xml(....);
#endif
• hwloc_type_sscanf_as_depth() is also added to directly return the corresponding level depth within a topol-
ogy.
Generated by Doxygen
84 Upgrading to the hwloc 2.0 API
• _membind_nodeset() memory binding interfaces deprecated: One should use the variant without _nodeset
suffix and pass the HWLOC_MEMBIND_BYNODESET flag.
• hwloc_cpuset_from/to_nodeset_strict() deprecated: Now useless since all topologies are NUMA. Use the
variant without the _strict suffix
• The Custom interface (hwloc_topology_set_custom(), etc.) was removed, as well as the corresponding
command-line tools (hwloc-assembler, etc.). Topologies always start with object with valid cpusets and node-
sets.
• obj->online_cpuset removed: Offline PUs are simply listed in the complete_cpuset as previ-
ously.
• obj->os_level removed.
Generated by Doxygen
Chapter 21
Topic Index
21.1 Topics
Here is a list of all topics with brief descriptions:
Error reporting in the API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
API version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Object Sets (hwloc_cpuset_t and hwloc_nodeset_t) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Object Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Object Structure and Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Topology Creation and Destruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Object levels, depths and types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Converting between Object Types and Attributes, and Strings . . . . . . . . . . . . . . . . . . . . . . . 102
Consulting and Adding Info Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
CPU binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Memory binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Changing the Source of Topology Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Topology Detection Configuration and Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Modifying a loaded Topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Kinds of object Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Finding Objects inside a CPU set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Finding Objects covering at least CPU set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Looking at Ancestor and Child Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Looking at Cache Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Finding objects, miscellaneous helpers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Distributing items over a topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
CPU and node sets of entire topologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Converting between CPU sets and node sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Finding I/O objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
The bitmap API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Exporting Topologies to XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Exporting Topologies to Synthetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Retrieve distances between objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Helpers for consulting distance matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Add distances between objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Remove distances between objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Comparing memory node attributes for finding where to allocate on . . . . . . . . . . . . . . . . . . . . 175
Managing memory attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Kinds of CPU cores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Linux-specific helpers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Interoperability with Linux libnuma unsigned long masks . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Interoperability with Linux libnuma bitmask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Windows-specific helpers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Interoperability with glibc sched affinity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Interoperability with OpenCL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Generated by Doxygen
86 Topic Index
Generated by Doxygen
Chapter 22
Generated by Doxygen
88 Data Structure Index
hwloc_topology_diff_u::hwloc_topology_diff_obj_attr_s . . . . . . . . . . . . . . . . . . . . . . . . . . 240
hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_string_s
String attribute modification with an optional name . . . . . . . . . . . . . . . . . . . . . . . . 241
hwloc_topology_diff_obj_attr_u
One object attribute difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_uint64_s
Integer attribute modification with an optional index . . . . . . . . . . . . . . . . . . . . . . . 242
hwloc_topology_diff_u::hwloc_topology_diff_too_complex_s . . . . . . . . . . . . . . . . . . . . . . . 243
hwloc_topology_diff_u
One element of a difference list between two topologies . . . . . . . . . . . . . . . . . . . . . 244
hwloc_topology_discovery_support
Flags describing actual discovery support for this topology . . . . . . . . . . . . . . . . . . . 244
hwloc_topology_membind_support
Flags describing actual memory binding support for this topology . . . . . . . . . . . . . . . . 245
hwloc_topology_misc_support
Flags describing miscellaneous features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
hwloc_topology_support
Set of flags describing actual support for this topology . . . . . . . . . . . . . . . . . . . . . . 247
Generated by Doxygen
Chapter 23
Topic Documentation
Functions
Note
This should not be confused with HWLOC_VERSION, the library version. Two stable releases of the same
series usually have the same HWLOC_API_VERSION even if their HWLOC_VERSION are different.
23.2.2.2 HWLOC_COMPONENT_ABI
#define HWLOC_COMPONENT_ABI 7
Current component and plugin ABI version (see hwloc/plugins.h)
Generated by Doxygen
90 Topic Documentation
unsigned hwloc_get_api_version (
void )
Indicate at runtime which hwloc API version was used at build time.
Should be HWLOC_API_VERSION if running on the same version.
Returns
23.3.2.2 hwloc_const_nodeset_t
23.3.2.3 hwloc_cpuset_t
23.3.2.4 hwloc_nodeset_t
Generated by Doxygen
23.4 Object Types 91
• #define HWLOC_TYPE_UNORDERED
Typedefs
Enumerations
• enum hwloc_obj_type_t {
HWLOC_OBJ_MACHINE , HWLOC_OBJ_PACKAGE , HWLOC_OBJ_CORE , HWLOC_OBJ_PU ,
HWLOC_OBJ_L1CACHE , HWLOC_OBJ_L2CACHE , HWLOC_OBJ_L3CACHE , HWLOC_OBJ_L4CACHE
,
HWLOC_OBJ_L5CACHE , HWLOC_OBJ_L1ICACHE , HWLOC_OBJ_L2ICACHE , HWLOC_OBJ_L3ICACHE
,
HWLOC_OBJ_GROUP , HWLOC_OBJ_NUMANODE , HWLOC_OBJ_BRIDGE , HWLOC_OBJ_PCI_DEVICE
,
HWLOC_OBJ_OS_DEVICE , HWLOC_OBJ_MISC , HWLOC_OBJ_MEMCACHE , HWLOC_OBJ_DIE ,
HWLOC_OBJ_TYPE_MAX }
• enum hwloc_obj_cache_type_e { HWLOC_OBJ_CACHE_UNIFIED , HWLOC_OBJ_CACHE_DATA ,
HWLOC_OBJ_CACHE_INSTRUCTION }
• enum hwloc_obj_bridge_type_e { HWLOC_OBJ_BRIDGE_HOST , HWLOC_OBJ_BRIDGE_PCI }
• enum hwloc_obj_osdev_type_e {
HWLOC_OBJ_OSDEV_BLOCK , HWLOC_OBJ_OSDEV_GPU , HWLOC_OBJ_OSDEV_NETWORK ,
HWLOC_OBJ_OSDEV_OPENFABRICS ,
HWLOC_OBJ_OSDEV_DMA , HWLOC_OBJ_OSDEV_COPROC }
Functions
#define HWLOC_TYPE_UNORDERED
Value returned by hwloc_compare_types() when types can not be compared.
23.4.3.2 hwloc_obj_cache_type_t
23.4.3.3 hwloc_obj_osdev_type_t
Generated by Doxygen
92 Topic Documentation
enum hwloc_obj_bridge_type_e
Type of one side (upstream or downstream) of an I/O bridge.
Enumerator
23.4.4.2 hwloc_obj_cache_type_e
enum hwloc_obj_cache_type_e
Cache type.
Enumerator
23.4.4.3 hwloc_obj_osdev_type_e
enum hwloc_obj_osdev_type_e
Type of a OS device.
Enumerator
23.4.4.4 hwloc_obj_type_t
enum hwloc_obj_type_t
Type of topology object.
Note
Do not rely on the ordering or completeness of the values as new ones may be defined in the future! If you
need to compare types, use hwloc_compare_types() instead.
Generated by Doxygen
23.4 Object Types 93
Enumerator
HWLOC_OBJ_MACHINE Machine. A set of processors and memory with cache coherency. This type is
always used for the root object of a topology, and never used anywhere else.
Hence its parent is always NULL.
HWLOC_OBJ_PACKAGE Physical package. The physical package that usually gets inserted into a
socket on the motherboard. A processor package usually contains multiple
cores, and possibly some dies.
HWLOC_OBJ_CORE Core. A computation unit (may be shared by several PUs, aka logical
processors).
HWLOC_OBJ_PU Processing Unit, or (Logical) Processor. An execution unit (may share a core
with some other logical processors, e.g. in the case of an SMT core). This is
the smallest object representing CPU resources, it cannot have any child
except Misc objects.
Objects of this kind are always reported and can thus be used as fallback
when others are not.
HWLOC_OBJ_L1CACHE Level 1 Data (or Unified) Cache.
HWLOC_OBJ_L2CACHE Level 2 Data (or Unified) Cache.
HWLOC_OBJ_L3CACHE Level 3 Data (or Unified) Cache.
HWLOC_OBJ_L4CACHE Level 4 Data (or Unified) Cache.
HWLOC_OBJ_L5CACHE Level 5 Data (or Unified) Cache.
HWLOC_OBJ_L1ICACHE Level 1 instruction Cache (filtered out by default).
HWLOC_OBJ_L2ICACHE Level 2 instruction Cache (filtered out by default).
HWLOC_OBJ_L3ICACHE Level 3 instruction Cache (filtered out by default).
HWLOC_OBJ_GROUP Group objects. Objects which do not fit in the above but are detected by hwloc
and are useful to take into account for affinity. For instance, some operating
systems expose their arbitrary processors aggregation this way. And hwloc
may insert such objects to group NUMA nodes according to their distances.
See also What are these Group objects in my topology?. These objects are
removed when they do not bring any structure (see
HWLOC_TYPE_FILTER_KEEP_STRUCTURE).
HWLOC_OBJ_NUMANODE NUMA node. An object that contains memory that is directly and
byte-accessible to the host processors. It is usually close to some cores (the
corresponding objects are descendants of the NUMA node object in the hwloc
tree). This is the smallest object representing Memory resources, it cannot
have any child except Misc objects. However it may have Memory-side cache
parents.
NUMA nodes may correspond to different kinds of memory (DRAM, HBM,
CXL-DRAM, etc.). When hwloc is able to guess that kind, it is specified in the
subtype field of the object. See also Normal attributes in the main
documentation.
There is always at least one such object in the topology even if the machine is
not NUMA.
Memory objects are not listed in the main children list, but rather in the
dedicated Memory children list.
NUMA nodes have a special depth HWLOC_TYPE_DEPTH_NUMANODE
instead of a normal depth just like other objects in the main tree.
HWLOC_OBJ_BRIDGE Bridge (filtered out by default). Any bridge (or PCI switch) that connects the
host or an I/O bus, to another I/O bus. Bridges are not added to the topology
unless their filtering is changed (see hwloc_topology_set_type_filter() and
hwloc_topology_set_io_types_filter()).
I/O objects are not listed in the main children list, but rather in the dedicated io
children list. I/O objects have NULL CPU and node sets.
Generated by Doxygen
94 Topic Documentation
Enumerator
HWLOC_OBJ_PCI_DEVICE PCI device (filtered out by default). PCI devices are not added to the topology
unless their filtering is changed (see hwloc_topology_set_type_filter() and
hwloc_topology_set_io_types_filter()).
I/O objects are not listed in the main children list, but rather in the dedicated io
children list. I/O objects have NULL CPU and node sets.
HWLOC_OBJ_OS_DEVICE Operating system device (filtered out by default). OS devices are not added to
the topology unless their filtering is changed (see
hwloc_topology_set_type_filter() and hwloc_topology_set_io_types_filter()).
I/O objects are not listed in the main children list, but rather in the dedicated io
children list. I/O objects have NULL CPU and node sets.
HWLOC_OBJ_MISC Miscellaneous objects (filtered out by default). Objects without particular
meaning, that can e.g. be added by the application for its own use, or by hwloc
for miscellaneous objects such as MemoryModule (DIMMs). They are not
added to the topology unless their filtering is changed (see
hwloc_topology_set_type_filter()).
These objects are not listed in the main children list, but rather in the dedicated
misc children list. Misc objects may only have Misc objects as children, and
those are in the dedicated misc children list as well. Misc objects have NULL
CPU and node sets.
HWLOC_OBJ_MEMCACHE Memory-side cache (filtered out by default). A cache in front of a specific
NUMA node. This object always has at least one NUMA node as a memory
child.
Memory objects are not listed in the main children list, but rather in the
dedicated Memory children list.
Memory-side cache have a special depth
HWLOC_TYPE_DEPTH_MEMCACHE instead of a normal depth just like
other objects in the main tree.
HWLOC_OBJ_DIE Die within a physical package. A subpart of the physical package, that contains
multiple cores. Some operating systems (e.g. Linux) may expose a single die
per package even if the hardware does not support dies at all. To avoid
showing such non-existing dies, the corresponding hwloc backend may filter
them out. This is functionally equivalent to
HWLOC_TYPE_FILTER_KEEP_STRUCTURE being enforced.
int hwloc_compare_types (
hwloc_obj_type_t type1,
hwloc_obj_type_t type2 )
Compare the depth of two object types.
Types shouldn't be compared as they are, since newer ones may be added in the future.
Returns
Generated by Doxygen
23.5 Object Structure and Attributes 95
Note
Object types containing CPUs can always be compared (usually, a machine contains packages, which contain
caches, which contain cores, which contain PUs).
HWLOC_OBJ_PU will always be the deepest, while HWLOC_OBJ_MACHINE is always the highest.
This does not mean that the actual topology will respect that order: e.g. as of today cores may also contain
caches, and packages may also contain nodes. This is thus just to be seen as a fallback comparison method.
• struct hwloc_obj
• union hwloc_obj_attr_u
• struct hwloc_info_s
Typedefs
Functions
Generated by Doxygen
96 Topic Documentation
int hwloc_topology_abi_check (
hwloc_topology_t topology )
Verify that the topology is compatible with the current hwloc library.
This is useful when using the same topology structure (in memory) in different libraries that may use different hwloc
installations (for instance if one library embeds a specific version of hwloc, while another library uses a default
system-wide hwloc installation).
If all libraries/programs use the same hwloc installation, this function always returns success.
Returns
0 on success.
-1 with errno set to EINVAL if incompatible.
Note
If sharing between processes with hwloc_shmem_topology_write(), the relevant check is already performed
inside hwloc_shmem_topology_adopt().
23.6.3.2 hwloc_topology_check()
void hwloc_topology_check (
hwloc_topology_t topology )
Run internal checks on a topology structure.
The program aborts if an inconsistency is detected in the given topology.
Parameters
topology is the topology to be checked
Note
23.6.3.3 hwloc_topology_destroy()
void hwloc_topology_destroy (
hwloc_topology_t topology )
Terminate and free a topology context.
Parameters
23.6.3.4 hwloc_topology_dup()
int hwloc_topology_dup (
hwloc_topology_t ∗ newtopology,
hwloc_topology_t oldtopology )
Duplicate a topology.
The entire topology structure as well as its objects are duplicated into a new one.
This is useful for keeping a backup while modifying a topology.
Generated by Doxygen
23.7 Object levels, depths and types 97
Returns
0 on success, -1 on error.
Note
Object userdata is not duplicated since hwloc does not know what it point to. The objects of both old and new
topologies will point to the same userdata.
23.6.3.5 hwloc_topology_init()
int hwloc_topology_init (
hwloc_topology_t ∗ topologyp )
Allocate a topology context.
Parameters
out topologyp is assigned a pointer to the new allocated context.
Returns
0 on success, -1 on error.
23.6.3.6 hwloc_topology_load()
int hwloc_topology_load (
hwloc_topology_t topology )
Build the actual topology.
Build the actual topology once initialized with hwloc_topology_init() and tuned with Topology Detection Configuration and Query
and Changing the Source of Topology Discovery routines. No other routine may be called earlier using this topology
context.
Parameters
topology is the topology to be loaded with objects.
Returns
0 on success, -1 on error.
Note
On failure, the topology is reinitialized. It should be either destroyed with hwloc_topology_destroy() or config-
ured and loaded again.
This function may be called only once per topology.
The binding of the current thread or process may temporarily change during this call but it will be restored
before it returns.
See also
Topology Detection Configuration and Query and Changing the Source of Topology Discovery
• enum hwloc_get_type_depth_e {
HWLOC_TYPE_DEPTH_UNKNOWN , HWLOC_TYPE_DEPTH_MULTIPLE , HWLOC_TYPE_DEPTH_NUMANODE
Generated by Doxygen
98 Topic Documentation
, HWLOC_TYPE_DEPTH_BRIDGE ,
HWLOC_TYPE_DEPTH_PCI_DEVICE , HWLOC_TYPE_DEPTH_OS_DEVICE , HWLOC_TYPE_DEPTH_MISC
, HWLOC_TYPE_DEPTH_MEMCACHE }
Functions
enum hwloc_get_type_depth_e
Enumerator
hwloc_obj_type_t hwloc_get_depth_type (
hwloc_topology_t topology,
int depth )
Returns the type of objects at depth depth.
depth should between 0 and hwloc_topology_get_depth()-1, or a virtual depth such as HWLOC_TYPE_DEPTH_NUMANODE.
Generated by Doxygen
23.7 Object levels, depths and types 99
Returns
23.7.3.2 hwloc_get_memory_parents_depth()
int hwloc_get_memory_parents_depth (
hwloc_topology_t topology )
Return the depth of parents where memory objects are attached.
Memory objects have virtual negative depths because they are not part of the main CPU-side hierarchy of objects.
This depth should not be compared with other level depths.
If all Memory objects are attached to Normal parents at the same depth, this parent depth may be compared to
other as usual, for instance for knowing whether NUMA nodes is attached above or below Packages.
Returns
The depth of Normal parents of all memory children if all these parents have the same depth. For instance
the depth of the Package level if all NUMA nodes are attached to Package objects.
HWLOC_TYPE_DEPTH_MULTIPLE if Normal parents of all memory children do not have the same depth.
For instance if some NUMA nodes are attached to Packages while others are attached to Groups.
23.7.3.3 hwloc_get_nbobjs_by_depth()
unsigned hwloc_get_nbobjs_by_depth (
hwloc_topology_t topology,
int depth )
Returns the width of level at depth depth.
Returns
23.7.3.4 hwloc_get_nbobjs_by_type()
23.7.3.5 hwloc_get_next_obj_by_depth()
Generated by Doxygen
100 Topic Documentation
23.7.3.6 hwloc_get_next_obj_by_type()
Returns
23.7.3.7 hwloc_get_obj_by_depth()
hwloc_obj_t hwloc_get_obj_by_depth (
hwloc_topology_t topology,
int depth,
unsigned idx )
Returns the topology object at logical index idx from depth depth.
Returns
23.7.3.8 hwloc_get_obj_by_type()
Returns
23.7.3.9 hwloc_get_root_obj()
23.7.3.10 hwloc_get_type_depth()
int hwloc_get_type_depth (
hwloc_topology_t topology,
hwloc_obj_type_t type )
Returns the depth of objects of type type.
Generated by Doxygen
23.7 Object levels, depths and types 101
Returns
Note
If the type is absent but a similar type is acceptable, see also hwloc_get_type_or_below_depth() and
hwloc_get_type_or_above_depth().
See also
23.7.3.11 hwloc_get_type_or_above_depth()
23.7.3.12 hwloc_get_type_or_below_depth()
23.7.3.13 hwloc_topology_get_depth()
int hwloc_topology_get_depth (
hwloc_topology_t restrict topology )
Get the depth of the hierarchical tree of objects.
This is the depth of HWLOC_OBJ_PU objects plus one.
Returns
Note
NUMA nodes, I/O and Misc objects are ignored when computing the depth of the tree (they are placed on
special levels).
Generated by Doxygen
102 Topic Documentation
int hwloc_obj_attr_snprintf (
char ∗restrict string,
size_t size,
hwloc_obj_t obj,
const char ∗restrict separator,
int verbose )
Stringify the attributes of a given topology object into a human-readable form.
Attribute values are separated by separator.
Only the major attributes are printed in non-verbose mode.
If size is 0, string may safely be NULL.
Returns
the number of characters that were actually written if not truncating, or that would have been written (not
including the ending \0).
23.8.2.2 hwloc_obj_type_snprintf()
int hwloc_obj_type_snprintf (
char ∗restrict string,
size_t size,
hwloc_obj_t obj,
int verbose )
Stringify the type of a given topology object into a human-readable form.
Contrary to hwloc_obj_type_string(), this function includes object-specific attributes (such as the Group depth, the
Bridge type, or OS device type) in the output, and it requires the caller to provide the output buffer.
The output is guaranteed to be the same for all objects of a same topology level.
If verbose is 1, longer type names are used, e.g. L1Cache instead of L1.
The output string may be parsed back by hwloc_type_sscanf().
If size is 0, string may safely be NULL.
Returns
the number of characters that were actually written if not truncating, or that would have been written (not
including the ending \0).
23.8.2.3 hwloc_obj_type_string()
Generated by Doxygen
23.9 Consulting and Adding Info Attributes 103
This function is the basic way to convert a generic type into a string. The output string may be parsed back by
hwloc_type_sscanf().
hwloc_obj_type_snprintf() may return a more precise output for a specific object, but it requires the caller to provide
the output buffer.
Returns
23.8.2.4 hwloc_type_sscanf()
int hwloc_type_sscanf (
const char ∗ string,
hwloc_obj_type_t ∗ typep,
union hwloc_obj_attr_u ∗ attrp,
size_t attrsize )
Return an object type and attributes from a type string.
Convert strings such as "Package" or "L1iCache" into the corresponding types. Matching is case-insensitive, and
only the first letters are actually required to match.
The matched object type is set in typep (which cannot be NULL).
Type-specific attributes, for instance Cache type, Cache depth, Group depth, Bridge type or OS Device type may be
returned in attrp. Attributes that are not specified in the string (for instance "Group" without a depth, or "L2Cache"
without a cache type) are set to -1.
attrp is only filled if not NULL and if its size specified in attrsize is large enough. It should be at least as
large as union hwloc_obj_attr_u.
Returns
Note
23.8.2.5 hwloc_type_sscanf_as_depth()
int hwloc_type_sscanf_as_depth (
const char ∗ string,
hwloc_obj_type_t ∗ typep,
hwloc_topology_t topology,
int ∗ depthp )
Return an object type and its level depth from a type string.
Convert strings such as "Package" or "L1iCache" into the corresponding types and return in depthp the depth of
the corresponding level in the topology topology.
If no object of this type is present on the underlying architecture, HWLOC_TYPE_DEPTH_UNKNOWN is returned.
If multiple such levels exist (for instance if giving Group without any depth), the function may return
HWLOC_TYPE_DEPTH_MULTIPLE instead.
The matched object type is set in typep if typep is non NULL.
Note
Generated by Doxygen
104 Topic Documentation
• int hwloc_obj_add_info (hwloc_obj_t obj, const char ∗name, const char ∗value)
• int hwloc_obj_set_subtype (hwloc_topology_t topology, hwloc_obj_t obj, const char ∗subtype)
int hwloc_obj_add_info (
hwloc_obj_t obj,
const char ∗ name,
const char ∗ value )
Add the given name and value pair to the given object info attributes.
The info pair is appended to the existing info array even if another pair with the same name already exists.
The input strings are copied before being added in the object infos.
Returns
0 on success, -1 on error.
Note
This function may be used to enforce object colors in the lstopo graphical output by adding "lstopoStyle" as a
name and "Background=#rrggbb" as a value. See CUSTOM COLORS in the lstopo(1) manpage for details.
If name or value contain some non-printable characters, they will be dropped when exporting to XML, see
hwloc_topology_export_xml() in hwloc/export.h.
23.9.2.2 hwloc_obj_get_info_by_name()
Returns
Note
The string should not be freed by the caller, it belongs to the hwloc library.
23.9.2.3 hwloc_obj_set_subtype()
int hwloc_obj_set_subtype (
hwloc_topology_t topology,
hwloc_obj_t obj,
const char ∗ subtype )
Set (or replace) the subtype of an object.
The given subtype is copied internally, the caller is responsible for freeing the original subtype if needed.
If another subtype already exists in object, it is replaced. The given subtype may be NULL to remove the
existing subtype.
Note
This function is mostly meant to initialize the subtype of user-added objects such as groups with
hwloc_topology_alloc_group_object().
Generated by Doxygen
23.10 CPU binding 105
Returns
0 on success.
-1 with errno set to ENOMEM on failure to allocate memory.
Functions
See also
Some example codes are available under doc/examples/ in the source tree.
Note
To unbind, just call the binding function with either a full cpuset or a cpuset equal to the system cpuset.
On some operating systems, CPU binding may have effects on memory binding, see HWLOC_CPUBIND_NOMEMBIND
Running lstopo --top or hwloc-ps can be a very convenient tool to check how binding actually happened.
Generated by Doxygen
106 Topic Documentation
enum hwloc_cpubind_flags_t
Process/Thread binding flags.
These bit flags can be used to refine the binding policy.
The default (0) is to bind the current process, assumed to be single-threaded, in a non-strict way. This is the most
portable way to bind as all operating systems usually provide it.
Note
Not all systems support all kinds of binding. See the "Detailed Description" section of CPU binding for a
description of errors that can occur.
Enumerator
When retrieving the binding of a process, this flag checks whether all its
threads actually have the same binding. If the flag is not given, the
binding of each thread will be accumulated.
Note
HWLOC_CPUBIND_NOMEMBIND Avoid any effect on memory binding. On some operating systems, some
CPU binding function would also bind the memory on the corresponding
NUMA node. It is often not a problem for the application, but if it is,
setting this flag will make hwloc avoid using OS functions that would also
bind memory. This will however reduce the support of CPU bindings, i.e.
potentially return -1 with errno set to ENOSYS in some cases.
This flag is only meaningful when used with functions that set the CPU
binding. It is ignored when used with functions that get CPU binding
information.
int hwloc_get_cpubind (
hwloc_topology_t topology,
hwloc_cpuset_t set,
int flags )
Get current process or thread binding.
Generated by Doxygen
23.10 CPU binding 107
The CPU-set set (previously allocated by the caller) is filled with the list of PUs which the process or thread
(according to flags) was last bound to.
Returns
0 on success, -1 on error.
23.10.3.2 hwloc_get_last_cpu_location()
int hwloc_get_last_cpu_location (
hwloc_topology_t topology,
hwloc_cpuset_t set,
int flags )
Get the last physical CPU where the current process or thread ran.
The CPU-set set (previously allocated by the caller) is filled with the list of PUs which the process or thread
(according to flags) last ran on.
The operating system may move some tasks from one processor to another at any time according to their binding,
so this function may return something that is already outdated.
flags can include either HWLOC_CPUBIND_PROCESS or HWLOC_CPUBIND_THREAD to specify whether the
query should be for the whole process (union of all CPUs on which all threads are running), or only the current
thread. If the process is single-threaded, flags can be set to zero to let hwloc use whichever method is available on
the underlying OS.
Returns
0 on success, -1 on error.
23.10.3.3 hwloc_get_proc_cpubind()
int hwloc_get_proc_cpubind (
hwloc_topology_t topology,
hwloc_pid_t pid,
hwloc_cpuset_t set,
int flags )
Get the current physical binding of process pid.
The CPU-set set (previously allocated by the caller) is filled with the list of PUs which the process was last bound
to.
Returns
0 on success, -1 on error.
Note
23.10.3.4 hwloc_get_proc_last_cpu_location()
int hwloc_get_proc_last_cpu_location (
hwloc_topology_t topology,
hwloc_pid_t pid,
hwloc_cpuset_t set,
int flags )
Get the last physical CPU where a process ran.
The CPU-set set (previously allocated by the caller) is filled with the list of PUs which the process last ran on.
The operating system may move some tasks from one processor to another at any time according to their binding,
so this function may return something that is already outdated.
Generated by Doxygen
108 Topic Documentation
Returns
0 on success, -1 on error.
Note
23.10.3.5 hwloc_get_thread_cpubind()
int hwloc_get_thread_cpubind (
hwloc_topology_t topology,
hwloc_thread_t thread,
hwloc_cpuset_t set,
int flags )
Get the current physical binding of thread tid.
The CPU-set set (previously allocated by the caller) is filled with the list of PUs which the thread was last bound
to.
Returns
0 on success, -1 on error.
Note
23.10.3.6 hwloc_set_cpubind()
int hwloc_set_cpubind (
hwloc_topology_t topology,
hwloc_const_cpuset_t set,
int flags )
Bind current process or thread on CPUs given in physical bitmap set.
Returns
0 on success.
-1 with errno set to ENOSYS if the action is not supported.
-1 with errno set to EXDEV if the binding cannot be enforced.
23.10.3.7 hwloc_set_proc_cpubind()
int hwloc_set_proc_cpubind (
hwloc_topology_t topology,
hwloc_pid_t pid,
hwloc_const_cpuset_t set,
int flags )
Bind a process pid on CPUs given in physical bitmap set.
Returns
0 on success, -1 on error.
Generated by Doxygen
23.11 Memory binding 109
Note
23.10.3.8 hwloc_set_thread_cpubind()
int hwloc_set_thread_cpubind (
hwloc_topology_t topology,
hwloc_thread_t thread,
hwloc_const_cpuset_t set,
int flags )
Bind a thread thread on CPUs given in physical bitmap set.
Returns
0 on success, -1 on error.
Note
• enum hwloc_membind_policy_t {
HWLOC_MEMBIND_DEFAULT , HWLOC_MEMBIND_FIRSTTOUCH , HWLOC_MEMBIND_BIND ,
HWLOC_MEMBIND_INTERLEAVE ,
HWLOC_MEMBIND_WEIGHTED_INTERLEAVE , HWLOC_MEMBIND_NEXTTOUCH , HWLOC_MEMBIND_MIXED
}
• enum hwloc_membind_flags_t {
HWLOC_MEMBIND_PROCESS , HWLOC_MEMBIND_THREAD , HWLOC_MEMBIND_STRICT ,
HWLOC_MEMBIND_MIGRATE ,
HWLOC_MEMBIND_NOCPUBIND , HWLOC_MEMBIND_BYNODESET }
Functions
Generated by Doxygen
110 Topic Documentation
• explicit memory allocation thanks to hwloc_alloc_membind() and friends: the binding will have effect on the
memory allocated by these functions.
• implicit memory binding through binding policy: hwloc_set_membind() and friends only define the current
policy of the process, which will be applied to the subsequent calls to malloc() and friends.
• migration of existing memory ranges, thanks to hwloc_set_area_membind() and friends, which move already-
allocated data.
Not all operating systems support all three ways. hwloc_topology_get_support() may be used to query about the
actual memory binding support in the currently used operating system.
When the requested binding operation is not available and the HWLOC_MEMBIND_STRICT flag was passed, the
function returns -1. errno will be set to ENOSYS when the system does support the specified action or policy
(e.g., some systems only allow binding memory on a per-thread basis, whereas other systems only allow binding
memory for all threads in a process). errno will be set to EXDEV when the requested set can not be enforced
(e.g., some systems only allow binding memory to a single NUMA node).
If HWLOC_MEMBIND_STRICT was not passed, the function may fail as well, or the operating system may use a
slightly different operation (with side-effects, smaller binding set, etc.) when the requested operation is not exactly
supported.
The most portable form that should be preferred over the others whenever possible is as follows. It allocates some
memory hopefully bound to the specified set. To do so, hwloc will possibly have to change the current memory
binding policy in order to actually get the memory bound, if the OS does not provide any other way to simply allocate
bound memory without changing the policy for all allocations. That is the difference with hwloc_alloc_membind(),
which will never change the current memory binding policy.
hwloc_alloc_membind_policy(topology, size, set,
HWLOC_MEMBIND_BIND, 0);
Each hwloc memory binding function takes a bitmap argument that is a CPU set by default, or a NUMA memory node
set if the flag HWLOC_MEMBIND_BYNODESET is specified. See Object Sets (hwloc_cpuset_t and hwloc_nodeset_t)
and The bitmap API for a discussion of CPU sets and NUMA memory node sets. It is also possible to convert
between CPU set and node set using hwloc_cpuset_to_nodeset() or hwloc_cpuset_from_nodeset().
Memory binding by CPU set cannot work for CPU-less NUMA memory nodes. Binding by nodeset should therefore
be preferred whenever possible.
See also
Some example codes are available under doc/examples/ in the source tree.
Note
On some operating systems, memory binding affects the CPU binding; see HWLOC_MEMBIND_NOCPUBIND
enum hwloc_membind_flags_t
Memory binding flags.
These flags can be used to refine the binding policy. All flags can be logically OR'ed together with the exception of
HWLOC_MEMBIND_PROCESS and HWLOC_MEMBIND_THREAD; these two flags are mutually exclusive.
Not all systems support all kinds of binding. hwloc_topology_get_support() may be used to query about the ac-
tual memory binding support in the currently used operating system. See the "Detailed Description" section of
Memory binding for a description of errors that can occur.
Generated by Doxygen
23.11 Memory binding 111
Enumerator
HWLOC_MEMBIND_PROCESS Set policy for all threads of the specified (possibly multithreaded)
process. This flag is mutually exclusive with
HWLOC_MEMBIND_THREAD.
HWLOC_MEMBIND_THREAD Set policy for a specific thread of the current process. This flag is
mutually exclusive with HWLOC_MEMBIND_PROCESS.
HWLOC_MEMBIND_STRICT Request strict binding from the OS. The function will fail if the binding
can not be guaranteed / completely enforced.
This flag has slightly different meanings depending on which function it
is used with.
HWLOC_MEMBIND_MIGRATE Migrate existing allocated memory. If the memory cannot be migrated
and the HWLOC_MEMBIND_STRICT flag is passed, an error will be
returned.
HWLOC_MEMBIND_NOCPUBIND Avoid any effect on CPU binding. On some operating systems, some
underlying memory binding functions also bind the application to the
corresponding CPU(s). Using this flag will cause hwloc to avoid using
OS functions that could potentially affect CPU bindings. Note, however,
that using NOCPUBIND may reduce hwloc's overall memory binding
support. Specifically: some of hwloc's memory binding functions may
fail with errno set to ENOSYS when used with NOCPUBIND.
HWLOC_MEMBIND_BYNODESET Consider the bitmap argument as a nodeset. The bitmap argument is
considered a nodeset if this flag is given, or a cpuset otherwise by
default.
Memory binding by CPU set cannot work for CPU-less NUMA memory
nodes. Binding by nodeset should therefore be preferred whenever
possible.
23.11.2.2 hwloc_membind_policy_t
enum hwloc_membind_policy_t
Memory binding policy.
These constants can be used to choose the binding policy. Only one policy can be used at a time (i.e., the values
cannot be OR'ed together).
Not all systems support all kinds of binding. hwloc_topology_get_support() may be used to query about the actual
memory binding policy support in the currently used operating system. See the "Detailed Description" section of
Memory binding for a description of errors that can occur.
Enumerator
Generated by Doxygen
112 Topic Documentation
Enumerator
void ∗ hwloc_alloc (
hwloc_topology_t topology,
size_t len )
Allocate some memory.
This is equivalent to malloc(), except that it tries to allocate page-aligned memory from the OS.
Returns
Note
23.11.3.2 hwloc_alloc_membind()
void ∗ hwloc_alloc_membind (
hwloc_topology_t topology,
size_t len,
Generated by Doxygen
23.11 Memory binding 113
hwloc_const_bitmap_t set,
hwloc_membind_policy_t policy,
int flags )
Allocate some memory on NUMA memory nodes specified by set.
Returns
Note
23.11.3.3 hwloc_alloc_membind_policy()
Returns
23.11.3.4 hwloc_free()
int hwloc_free (
hwloc_topology_t topology,
void ∗ addr,
size_t len )
Free memory that was previously allocated by hwloc_alloc() or hwloc_alloc_membind().
Returns
0 on success, -1 on error.
23.11.3.5 hwloc_get_area_membind()
int hwloc_get_area_membind (
hwloc_topology_t topology,
const void ∗ addr,
size_t len,
hwloc_bitmap_t set,
hwloc_membind_policy_t ∗ policy,
int flags )
Query the CPUs near the physical NUMA node(s) and binding policy of the memory identified by (addr, len ).
The bitmap set (previously allocated by the caller) is filled with the memory area binding.
Generated by Doxygen
114 Topic Documentation
This function has two output parameters: set and policy. The values returned in these parameters depend on
both the flags passed in and the memory binding policies and nodesets of the pages in the address range.
If HWLOC_MEMBIND_STRICT is specified, the target pages are first checked to see if they all have the same
memory binding policy and nodeset. If they do not, -1 is returned and errno is set to EXDEV. If they are identical
across all pages, the set and policy are returned in set and policy, respectively.
If HWLOC_MEMBIND_STRICT is not specified, the union of all NUMA node(s) containing pages in the address
range is calculated. If all pages in the target have the same policy, it is returned in policy. Otherwise, policy
is set to HWLOC_MEMBIND_MIXED.
If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset.
If any other flags are specified, -1 is returned and errno is set to EINVAL.
Returns
0 on success.
-1 with errno set to EINVAL if len is 0.
23.11.3.6 hwloc_get_area_memlocation()
int hwloc_get_area_memlocation (
hwloc_topology_t topology,
const void ∗ addr,
size_t len,
hwloc_bitmap_t set,
int flags )
Get the NUMA nodes where memory identified by (addr, len ) is physically allocated.
The bitmap set (previously allocated by the caller) is filled according to the NUMA nodes where the memory area
pages are physically allocated. If no page is actually allocated yet, set may be empty.
If pages spread to multiple nodes, it is not specified whether they spread equitably, or whether most of them are on
a single node, etc.
The operating system may move memory pages from one processor to another at any time according to their
binding, so this function may return something that is already outdated.
If HWLOC_MEMBIND_BYNODESET is specified in flags, set is considered a nodeset. Otherwise it's a cpuset.
If len is 0, set is emptied.
Returns
0 on success, -1 on error.
23.11.3.7 hwloc_get_membind()
int hwloc_get_membind (
hwloc_topology_t topology,
hwloc_bitmap_t set,
hwloc_membind_policy_t ∗ policy,
int flags )
Query the default memory binding policy and physical locality of the current process or thread.
The bitmap set (previously allocated by the caller) is filled with the process or thread memory binding.
This function has two output parameters: set and policy. The values returned in these parameters depend on
both the flags passed in and the current memory binding policies and nodesets in the queried target.
Passing the HWLOC_MEMBIND_PROCESS flag specifies that the query target is the current policies and nodesets
for all the threads in the current process. Passing HWLOC_MEMBIND_THREAD specifies that the query target is
the current policy and nodeset for only the thread invoking this function.
If neither of these flags are passed (which is the most portable method), the process is assumed to be single
threaded. This allows hwloc to use either process-based OS functions or thread-based OS functions, depending on
which are available.
HWLOC_MEMBIND_STRICT is only meaningful when HWLOC_MEMBIND_PROCESS is also specified. In this
case, hwloc will check the default memory policies and nodesets for all threads in the process. If they are not
identical, -1 is returned and errno is set to EXDEV. If they are identical, the values are returned in set and policy.
Generated by Doxygen
23.11 Memory binding 115
0 on success, -1 on error.
23.11.3.8 hwloc_get_proc_membind()
int hwloc_get_proc_membind (
hwloc_topology_t topology,
hwloc_pid_t pid,
hwloc_bitmap_t set,
hwloc_membind_policy_t ∗ policy,
int flags )
Query the default memory binding policy and physical locality of the specified process.
The bitmap set (previously allocated by the caller) is filled with the process memory binding.
This function has two output parameters: set and policy. The values returned in these parameters depend on
both the flags passed in and the current memory binding policies and nodesets in the queried target.
Passing the HWLOC_MEMBIND_PROCESS flag specifies that the query target is the current policies and nodesets
for all the threads in the specified process. If HWLOC_MEMBIND_PROCESS is not specified (which is the most
portable method), the process is assumed to be single threaded. This allows hwloc to use either process-based OS
functions or thread-based OS functions, depending on which are available.
Note that it does not make sense to pass HWLOC_MEMBIND_THREAD to this function.
If HWLOC_MEMBIND_STRICT is specified, hwloc will check the default memory policies and nodesets for all
threads in the specified process. If they are not identical, -1 is returned and errno is set to EXDEV. If they are
identical, the values are returned in set and policy.
Otherwise, set is set to the logical OR of all threads' default set. If all threads' default policies are the same,
policy is set to that policy. If they are different, policy is set to HWLOC_MEMBIND_MIXED.
If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset.
If any other flags are specified, -1 is returned and errno is set to EINVAL.
Returns
0 on success, -1 on error.
Note
23.11.3.9 hwloc_set_area_membind()
int hwloc_set_area_membind (
hwloc_topology_t topology,
const void ∗ addr,
size_t len,
hwloc_const_bitmap_t set,
hwloc_membind_policy_t policy,
int flags )
Bind the already-allocated memory identified by (addr, len) to the NUMA node(s) specified by set.
If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset.
Returns
0 on success or if len is 0.
-1 with errno set to ENOSYS if the action is not supported.
-1 with errno set to EXDEV if the binding cannot be enforced.
Generated by Doxygen
116 Topic Documentation
23.11.3.10 hwloc_set_membind()
int hwloc_set_membind (
hwloc_topology_t topology,
hwloc_const_bitmap_t set,
hwloc_membind_policy_t policy,
int flags )
Set the default memory binding policy of the current process or thread to prefer the NUMA node(s) specified by
set.
If neither HWLOC_MEMBIND_PROCESS nor HWLOC_MEMBIND_THREAD is specified, the current process is
assumed to be single-threaded. This is the most portable form as it permits hwloc to use either process-based OS
functions or thread-based OS functions, depending on which are available.
If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset.
Returns
0 on success.
-1 with errno set to ENOSYS if the action is not supported.
-1 with errno set to EXDEV if the binding cannot be enforced.
23.11.3.11 hwloc_set_proc_membind()
int hwloc_set_proc_membind (
hwloc_topology_t topology,
hwloc_pid_t pid,
hwloc_const_bitmap_t set,
hwloc_membind_policy_t policy,
int flags )
Set the default memory binding policy of the specified process to prefer the NUMA node(s) specified by set.
If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset.
Returns
0 on success.
-1 with errno set to ENOSYS if the action is not supported.
-1 with errno set to EXDEV if the binding cannot be enforced.
Note
Functions
Generated by Doxygen
23.12 Changing the Source of Topology Discovery 117
enum hwloc_topology_components_flag_e
Flags to be passed to hwloc_topology_set_components()
Enumerator
int hwloc_topology_set_components (
hwloc_topology_t restrict topology,
unsigned long flags,
const char ∗restrict name )
Prevent a discovery component from being used for a topology.
name is the name of the discovery component that should not be used when loading topology topology. The
name is a string such as "cuda".
For components with multiple phases, it may also be suffixed with the name of a phase, for instance "linux:io".
flags should be HWLOC_TOPOLOGY_COMPONENTS_FLAG_BLACKLIST.
This may be used to avoid expensive parts of the discovery process. For instance, CUDA-specific discovery may
be expensive and unneeded while generic I/O discovery could still be useful.
Returns
0 on success.
-1 on error, for instance if flags are invalid.
23.12.3.2 hwloc_topology_set_pid()
int hwloc_topology_set_pid (
hwloc_topology_t restrict topology,
hwloc_pid_t pid )
Change which process the topology is viewed from.
On some systems, processes may have different views of the machine, for instance the set of allowed CPUs. By
default, hwloc exposes the view from the current process. Calling hwloc_topology_set_pid() permits to make it
expose the topology of the machine from the point of view of another process.
Generated by Doxygen
118 Topic Documentation
Note
Returns
0 on success, -1 on error.
23.12.3.3 hwloc_topology_set_synthetic()
int hwloc_topology_set_synthetic (
hwloc_topology_t restrict topology,
const char ∗restrict description )
Enable synthetic topology.
Gather topology information from the given description, a space-separated string of <type:number> describ-
ing the object type and arity at each level. All types may be omitted (space-separated string of numbers) so that
hwloc chooses all types according to usual topologies. See also the Synthetic topologies.
Setting the environment variable HWLOC_SYNTHETIC may also result in this behavior.
If description was properly parsed and describes a valid topology configuration, this function returns 0. Other-
wise -1 is returned and errno is set to EINVAL.
Note that this function does not actually load topology information; it just tells hwloc where to load it from. You'll still
need to invoke hwloc_topology_load() to actually load the topology information.
Returns
0 on success.
-1 with errno set to EINVAL if the description was invalid.
Note
For convenience, this backend provides empty binding hooks which just return success.
On success, the synthetic component replaces the previously enabled component (if any), but the topology is
not actually modified until hwloc_topology_load().
23.12.3.4 hwloc_topology_set_xml()
int hwloc_topology_set_xml (
hwloc_topology_t restrict topology,
const char ∗restrict xmlpath )
Enable XML-file based topology.
Gather topology information from the XML file given at xmlpath. Setting the environment variable
HWLOC_XMLFILE may also result in this behavior. This file may have been generated earlier with
hwloc_topology_export_xml() in hwloc/export.h, or lstopo file.xml.
Note that this function does not actually load topology information; it just tells hwloc where to load it from. You'll still
need to invoke hwloc_topology_load() to actually load the topology information.
Returns
0 on success.
-1 with errno set to EINVAL on failure to read the XML file.
Generated by Doxygen
23.13 Topology Detection Configuration and Query 119
Note
23.12.3.5 hwloc_topology_set_xmlbuffer()
int hwloc_topology_set_xmlbuffer (
hwloc_topology_t restrict topology,
const char ∗restrict buffer,
int size )
Enable XML based topology using a memory buffer (instead of a file, as with hwloc_topology_set_xml()).
Gather topology information from the XML memory buffer given at buffer and of length size (including an
ending \0). This buffer may have been filled earlier with hwloc_topology_export_xmlbuffer() in hwloc/export.h.
Note that this function does not actually load topology information; it just tells hwloc where to load it from. You'll still
need to invoke hwloc_topology_load() to actually load the topology information.
Returns
0 on success.
-1 with errno set to EINVAL on failure to read the XML buffer.
Note
• struct hwloc_topology_discovery_support
• struct hwloc_topology_cpubind_support
• struct hwloc_topology_membind_support
• struct hwloc_topology_misc_support
• struct hwloc_topology_support
Enumerations
• enum hwloc_topology_flags_e {
HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED , HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM ,
HWLOC_TOPOLOGY_FLAG_THISSYSTEM_ALLOWED_RESOURCES , HWLOC_TOPOLOGY_FLAG_IMPORT_SUPPORT
= (1UL<<3) ,
HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING = (1UL<<4) , HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_ME
= (1UL<<5) , HWLOC_TOPOLOGY_FLAG_DONT_CHANGE_BINDING = (1UL<<6) , HWLOC_TOPOLOGY_FLAG_NO_DIS
Generated by Doxygen
120 Topic Documentation
= (1UL<<7) ,
HWLOC_TOPOLOGY_FLAG_NO_MEMATTRS = (1UL<<8) , HWLOC_TOPOLOGY_FLAG_NO_CPUKINDS
= (1UL<<9) }
• enum hwloc_type_filter_e { HWLOC_TYPE_FILTER_KEEP_ALL , HWLOC_TYPE_FILTER_KEEP_NONE ,
HWLOC_TYPE_FILTER_KEEP_STRUCTURE , HWLOC_TYPE_FILTER_KEEP_IMPORTANT }
Functions
enum hwloc_topology_flags_e
Flags to be set onto a topology context before load.
Flags should be given to hwloc_topology_set_flags(). They may also be returned by hwloc_topology_get_flags().
Generated by Doxygen
23.13 Topology Detection Configuration and Query 121
Enumerator
Generated by Doxygen
122 Topic Documentation
Enumerator
Generated by Doxygen
23.13 Topology Detection Configuration and Query 123
Enumerator
Generated by Doxygen
124 Topic Documentation
Enumerator
23.13.2.2 hwloc_type_filter_e
enum hwloc_type_filter_e
Type filtering flags.
By default, most objects are kept (HWLOC_TYPE_FILTER_KEEP_ALL). Instruction caches, memory-side caches,
I/O and Misc objects are ignored by default (HWLOC_TYPE_FILTER_KEEP_NONE). Group levels are ignored
unless they bring structure (HWLOC_TYPE_FILTER_KEEP_STRUCTURE).
Note that group objects are also ignored individually (without the entire level) when they do not bring structure.
Enumerator
Generated by Doxygen
23.13 Topology Detection Configuration and Query 125
Note
23.13.3.2 hwloc_topology_get_support()
Note
23.13.3.3 hwloc_topology_get_type_filter()
int hwloc_topology_get_type_filter (
hwloc_topology_t topology,
hwloc_obj_type_t type,
enum hwloc_type_filter_e ∗ filter )
Get the current filtering for the given object type.
Returns
0 on success, -1 on error.
23.13.3.4 hwloc_topology_get_userdata()
void ∗ hwloc_topology_get_userdata (
hwloc_topology_t topology )
Retrieve the topology-specific userdata pointer.
Retrieve the application-given private data pointer that was previously set with hwloc_topology_set_userdata().
Returns
Generated by Doxygen
126 Topic Documentation
23.13.3.5 hwloc_topology_is_thissystem()
int hwloc_topology_is_thissystem (
hwloc_topology_t restrict topology )
Does the topology context come from this system?
Returns
1 if this topology context was built using the system running this program.
0 instead (for instance if using another file-system root, a XML topology file, or a synthetic topology).
Note
23.13.3.6 hwloc_topology_set_all_types_filter()
int hwloc_topology_set_all_types_filter (
hwloc_topology_t topology,
enum hwloc_type_filter_e filter )
Set the filtering for all object types.
If some types do not support this filtering, they are silently ignored.
Returns
0 on success, -1 on error.
23.13.3.7 hwloc_topology_set_cache_types_filter()
int hwloc_topology_set_cache_types_filter (
hwloc_topology_t topology,
enum hwloc_type_filter_e filter )
Set the filtering for all CPU cache object types.
Memory-side caches are not involved since they are not CPU caches.
Returns
0 on success, -1 on error.
23.13.3.8 hwloc_topology_set_flags()
int hwloc_topology_set_flags (
hwloc_topology_t topology,
unsigned long flags )
Set OR'ed flags to non-yet-loaded topology.
Set a OR'ed set of hwloc_topology_flags_e onto a topology that was not yet loaded.
If this function is called multiple times, the last invocation will erase and replace the set of flags that was previously
set.
By default, no flags are set (0).
The flags set in a topology may be retrieved with hwloc_topology_get_flags().
Returns
0 on success.
-1 on error, for instance if flags are invalid.
Generated by Doxygen
23.14 Modifying a loaded Topology 127
23.13.3.9 hwloc_topology_set_icache_types_filter()
int hwloc_topology_set_icache_types_filter (
hwloc_topology_t topology,
enum hwloc_type_filter_e filter )
Set the filtering for all CPU instruction cache object types.
Memory-side caches are not involved since they are not CPU caches.
Returns
0 on success, -1 on error.
23.13.3.10 hwloc_topology_set_io_types_filter()
int hwloc_topology_set_io_types_filter (
hwloc_topology_t topology,
enum hwloc_type_filter_e filter )
Set the filtering for all I/O object types.
Returns
0 on success, -1 on error.
23.13.3.11 hwloc_topology_set_type_filter()
int hwloc_topology_set_type_filter (
hwloc_topology_t topology,
hwloc_obj_type_t type,
enum hwloc_type_filter_e filter )
Set the filtering for the given object type.
Returns
0 on success, -1 on error.
23.13.3.12 hwloc_topology_set_userdata()
void hwloc_topology_set_userdata (
hwloc_topology_t topology,
const void ∗ userdata )
Set the topology-specific userdata pointer.
Each topology may store one application-given private data pointer. It is initialized to NULL. hwloc will never modify
it.
Use it as you wish, after hwloc_topology_init() and until hwloc_topolog_destroy().
This pointer is not exported to XML.
• enum hwloc_restrict_flags_e {
HWLOC_RESTRICT_FLAG_REMOVE_CPULESS , HWLOC_RESTRICT_FLAG_BYNODESET = (1UL<<3)
, HWLOC_RESTRICT_FLAG_REMOVE_MEMLESS , HWLOC_RESTRICT_FLAG_ADAPT_MISC ,
HWLOC_RESTRICT_FLAG_ADAPT_IO }
• enum hwloc_allow_flags_e { HWLOC_ALLOW_FLAG_ALL , HWLOC_ALLOW_FLAG_LOCAL_RESTRICTIONS
, HWLOC_ALLOW_FLAG_CUSTOM }
Generated by Doxygen
128 Topic Documentation
Functions
enum hwloc_allow_flags_e
Flags to be given to hwloc_topology_allow().
Enumerator
23.14.2.2 hwloc_restrict_flags_e
enum hwloc_restrict_flags_e
Flags to be given to hwloc_topology_restrict().
Enumerator
Generated by Doxygen
23.14 Modifying a loaded Topology 129
Enumerator
int hwloc_obj_add_other_obj_sets (
hwloc_obj_t dst,
hwloc_obj_t src )
Setup object cpusets/nodesets by OR'ing another object's sets.
For each defined cpuset or nodeset in src, allocate the corresponding set in dst and add src to it by OR'ing
sets.
This function is convenient between hwloc_topology_alloc_group_object() and hwloc_topology_insert_group_object().
It builds the sets of the new Group that will be inserted as a new intermediate parent of several objects.
Returns
0 on success.
-1 with errno set to ENOMEM if some internal reallocation failed.
23.14.3.2 hwloc_topology_alloc_group_object()
hwloc_obj_t hwloc_topology_alloc_group_object (
hwloc_topology_t topology )
Allocate a Group object to insert later with hwloc_topology_insert_group_object().
This function returns a new Group object.
The caller should (at least) initialize its sets before inserting the object in the topology, see hwloc_topology_insert_group_object().
Or it may decide not to insert and just free the group object by calling hwloc_topology_free_group_object().
Returns
Note
If successfully inserted by hwloc_topology_insert_group_object(), the object will be freed when the entire
topology is freed. If insertion failed (e.g. NULL or empty CPU and node-sets), it is freed before returning the
error.
23.14.3.3 hwloc_topology_allow()
int hwloc_topology_allow (
hwloc_topology_t restrict topology,
hwloc_const_cpuset_t cpuset,
Generated by Doxygen
130 Topic Documentation
hwloc_const_nodeset_t nodeset,
unsigned long flags )
Change the sets of allowed PUs and NUMA nodes in the topology.
This function only works if the HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED was set on the topology.
It does not modify any object, it only changes the sets returned by hwloc_topology_get_allowed_cpuset() and
hwloc_topology_get_allowed_nodeset().
It is notably useful when importing a topology from another process running in a different Linux Cgroup.
flags must be set to one flag among hwloc_allow_flags_e.
Returns
0 on success, -1 on error.
Note
23.14.3.4 hwloc_topology_free_group_object()
int hwloc_topology_free_group_object (
hwloc_topology_t topology,
hwloc_obj_t group )
Free a group object allocated with hwloc_topology_alloc_group_object().
This function is only useful if the group object was not given to hwloc_topology_insert_group_object() as planned.
Note
Returns
0 on success.
-1 on error, for instance if an invalid topology is given.
23.14.3.5 hwloc_topology_insert_group_object()
hwloc_obj_t hwloc_topology_insert_group_object (
hwloc_topology_t topology,
hwloc_obj_t group )
Add more structure to the topology by adding an intermediate Group.
The caller should first allocate a new Group object with hwloc_topology_alloc_group_object(). Then it must setup
at least one of its CPU or node sets to specify the final location of the Group in the topology. Then the object can
be passed to this function for actual insertion in the topology.
The main use case for this function is to group a subset of siblings among the list of children below a single parent.
For instance, if grouping 4 cores out of a 8-core socket, the logical list of cores will be reordered so that the 4
grouped ones are consecutive. Then, if needed, a new depth is added between the parent and those children, and
the Group is inserted there. At the end, the 4 grouped cores are now children of the Group, which replaces them as
a child of the original parent.
In practice, the grouped objects are specified through cpusets and/or nodesets, for instance using
hwloc_obj_add_other_obj_sets() iteratively. Hence it is possible to group objects that are not children of the
same parent, for instance some PUs below the 4 cores in example above. However this general case may fail if
the expected Group conflicts with the existing hierarchy. For instance if each core has two PUs, it is not possible to
insert a Group containing a single PU of each core.
To specify the objects to group, either the cpuset or nodeset field (or both, if compatible) must be set to a non-empty
bitmap. The complete_cpuset or complete_nodeset may be set instead if inserting with respect to the complete
topology (including disallowed, offline or unknown objects). These sets cannot be larger than the current topology,
or they would get restricted silently. The core will setup the other sets after actual insertion.
The subtype object attribute may be defined with hwloc_obj_set_subtype() to display something else than "Group"
as the type name for this object in lstopo. Custom name-value info pairs may be added with hwloc_obj_add_info()
after insertion.
Generated by Doxygen
23.14 Modifying a loaded Topology 131
The group dont_merge attribute may be set to 1 to prevent the hwloc core from ever merging this object with
another hierarchically-identical object. This is useful when the Group itself describes an important feature that
cannot be exposed anywhere else in the hierarchy.
The group kind attribute may be set to a high value such as 0xffffffff to tell hwloc that this new Group
should always be discarded in favor of any existing Group with the same locality.
Note
Inserting a group adds some locality information to the topology, hence the existing objects may get reordered
(including PUs and NUMA nodes), and their logical indexes may change.
If the insertion fails, the input group object is freed.
If the group object should be discarded instead of inserted, it may be passed to hwloc_topology_free_group_object()
instead.
topology must be the same as the one previously passed to hwloc_topology_alloc_group_object().
Returns
23.14.3.6 hwloc_topology_insert_misc_object()
hwloc_obj_t hwloc_topology_insert_misc_object (
hwloc_topology_t topology,
hwloc_obj_t parent,
const char ∗ name )
Add a MISC object as a leaf of the topology.
A new MISC object will be created and inserted into the topology at the position given by parent. It is appended to
the list of existing Misc children, without ever adding any intermediate hierarchy level. This is useful for annotating
the topology without actually changing the hierarchy.
name is supposed to be unique across all Misc objects in the topology. It will be duplicated to setup the new object
attributes.
The new leaf object will not have any cpuset.
The subtype object attribute may be defined with hwloc_obj_set_subtype() after successful insertion.
Returns
Note
If name contains some non-printable characters, they will be dropped when exporting to XML, see
hwloc_topology_export_xml() in hwloc/export.h.
23.14.3.7 hwloc_topology_refresh()
int hwloc_topology_refresh (
hwloc_topology_t topology )
Refresh internal structures after topology modification.
Generated by Doxygen
132 Topic Documentation
Modifying the topology (by restricting, adding objects, modifying structures such as distances or memory attributes,
etc.) may cause some internal caches to become invalid. These caches are automatically refreshed when accessed
but this refreshing is not thread-safe.
This function is not thread-safe either, but it is a good way to end a non-thread-safe phase of topology modification.
Once this refresh is done, multiple threads may concurrently consult the topology, objects, distances, attributes, etc.
See also Thread Safety
Returns
0 on success.
-1 on error, for instance if some internal reallocation failed.
23.14.3.8 hwloc_topology_restrict()
int hwloc_topology_restrict (
hwloc_topology_t restrict topology,
hwloc_const_bitmap_t set,
unsigned long flags )
Restrict the topology to the given CPU set or nodeset.
Topology topology is modified so as to remove all objects that are not included (or partially included) in the CPU
set set. All objects CPU and node sets are restricted accordingly.
By default, set is a CPU set. It means that the set of PUs in the topology is restricted. Once some PUs got
removed, their parents may also get removed recursively if they became child-less.
If HWLOC_RESTRICT_FLAG_BYNODESET is passed in flags, set is considered a nodeset instead of a CPU
set. It means that the set of NUMA nodes in the topology is restricted (instead of PUs). Once some NUMA nodes
got removed, their parents may also get removed recursively if they became child-less.
flags is a OR'ed set of hwloc_restrict_flags_e.
Note
Restricting the topology removes some locality information, hence the remaining objects may get reordered
(including PUs and NUMA nodes), and their logical indexes may change.
This call may not be reverted by restricting back to a larger set. Once dropped during restriction, objects may
not be brought back, except by loading another topology with hwloc_topology_load().
Returns
0 on success.
-1 with errno set to EINVAL if the input set is invalid. The topology is not modified in this case.
-1 with errno set to ENOMEM on failure to allocate internal data. The topology is reinitialized in this case. It
should be either destroyed with hwloc_topology_destroy() or configured and loaded again.
Generated by Doxygen
23.15 Kinds of object Type 133
int hwloc_obj_type_is_cache (
hwloc_obj_type_t type )
Check whether an object type is a CPU Cache (Data, Unified or Instruction).
Memory-side caches are not CPU caches.
Returns
23.15.2.2 hwloc_obj_type_is_dcache()
int hwloc_obj_type_is_dcache (
hwloc_obj_type_t type )
Check whether an object type is a CPU Data or Unified Cache.
Memory-side caches are not CPU caches.
Returns
23.15.2.3 hwloc_obj_type_is_icache()
int hwloc_obj_type_is_icache (
hwloc_obj_type_t type )
Check whether an object type is a CPU Instruction Cache,.
Memory-side caches are not CPU caches.
Returns
23.15.2.4 hwloc_obj_type_is_io()
int hwloc_obj_type_is_io (
hwloc_obj_type_t type )
Check whether an object type is I/O.
I/O objects are objects attached to their parents in the I/O children list. This current includes Bridges, PCI and OS
devices.
Returns
23.15.2.5 hwloc_obj_type_is_memory()
int hwloc_obj_type_is_memory (
hwloc_obj_type_t type )
Check whether an object type is Memory.
Memory objects are objects attached to their parents in the Memory children list. This current includes NUMA nodes
and Memory-side caches.
Returns
Generated by Doxygen
134 Topic Documentation
23.15.2.6 hwloc_obj_type_is_normal()
int hwloc_obj_type_is_normal (
hwloc_obj_type_t type )
Check whether an object type is Normal.
Normal objects are objects of the main CPU hierarchy (Machine, Package, Core, PU, CPU caches, etc.), but they
are not NUMA nodes, I/O devices or Misc objects.
They are attached to parent as Normal children, not as Memory, I/O or Misc children.
Returns
Returns
the first object that is included in set and whose parent is not.
NULL if no such object exists.
This is convenient for iterating over all largest objects within a CPU set by doing a loop getting the first largest object
and clearing its CPU set from the remaining CPU set.
23.16.2.2 hwloc_get_largest_objs_inside_cpuset()
int hwloc_get_largest_objs_inside_cpuset (
hwloc_topology_t topology,
hwloc_const_cpuset_t set,
Generated by Doxygen
23.16 Finding Objects inside a CPU set 135
Returns
23.16.2.3 hwloc_get_nbobjs_inside_cpuset_by_depth()
Returns
Note
Objects with empty CPU sets are ignored (otherwise they would be considered included in any given set).
This function cannot work if objects at the given depth do not have CPU sets (I/O or Misc objects).
23.16.2.4 hwloc_get_nbobjs_inside_cpuset_by_type()
Returns
Note
Objects with empty CPU sets are ignored (otherwise they would be considered included in any given set).
This function cannot work if objects of the given type do not have CPU sets (I/O objects).
23.16.2.5 hwloc_get_next_obj_inside_cpuset_by_depth()
Generated by Doxygen
136 Topic Documentation
Returns
Note
Objects with empty CPU sets are ignored (otherwise they would be considered included in any given set).
This function cannot work if objects at the given depth do not have CPU sets (I/O or Misc objects).
23.16.2.6 hwloc_get_next_obj_inside_cpuset_by_type()
Returns
Note
Objects with empty CPU sets are ignored (otherwise they would be considered included in any given set).
This function cannot work if objects of the given type do not have CPU sets (I/O or Misc objects).
23.16.2.7 hwloc_get_obj_index_inside_cpuset()
Returns
the logical index among the objects included in the set if any.
-1 if the object is not included in the set.
Note
Objects with empty CPU sets are ignored (otherwise they would be considered included in any given set).
This function cannot work if obj does not have CPU sets (I/O objects).
Generated by Doxygen
23.17 Finding Objects covering at least CPU set 137
23.16.2.8 hwloc_get_obj_inside_cpuset_by_depth()
Note
Objects with empty CPU sets are ignored (otherwise they would be considered included in any given set).
This function cannot work if objects at the given depth do not have CPU sets (I/O or Misc objects).
23.16.2.9 hwloc_get_obj_inside_cpuset_by_type()
Note
Objects with empty CPU sets are ignored (otherwise they would be considered included in any given set).
This function cannot work if objects of the given type do not have CPU sets (I/O or Misc objects).
Generated by Doxygen
138 Topic Documentation
Returns
Note
This function cannot work if parent does not have a CPU set (I/O or Misc objects).
23.17.2.2 hwloc_get_next_obj_covering_cpuset_by_depth()
Returns
the first object at depth depth covering at least part of CPU set set if object prev is NULL.
the next one if prev is not NULL.
NULL if there is no next object.
Note
This function cannot work if objects at the given depth do not have CPU sets (I/O or Misc objects).
23.17.2.3 hwloc_get_next_obj_covering_cpuset_by_type()
Returns
the first object of type type covering at least part of CPU set set if object prev is NULL.
the next one if prev is not NULL.
NULL if there is no next object.
NULL if there is no depth for the given type.
NULL if there are multiple depths for the given type, the caller should fallback to hwloc_get_next_obj_covering_cpuset_by_depth(
Note
This function cannot work if objects of the given type do not have CPU sets (I/O or Misc objects).
Generated by Doxygen
23.18 Looking at Ancestor and Child Objects 139
23.17.2.4 hwloc_get_obj_covering_cpuset()
Returns
Returns
Note
depth should not be the depth of PU or NUMA objects since they are ancestors of no objects (except Misc
or I/O). This function rather expects an intermediate level depth, such as the depth of Packages, Cores, or
Caches.
23.18.2.2 hwloc_get_ancestor_obj_by_type()
Generated by Doxygen
140 Topic Documentation
Returns
Note
if multiple matching ancestors exist (e.g. multiple levels of HWLOC_OBJ_GROUP) the lowest one is returned.
type should not be HWLOC_OBJ_PU or HWLOC_OBJ_NUMANODE since these objects are ances-
tors of no objects (except Misc or I/O). This function rather expects an intermediate object type, such as
HWLOC_OBJ_PACKAGE, HWLOC_OBJ_CORE, etc.
23.18.2.3 hwloc_get_common_ancestor_obj()
Returns
Note
23.18.2.4 hwloc_get_next_child()
Returns
23.18.2.5 hwloc_obj_is_in_subtree()
Returns
Note
This function cannot work if obj and subtree_root objects do not have CPU sets (I/O or Misc objects).
Generated by Doxygen
23.19 Looking at Cache Objects 141
Returns
23.19.2.2 hwloc_get_cache_type_depth()
Returns
the depth of the unique matching unified cache level is returned if cachetype is HWLOC_OBJ_CACHE_UNIFIED.
the depth of either a matching cache level or a unified cache level if cachetype is HWLOC_OBJ_CACHE_DATA
or HWLOC_OBJ_CACHE_INSTRUCTION.
the depth of the matching level if cachetype is -1 but only one level matches.
HWLOC_TYPE_DEPTH_MULTIPLE if cachetype is -1 but multiple levels match.
HWLOC_TYPE_DEPTH_UNKNOWN if no cache level matches.
23.19.2.3 hwloc_get_shared_cache_covering_obj()
Returns
a shared cache.
NULL if no cache matches or if an invalid object is given (e.g. I/O object).
Generated by Doxygen
142 Topic Documentation
int hwloc_bitmap_singlify_per_core (
hwloc_topology_t topology,
hwloc_bitmap_t cpuset,
unsigned which )
Remove simultaneous multithreading PUs from a CPU set.
For each core in topology, if cpuset contains some PUs of that core, modify cpuset to only keep a single
PU for that core.
which specifies which PU will be kept. PU are considered in physical index order. If 0, for each core, the function
keeps the first PU that was originally set in cpuset.
If which is larger than the number of PUs in a core there were originally set in cpuset, no PU is kept for that
core.
Returns
0.
Note
PUs that are not below a Core object are ignored (for instance if the topology does not contain any Core
object). None of them is removed from cpuset.
23.20.2.2 hwloc_get_closest_objs()
unsigned hwloc_get_closest_objs (
hwloc_topology_t topology,
hwloc_obj_t src,
hwloc_obj_t ∗restrict objs,
unsigned max )
Do a depth-first traversal of the topology to find and sort.
all objects that are at the same depth than src. Report in objs up to max physically closest ones to src.
Generated by Doxygen
23.20 Finding objects, miscellaneous helpers 143
Returns
Note
23.20.2.3 hwloc_get_numanode_obj_by_os_index()
23.20.2.4 hwloc_get_obj_below_array_by_type()
Note
This function requires all these objects and the root object to have a CPU set.
23.20.2.5 hwloc_get_obj_below_by_type()
Generated by Doxygen
144 Topic Documentation
Returns
Note
23.20.2.6 hwloc_get_obj_with_same_locality()
hwloc_obj_t hwloc_get_obj_with_same_locality (
hwloc_topology_t topology,
hwloc_obj_t src,
hwloc_obj_type_t type,
const char ∗ subtype,
const char ∗ nameprefix,
unsigned long flags )
Return an object of a different type with same locality.
If the source object src is a normal or memory type, this function returns an object of type type with same CPU
and node sets, either below or above in the hierarchy.
If the source object src is a PCI or an OS device within a PCI device, the function may either return that PCI device,
or another OS device in the same PCI parent. This may for instance be useful for converting between OS devices
such as "nvml0" or "rsmi1" used in distance structures into the the PCI device, or the CUDA or OpenCL OS device
that correspond to the same physical card.
If not NULL, parameter subtype only select objects whose subtype attribute exists and is subtype (case-
insensitively), for instance "OpenCL" or "CUDA".
If not NULL, parameter nameprefix only selects objects whose name attribute exists and starts with
nameprefix (case-insensitively), for instance "rsmi" for matching "rsmi0".
If multiple objects match, the first one is returned.
This function will not walk the hierarchy across bridges since the PCI locality may become different. This function
cannot also convert between normal/memory objects and I/O or Misc objects.
flags must be 0 for now.
Returns
23.20.2.7 hwloc_get_pu_obj_by_os_index()
Returns
Generated by Doxygen
23.22 CPU and node sets of entire topologies 145
Functions
• static int hwloc_distrib (hwloc_topology_t topology, hwloc_obj_t ∗roots, unsigned n_roots, hwloc_cpuset_t
∗set, unsigned n, int until, unsigned long flags)
enum hwloc_distrib_flags_e
Flags to be given to hwloc_distrib().
Enumerator
0 on success, -1 on error.
Note
On hybrid CPUs (or asymmetric platforms), distribution may be suboptimal since the number of cores or PUs
inside packages or below caches may vary (the top-down recursive partitioning ignores these numbers until
reaching their levels). Hence it is recommended to distribute only inside a single homogeneous domain.
For instance on a CPU with energy-efficient E-cores and high-performance P-cores, one should distribute
separately N tasks on E-cores and M tasks on P-cores instead of trying to distribute directly M+N tasks on the
entire CPUs.
This function requires the roots objects to have a CPU set.
Generated by Doxygen
146 Topic Documentation
hwloc_const_cpuset_t hwloc_topology_get_allowed_cpuset (
hwloc_topology_t topology )
Get allowed CPU set.
Returns
Note
23.22.2.2 hwloc_topology_get_allowed_nodeset()
hwloc_const_nodeset_t hwloc_topology_get_allowed_nodeset (
hwloc_topology_t topology )
Get allowed node set.
Returns
Note
23.22.2.3 hwloc_topology_get_complete_cpuset()
hwloc_const_cpuset_t hwloc_topology_get_complete_cpuset (
hwloc_topology_t topology )
Get complete CPU set.
Generated by Doxygen
23.22 CPU and node sets of entire topologies 147
Returns
Note
23.22.2.4 hwloc_topology_get_complete_nodeset()
hwloc_const_nodeset_t hwloc_topology_get_complete_nodeset (
hwloc_topology_t topology )
Get complete node set.
Returns
Note
23.22.2.5 hwloc_topology_get_topology_cpuset()
hwloc_const_cpuset_t hwloc_topology_get_topology_cpuset (
hwloc_topology_t topology )
Get topology CPU set.
Returns
the CPU set of processors of the system for which hwloc provides topology information. This is equivalent to
the cpuset of the system object.
Note
23.22.2.6 hwloc_topology_get_topology_nodeset()
hwloc_const_nodeset_t hwloc_topology_get_topology_nodeset (
hwloc_topology_t topology )
Get topology node set.
Returns
the node set of memory of the system for which hwloc provides topology information. This is equivalent to the
nodeset of the system object.
Note
Generated by Doxygen
148 Topic Documentation
Returns
0 on success.
-1 with errno set to ENOMEM on internal reallocation failure.
23.23.2.2 hwloc_cpuset_to_nodeset()
Returns
0 on success.
-1 with errno set to ENOMEM on internal reallocation failure.
Generated by Doxygen
23.24 Finding I/O objects 149
23.24.2.2 hwloc_get_next_bridge()
Returns
23.24.2.3 hwloc_get_next_osdev()
Returns
23.24.2.4 hwloc_get_next_pcidev()
Returns
23.24.2.5 hwloc_get_non_io_ancestor_obj()
Generated by Doxygen
150 Topic Documentation
Returns
a non-I/O object.
Note
23.24.2.6 hwloc_get_pcidev_by_busid()
Returns
23.24.2.7 hwloc_get_pcidev_by_busidstring()
Returns
Typedefs
Functions
Generated by Doxygen
23.25 The bitmap API 151
Generated by Doxygen
152 Topic Documentation
Note
Most functions below return 0 on success and -1 on error. The usual error case would be an in-
ternal failure to realloc/extend the storage of the bitmap (errno would be set to ENOMEM). See also
Error reporting in the API.
Several examples of using the bitmap API are available under the doc/examples/ directory in the source tree.
Regression tests such as tests/hwloc/hwloc_bitmap∗.c also make intensive use of this API.
#define hwloc_bitmap_foreach_begin(
id,
bitmap )
Loop macro iterating on bitmap bitmap.
The loop must start with hwloc_bitmap_foreach_begin() and end with hwloc_bitmap_foreach_end() followed by a
terminating ';'.
id is the loop variable; it should be an unsigned int. The first iteration will set id to the lowest index in the bitmap.
Successive iterations will iterate through, in order, all remaining indexes set in the bitmap. To be specific: each
iteration will return a value for id such that hwloc_bitmap_isset(bitmap, id) is true.
The assert prevents the loop from being infinite if the bitmap is infinitely set.
23.25.2.2 hwloc_bitmap_foreach_end
#define hwloc_bitmap_foreach_end( )
End of loop macro iterating on a bitmap.
Needs a terminating ';'.
See also
hwloc_bitmap_foreach_begin()
23.25.3.2 hwloc_const_bitmap_t
int hwloc_bitmap_allbut (
hwloc_bitmap_t bitmap,
unsigned id )
Fill the bitmap and clear the index id.
23.25.4.2 hwloc_bitmap_alloc()
hwloc_bitmap_t hwloc_bitmap_alloc (
void )
Allocate a new empty bitmap.
Generated by Doxygen
23.25 The bitmap API 153
Returns
23.25.4.3 hwloc_bitmap_alloc_full()
hwloc_bitmap_t hwloc_bitmap_alloc_full (
void )
Allocate a new full bitmap.
Returns
23.25.4.4 hwloc_bitmap_and()
int hwloc_bitmap_and (
hwloc_bitmap_t res,
hwloc_const_bitmap_t bitmap1,
hwloc_const_bitmap_t bitmap2 )
And bitmaps bitmap1 and bitmap2 and store the result in bitmap res.
res can be the same as bitmap1 or bitmap2
23.25.4.5 hwloc_bitmap_andnot()
int hwloc_bitmap_andnot (
hwloc_bitmap_t res,
hwloc_const_bitmap_t bitmap1,
hwloc_const_bitmap_t bitmap2 )
And bitmap bitmap1 and the negation of bitmap2 and store the result in bitmap res.
res can be the same as bitmap1 or bitmap2
23.25.4.6 hwloc_bitmap_asprintf()
int hwloc_bitmap_asprintf (
char ∗∗ strp,
hwloc_const_bitmap_t bitmap )
Stringify a bitmap into a newly allocated string.
Returns
0 on success, -1 on error.
23.25.4.7 hwloc_bitmap_clr()
int hwloc_bitmap_clr (
hwloc_bitmap_t bitmap,
unsigned id )
Remove index id from bitmap bitmap.
23.25.4.8 hwloc_bitmap_clr_range()
int hwloc_bitmap_clr_range (
hwloc_bitmap_t bitmap,
unsigned begin,
int end )
Remove indexes from begin to end in bitmap bitmap.
If end is -1, the range is infinite.
Generated by Doxygen
154 Topic Documentation
23.25.4.9 hwloc_bitmap_compare()
int hwloc_bitmap_compare (
hwloc_const_bitmap_t bitmap1,
hwloc_const_bitmap_t bitmap2 )
Compare bitmaps bitmap1 and bitmap2 in lexicographic order.
Lexicographic comparison of bitmaps, starting for their highest indexes. Compare last indexes first, then second,
etc. The empty bitmap is considered lower than anything.
Returns
For instance comparing binary bitmaps 0011 and 0110 returns -1 (hence 0011 is considered smaller than 0110).
Comparing 00101 and 01010 returns -1 too.
Note
This is different from the non-existing hwloc_bitmap_compare_last() which would only compare the highest
index of each bitmap.
23.25.4.10 hwloc_bitmap_compare_first()
int hwloc_bitmap_compare_first (
hwloc_const_bitmap_t bitmap1,
hwloc_const_bitmap_t bitmap2 )
Compare bitmaps bitmap1 and bitmap2 using their lowest index.
A bitmap is considered smaller if its least significant bit is smaller. The empty bitmap is considered higher than
anything (because its least significant bit does not exist).
Returns
For instance comparing binary bitmaps 0011 and 0110 returns -1 (hence 0011 is considered smaller than 0110)
because least significant bit of 0011 (0001) is smaller than least significant bit of 0110 (0010). Comparing 01001
and 00110 would also return -1 for the same reason.
Returns
0 if bitmaps are considered equal, even if they are not strictly equal. They just need to have the same least
significant bit. For instance, comparing binary bitmaps 0010 and 0110 returns 0 because they have the same
least significant bit.
23.25.4.11 hwloc_bitmap_copy()
int hwloc_bitmap_copy (
hwloc_bitmap_t dst,
hwloc_const_bitmap_t src )
Copy the contents of bitmap src into the already allocated bitmap dst.
23.25.4.12 hwloc_bitmap_dup()
hwloc_bitmap_t hwloc_bitmap_dup (
hwloc_const_bitmap_t bitmap )
Duplicate bitmap bitmap by allocating a new bitmap and copying bitmap contents.
If bitmap is NULL, NULL is returned.
Generated by Doxygen
23.25 The bitmap API 155
23.25.4.13 hwloc_bitmap_fill()
void hwloc_bitmap_fill (
hwloc_bitmap_t bitmap )
Fill bitmap bitmap with all possible indexes (even if those objects don't exist or are otherwise unavailable)
23.25.4.14 hwloc_bitmap_first()
int hwloc_bitmap_first (
hwloc_const_bitmap_t bitmap )
Compute the first index (least significant bit) in bitmap bitmap.
Returns
23.25.4.15 hwloc_bitmap_first_unset()
int hwloc_bitmap_first_unset (
hwloc_const_bitmap_t bitmap )
Compute the first unset index (least significant bit) in bitmap bitmap.
Returns
23.25.4.16 hwloc_bitmap_free()
void hwloc_bitmap_free (
hwloc_bitmap_t bitmap )
Free bitmap bitmap.
If bitmap is NULL, no operation is performed.
23.25.4.17 hwloc_bitmap_from_ith_ulong()
int hwloc_bitmap_from_ith_ulong (
hwloc_bitmap_t bitmap,
unsigned i,
unsigned long mask )
Setup bitmap bitmap from unsigned long mask used as i -th subset.
23.25.4.18 hwloc_bitmap_from_ulong()
int hwloc_bitmap_from_ulong (
hwloc_bitmap_t bitmap,
unsigned long mask )
Setup bitmap bitmap from unsigned long mask.
23.25.4.19 hwloc_bitmap_from_ulongs()
int hwloc_bitmap_from_ulongs (
hwloc_bitmap_t bitmap,
unsigned nr,
const unsigned long ∗ masks )
Setup bitmap bitmap from unsigned longs masks used as first nr subsets.
Generated by Doxygen
156 Topic Documentation
23.25.4.20 hwloc_bitmap_intersects()
int hwloc_bitmap_intersects (
hwloc_const_bitmap_t bitmap1,
hwloc_const_bitmap_t bitmap2 )
Test whether bitmaps bitmap1 and bitmap2 intersects.
Returns
Note
23.25.4.21 hwloc_bitmap_isequal()
int hwloc_bitmap_isequal (
hwloc_const_bitmap_t bitmap1,
hwloc_const_bitmap_t bitmap2 )
Test whether bitmap bitmap1 is equal to bitmap bitmap2.
Returns
23.25.4.22 hwloc_bitmap_isfull()
int hwloc_bitmap_isfull (
hwloc_const_bitmap_t bitmap )
Test whether bitmap bitmap is completely full.
Returns
Note
23.25.4.23 hwloc_bitmap_isincluded()
int hwloc_bitmap_isincluded (
hwloc_const_bitmap_t sub_bitmap,
hwloc_const_bitmap_t super_bitmap )
Test whether bitmap sub_bitmap is part of bitmap super_bitmap.
Returns
Note
23.25.4.24 hwloc_bitmap_isset()
int hwloc_bitmap_isset (
hwloc_const_bitmap_t bitmap,
unsigned id )
Test whether index id is part of bitmap bitmap.
Returns
Generated by Doxygen
23.25 The bitmap API 157
23.25.4.25 hwloc_bitmap_iszero()
int hwloc_bitmap_iszero (
hwloc_const_bitmap_t bitmap )
Test whether bitmap bitmap is empty.
Returns
23.25.4.26 hwloc_bitmap_last()
int hwloc_bitmap_last (
hwloc_const_bitmap_t bitmap )
Compute the last index (most significant bit) in bitmap bitmap.
Returns
23.25.4.27 hwloc_bitmap_last_unset()
int hwloc_bitmap_last_unset (
hwloc_const_bitmap_t bitmap )
Compute the last unset index (most significant bit) in bitmap bitmap.
Returns
23.25.4.28 hwloc_bitmap_list_asprintf()
int hwloc_bitmap_list_asprintf (
char ∗∗ strp,
hwloc_const_bitmap_t bitmap )
Stringify a bitmap into a newly allocated list string.
Returns
0 on success, -1 on error.
23.25.4.29 hwloc_bitmap_list_snprintf()
int hwloc_bitmap_list_snprintf (
char ∗restrict buf,
size_t buflen,
hwloc_const_bitmap_t bitmap )
Stringify a bitmap in the list format.
Lists are comma-separated indexes or ranges. Ranges are dash separated indexes. The last range may not have
an ending indexes if the bitmap is infinitely set.
Up to buflen characters may be written in buffer buf.
If buflen is 0, buf may safely be NULL.
Returns
the number of characters that were actually written if not truncating, or that would have been written (not
including the ending \0).
Generated by Doxygen
158 Topic Documentation
23.25.4.30 hwloc_bitmap_list_sscanf()
int hwloc_bitmap_list_sscanf (
hwloc_bitmap_t bitmap,
const char ∗restrict string )
Parse a list string and stores it in bitmap bitmap.
Returns
0 on success, -1 on error.
23.25.4.31 hwloc_bitmap_next()
int hwloc_bitmap_next (
hwloc_const_bitmap_t bitmap,
int prev )
Compute the next index in bitmap bitmap which is after index prev.
Returns
23.25.4.32 hwloc_bitmap_next_unset()
int hwloc_bitmap_next_unset (
hwloc_const_bitmap_t bitmap,
int prev )
Compute the next unset index in bitmap bitmap which is after index prev.
Returns
23.25.4.33 hwloc_bitmap_not()
int hwloc_bitmap_not (
hwloc_bitmap_t res,
hwloc_const_bitmap_t bitmap )
Negate bitmap bitmap and store the result in bitmap res.
res can be the same as bitmap
23.25.4.34 hwloc_bitmap_nr_ulongs()
int hwloc_bitmap_nr_ulongs (
hwloc_const_bitmap_t bitmap )
Return the number of unsigned longs required for storing bitmap bitmap entirely.
This is the number of contiguous unsigned longs from the very first bit of the bitmap (even if unset) up to the
last set bit. This is useful for knowing the nr parameter to pass to hwloc_bitmap_to_ulongs() (or which calls to
hwloc_bitmap_to_ith_ulong() are needed) to entirely convert a bitmap into multiple unsigned longs.
When called on the output of hwloc_topology_get_topology_cpuset(), the returned number is large enough for all
cpusets of the topology.
Returns
Generated by Doxygen
23.25 The bitmap API 159
23.25.4.35 hwloc_bitmap_only()
int hwloc_bitmap_only (
hwloc_bitmap_t bitmap,
unsigned id )
Empty the bitmap bitmap and add bit id.
23.25.4.36 hwloc_bitmap_or()
int hwloc_bitmap_or (
hwloc_bitmap_t res,
hwloc_const_bitmap_t bitmap1,
hwloc_const_bitmap_t bitmap2 )
Or bitmaps bitmap1 and bitmap2 and store the result in bitmap res.
res can be the same as bitmap1 or bitmap2
23.25.4.37 hwloc_bitmap_set()
int hwloc_bitmap_set (
hwloc_bitmap_t bitmap,
unsigned id )
Add index id in bitmap bitmap.
23.25.4.38 hwloc_bitmap_set_ith_ulong()
int hwloc_bitmap_set_ith_ulong (
hwloc_bitmap_t bitmap,
unsigned i,
unsigned long mask )
Replace i -th subset of bitmap bitmap with unsigned long mask.
23.25.4.39 hwloc_bitmap_set_range()
int hwloc_bitmap_set_range (
hwloc_bitmap_t bitmap,
unsigned begin,
int end )
Add indexes from begin to end in bitmap bitmap.
If end is -1, the range is infinite.
23.25.4.40 hwloc_bitmap_singlify()
int hwloc_bitmap_singlify (
hwloc_bitmap_t bitmap )
Keep a single index among those set in bitmap bitmap.
May be useful before binding so that the process does not have a chance of migrating between multiple processors
in the original mask. Instead of running the task on any PU inside the given CPU set, the operating system scheduler
will be forced to run it on a single of these PUs. It avoids a migration overhead and cache-line ping-pongs between
PUs.
Note
This function is NOT meant to distribute multiple processes within a single CPU set. It always return the same
single bit when called multiple times on the same input set. hwloc_distrib() may be used for generating CPU
sets to distribute multiple tasks below a single multi-PU object.
This function cannot be applied to an object set directly. It should be applied to a copy (which may be obtained
with hwloc_bitmap_dup()).
Generated by Doxygen
160 Topic Documentation
23.25.4.41 hwloc_bitmap_snprintf()
int hwloc_bitmap_snprintf (
char ∗restrict buf,
size_t buflen,
hwloc_const_bitmap_t bitmap )
Stringify a bitmap.
Up to buflen characters may be written in buffer buf.
If buflen is 0, buf may safely be NULL.
Returns
the number of characters that were actually written if not truncating, or that would have been written (not
including the ending \0).
23.25.4.42 hwloc_bitmap_sscanf()
int hwloc_bitmap_sscanf (
hwloc_bitmap_t bitmap,
const char ∗restrict string )
Parse a bitmap string and stores it in bitmap bitmap.
Returns
0 on success, -1 on error.
23.25.4.43 hwloc_bitmap_taskset_asprintf()
int hwloc_bitmap_taskset_asprintf (
char ∗∗ strp,
hwloc_const_bitmap_t bitmap )
Stringify a bitmap into a newly allocated taskset-specific string.
Returns
0 on success, -1 on error.
23.25.4.44 hwloc_bitmap_taskset_snprintf()
int hwloc_bitmap_taskset_snprintf (
char ∗restrict buf,
size_t buflen,
hwloc_const_bitmap_t bitmap )
Stringify a bitmap in the taskset-specific format.
The taskset command manipulates bitmap strings that contain a single (possible very long) hexadecimal number
starting with 0x.
Up to buflen characters may be written in buffer buf.
If buflen is 0, buf may safely be NULL.
Returns
the number of characters that were actually written if not truncating, or that would have been written (not
including the ending \0).
23.25.4.45 hwloc_bitmap_taskset_sscanf()
int hwloc_bitmap_taskset_sscanf (
hwloc_bitmap_t bitmap,
const char ∗restrict string )
Parse a taskset-specific bitmap string and stores it in bitmap bitmap.
Generated by Doxygen
23.26 Exporting Topologies to XML 161
Returns
0 on success, -1 on error.
23.25.4.46 hwloc_bitmap_to_ith_ulong()
23.25.4.47 hwloc_bitmap_to_ulong()
23.25.4.48 hwloc_bitmap_to_ulongs()
int hwloc_bitmap_to_ulongs (
hwloc_const_bitmap_t bitmap,
unsigned nr,
unsigned long ∗ masks )
Convert the first nr subsets of bitmap bitmap into the array of nr unsigned long masks.
nr may be determined earlier with hwloc_bitmap_nr_ulongs().
Returns
23.25.4.49 hwloc_bitmap_weight()
int hwloc_bitmap_weight (
hwloc_const_bitmap_t bitmap )
Compute the "weight" of bitmap bitmap (i.e., number of indexes that are in the bitmap).
Returns
23.25.4.50 hwloc_bitmap_xor()
int hwloc_bitmap_xor (
hwloc_bitmap_t res,
hwloc_const_bitmap_t bitmap1,
hwloc_const_bitmap_t bitmap2 )
Xor bitmaps bitmap1 and bitmap2 and store the result in bitmap res.
res can be the same as bitmap1 or bitmap2
23.25.4.51 hwloc_bitmap_zero()
void hwloc_bitmap_zero (
hwloc_bitmap_t bitmap )
Empty the bitmap bitmap.
Generated by Doxygen
162 Topic Documentation
Functions
• int hwloc_topology_export_xml (hwloc_topology_t topology, const char ∗xmlpath, unsigned long flags)
• int hwloc_topology_export_xmlbuffer (hwloc_topology_t topology, char ∗∗xmlbuffer, int ∗buflen, unsigned long
flags)
• void hwloc_free_xmlbuffer (hwloc_topology_t topology, char ∗xmlbuffer)
• void hwloc_topology_set_userdata_export_callback (hwloc_topology_t topology, void(∗export_cb)(void
∗reserved, hwloc_topology_t topology, hwloc_obj_t obj))
• int hwloc_export_obj_userdata (void ∗reserved, hwloc_topology_t topology, hwloc_obj_t obj, const char
∗name, const void ∗buffer, size_t length)
• int hwloc_export_obj_userdata_base64 (void ∗reserved, hwloc_topology_t topology, hwloc_obj_t obj, const
char ∗name, const void ∗buffer, size_t length)
• void hwloc_topology_set_userdata_import_callback (hwloc_topology_t topology, void(∗import_cb)(hwloc_topology_t
topology, hwloc_obj_t obj, const char ∗name, const void ∗buffer, size_t length))
enum hwloc_topology_export_xml_flags_e
Flags for exporting XML topologies.
Flags to be given as a OR'ed set to hwloc_topology_export_xml().
Enumerator
int hwloc_export_obj_userdata (
void ∗ reserved,
hwloc_topology_t topology,
hwloc_obj_t obj,
const char ∗ name,
const void ∗ buffer,
size_t length )
Export some object userdata to XML.
This function may only be called from within the export() callback passed to hwloc_topology_set_userdata_export_callback().
It may be invoked one of multiple times to export some userdata to XML. The buffer content of length length
is stored with optional name name.
When importing this XML file, the import() callback (if set) will be called exactly as many times as
hwloc_export_obj_userdata() was called during export(). It will receive the corresponding name, buffer and
length arguments.
reserved, topology and obj must be the first three parameters that were given to the export callback.
Only printable characters may be exported to XML string attributes.
If exporting binary data, the application should first encode into printable characters only (or use hwloc_export_obj_userdata_base64())
It should also take care of portability issues if the export may be reimported on a different architecture.
Returns
0 on success.
-1 with errno set to EINVAL if a non-printable character is passed in name or buffer.
Generated by Doxygen
23.26 Exporting Topologies to XML 163
23.26.3.2 hwloc_export_obj_userdata_base64()
int hwloc_export_obj_userdata_base64 (
void ∗ reserved,
hwloc_topology_t topology,
hwloc_obj_t obj,
const char ∗ name,
const void ∗ buffer,
size_t length )
Encode and export some object userdata to XML.
This function is similar to hwloc_export_obj_userdata() but it encodes the input buffer into printable characters
before exporting. On import, decoding is automatically performed before the data is given to the import() callback if
any.
This function may only be called from within the export() callback passed to hwloc_topology_set_userdata_export_callback().
The name must be made of printable characters for export to XML string attributes.
The function does not take care of portability issues if the export may be reimported on a different architecture.
Returns
0 on success.
-1 with errno set to EINVAL if a non-printable character is passed in name.
23.26.3.3 hwloc_free_xmlbuffer()
void hwloc_free_xmlbuffer (
hwloc_topology_t topology,
char ∗ xmlbuffer )
Free a buffer allocated by hwloc_topology_export_xmlbuffer()
23.26.3.4 hwloc_topology_export_xml()
int hwloc_topology_export_xml (
hwloc_topology_t topology,
const char ∗ xmlpath,
unsigned long flags )
Export the topology into an XML file.
This file may be loaded later through hwloc_topology_set_xml().
By default, the latest export format is used, which means older hwloc releases (e.g. v1.x) will not be able to import
it. Exporting to v1.x specific XML format is possible using flag HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1
but it may miss some details about the topology. If there is any chance that the exported file may ever be imported
back by a process using hwloc 1.x, one should consider detecting it at runtime and using the corresponding export
format.
flags is a OR'ed set of hwloc_topology_export_xml_flags_e.
Returns
0 on success, or -1 on error.
Note
Generated by Doxygen
164 Topic Documentation
23.26.3.5 hwloc_topology_export_xmlbuffer()
int hwloc_topology_export_xmlbuffer (
hwloc_topology_t topology,
char ∗∗ xmlbuffer,
int ∗ buflen,
unsigned long flags )
Export the topology into a newly-allocated XML memory buffer.
xmlbuffer is allocated by the callee and should be freed with hwloc_free_xmlbuffer() later in the caller.
This memory buffer may be loaded later through hwloc_topology_set_xmlbuffer().
By default, the latest export format is used, which means older hwloc releases (e.g. v1.x) will not be able to import it.
Exporting to v1.x specific XML format is possible using flag HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1 but
it may miss some details about the topology. If there is any chance that the exported buffer may ever be imported
back by a process using hwloc 1.x, one should consider detecting it at runtime and using the corresponding export
format.
The returned buffer ends with a \0 that is included in the returned length.
flags is a OR'ed set of hwloc_topology_export_xml_flags_e.
Returns
0 on success, or -1 on error.
Note
23.26.3.6 hwloc_topology_set_userdata_export_callback()
void hwloc_topology_set_userdata_export_callback (
hwloc_topology_t topology,
void(∗)(void ∗reserved, hwloc_topology_t topology, hwloc_obj_t obj) export_cb )
Set the application-specific callback for exporting object userdata.
The object userdata pointer is not exported to XML by default because hwloc does not know what it contains.
This function lets applications set export_cb to a callback function that converts this opaque userdata into an
exportable string.
export_cb is invoked during XML export for each object whose userdata pointer is not NULL. The callback
should use hwloc_export_obj_userdata() or hwloc_export_obj_userdata_base64() to actually export something to
XML (possibly multiple times per object).
export_cb may be set to NULL if userdata should not be exported to XML.
Note
23.26.3.7 hwloc_topology_set_userdata_import_callback()
void hwloc_topology_set_userdata_import_callback (
hwloc_topology_t topology,
void(∗)(hwloc_topology_t topology, hwloc_obj_t obj, const char ∗name, const void
∗buffer, size_t length) import_cb )
Set the application-specific callback for importing userdata.
On XML import, userdata is ignored by default because hwloc does not know how to store it in memory.
This function lets applications set import_cb to a callback function that will get the XML-stored userdata and
store it in the object as expected by the application.
import_cb is called during hwloc_topology_load() as many times as hwloc_export_obj_userdata() was called
during export. The topology is not entirely setup yet. Object attributes are ready to consult, but links between
objects are not.
import_cb may be NULL if userdata should be ignored during import.
Generated by Doxygen
23.27 Exporting Topologies to Synthetic 165
Note
Functions
• int hwloc_topology_export_synthetic (hwloc_topology_t topology, char ∗buffer, size_t buflen, unsigned long
flags)
enum hwloc_topology_export_synthetic_flags_e
Flags for exporting synthetic topologies.
Flags to be given as a OR'ed set to hwloc_topology_export_synthetic().
Enumerator
int hwloc_topology_export_synthetic (
hwloc_topology_t topology,
Generated by Doxygen
166 Topic Documentation
char ∗ buffer,
size_t buflen,
unsigned long flags )
Export the topology as a synthetic string.
At most buflen characters will be written in buffer, including the terminating \0.
This exported string may be given back to hwloc_topology_set_synthetic().
flags is a OR'ed set of hwloc_topology_export_synthetic_flags_e.
Returns
The number of characters that were written, not including the terminating \0.
-1 if the topology could not be exported, for instance if it is not symmetric.
Note
I/O and Misc children are ignored, the synthetic string only describes normal children.
A 1024-byte buffer should be large enough for exporting topologies in the vast majority of cases.
• struct hwloc_distances_s
Enumerations
• enum hwloc_distances_kind_e {
HWLOC_DISTANCES_KIND_FROM_OS , HWLOC_DISTANCES_KIND_FROM_USER , HWLOC_DISTANCES_KIND_MEANS
, HWLOC_DISTANCES_KIND_MEANS_BANDWIDTH ,
HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES }
• enum hwloc_distances_transform_e { HWLOC_DISTANCES_TRANSFORM_REMOVE_NULL , HWLOC_DISTANCES_TRANS
, HWLOC_DISTANCES_TRANSFORM_MERGE_SWITCH_PORTS , HWLOC_DISTANCES_TRANSFORM_TRANSITIVE_CL
}
Functions
enum hwloc_distances_kind_e
Kinds of distance matrices.
The kind attribute of struct hwloc_distances_s is a OR'ed set of kinds.
Generated by Doxygen
23.28 Retrieve distances between objects 167
Each distance matrix may have only one kind among HWLOC_DISTANCES_KIND_FROM_∗ specifying where
distance information comes from, and one kind among HWLOC_DISTANCES_KIND_MEANS_∗ specifying whether
values are latencies or bandwidths.
Generated by Doxygen
168 Topic Documentation
Enumerator
23.28.2.2 hwloc_distances_transform_e
enum hwloc_distances_transform_e
Transformations of distances structures.
Enumerator
Generated by Doxygen
23.28 Retrieve distances between objects 169
Enumerator
int hwloc_distances_get (
hwloc_topology_t topology,
unsigned ∗ nr,
struct hwloc_distances_s ∗∗ distances,
unsigned long kind,
unsigned long flags )
Retrieve distance matrices.
Retrieve distance matrices from the topology into the distances array.
flags is currently unused, should be 0.
kind serves as a filter. If 0, all distance matrices are returned. If it contains some HWLOC_DISTANCES_KIND←-
_FROM_∗, only distance matrices whose kind matches one of these are returned. If it contains some HWLOC_←-
DISTANCES_KIND_MEANS_∗, only distance matrices whose kind matches one of these are returned.
On input, nr points to the number of distance matrices that may be stored in distances. On output, nr points to
the number of distance matrices that were actually found, even if some of them couldn't be stored in distances.
Distance matrices that couldn't be stored are ignored, but the function still returns success (0). The caller may find
out by comparing the value pointed by nr before and after the function call.
Each distance matrix returned in the distances array should be released by the caller using hwloc_distances_release().
Returns
0 on success, -1 on error.
23.28.3.2 hwloc_distances_get_by_depth()
int hwloc_distances_get_by_depth (
hwloc_topology_t topology,
int depth,
unsigned ∗ nr,
struct hwloc_distances_s ∗∗ distances,
unsigned long kind,
unsigned long flags )
Retrieve distance matrices for object at a specific depth in the topology.
Identical to hwloc_distances_get() with the additional depth filter.
Returns
0 on success, -1 on error.
23.28.3.3 hwloc_distances_get_by_name()
int hwloc_distances_get_by_name (
hwloc_topology_t topology,
const char ∗ name,
unsigned ∗ nr,
struct hwloc_distances_s ∗∗ distances,
unsigned long flags )
Generated by Doxygen
170 Topic Documentation
Returns
0 on success, -1 on error.
23.28.3.4 hwloc_distances_get_by_type()
int hwloc_distances_get_by_type (
hwloc_topology_t topology,
hwloc_obj_type_t type,
unsigned ∗ nr,
struct hwloc_distances_s ∗∗ distances,
unsigned long kind,
unsigned long flags )
Retrieve distance matrices for object of a specific type.
Identical to hwloc_distances_get() with the additional type filter.
Returns
0 on success, -1 on error.
23.28.3.5 hwloc_distances_get_name()
Returns
Note
The returned name should not be freed by the caller, it belongs to the hwloc library.
23.28.3.6 hwloc_distances_release()
void hwloc_distances_release (
hwloc_topology_t topology,
struct hwloc_distances_s ∗ distances )
Release a distance matrix structure previously returned by hwloc_distances_get().
Note
23.28.3.7 hwloc_distances_transform()
int hwloc_distances_transform (
hwloc_topology_t topology,
struct hwloc_distances_s ∗ distances,
enum hwloc_distances_transform_e transform,
void ∗ transform_attr,
unsigned long flags )
Generated by Doxygen
23.29 Helpers for consulting distance matrices 171
Note
Objects in distances array objs may be directly modified in place without using hwloc_distances_transform().
One may use hwloc_get_obj_with_same_locality() to easily convert between similar objects of different types.
Returns
23.29.2.2 hwloc_distances_obj_pair_values()
Returns
0 on success.
-1 if object obj1 or obj2 is not involved in structure distances.
Generated by Doxygen
172 Topic Documentation
Enumerations
Functions
enum hwloc_distances_add_flag_e
Flags for adding a new distances to a topology.
Enumerator
Generated by Doxygen
23.30 Add distances between objects 173
int hwloc_distances_add_commit (
hwloc_topology_t topology,
hwloc_distances_add_handle_t handle,
unsigned long flags )
Commit a new distances structure.
This function finalizes the distances structure and inserts in it the topology.
Parameter handle was previously returned by hwloc_distances_add_create(). Then objects and values were
specified with hwloc_distances_add_values().
flags configures the behavior of the function using an optional OR'ed set of hwloc_distances_add_flag_e. It may
be used to request the grouping of existing objects based on distances.
On error, the temporary distances structure and its content are destroyed.
Returns
0 on success.
-1 on error.
23.30.4.2 hwloc_distances_add_create()
hwloc_distances_add_handle_t hwloc_distances_add_create (
hwloc_topology_t topology,
const char ∗ name,
unsigned long kind,
unsigned long flags )
Create a new empty distances structure.
Create an empty distances structure to be filled with hwloc_distances_add_values() and then committed with
hwloc_distances_add_commit().
Parameter name is optional, it may be NULL. Otherwise, it will be copied internally and may later be freed by the
caller.
kind specifies the kind of distance as a OR'ed set of hwloc_distances_kind_e. Only one kind of meaning and
one kind of provenance may be given if appropriate (e.g. HWLOC_DISTANCES_KIND_MEANS_BANDWIDTH and
HWLOC_DISTANCES_KIND_FROM_USER). Kind HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES
will be automatically set according to objects having different types in hwloc_distances_add_values().
flags must be 0 for now.
Returns
23.30.4.3 hwloc_distances_add_values()
int hwloc_distances_add_values (
hwloc_topology_t topology,
hwloc_distances_add_handle_t handle,
unsigned nbobjs,
hwloc_obj_t ∗ objs,
hwloc_uint64_t ∗ values,
unsigned long flags )
Specify the objects and values in a new empty distances structure.
Specify the objects and values for a new distances structure that was returned as a handle by hwloc_distances_add_create().
The structure must then be committed with hwloc_distances_add_commit().
The number of objects is nbobjs and the array of objects is objs. Distance values are stored as a one-dimension
array in values. The distance from object i to object j is in slot i∗nbobjs+j.
Generated by Doxygen
174 Topic Documentation
0 on success.
-1 on error.
int hwloc_distances_release_remove (
hwloc_topology_t topology,
struct hwloc_distances_s ∗ distances )
Release and remove the given distance matrice from the topology.
This function includes a call to hwloc_distances_release().
Returns
0 on success, -1 on error.
23.31.2.2 hwloc_distances_remove()
int hwloc_distances_remove (
hwloc_topology_t topology )
Remove all distance matrices from a topology.
Remove all distance matrices, either provided by the user or gathered through the OS.
If these distances were used to group objects, these additional Group objects are not removed from the topology.
Returns
0 on success, -1 on error.
23.31.2.3 hwloc_distances_remove_by_depth()
int hwloc_distances_remove_by_depth (
hwloc_topology_t topology,
int depth )
Remove distance matrices for objects at a specific depth in the topology.
Identical to hwloc_distances_remove() but only applies to one level of the topology.
Returns
0 on success, -1 on error.
Generated by Doxygen
23.32 Comparing memory node attributes for finding where to allocate on 175
23.31.2.4 hwloc_distances_remove_by_type()
Returns
0 on success, -1 on error.
• struct hwloc_location
Typedefs
Enumerations
• enum hwloc_memattr_id_e {
HWLOC_MEMATTR_ID_CAPACITY , HWLOC_MEMATTR_ID_LOCALITY , HWLOC_MEMATTR_ID_BANDWIDTH
, HWLOC_MEMATTR_ID_READ_BANDWIDTH ,
HWLOC_MEMATTR_ID_WRITE_BANDWIDTH , HWLOC_MEMATTR_ID_LATENCY , HWLOC_MEMATTR_ID_READ_LATEN
, HWLOC_MEMATTR_ID_WRITE_LATENCY ,
HWLOC_MEMATTR_ID_MAX }
• enum hwloc_location_type_e { HWLOC_LOCATION_TYPE_CPUSET , HWLOC_LOCATION_TYPE_OBJECT
}
• enum hwloc_local_numanode_flag_e { HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY ,
HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY , HWLOC_LOCAL_NUMANODE_FLAG_ALL
}
Functions
Generated by Doxygen
176 Topic Documentation
depends on their locality (NUMA platforms) as well as the intrinsic performance of the targets (heterogeneous
platforms).
The following attributes describe the performance of memory accesses from an Initiator to a memory Target, for
instance their latency or bandwidth. Initiators performing these memory accesses are usually some PUs or Cores
(described as a CPU set). Hence a Core may choose where to allocate a memory buffer by comparing the attributes
of different target memory nodes nearby.
There are also some attributes that are system-wide. Their value does not depend on a specific initiator performing
an access. The memory node Capacity is an example of such attribute without initiator.
One way to use this API is to start with a cpuset describing the Cores where a program is bound. The best target
NUMA node for allocating memory in this program on these Cores may be obtained by passing this cpuset as an
initiator to hwloc_memattr_get_best_target() with the relevant memory attribute. For instance, if the code is latency
limited, use the Latency attribute.
A more flexible approach consists in getting the list of local NUMA nodes by passing this cpuset to
hwloc_get_local_numanode_objs(). Attribute values for these nodes, if any, may then be obtained with
hwloc_memattr_get_value() and manually compared with the desired criteria.
Memory attributes are also used internally to build Memory Tiers which provide an easy way to distinguish NUMA
nodes of different kinds, as explained in Heterogeneous Memory.
See also
Note
The API also supports specific objects as initiator, but it is currently not used internally by hwloc. Users may
for instance use it to provide custom performance values for host memory accesses performed by GPUs.
The interface actually also accepts targets that are not NUMA nodes.
enum hwloc_local_numanode_flag_e
Flags for selecting target NUMA nodes.
Enumerator
Generated by Doxygen
23.32 Comparing memory node attributes for finding where to allocate on 177
23.32.3.2 hwloc_location_type_e
enum hwloc_location_type_e
Type of location.
Enumerator
23.32.3.3 hwloc_memattr_id_e
enum hwloc_memattr_id_e
Predefined memory attribute IDs. See hwloc_memattr_id_t for the generic definition of IDs for predefined or custom
attributes.
Enumerator
Generated by Doxygen
178 Topic Documentation
Enumerator
int hwloc_get_local_numanode_objs (
hwloc_topology_t topology,
struct hwloc_location ∗ location,
unsigned ∗ nr,
hwloc_obj_t ∗ nodes,
unsigned long flags )
Return an array of local NUMA nodes.
By default only select the NUMA nodes whose locality is exactly the given location. More nodes may be selected
if additional flags are given as a OR'ed set of hwloc_local_numanode_flag_e.
If location is given as an explicit object, its CPU set is used to find NUMA nodes with the corresponding locality.
If the object does not have a CPU set (e.g. I/O object), the CPU parent (where the I/O object is attached) is used.
On input, nr points to the number of nodes that may be stored in the nodes array. On output, nr will be changed
to the number of stored nodes, or the number of nodes that would have been stored if there were enough room.
Returns
0 on success or -1 on error.
Generated by Doxygen
23.32 Comparing memory node attributes for finding where to allocate on 179
Note
Some of these NUMA nodes may not have any memory attribute values and hence not be reported as actual
targets in other functions.
The number of NUMA nodes in the topology (obtained by hwloc_bitmap_weight() on the root object nodeset)
may be used to allocate the nodes array.
When an object CPU set is given as locality, for instance a Package, and when flags contain both
HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY and HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALIT
the returned array corresponds to the nodeset of that object.
23.32.4.2 hwloc_memattr_get_best_initiator()
int hwloc_memattr_get_best_initiator (
hwloc_topology_t topology,
hwloc_memattr_id_t attribute,
hwloc_obj_t target_node,
unsigned long flags,
struct hwloc_location ∗ best_initiator,
hwloc_uint64_t ∗ value )
Return the best initiator for the given attribute and target NUMA node.
If value is non NULL, the corresponding value is returned there.
If multiple initiators have the same attribute values, only one is returned (and there is no way to clarify how that one
is chosen). Applications that want to detect initiators with identical/similar values, or that want to look at values for
multiple attributes, should rather get all values using hwloc_memattr_get_value() and manually select the initiator
they consider the best.
The returned initiator should not be modified or freed, it belongs to the topology.
target_node cannot be NULL.
flags must be 0 for now.
Returns
0 on success.
-1 with errno set to ENOENT if there are no matching initiators.
-1 with errno set to EINVAL if the attribute does not relate to a specific initiator (it does not have the flag
HWLOC_MEMATTR_FLAG_NEED_INITIATOR).
23.32.4.3 hwloc_memattr_get_best_target()
int hwloc_memattr_get_best_target (
hwloc_topology_t topology,
hwloc_memattr_id_t attribute,
struct hwloc_location ∗ initiator,
unsigned long flags,
hwloc_obj_t ∗ best_target,
hwloc_uint64_t ∗ value )
Return the best target NUMA node for the given attribute and initiator.
If the attribute does not relate to a specific initiator (it does not have the flag HWLOC_MEMATTR_FLAG_NEED_INITIATOR),
location initiator is ignored and may be NULL.
If value is non NULL, the corresponding value is returned there.
If multiple targets have the same attribute values, only one is returned (and there is no way to clarify how that one
is chosen). Applications that want to detect targets with identical/similar values, or that want to look at values for
multiple attributes, should rather get all values using hwloc_memattr_get_value() and manually select the target
they consider the best.
flags must be 0 for now.
Generated by Doxygen
180 Topic Documentation
Returns
0 on success.
-1 with errno set to ENOENT if there are no matching targets.
-1 with errno set to EINVAL if flags are invalid, or no such attribute exists.
Note
23.32.4.4 hwloc_memattr_get_by_name()
int hwloc_memattr_get_by_name (
hwloc_topology_t topology,
const char ∗ name,
hwloc_memattr_id_t ∗ id )
Return the identifier of the memory attribute with the given name.
Returns
0 on success.
-1 with errno set to EINVAL if no such attribute exists.
23.32.4.5 hwloc_memattr_get_initiators()
int hwloc_memattr_get_initiators (
hwloc_topology_t topology,
hwloc_memattr_id_t attribute,
hwloc_obj_t target_node,
unsigned long flags,
unsigned ∗ nr,
struct hwloc_location ∗ initiators,
hwloc_uint64_t ∗ values )
Return the initiators that have values for a given attribute for a specific target NUMA node.
Return initiators for the given attribute and target node in the initiators array. If values is not NULL, the
corresponding attribute values are stored in the array it points to.
On input, nr points to the number of initiators that may be stored in the array initiators (and values). On
output, nr points to the number of initiators (and values) that were actually found, even if some of them couldn't be
stored in the array. Initiators that couldn't be stored are ignored, but the function still returns success (0). The caller
may find out by comparing the value pointed by nr before and after the function call.
The returned initiators should not be modified or freed, they belong to the topology.
target_node cannot be NULL.
flags must be 0 for now.
If the attribute does not relate to a specific initiator (it does not have the flag HWLOC_MEMATTR_FLAG_NEED_INITIATOR),
no initiator is returned.
Returns
0 on success or -1 on error.
Note
This function is meant for tools and debugging (listing internal information) rather than for application queries.
Applications should rather select useful NUMA nodes with hwloc_get_local_numanode_objs() and then look
at their attribute values for some relevant initiators.
Generated by Doxygen
23.32 Comparing memory node attributes for finding where to allocate on 181
23.32.4.6 hwloc_memattr_get_targets()
int hwloc_memattr_get_targets (
hwloc_topology_t topology,
hwloc_memattr_id_t attribute,
struct hwloc_location ∗ initiator,
unsigned long flags,
unsigned ∗ nr,
hwloc_obj_t ∗ targets,
hwloc_uint64_t ∗ values )
Return the target NUMA nodes that have some values for a given attribute.
Return targets for the given attribute in the targets array (for the given initiator if any). If values is not NULL,
the corresponding attribute values are stored in the array it points to.
On input, nr points to the number of targets that may be stored in the array targets (and values). On output,
nr points to the number of targets (and values) that were actually found, even if some of them couldn't be stored in
the array. Targets that couldn't be stored are ignored, but the function still returns success (0). The caller may find
out by comparing the value pointed by nr before and after the function call.
The returned targets should not be modified or freed, they belong to the topology.
Argument initiator is ignored if the attribute does not relate to a specific initiator (it does not have the flag
HWLOC_MEMATTR_FLAG_NEED_INITIATOR). Otherwise initiator may be non NULL to report only targets
that have a value for that initiator.
flags must be 0 for now.
Note
This function is meant for tools and debugging (listing internal information) rather than for application queries.
Applications should rather select useful NUMA nodes with hwloc_get_local_numanode_objs() and then look
at their attribute values.
Returns
0 on success or -1 on error.
Note
23.32.4.7 hwloc_memattr_get_value()
int hwloc_memattr_get_value (
hwloc_topology_t topology,
hwloc_memattr_id_t attribute,
hwloc_obj_t target_node,
struct hwloc_location ∗ initiator,
unsigned long flags,
hwloc_uint64_t ∗ value )
Return an attribute value for a specific target NUMA node.
If the attribute does not relate to a specific initiator (it does not have the flag HWLOC_MEMATTR_FLAG_NEED_INITIATOR),
location initiator is ignored and may be NULL.
target_node cannot be NULL. If attribute is HWLOC_MEMATTR_ID_CAPACITY, target_node must
be a NUMA node. If it is HWLOC_MEMATTR_ID_LOCALITY, target_node must have a CPU set.
flags must be 0 for now.
Returns
0 on success.
-1 on error, for instance with errno set to EINVAL if flags are invalid or no such attribute exists.
Generated by Doxygen
182 Topic Documentation
Note
Functions
enum hwloc_memattr_flag_e
Memory attribute flags. Given to hwloc_memattr_register() and returned by hwloc_memattr_get_flags().
Enumerator
HWLOC_MEMATTR_FLAG_HIGHER_FIRST The best nodes for this memory attribute are those with the
higher values. For instance Bandwidth.
HWLOC_MEMATTR_FLAG_LOWER_FIRST The best nodes for this memory attribute are those with the
lower values. For instance Latency.
HWLOC_MEMATTR_FLAG_NEED_INITIATOR The value returned for this memory attribute depends on the
given initiator. For instance Bandwidth and Latency, but not
Capacity.
int hwloc_memattr_get_flags (
Generated by Doxygen
23.33 Managing memory attributes 183
hwloc_topology_t topology,
hwloc_memattr_id_t attribute,
unsigned long ∗ flags )
Return the flags of the given attribute.
Flags are a OR'ed set of hwloc_memattr_flag_e.
The output pointer flags cannot be NULL.
Returns
0 on success.
-1 with errno set to EINVAL if the attribute does not exist.
23.33.3.2 hwloc_memattr_get_name()
int hwloc_memattr_get_name (
hwloc_topology_t topology,
hwloc_memattr_id_t attribute,
const char ∗∗ name )
Return the name of a memory attribute.
The output pointer name cannot be NULL.
Returns
0 on success.
-1 with errno set to EINVAL if the attribute does not exist.
23.33.3.3 hwloc_memattr_register()
int hwloc_memattr_register (
hwloc_topology_t topology,
const char ∗ name,
unsigned long flags,
hwloc_memattr_id_t ∗ id )
Register a new memory attribute.
Add a new custom memory attribute. Flags are a OR'ed set of hwloc_memattr_flag_e. It must contain one of
HWLOC_MEMATTR_FLAG_HIGHER_FIRST or HWLOC_MEMATTR_FLAG_LOWER_FIRST but not both.
The new attribute id is immediately after the last existing attribute ID (which is either the ID of the last registered
attribute if any, or the ID of the last predefined attribute in hwloc_memattr_id_e).
Returns
0 on success.
-1 with errno set to EINVAL if an invalid set of flags is given.
-1 with errno set to EBUSY if another attribute already uses this name.
23.33.3.4 hwloc_memattr_set_value()
int hwloc_memattr_set_value (
hwloc_topology_t topology,
hwloc_memattr_id_t attribute,
hwloc_obj_t target_node,
struct hwloc_location ∗ initiator,
unsigned long flags,
hwloc_uint64_t value )
Set an attribute value for a specific target NUMA node.
If the attribute does not relate to a specific initiator (it does not have the flag HWLOC_MEMATTR_FLAG_NEED_INITIATOR),
location initiator is ignored and may be NULL.
Generated by Doxygen
184 Topic Documentation
The initiator will be copied into the topology, the caller should free anything allocated to store the initiator, for instance
the cpuset.
target_node cannot be NULL.
attribute cannot be ::HWLOC_MEMATTR_FLAG_ID_CAPACITY or ::HWLOC_MEMATTR_FLAG_ID_←-
LOCALITY.
flags must be 0 for now.
Note
Returns
0 on success or -1 on error.
int hwloc_cpukinds_get_by_cpuset (
hwloc_topology_t topology,
Generated by Doxygen
23.34 Kinds of CPU cores 185
hwloc_const_bitmap_t cpuset,
unsigned long flags )
Get the index of the CPU kind that contains CPUs listed in cpuset.
flags must be 0 for now.
Returns
23.34.2.2 hwloc_cpukinds_get_info()
int hwloc_cpukinds_get_info (
hwloc_topology_t topology,
unsigned kind_index,
hwloc_bitmap_t cpuset,
int ∗ efficiency,
unsigned ∗ nr_infos,
struct hwloc_info_s ∗∗ infos,
unsigned long flags )
Get the CPU set and infos about a CPU kind in the topology.
kind_index identifies one kind of CPU between 0 and the number of kinds returned by hwloc_cpukinds_get_nr()
minus 1.
If not NULL, the bitmap cpuset will be filled with the set of PUs of this kind.
The integer pointed by efficiency, if not NULL will, be filled with the ranking of this kind of CPU in term of
efficiency (see above). It ranges from 0 to the number of kinds (as reported by hwloc_cpukinds_get_nr()) minus 1.
Kinds with lower efficiency are reported first.
If there is a single kind in the topology, its efficiency 0. If the efficiency of some kinds of cores is unknown, the
efficiency of all kinds is set to -1, and kinds are reported in no specific order.
The array of info attributes (for instance the "CoreType", "FrequencyMaxMHz" or "FrequencyBaseMHz", see
CPU Kinds) and its length are returned in infos or nr_infos. The array belongs to the topology, it should
not be freed or modified.
If nr_infos or infos is NULL, no info is returned.
flags must be 0 for now.
Returns
0 on success.
-1 with errno set to ENOENT if kind_index does not match any CPU kind.
-1 with errno set to EINVAL if parameters are invalid.
23.34.2.3 hwloc_cpukinds_get_nr()
int hwloc_cpukinds_get_nr (
hwloc_topology_t topology,
unsigned long flags )
Get the number of different kinds of CPU cores in the topology.
flags must be 0 for now.
Returns
Generated by Doxygen
186 Topic Documentation
23.34.2.4 hwloc_cpukinds_register()
int hwloc_cpukinds_register (
hwloc_topology_t topology,
hwloc_bitmap_t cpuset,
int forced_efficiency,
unsigned nr_infos,
struct hwloc_info_s ∗ infos,
unsigned long flags )
Register a kind of CPU in the topology.
Mark the PUs listed in cpuset as being of the same kind with respect to the given attributes.
forced_efficiency should be -1 if unknown. Otherwise it is an abstracted efficiency value to enforce the
ranking of all kinds if all of them have valid (and different) efficiencies.
The array infos of size nr_infos may be used to provide info names and values describing this kind of PUs.
flags must be 0 for now.
Parameters cpuset and infos will be duplicated internally, the caller is responsible for freeing them.
If cpuset overlaps with some existing kinds, those might get modified or split. For instance if existing kind A
contains PUs 0 and 1, and one registers another kind for PU 1 and 2, there will be 3 resulting kinds: existing
kind A is restricted to only PU 0; new kind B contains only PU 1 and combines information from A and from the
newly-registered kind; new kind C contains only PU 2 and only gets information from the newly-registered kind.
Note
The efficiency forced_efficiency provided to this function may be different from the one reported later
by hwloc_cpukinds_get_info() because hwloc will scale efficiency values down to between 0 and the number
of kinds minus 1.
Returns
0 on success.
-1 with errno set to EINVAL if some parameters are invalid, for instance if cpuset is NULL or empty.
int hwloc_linux_get_tid_cpubind (
hwloc_topology_t topology,
pid_t tid,
hwloc_cpuset_t set )
Get the current binding of thread tid.
The CPU-set set (previously allocated by the caller) is filled with the list of PUs which the thread was last bound
to.
The behavior is exactly the same as the Linux sched_getaffinity system call, but uses a hwloc cpuset.
Generated by Doxygen
23.35 Linux-specific helpers 187
Returns
0 on success, -1 on error.
Note
23.35.2.2 hwloc_linux_get_tid_last_cpu_location()
int hwloc_linux_get_tid_last_cpu_location (
hwloc_topology_t topology,
pid_t tid,
hwloc_bitmap_t set )
Get the last physical CPU where thread tid ran.
The CPU-set set (previously allocated by the caller) is filled with the PU which the thread last ran on.
Returns
0 on success, -1 on error.
Note
23.35.2.3 hwloc_linux_read_path_as_cpumask()
int hwloc_linux_read_path_as_cpumask (
const char ∗ path,
hwloc_bitmap_t set )
Convert a linux kernel cpumask file path into a hwloc bitmap set.
Might be used when reading CPU set from sysfs attributes such as topology and caches for processors, or local←-
_cpus for devices.
Returns
0 on success, -1 on error.
Note
23.35.2.4 hwloc_linux_set_tid_cpubind()
int hwloc_linux_set_tid_cpubind (
hwloc_topology_t topology,
pid_t tid,
hwloc_const_cpuset_t set )
Bind a thread tid on cpus given in cpuset set.
The behavior is exactly the same as the Linux sched_setaffinity system call, but uses a hwloc cpuset.
Returns
0 on success, -1 on error.
Note
Generated by Doxygen
188 Topic Documentation
Note
Returns
0 on success.
-1 on error, for instance if failing an internal reallocation.
23.36.2.2 hwloc_cpuset_to_linux_libnuma_ulongs()
Returns
0.
Generated by Doxygen
23.37 Interoperability with Linux libnuma bitmask 189
23.36.2.3 hwloc_nodeset_from_linux_libnuma_ulongs()
Returns
0 on success.
-1 with errno set to ENOMEM if some internal reallocation failed.
23.36.2.4 hwloc_nodeset_to_linux_libnuma_ulongs()
Returns
0.
Note
Generated by Doxygen
190 Topic Documentation
0 on success.
-1 with errno set to ENOMEM if some internal reallocation failed.
23.37.2.2 hwloc_cpuset_to_linux_libnuma_bitmask()
23.37.2.3 hwloc_nodeset_from_linux_libnuma_bitmask()
0 on success.
-1 with errno set to ENOMEM if some internal reallocation failed.
23.37.2.4 hwloc_nodeset_to_linux_libnuma_bitmask()
Generated by Doxygen
23.39 Interoperability with glibc sched affinity 191
int hwloc_windows_get_nr_processor_groups (
hwloc_topology_t topology,
unsigned long flags )
Get the number of Windows processor groups.
flags must be 0 for now.
Returns
at least 1 on success.
-1 on error, for instance if the topology does not match the current system (e.g. loaded from another machine
through XML).
23.38.2.2 hwloc_windows_get_processor_group_cpuset()
int hwloc_windows_get_processor_group_cpuset (
hwloc_topology_t topology,
unsigned pg_index,
hwloc_cpuset_t cpuset,
unsigned long flags )
Get the CPU-set of a Windows processor group.
Get the set of PU included in the processor group specified by pg_index. pg_index must be between 0 and
the value returned by hwloc_windows_get_nr_processor_groups() minus 1.
flags must be 0 for now.
Returns
0 on success.
-1 on error, for instance if pg_index is invalid, or if the topology does not match the current system (e.g.
loaded from another machine through XML).
Note
Generated by Doxygen
192 Topic Documentation
0 on success.
-1 with errno set to ENOMEM if some internal reallocation failed.
23.39.2.2 hwloc_cpuset_to_glibc_sched_affinity()
0.
• static int hwloc_opencl_get_device_pci_busid (cl_device_id device, unsigned ∗domain, unsigned ∗bus, un-
signed ∗dev, unsigned ∗func)
• static int hwloc_opencl_get_device_cpuset (hwloc_topology_t topology, cl_device_id device, hwloc_cpuset_t
set)
• static hwloc_obj_t hwloc_opencl_get_device_osdev_by_index (hwloc_topology_t topology, unsigned
platform_index, unsigned device_index)
• static hwloc_obj_t hwloc_opencl_get_device_osdev (hwloc_topology_t topology, cl_device_id device)
Generated by Doxygen
23.40 Interoperability with OpenCL 193
Get the CPU set of processors that are physically close to OpenCL device device.
Store in set the CPU-set describing the locality of the OpenCL device device.
Topology topology and device device must match the local machine. I/O devices detection and the OpenCL
component are not needed in the topology.
The function only returns the locality of the device. If more information about the device is needed, OS objects
should be used instead, see hwloc_opencl_get_device_osdev() and hwloc_opencl_get_device_osdev_by_index().
This function is currently only implemented in a meaningful way for Linux with the AMD or NVIDIA OpenCL imple-
mentation; other systems will simply get a full cpuset.
Returns
0 on success.
-1 on error, for instance if the device could not be found.
23.40.2.2 hwloc_opencl_get_device_osdev()
Returns
The hwloc OS device object corresponding to the given OpenCL device device.
NULL if none could be found, for instance if required OpenCL attributes are not available.
This function currently only works on AMD and NVIDIA OpenCL devices that support relevant OpenCL extensions.
hwloc_opencl_get_device_osdev_by_index() should be preferred whenever possible, i.e. when platform and device
index are known.
Topology topology and device device must match the local machine. I/O devices detection and the Open←-
CL component must be enabled in the topology. If not, the locality of the object may still be found using
hwloc_opencl_get_device_cpuset().
Note
23.40.2.3 hwloc_opencl_get_device_osdev_by_index()
Returns
The hwloc OS device object describing the OpenCL device whose platform index is platform_index, and
whose device index within this platform if device_index.
NULL if there is none.
The topology topology does not necessarily have to match the current machine. For instance the topology may
be an XML import of a remote host. I/O devices detection and the OpenCL component must be enabled in the
topology.
Note
The corresponding PCI device object can be obtained by looking at the OS device parent object (unless PCI
devices are filtered out).
Generated by Doxygen
194 Topic Documentation
23.40.2.4 hwloc_opencl_get_device_pci_busid()
0 on success.
-1 on error, for instance if device information could not be found.
• static int hwloc_cuda_get_device_pci_ids (hwloc_topology_t topology, CUdevice cudevice, int ∗domain, int
∗bus, int ∗dev)
• static int hwloc_cuda_get_device_cpuset (hwloc_topology_t topology, CUdevice cudevice, hwloc_cpuset_t
set)
• static hwloc_obj_t hwloc_cuda_get_device_pcidev (hwloc_topology_t topology, CUdevice cudevice)
• static hwloc_obj_t hwloc_cuda_get_device_osdev (hwloc_topology_t topology, CUdevice cudevice)
• static hwloc_obj_t hwloc_cuda_get_device_osdev_by_index (hwloc_topology_t topology, unsigned idx)
Returns
0 on success.
-1 on error, for instance if device information could not be found.
23.41.2.2 hwloc_cuda_get_device_osdev()
Generated by Doxygen
23.41 Interoperability with the CUDA Driver API 195
Returns
The hwloc OS device object that describes the given CUDA device cudevice.
NULL if none could be found.
Topology topology and device cudevice must match the local machine. I/O devices detection and the
CUDA component must be enabled in the topology. If not, the locality of the object may still be found using
hwloc_cuda_get_device_cpuset().
Note
23.41.2.3 hwloc_cuda_get_device_osdev_by_index()
Returns
The hwloc OS device object describing the CUDA device whose index is idx.
NULL if none could be found.
The topology topology does not necessarily have to match the current machine. For instance the topology
may be an XML import of a remote host. I/O devices detection and the CUDA component must be enabled in the
topology.
Note
The corresponding PCI device object can be obtained by looking at the OS device parent object (unless PCI
devices are filtered out).
This function is identical to hwloc_cudart_get_device_osdev_by_index().
23.41.2.4 hwloc_cuda_get_device_pci_ids()
0 on success.
-1 on error, for instance if device information could not be found.
23.41.2.5 hwloc_cuda_get_device_pcidev()
Generated by Doxygen
196 Topic Documentation
Returns
The hwloc PCI device object describing the CUDA device cudevice.
NULL if none could be found.
Topology topology and device cudevice must match the local machine. I/O devices detection must be enabled
in topology topology. The CUDA component is not needed in the topology.
• static int hwloc_cudart_get_device_pci_ids (hwloc_topology_t topology, int idx, int ∗domain, int ∗bus, int ∗dev)
• static int hwloc_cudart_get_device_cpuset (hwloc_topology_t topology, int idx, hwloc_cpuset_t set)
• static hwloc_obj_t hwloc_cudart_get_device_pcidev (hwloc_topology_t topology, int idx)
• static hwloc_obj_t hwloc_cudart_get_device_osdev_by_index (hwloc_topology_t topology, unsigned idx)
0 on success.
-1 on error, for instance if device information could not be found.
23.42.2.2 hwloc_cudart_get_device_osdev_by_index()
The hwloc OS device object describing the CUDA device whose index is idx.
NULL if none could be found.
The topology topology does not necessarily have to match the current machine. For instance the topology
may be an XML import of a remote host. I/O devices detection and the CUDA component must be enabled in the
topology. If not, the locality of the object may still be found using hwloc_cudart_get_device_cpuset().
Note
The corresponding PCI device object can be obtained by looking at the OS device parent object (unless PCI
devices are filtered out).
This function is identical to hwloc_cuda_get_device_osdev_by_index().
Generated by Doxygen
23.43 Interoperability with the NVIDIA Management Library 197
23.42.2.3 hwloc_cudart_get_device_pci_ids()
0 on success.
-1 on error, for instance if device information could not be found.
23.42.2.4 hwloc_cudart_get_device_pcidev()
Returns
The hwloc PCI device object describing the CUDA device whose index is idx.
NULL if none could be found.
Topology topology and device idx must match the local machine. I/O devices detection must be enabled in
topology topology. The CUDA component is not needed in the topology.
Generated by Doxygen
198 Topic Documentation
Returns
0 on success.
-1 on error, for instance if device information could not be found.
23.43.2.2 hwloc_nvml_get_device_osdev()
Returns
The hwloc OS device object that describes the given NVML device device.
NULL if none could be found.
Topology topology and device device must match the local machine. I/O devices detection and the
NVML component must be enabled in the topology. If not, the locality of the object may still be found using
hwloc_nvml_get_device_cpuset().
Note
The corresponding hwloc PCI device may be found by looking at the result parent pointer (unless PCI devices
are filtered out).
23.43.2.3 hwloc_nvml_get_device_osdev_by_index()
Returns
The hwloc OS device object describing the NVML device whose index is idx.
NULL if none could be found.
The topology topology does not necessarily have to match the current machine. For instance the topology
may be an XML import of a remote host. I/O devices detection and the NVML component must be enabled in the
topology.
Note
The corresponding PCI device object can be obtained by looking at the OS device parent object (unless PCI
devices are filtered out).
Generated by Doxygen
23.44 Interoperability with the ROCm SMI Management Library 199
Returns
0 on success.
-1 on error, for instance if device information could not be found.
23.44.2.2 hwloc_rsmi_get_device_osdev()
Returns
The hwloc OS device object that describes the given AMD GPU, whose index is dv_ind.
NULL if none could be found.
Topology topology and device dv_ind must match the local machine. I/O devices detection and the ROCm
SMI component must be enabled in the topology. If not, the locality of the object may still be found using
hwloc_rsmi_get_device_cpuset().
Note
The corresponding hwloc PCI device may be found by looking at the result parent pointer (unless PCI devices
are filtered out).
23.44.2.3 hwloc_rsmi_get_device_osdev_by_index()
Returns
The hwloc OS device object describing the AMD GPU device whose index is dv_ind.
NULL if none could be found.
The topology topology does not necessarily have to match the current machine. For instance the topology may
be an XML import of a remote host. I/O devices detection and the ROCm SMI component must be enabled in the
topology.
Note
The corresponding PCI device object can be obtained by looking at the OS device parent object (unless PCI
devices are filtered out).
Generated by Doxygen
200 Topic Documentation
0 on success.
-1 on error, for instance if device information could not be found.
23.45.2.2 hwloc_levelzero_get_device_osdev()
The hwloc OS device object that describes the given Level Zero device device.
NULL if none could be found.
Topology topology and device dv_ind must match the local machine. I/O devices detection and the Level
Zero component must be enabled in the topology. If not, the locality of the object may still be found using
hwloc_levelzero_get_device_cpuset().
Note
The corresponding hwloc PCI device may be found by looking at the result parent pointer (unless PCI devices
are filtered out).
Generated by Doxygen
23.46 Interoperability with OpenGL displays 201
Returns
0 on success.
-1 if none could be found.
The topology topology does not necessarily have to match the current machine. For instance the topology may
be an XML import of a remote host. I/O devices detection and the GL component must be enabled in the topology.
23.46.2.2 hwloc_gl_get_display_osdev_by_name()
Returns
The hwloc OS device object describing the OpenGL display whose name is name, built as ":port.device" such
as ":0.0" .
NULL if none could be found.
The topology topology does not necessarily have to match the current machine. For instance the topology may
be an XML import of a remote host. I/O devices detection and the GL component must be enabled in the topology.
Note
The corresponding PCI device object can be obtained by looking at the OS device parent object (unless PCI
devices are filtered out).
23.46.2.3 hwloc_gl_get_display_osdev_by_port_device()
Generated by Doxygen
202 Topic Documentation
Returns
The hwloc OS device object describing the OpenGL display whose port (server) is port and device (screen)
is device.
NULL if none could be found.
The topology topology does not necessarily have to match the current machine. For instance the topology may
be an XML import of a remote host. I/O devices detection and the GL component must be enabled in the topology.
Note
The corresponding PCI device object can be obtained by looking at the OS device parent object (unless PCI
devices are filtered out).
Returns
0 on success.
-1 on error, for instance if device information could not be found.
23.47.2.2 hwloc_ibv_get_device_osdev()
Generated by Doxygen
23.48 Topology differences 203
Returns
The hwloc OS device object describing the OpenFabrics device ibdev (InfiniBand, etc).
NULL if none could be found.
Topology topology and device ibdev must match the local machine. I/O devices detection must be enabled in
the topology. If not, the locality of the object may still be found using hwloc_ibv_get_device_cpuset().
Note
The corresponding PCI device object can be obtained by looking at the OS device parent object.
23.47.2.3 hwloc_ibv_get_device_osdev_by_name()
Returns
The hwloc OS device object describing the OpenFabrics device (InfiniBand, Omni-Path, usNIC, etc) whose
name is ibname (mlx5_0, hfi1_0, usnic_0, qib0, etc).
NULL if none could be found.
Note
The corresponding PCI device object can be obtained by looking at the OS device parent object.
• union hwloc_topology_diff_obj_attr_u
• union hwloc_topology_diff_u
Typedefs
Enumerations
Functions
Generated by Doxygen
204 Topic Documentation
• int hwloc_topology_diff_export_xml (hwloc_topology_diff_t diff, const char ∗refname, const char ∗xmlpath)
• int hwloc_topology_diff_load_xmlbuffer (const char ∗xmlbuffer, int buflen, hwloc_topology_diff_t ∗diff, char
∗∗refname)
• int hwloc_topology_diff_export_xmlbuffer (hwloc_topology_diff_t diff, const char ∗refname, char ∗∗xmlbuffer,
int ∗buflen)
23.48.2.2 hwloc_topology_diff_t
23.48.2.3 hwloc_topology_diff_type_t
enum hwloc_topology_diff_apply_flags_e
Flags to be given to hwloc_topology_diff_apply().
Enumerator
23.48.3.2 hwloc_topology_diff_obj_attr_type_e
enum hwloc_topology_diff_obj_attr_type_e
Type of one object attribute difference.
Generated by Doxygen
23.48 Topology differences 205
Enumerator
23.48.3.3 hwloc_topology_diff_type_e
enum hwloc_topology_diff_type_e
Type of one element of a difference list.
Enumerator
int hwloc_topology_diff_apply (
hwloc_topology_t topology,
hwloc_topology_diff_t diff,
unsigned long flags )
Apply a topology diff to an existing topology.
flags is an OR'ed set of hwloc_topology_diff_apply_flags_e.
The new topology is modified in place. hwloc_topology_dup() may be used to duplicate it before patching.
If the difference cannot be applied entirely, all previous applied elements are unapplied before returning.
Returns
0 on success.
-N if applying the difference failed while trying to apply the N-th part of the difference. For instance -1 is
returned if the very first difference element could not be applied.
23.48.4.2 hwloc_topology_diff_build()
int hwloc_topology_diff_build (
hwloc_topology_t topology,
hwloc_topology_t newtopology,
unsigned long flags,
hwloc_topology_diff_t ∗ diff )
Compute the difference between 2 topologies.
The difference is stored as a list of hwloc_topology_diff_t entries starting at diff. It is computed by doing a
depth-first traversal of both topology trees simultaneously.
If the difference between 2 objects is too complex to be represented (for instance if some objects have different
types, or different numbers of children), a special diff entry of type HWLOC_TOPOLOGY_DIFF_TOO_COMPLEX
Generated by Doxygen
206 Topic Documentation
is queued. The computation of the diff does not continue below these objects. So each such diff entry means that
the difference between two subtrees could not be computed.
Returns
Note
23.48.4.3 hwloc_topology_diff_destroy()
int hwloc_topology_diff_destroy (
hwloc_topology_diff_t diff )
Destroy a list of topology differences.
Returns
0.
23.48.4.4 hwloc_topology_diff_export_xml()
int hwloc_topology_diff_export_xml (
hwloc_topology_diff_t diff,
const char ∗ refname,
const char ∗ xmlpath )
Export a list of topology differences to a XML file.
If not NULL, refname defines an identifier string for the reference topology which was used as a base when
computing this difference. This identifier is usually the name of the other XML file that contains the reference
topology. This attribute is given back when reading the diff from XML.
Returns
0 on success, -1 on error.
23.48.4.5 hwloc_topology_diff_export_xmlbuffer()
int hwloc_topology_diff_export_xmlbuffer (
hwloc_topology_diff_t diff,
const char ∗ refname,
char ∗∗ xmlbuffer,
int ∗ buflen )
Export a list of topology differences to a XML buffer.
If not NULL, refname defines an identifier string for the reference topology which was used as a base when
computing this difference. This identifier is usually the name of the other XML file that contains the reference
topology. This attribute is given back when reading the diff from XML.
The returned buffer ends with a \0 that is included in the returned length.
Generated by Doxygen
23.49 Sharing topologies between processes 207
Returns
0 on success, -1 on error.
Note
23.48.4.6 hwloc_topology_diff_load_xml()
int hwloc_topology_diff_load_xml (
const char ∗ xmlpath,
hwloc_topology_diff_t ∗ diff,
char ∗∗ refname )
Load a list of topology differences from a XML file.
If not NULL, refname will be filled with the identifier string of the reference topology for the difference file, if any
was specified in the XML file. This identifier is usually the name of the other XML file that contains the reference
topology.
Returns
0 on success, -1 on error.
Note
23.48.4.7 hwloc_topology_diff_load_xmlbuffer()
int hwloc_topology_diff_load_xmlbuffer (
const char ∗ xmlbuffer,
int buflen,
hwloc_topology_diff_t ∗ diff,
char ∗∗ refname )
Load a list of topology differences from a XML buffer.
Build a list of differences from the XML memory buffer given at xmlbuffer and of length buflen (including an
ending \0). This buffer may have been filled earlier with hwloc_topology_diff_export_xmlbuffer().
If not NULL, refname will be filled with the identifier string of the reference topology for the difference file, if any
was specified in the XML file. This identifier is usually the name of the other XML file that contains the reference
topology.
Returns
0 on success, -1 on error.
Note
Generated by Doxygen
208 Topic Documentation
int hwloc_shmem_topology_adopt (
hwloc_topology_t ∗ topologyp,
int fd,
hwloc_uint64_t fileoffset,
void ∗ mmap_address,
size_t length,
unsigned long flags )
Adopt a shared memory topology stored in a file.
Map a file in virtual memory and adopt the topology that was previously stored there with hwloc_shmem_topology_write().
The returned adopted topology in topologyp can be used just like any topology. And it must be destroyed with
hwloc_topology_destroy() as usual.
However the topology is read-only. For instance, it cannot be modified with hwloc_topology_restrict() and object
userdata pointers cannot be changed.
The segment of the file pointed by descriptor fd, starting at offset fileoffset, and of length length (in bytes),
will be mapped at virtual address mmap_address.
The file pointed by descriptor fd, the offset fileoffset, the requested mapping virtual address mmap_←-
address and the length length must be identical to what was given to hwloc_shmem_topology_write() earlier.
Note
Returns
0 on success.
-1 with errno set to EBUSY if the virtual memory mapping defined by mmap_address and length isn't
available in the process.
-1 with errno set to EINVAL if fileoffset, mmap_address or length aren't page-aligned, or do not
match what was given to hwloc_shmem_topology_write() earlier.
-1 with errno set to EINVAL if the layout of the topology structure is different between the writer process and
the adopter process.
23.49.2.2 hwloc_shmem_topology_get_length()
int hwloc_shmem_topology_get_length (
hwloc_topology_t topology,
size_t ∗ lengthp,
unsigned long flags )
Get the required shared memory length for storing a topology.
This length (in bytes) must be used in hwloc_shmem_topology_write() and hwloc_shmem_topology_adopt() later.
Generated by Doxygen
23.50 Components and Plugins: Discovery components 209
Returns
Note
23.49.2.3 hwloc_shmem_topology_write()
int hwloc_shmem_topology_write (
hwloc_topology_t topology,
int fd,
hwloc_uint64_t fileoffset,
void ∗ mmap_address,
size_t length,
unsigned long flags )
Duplicate a topology to a shared memory file.
Temporarily map a file in virtual memory and duplicate the topology topology by allocating duplicates in there.
The segment of the file pointed by descriptor fd, starting at offset fileoffset, and of length length (in bytes),
will be temporarily mapped at virtual address mmap_address during the duplication.
The mapping length length must have been previously obtained with hwloc_shmem_topology_get_length() and
the topology must not have been modified in the meantime.
Note
Returns
0 on success.
-1 with errno set to EBUSY if the virtual memory mapping defined by mmap_address and length isn't
available in the process.
-1 with errno set to EINVAL if fileoffset, mmap_address or length aren't page-aligned.
• struct hwloc_disc_component
• struct hwloc_disc_status
• struct hwloc_backend
Typedefs
Generated by Doxygen
210 Topic Documentation
Enumerations
• enum hwloc_disc_phase_e {
HWLOC_DISC_PHASE_GLOBAL , HWLOC_DISC_PHASE_CPU , HWLOC_DISC_PHASE_MEMORY ,
HWLOC_DISC_PHASE_PCI ,
HWLOC_DISC_PHASE_IO , HWLOC_DISC_PHASE_MISC , HWLOC_DISC_PHASE_ANNOTATE ,
HWLOC_DISC_PHASE_TWEAK }
• enum hwloc_disc_status_flag_e { HWLOC_DISC_STATUS_FLAG_GOT_ALLOWED_RESOURCES }
Functions
enum hwloc_disc_phase_e
Discovery phase.
Enumerator
23.51.3.2 hwloc_disc_status_flag_e
enum hwloc_disc_status_flag_e
Discovery status flags.
Generated by Doxygen
23.52 Components and Plugins: Generic components 211
Enumerator
23.51.4.2 hwloc_backend_enable()
int hwloc_backend_enable (
struct hwloc_backend ∗ backend )
Enable a previously allocated and setup backend.
• struct hwloc_component
Typedefs
Enumerations
enum hwloc_component_type_e
Generic component type.
Enumerator
Generated by Doxygen
212 Topic Documentation
Functions
23.53.2.2 HWLOC_SHOW_CRITICAL_ERRORS
hwloc_obj_t hwloc__insert_object_by_cpuset (
struct hwloc_topology ∗ topology,
hwloc_obj_t root,
hwloc_obj_t obj,
const char ∗ reason )
Add an object to the topology.
Insert new object obj in the topology starting under existing object root (if NULL, the topology root object is
used).
It is sorted along the tree of other objects according to the inclusion of cpusets, to eventually be added as a child of
the smallest object including this object.
If the cpuset is empty, the type of the object (and maybe some attributes) must be enough to find where to insert
the object. This is especially true for NUMA nodes with memory and no CPUs.
The given object should not have children.
This shall only be called before levels are built.
The caller should check whether the object type is filtered-out before calling this function.
The topology cpuset/nodesets will be enlarged to include the object sets.
reason is a unique string identifying where and why this insertion call was performed (it will be displayed in case
of internal insertion error).
Returns the object on success. Returns NULL and frees obj on error. Returns another object and frees obj if it was
merged with an identical pre-existing object.
Generated by Doxygen
23.53 Components and Plugins: Core functions to be used by components 213
23.53.3.2 hwloc_alloc_setup_object()
hwloc_obj_t hwloc_alloc_setup_object (
hwloc_topology_t topology,
hwloc_obj_type_t type,
unsigned os_index )
Allocate and initialize an object of the given type and physical index.
If os_index is unknown or irrelevant, use HWLOC_UNKNOWN_INDEX.
23.53.3.3 hwloc_hide_errors()
int hwloc_hide_errors (
void )
Check whether error messages are hidden.
Callers should print critical error messages (e.g. invalid hw topo info, invalid config) only if this function returns
strictly less than 2.
Callers should print non-critical error messages (e.g. failure to initialize CUDA) if this function returns 0.
This function return 1 by default (show critical only), 0 in lstopo (show all), or anything set in HWLOC_HIDE_←-
ERRORS in the environment.
Use macros HWLOC_SHOW_CRITICAL_ERRORS() and HWLOC_SHOW_ALL_ERRORS() for clarity.
23.53.3.4 hwloc_insert_object_by_parent()
void hwloc_insert_object_by_parent (
struct hwloc_topology ∗ topology,
hwloc_obj_t parent,
hwloc_obj_t obj )
Insert an object somewhere in the topology.
It is added as the last child of the given parent. The cpuset is completely ignored, so strange objects such as I/O
devices should preferably be inserted with this.
When used for "normal" children with cpusets (when importing from XML when duplicating a topology), the caller
should make sure that:
The given object may have normal, I/O or Misc children, as long as they are in order as well. These children must
have valid parent and next_sibling pointers.
The caller should check whether the object type is filtered-out before calling this function.
23.53.3.5 hwloc_obj_add_children_sets()
int hwloc_obj_add_children_sets (
hwloc_obj_t obj )
Setup object cpusets/nodesets by OR'ing its children.
Used when adding an object late in the topology. Will update the new object by OR'ing all its new children sets.
Used when PCI backend adds a hostbridge parent, when distances add a new Group, etc.
23.53.3.6 hwloc_plugin_check_namespace()
Generated by Doxygen
214 Topic Documentation
Returns
0 on success.
-1 if the plugin cannot be successfully loaded. The caller plugin init() callback should return a negative error
code as well.
Plugins should call this function in their init() callback to avoid later crashes if lazy symbol resolution is used by the
upper layer that loaded hwloc (e.g. OpenCL implementations using dlopen with RTLD_LAZY).
Note
The build system must define HWLOC_INSIDE_PLUGIN if and only if building the caller as a plugin.
This function should remain inline so plugins can call it even when they cannot find libhwloc symbols.
23.53.3.7 hwloc_topology_reconnect()
int hwloc_topology_reconnect (
hwloc_topology_t topology,
unsigned long flags )
Request a reconnection of children and levels in the topology.
May be used by backends during discovery if they need arrays or lists of object within levels or children to be fully
connected.
flags is currently unused, must 0.
Returns
23.54.2.2 hwloc_filter_check_keep_object_type()
Generated by Doxygen
23.55 Components and Plugins: helpers for PCI discovery 215
Returns
23.54.2.3 hwloc_filter_check_osdev_subtype_important()
Returns
1 if important, 0 otherwise.
23.54.2.4 hwloc_filter_check_pcidev_subtype_important()
Returns
1 if important, 0 otherwise.
hwloc_obj_type_t hwloc_pcidisc_check_bridge_type (
unsigned device_class,
const unsigned char ∗ config )
Return the hwloc object type (PCI device or Bridge) for the given class and configuration space.
This function requires 16 bytes of common configuration header at the beginning of config.
23.55.2.2 hwloc_pcidisc_find_bridge_buses()
int hwloc_pcidisc_find_bridge_buses (
unsigned domain,
unsigned bus,
unsigned dev,
unsigned func,
unsigned ∗ secondary_busp,
Generated by Doxygen
216 Topic Documentation
unsigned ∗ subordinate_busp,
const unsigned char ∗ config )
Fills the attributes of the given PCI bridge using the given PCI config space.
This function requires 32 bytes of common configuration header at the beginning of config.
Returns -1 and destroys /p obj if bridge fields are invalid.
23.55.2.3 hwloc_pcidisc_find_cap()
unsigned hwloc_pcidisc_find_cap (
const unsigned char ∗ config,
unsigned cap )
Return the offset of the given capability in the PCI config space buffer.
This function requires a 256-bytes config space. Unknown/unavailable bytes should be set to 0xff.
23.55.2.4 hwloc_pcidisc_find_linkspeed()
int hwloc_pcidisc_find_linkspeed (
const unsigned char ∗ config,
unsigned offset,
float ∗ linkspeed )
Fill linkspeed by reading the PCI config space where PCI_CAP_ID_EXP is at position offset.
Needs 20 bytes of EXP capability block starting at offset in the config space for registers up to link status.
23.55.2.5 hwloc_pcidisc_tree_attach()
int hwloc_pcidisc_tree_attach (
struct hwloc_topology ∗ topology,
struct hwloc_obj ∗ tree )
Add some hostbridges on top of the given tree of PCI objects and attach them to the topology.
Other backends may lookup PCI objects or localities (for instance to attach OS devices) by using hwloc_pcidisc_←-
find_by_busid() or hwloc_pcidisc_find_busid_parent().
23.55.2.6 hwloc_pcidisc_tree_insert_by_busid()
void hwloc_pcidisc_tree_insert_by_busid (
struct hwloc_obj ∗∗ treep,
struct hwloc_obj ∗ obj )
Insert a PCI object in the given PCI tree by looking at PCI bus IDs.
If treep points to NULL, the new object is inserted there.
Generated by Doxygen
23.57 Components and Plugins: distances 217
23.56.2.2 hwloc_pci_find_parent_by_busid()
Functions
int hwloc_backend_distances_add_commit (
Generated by Doxygen
218 Topic Documentation
hwloc_topology_t topology,
hwloc_backend_distances_add_handle_t handle,
unsigned long flags )
Commit a new distances structure.
This is similar to hwloc_distances_add_commit() but this variant is designed for backend inserting distances during
topology discovery.
23.57.3.2 hwloc_backend_distances_add_create()
hwloc_backend_distances_add_handle_t hwloc_backend_distances_add_create (
hwloc_topology_t topology,
const char ∗ name,
unsigned long kind,
unsigned long flags )
Create a new empty distances structure.
This is identical to hwloc_distances_add_create() but this variant is designed for backend inserting distances during
topology discovery.
23.57.3.3 hwloc_backend_distances_add_values()
int hwloc_backend_distances_add_values (
hwloc_topology_t topology,
hwloc_backend_distances_add_handle_t handle,
unsigned nbobjs,
hwloc_obj_t ∗ objs,
hwloc_uint64_t ∗ values,
unsigned long flags )
Specify the objects and values in a new empty distances structure.
This is similar to hwloc_distances_add_values() but this variant is designed for backend inserting distances during
topology discovery.
The only semantical difference is that objs and values are not duplicated, but directly attached to the topology.
On success, these arrays are given to the core and should not ever be freed by the caller anymore.
Generated by Doxygen
Chapter 24
Data Fields
• unsigned phases
• unsigned long flags
• int is_thissystem
• void ∗ private_data
• void(∗ disable )(struct hwloc_backend ∗backend)
• int(∗ discover )(struct hwloc_backend ∗backend, struct hwloc_disc_status ∗status)
• int(∗ get_pci_busid_cpuset )(struct hwloc_backend ∗backend, struct hwloc_pcidev_attr_s ∗busid,
hwloc_bitmap_t cpuset)
24.1.2.2 discover
24.1.2.3 flags
Generated by Doxygen
220 Data Structure Documentation
24.1.2.4 get_pci_busid_cpuset
24.1.2.5 is_thissystem
int hwloc_backend::is_thissystem
Backend-specific 'is_thissystem' property. Set to 0 if the backend disables the thissystem flag for this topology (e.g.
loading from xml or synthetic string, or using a different fsroot on Linux, or a x86 CPUID dump). Set to -1 if the
backend doesn't care (default).
24.1.2.6 phases
unsigned hwloc_backend::phases
Discovery phases performed by this component, possibly without some of them if excluded by other components.
OR'ed set of hwloc_disc_phase_t.
24.1.2.7 private_data
void∗ hwloc_backend::private_data
Backend private data, or NULL if none.
The documentation for this struct was generated from the following file:
• plugins.h
Data Fields
• union {
struct hwloc_pcidev_attr_s pci
} upstream
• hwloc_obj_bridge_type_t upstream_type
• union {
struct {
unsigned short domain
unsigned char secondary_bus
unsigned char subordinate_bus
} pci
} downstream
• hwloc_obj_bridge_type_t downstream_type
• unsigned depth
unsigned hwloc_obj_attr_u::hwloc_bridge_attr_s::depth
Generated by Doxygen
24.3 hwloc_obj_attr_u::hwloc_cache_attr_s Struct Reference 221
24.2.2.2 domain
24.2.2.3 [union]
24.2.2.4 downstream_type
hwloc_obj_bridge_type_t hwloc_obj_attr_u::hwloc_bridge_attr_s::downstream_type
Downstream Bridge type.
24.2.2.7 secondary_bus
24.2.2.8 subordinate_bus
24.2.2.9 [union]
24.2.2.10 upstream_type
hwloc_obj_bridge_type_t hwloc_obj_attr_u::hwloc_bridge_attr_s::upstream_type
Upstream Bridge type.
The documentation for this struct was generated from the following file:
• hwloc.h
Data Fields
• hwloc_uint64_t size
• unsigned depth
• unsigned linesize
• int associativity
• hwloc_obj_cache_type_t type
Generated by Doxygen
222 Data Structure Documentation
int hwloc_obj_attr_u::hwloc_cache_attr_s::associativity
Ways of associativity, -1 if fully associative, 0 if unknown.
24.3.2.2 depth
unsigned hwloc_obj_attr_u::hwloc_cache_attr_s::depth
Depth of cache (e.g., L1, L2, ...etc.)
24.3.2.3 linesize
unsigned hwloc_obj_attr_u::hwloc_cache_attr_s::linesize
Cache-line size in bytes. 0 if unknown.
24.3.2.4 size
hwloc_uint64_t hwloc_obj_attr_u::hwloc_cache_attr_s::size
Size of cache in bytes.
24.3.2.5 type
hwloc_obj_cache_type_t hwloc_obj_attr_u::hwloc_cache_attr_s::type
Cache type.
The documentation for this struct was generated from the following file:
• hwloc.h
Data Fields
• cl_uint pci_domain
• cl_uint pci_bus
• cl_uint pci_device
• cl_uint pci_function
cl_uint hwloc_cl_device_pci_bus_info_khr::pci_bus
24.4.1.2 pci_device
cl_uint hwloc_cl_device_pci_bus_info_khr::pci_device
24.4.1.3 pci_domain
cl_uint hwloc_cl_device_pci_bus_info_khr::pci_domain
24.4.1.4 pci_function
cl_uint hwloc_cl_device_pci_bus_info_khr::pci_function
The documentation for this struct was generated from the following file:
• opencl.h
Generated by Doxygen
24.5 hwloc_cl_device_topology_amd Union Reference 223
Data Fields
• struct {
cl_uint type
cl_uint data [5]
} raw
• struct {
cl_uint type
cl_char unused [17]
cl_char bus
cl_char device
cl_char function
} pcie
cl_char hwloc_cl_device_topology_amd::bus
24.5.1.2 data
cl_uint hwloc_cl_device_topology_amd::data[5]
24.5.1.3 device
cl_char hwloc_cl_device_topology_amd::device
24.5.1.4 function
cl_char hwloc_cl_device_topology_amd::function
24.5.1.5 [struct]
24.5.1.6 [struct]
24.5.1.7 type
cl_uint hwloc_cl_device_topology_amd::type
24.5.1.8 unused
cl_char hwloc_cl_device_topology_amd::unused[17]
The documentation for this union was generated from the following file:
• opencl.h
Generated by Doxygen
224 Data Structure Documentation
Data Fields
• unsigned abi
• int(∗ init )(unsigned long flags)
• void(∗ finalize )(unsigned long flags)
• hwloc_component_type_t type
• unsigned long flags
• void ∗ data
unsigned hwloc_component::abi
Component ABI version, set to HWLOC_COMPONENT_ABI.
24.6.2.2 data
void∗ hwloc_component::data
Component data, pointing to a struct hwloc_disc_component or struct hwloc_xml_component.
24.6.2.3 finalize
If the component uses ltdl for loading its own plugins, it should load/unload them only in init() and finalize(), to
avoid race conditions with hwloc's use of ltdl.
24.6.2.4 flags
24.6.2.5 init
Note
If the component uses ltdl for loading its own plugins, it should load/unload them only in init() and finalize(), to
avoid race conditions with hwloc's use of ltdl.
Generated by Doxygen
24.7 hwloc_disc_component Struct Reference 225
24.6.2.6 type
hwloc_component_type_t hwloc_component::type
Component type.
The documentation for this struct was generated from the following file:
• plugins.h
Data Fields
unsigned hwloc_disc_component::enabled_by_default
Enabled by default. If unset, if will be disabled unless explicitly requested.
24.7.2.2 excluded_phases
unsigned hwloc_disc_component::excluded_phases
Component phases to exclude, as an OR'ed set of hwloc_disc_phase_t.
For a GLOBAL component, this usually includes all other phases (∼UL).
Other components only exclude types that may bring conflicting topology information. MISC components should
likely not be excluded since they usually bring non-primary additional information.
24.7.2.3 instantiate
24.7.2.4 name
24.7.2.5 phases
unsigned hwloc_disc_component::phases
Discovery phases performed by this component. OR'ed set of hwloc_disc_phase_t.
Generated by Doxygen
226 Data Structure Documentation
24.7.2.6 priority
unsigned hwloc_disc_component::priority
Component priority. Used to sort topology->components, higher priority first. Also used to decide between two
components with the same name.
Usual values are 50 for native OS (or platform) components, 45 for x86, 40 for no-OS fallback, 30 for global compo-
nents (xml, synthetic), 20 for pci, 10 for other misc components (opencl etc.).
The documentation for this struct was generated from the following file:
• plugins.h
Data Fields
• hwloc_disc_phase_t phase
• unsigned excluded_phases
• unsigned long flags
unsigned hwloc_disc_status::excluded_phases
Dynamically excluded phases. If a component decides during discovery that some phases are no longer needed.
24.8.2.2 flags
24.8.2.3 phase
hwloc_disc_phase_t hwloc_disc_status::phase
The current discovery phase that is performed. Must match one of the phases in the component phases field.
The documentation for this struct was generated from the following file:
• plugins.h
Data Fields
• unsigned nbobjs
• hwloc_obj_t ∗ objs
• unsigned long kind
• hwloc_uint64_t ∗ values
Generated by Doxygen
24.10 hwloc_obj_attr_u::hwloc_group_attr_s Struct Reference 227
24.9.2.2 nbobjs
unsigned hwloc_distances_s::nbobjs
Number of objects described by the distance matrix.
24.9.2.3 objs
hwloc_obj_t∗ hwloc_distances_s::objs
Array of objects described by the distance matrix. These objects are not in any particular order, see
hwloc_distances_obj_index() and hwloc_distances_obj_pair_values() for easy ways to find objects in this array
and their corresponding values.
24.9.2.4 values
hwloc_uint64_t∗ hwloc_distances_s::values
Matrix of distances between objects, stored as a one-dimension array.
Distance from i-th to j-th object is stored in slot i∗nbobjs+j. The meaning of the value depends on the kind attribute.
The documentation for this struct was generated from the following file:
• distances.h
Data Fields
• unsigned depth
• unsigned kind
• unsigned subkind
• unsigned char dont_merge
Generated by Doxygen
228 Data Structure Documentation
unsigned hwloc_obj_attr_u::hwloc_group_attr_s::depth
Depth of group object. It may change if intermediate Group objects are added.
24.10.2.2 dont_merge
24.10.2.3 kind
unsigned hwloc_obj_attr_u::hwloc_group_attr_s::kind
Internally-used kind of group.
24.10.2.4 subkind
unsigned hwloc_obj_attr_u::hwloc_group_attr_s::subkind
Internally-used subkind to distinguish different levels of groups with same kind.
The documentation for this struct was generated from the following file:
• hwloc.h
Data Fields
• char ∗ name
• char ∗ value
See also
char∗ hwloc_info_s::name
Info name.
24.11.2.2 value
char∗ hwloc_info_s::value
Info value.
The documentation for this struct was generated from the following file:
• hwloc.h
Generated by Doxygen
24.13 hwloc_location::hwloc_location_u Union Reference 229
Data Structures
• union hwloc_location_u
Data Fields
24.12.2.2 type
• memattrs.h
Data Fields
• hwloc_cpuset_t cpuset
• hwloc_obj_t object
hwloc_cpuset_t hwloc_location::hwloc_location_u::cpuset
Location as a cpuset, when the location type is HWLOC_LOCATION_TYPE_CPUSET.
24.13.2.2 object
hwloc_obj_t hwloc_location::hwloc_location_u::object
Location as an object, when the location type is HWLOC_LOCATION_TYPE_OBJECT.
The documentation for this union was generated from the following file:
• memattrs.h
24.14 hwloc_obj_attr_u::hwloc_numanode_attr_s::hwloc_memory_←-
page_type_s Struct Reference
#include <hwloc.h>
Generated by Doxygen
230 Data Structure Documentation
Data Fields
• hwloc_uint64_t size
• hwloc_uint64_t count
hwloc_uint64_t hwloc_obj_attr_u::hwloc_numanode_attr_s::hwloc_memory_page_type_s::count
Number of pages of this size.
24.14.2.2 size
hwloc_uint64_t hwloc_obj_attr_u::hwloc_numanode_attr_s::hwloc_memory_page_type_s::size
Size of pages.
The documentation for this struct was generated from the following file:
• hwloc.h
Data Structures
• struct hwloc_memory_page_type_s
Data Fields
• hwloc_uint64_t local_memory
• unsigned page_types_len
• struct hwloc_obj_attr_u::hwloc_numanode_attr_s::hwloc_memory_page_type_s ∗ page_types
hwloc_uint64_t hwloc_obj_attr_u::hwloc_numanode_attr_s::local_memory
Local memory (in bytes)
24.15.2.2 page_types
Generated by Doxygen
24.16 hwloc_obj Struct Reference 231
24.15.2.3 page_types_len
unsigned hwloc_obj_attr_u::hwloc_numanode_attr_s::page_types_len
Size of array page_types.
The documentation for this struct was generated from the following file:
• hwloc.h
Data Fields
• hwloc_obj_type_t type
• char ∗ subtype
• unsigned os_index
• char ∗ name
• hwloc_uint64_t total_memory
• union hwloc_obj_attr_u ∗ attr
• int depth
• unsigned logical_index
• struct hwloc_obj ∗ next_cousin
• struct hwloc_obj ∗ prev_cousin
• struct hwloc_obj ∗ parent
• unsigned sibling_rank
• struct hwloc_obj ∗ next_sibling
• struct hwloc_obj ∗ prev_sibling
• int symmetric_subtree
• hwloc_cpuset_t cpuset
• hwloc_cpuset_t complete_cpuset
• hwloc_nodeset_t nodeset
• hwloc_nodeset_t complete_nodeset
• struct hwloc_info_s ∗ infos
• unsigned infos_count
• void ∗ userdata
• hwloc_uint64_t gp_index
List and array of normal children below this object (except Memory, I/O and Misc children).
• unsigned arity
• struct hwloc_obj ∗∗ children
• struct hwloc_obj ∗ first_child
• struct hwloc_obj ∗ last_child
• unsigned memory_arity
• struct hwloc_obj ∗ memory_first_child
• unsigned io_arity
• struct hwloc_obj ∗ io_first_child
• unsigned misc_arity
• struct hwloc_obj ∗ misc_first_child
Generated by Doxygen
232 Data Structure Documentation
unsigned hwloc_obj::arity
Number of normal children. Memory, Misc and I/O children are not listed here but rather in their dedicated children
list.
24.16.2.2 attr
24.16.2.3 children
24.16.2.4 complete_cpuset
hwloc_cpuset_t hwloc_obj::complete_cpuset
The complete CPU set of processors of this object,.
This may include not only the same as the cpuset field, but also some CPUs for which topology in-
formation is unknown or incomplete, some offlines CPUs, and the CPUs that are ignored when the
HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED flag is not set. Thus no corresponding PU object may be
found in the topology, because the precise position is undefined. It is however known that it would be somewhere
under this object.
Note
24.16.2.5 complete_nodeset
hwloc_nodeset_t hwloc_obj::complete_nodeset
The complete NUMA node set of this object,.
This may include not only the same as the nodeset field, but also some NUMA nodes for which topol-
ogy information is unknown or incomplete, some offlines nodes, and the nodes that are ignored when the
HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED flag is not set. Thus no corresponding NUMA node object
may be found in the topology, because the precise position is undefined. It is however known that it would be
somewhere under this object.
If there are no NUMA nodes in the machine, all the memory is close to this object, so only the first bit is set in
complete_nodeset.
Note
24.16.2.6 cpuset
hwloc_cpuset_t hwloc_obj::cpuset
CPUs covered by this object.
This is the set of CPUs for which there are PU objects in the topology under this object, i.e. which are known to be
physically contained in this object and known how (the children path between this object and the PU objects).
If the HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED configuration flag is set, some of these CPUs may
be online but not allowed for binding, see hwloc_topology_get_allowed_cpuset().
Generated by Doxygen
24.16 hwloc_obj Struct Reference 233
Note
All objects have non-NULL CPU and node sets except Misc and I/O objects.
Its value must not be changed, hwloc_bitmap_dup() must be used instead.
24.16.2.7 depth
int hwloc_obj::depth
Vertical index in the hierarchy.
For normal objects, this is the depth of the horizontal level that contains this object and its cousins of the same type.
If the topology is symmetric, this is equal to the parent depth plus one, and also equal to the number of parent/child
links from the root object to here.
For special objects (NUMA nodes, I/O and Misc) that are not in the main tree, this is a special negative value that
corresponds to their dedicated level, see hwloc_get_type_depth() and hwloc_get_type_depth_e. Those special
values can be passed to hwloc functions such hwloc_get_nbobjs_by_depth() as usual.
24.16.2.8 first_child
24.16.2.9 gp_index
hwloc_uint64_t hwloc_obj::gp_index
Global persistent index. Generated by hwloc, unique across the topology (contrary to os_index) and persistent
across topology changes (contrary to logical_index). Mostly used internally, but could also be used by application
to identify objects.
24.16.2.10 infos
24.16.2.11 infos_count
unsigned hwloc_obj::infos_count
Size of infos array.
24.16.2.12 io_arity
unsigned hwloc_obj::io_arity
Number of I/O children. These children are listed in io_first_child.
24.16.2.13 io_first_child
24.16.2.14 last_child
24.16.2.15 logical_index
unsigned hwloc_obj::logical_index
Horizontal index in the whole list of similar objects, hence guaranteed unique across the entire machine. Could be a
"cousin_rank" since it's the rank within the "cousin" list below Note that this index may change when restricting the
topology or when inserting a group.
Generated by Doxygen
234 Data Structure Documentation
24.16.2.16 memory_arity
unsigned hwloc_obj::memory_arity
Number of Memory children. These children are listed in memory_first_child.
24.16.2.17 memory_first_child
24.16.2.18 misc_arity
unsigned hwloc_obj::misc_arity
Number of Misc children. These children are listed in misc_first_child.
24.16.2.19 misc_first_child
24.16.2.20 name
char∗ hwloc_obj::name
Object-specific name if any. Mostly used for identifying OS devices and Misc objects where a name string is more
useful than numerical indexes.
24.16.2.21 next_cousin
24.16.2.22 next_sibling
24.16.2.23 nodeset
hwloc_nodeset_t hwloc_obj::nodeset
NUMA nodes covered by this object or containing this object.
This is the set of NUMA nodes for which there are NUMA node objects in the topology under or above this object,
i.e. which are known to be physically contained in this object or containing it and known how (the children path
between this object and the NUMA node objects).
In the end, these nodes are those that are close to the current object. Function hwloc_get_local_numanode_objs()
may be used to list those NUMA nodes more precisely.
If the HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED configuration flag is set, some of these nodes may
be online but not allowed for allocation, see hwloc_topology_get_allowed_nodeset().
If there are no NUMA nodes in the machine, all the memory is close to this object, so only the first bit may be set in
nodeset.
Note
All objects have non-NULL CPU and node sets except Misc and I/O objects.
Its value must not be changed, hwloc_bitmap_dup() must be used instead.
Generated by Doxygen
24.16 hwloc_obj Struct Reference 235
24.16.2.24 os_index
unsigned hwloc_obj::os_index
OS-provided physical index number. It is not guaranteed unique across the entire machine, except for PUs and
NUMA nodes. Set to HWLOC_UNKNOWN_INDEX if unknown or irrelevant for this object.
24.16.2.25 parent
24.16.2.26 prev_cousin
24.16.2.27 prev_sibling
24.16.2.28 sibling_rank
unsigned hwloc_obj::sibling_rank
Index in parent's children[] array. Or the index in parent's Memory, I/O or Misc children list.
24.16.2.29 subtype
char∗ hwloc_obj::subtype
Subtype string to better describe the type field.
24.16.2.30 symmetric_subtree
int hwloc_obj::symmetric_subtree
Set if the subtree of normal objects below this object is symmetric, which means all normal children and their
children have identical subtrees.
Memory, I/O and Misc children are ignored.
If set in the topology root object, lstopo may export the topology as a synthetic string.
24.16.2.31 total_memory
hwloc_uint64_t hwloc_obj::total_memory
Total memory (in bytes) in NUMA nodes below this object.
24.16.2.32 type
hwloc_obj_type_t hwloc_obj::type
Type of object.
24.16.2.33 userdata
void∗ hwloc_obj::userdata
Application-given private data pointer, initialized to NULL, use it as you wish. See hwloc_topology_set_userdata_export_callback()
in hwloc/export.h if you wish to export this field to XML.
The documentation for this struct was generated from the following file:
• hwloc.h
Generated by Doxygen
236 Data Structure Documentation
Data Structures
• struct hwloc_bridge_attr_s
• struct hwloc_cache_attr_s
• struct hwloc_group_attr_s
• struct hwloc_numanode_attr_s
• struct hwloc_osdev_attr_s
• struct hwloc_pcidev_attr_s
Data Fields
24.17.2.2 cache
24.17.2.3 group
24.17.2.4 numanode
24.17.2.5 osdev
24.17.2.6 pcidev
• hwloc.h
Generated by Doxygen
24.19 hwloc_obj_attr_u::hwloc_pcidev_attr_s Struct Reference 237
Data Fields
• hwloc_obj_osdev_type_t type
hwloc_obj_osdev_type_t hwloc_obj_attr_u::hwloc_osdev_attr_s::type
The documentation for this struct was generated from the following file:
• hwloc.h
Data Fields
24.19.2.2 class_id
24.19.2.3 dev
24.19.2.4 device_id
Generated by Doxygen
238 Data Structure Documentation
24.19.2.5 domain
24.19.2.6 func
24.19.2.7 linkspeed
float hwloc_obj_attr_u::hwloc_pcidev_attr_s::linkspeed
Link speed in GB/s. This datarate is the currently configured speed of the entire PCI link (sum of the bandwidth of
all PCI lanes in that link). It may change during execution since some devices are able to slow their PCI links down
when idle.
24.19.2.8 revision
24.19.2.9 subdevice_id
24.19.2.10 subvendor_id
24.19.2.11 vendor_id
• hwloc.h
Data Fields
Generated by Doxygen
24.20 hwloc_topology_cpubind_support Struct Reference 239
24.20.2.2 get_proc_last_cpu_location
24.20.2.3 get_thisproc_cpubind
24.20.2.4 get_thisproc_last_cpu_location
24.20.2.5 get_thisthread_cpubind
24.20.2.6 get_thisthread_last_cpu_location
24.20.2.7 get_thread_cpubind
24.20.2.8 set_proc_cpubind
24.20.2.9 set_thisproc_cpubind
24.20.2.10 set_thisthread_cpubind
Generated by Doxygen
240 Data Structure Documentation
24.20.2.11 set_thread_cpubind
• hwloc.h
Data Fields
• hwloc_topology_diff_type_t type
• union hwloc_topology_diff_u ∗ next
24.21.1.2 type
hwloc_topology_diff_type_t hwloc_topology_diff_u::hwloc_topology_diff_generic_s::type
The documentation for this struct was generated from the following file:
• diff.h
24.22 hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_←-
generic_s Struct Reference
#include <diff.h>
Data Fields
• hwloc_topology_diff_obj_attr_type_t type
hwloc_topology_diff_obj_attr_type_t hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_←-
attr_generic_s::type
The documentation for this struct was generated from the following file:
• diff.h
Generated by Doxygen
24.24 hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_string_s Struct Reference 241
Data Fields
• hwloc_topology_diff_type_t type
• union hwloc_topology_diff_u ∗ next
• int obj_depth
• unsigned obj_index
• union hwloc_topology_diff_obj_attr_u diff
24.23.1.2 next
24.23.1.3 obj_depth
int hwloc_topology_diff_u::hwloc_topology_diff_obj_attr_s::obj_depth
24.23.1.4 obj_index
unsigned hwloc_topology_diff_u::hwloc_topology_diff_obj_attr_s::obj_index
24.23.1.5 type
hwloc_topology_diff_type_t hwloc_topology_diff_u::hwloc_topology_diff_obj_attr_s::type
The documentation for this struct was generated from the following file:
• diff.h
24.24 hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_←-
string_s Struct Reference
#include <diff.h>
Data Fields
• hwloc_topology_diff_obj_attr_type_t type
• char ∗ name
• char ∗ oldvalue
• char ∗ newvalue
char∗ hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_string_s::name
24.24.2.2 newvalue
char∗ hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_string_s::newvalue
Generated by Doxygen
242 Data Structure Documentation
24.24.2.3 oldvalue
char∗ hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_string_s::oldvalue
24.24.2.4 type
hwloc_topology_diff_obj_attr_type_t hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_←-
attr_string_s::type
The documentation for this struct was generated from the following file:
• diff.h
Data Structures
• struct hwloc_topology_diff_obj_attr_generic_s
• struct hwloc_topology_diff_obj_attr_string_s
• struct hwloc_topology_diff_obj_attr_uint64_s
Data Fields
24.25.2.2 string
24.25.2.3 uint64
• diff.h
24.26 hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_←-
uint64_s Struct Reference
#include <diff.h>
Generated by Doxygen
24.27 hwloc_topology_diff_u::hwloc_topology_diff_too_complex_s Struct Reference 243
Data Fields
• hwloc_topology_diff_obj_attr_type_t type
• hwloc_uint64_t index
• hwloc_uint64_t oldvalue
• hwloc_uint64_t newvalue
hwloc_uint64_t hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_uint64_s::index
24.26.2.2 newvalue
hwloc_uint64_t hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_uint64_s::newvalue
24.26.2.3 oldvalue
hwloc_uint64_t hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_uint64_s::oldvalue
24.26.2.4 type
hwloc_topology_diff_obj_attr_type_t hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_←-
attr_uint64_s::type
The documentation for this struct was generated from the following file:
• diff.h
24.27 hwloc_topology_diff_u::hwloc_topology_diff_too_complex_s
Struct Reference
#include <diff.h>
Data Fields
• hwloc_topology_diff_type_t type
• union hwloc_topology_diff_u ∗ next
• int obj_depth
• unsigned obj_index
24.27.1.2 obj_depth
int hwloc_topology_diff_u::hwloc_topology_diff_too_complex_s::obj_depth
24.27.1.3 obj_index
unsigned hwloc_topology_diff_u::hwloc_topology_diff_too_complex_s::obj_index
Generated by Doxygen
244 Data Structure Documentation
24.27.1.4 type
hwloc_topology_diff_type_t hwloc_topology_diff_u::hwloc_topology_diff_too_complex_s::type
The documentation for this struct was generated from the following file:
• diff.h
Data Structures
• struct hwloc_topology_diff_generic_s
• struct hwloc_topology_diff_obj_attr_s
• struct hwloc_topology_diff_too_complex_s
Data Fields
24.28.2.2 obj_attr
24.28.2.3 too_complex
• diff.h
Data Fields
• unsigned char pu
• unsigned char numa
• unsigned char numa_memory
• unsigned char disallowed_pu
• unsigned char disallowed_numa
• unsigned char cpukind_efficiency
Generated by Doxygen
24.30 hwloc_topology_membind_support Struct Reference 245
24.29.2.2 disallowed_numa
24.29.2.3 disallowed_pu
24.29.2.4 numa
24.29.2.5 numa_memory
24.29.2.6 pu
• hwloc.h
Data Fields
Generated by Doxygen
246 Data Structure Documentation
24.30.2.2 bind_membind
24.30.2.3 firsttouch_membind
24.30.2.4 get_area_membind
24.30.2.5 get_area_memlocation
24.30.2.6 get_proc_membind
24.30.2.7 get_thisproc_membind
24.30.2.8 get_thisthread_membind
24.30.2.9 interleave_membind
24.30.2.10 migrate_membind
Generated by Doxygen
24.31 hwloc_topology_misc_support Struct Reference 247
24.30.2.11 nexttouch_membind
24.30.2.12 set_area_membind
24.30.2.13 set_proc_membind
24.30.2.14 set_thisproc_membind
24.30.2.15 set_thisthread_membind
24.30.2.16 weighted_interleave_membind
• hwloc.h
Data Fields
• hwloc.h
Generated by Doxygen
248 Data Structure Documentation
Data Fields
24.32.2.2 discovery
24.32.2.3 membind
24.32.2.4 misc
• hwloc.h
Generated by Doxygen
Index
Generated by Doxygen
250 INDEX
Generated by Doxygen
INDEX 251
Generated by Doxygen
252 INDEX
Generated by Doxygen
INDEX 253
Generated by Doxygen
254 INDEX
Generated by Doxygen
INDEX 255
Generated by Doxygen
256 INDEX
hwloc_get_next_obj_covering_cpuset_by_type hwloc_gl_get_display_by_osdev
Finding Objects covering at least CPU set, 138 Interoperability with OpenGL displays, 201
hwloc_get_next_obj_inside_cpuset_by_depth hwloc_gl_get_display_osdev_by_name
Finding Objects inside a CPU set, 135 Interoperability with OpenGL displays, 201
hwloc_get_next_obj_inside_cpuset_by_type hwloc_gl_get_display_osdev_by_port_device
Finding Objects inside a CPU set, 136 Interoperability with OpenGL displays, 201
hwloc_get_next_osdev hwloc_hide_errors
Finding I/O objects, 149 Components and Plugins: Core functions to be
hwloc_get_next_pcidev used by components, 213
Finding I/O objects, 149 hwloc_ibv_get_device_cpuset
hwloc_get_non_io_ancestor_obj Interoperability with OpenFabrics, 202
Finding I/O objects, 149 hwloc_ibv_get_device_osdev
hwloc_get_numanode_obj_by_os_index Interoperability with OpenFabrics, 202
Finding objects, miscellaneous helpers, 143 hwloc_ibv_get_device_osdev_by_name
hwloc_get_obj_below_array_by_type Interoperability with OpenFabrics, 203
Finding objects, miscellaneous helpers, 143 hwloc_info_s, 228
hwloc_get_obj_below_by_type name, 228
Finding objects, miscellaneous helpers, 143 value, 228
hwloc_get_obj_by_depth hwloc_insert_object_by_parent
Object levels, depths and types, 100 Components and Plugins: Core functions to be
hwloc_get_obj_by_type used by components, 213
Object levels, depths and types, 100 hwloc_levelzero_get_device_cpuset
hwloc_get_obj_covering_cpuset Interoperability with the oneAPI Level Zero inter-
Finding Objects covering at least CPU set, 138 face., 200
hwloc_get_obj_index_inside_cpuset hwloc_levelzero_get_device_osdev
Finding Objects inside a CPU set, 136 Interoperability with the oneAPI Level Zero inter-
hwloc_get_obj_inside_cpuset_by_depth face., 200
Finding Objects inside a CPU set, 136 hwloc_linux_get_tid_cpubind
hwloc_get_obj_inside_cpuset_by_type Linux-specific helpers, 186
Finding Objects inside a CPU set, 137 hwloc_linux_get_tid_last_cpu_location
hwloc_get_obj_with_same_locality Linux-specific helpers, 187
Finding objects, miscellaneous helpers, 144 hwloc_linux_read_path_as_cpumask
hwloc_get_pcidev_by_busid Linux-specific helpers, 187
Finding I/O objects, 150 hwloc_linux_set_tid_cpubind
hwloc_get_pcidev_by_busidstring Linux-specific helpers, 187
Finding I/O objects, 150 HWLOC_LOCAL_NUMANODE_FLAG_ALL
hwloc_get_proc_cpubind Comparing memory node attributes for finding
CPU binding, 107 where to allocate on, 176
hwloc_get_proc_last_cpu_location hwloc_local_numanode_flag_e
CPU binding, 107 Comparing memory node attributes for finding
hwloc_get_proc_membind where to allocate on, 176
Memory binding, 115 HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY
hwloc_get_pu_obj_by_os_index Comparing memory node attributes for finding
Finding objects, miscellaneous helpers, 144 where to allocate on, 176
hwloc_get_root_obj HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY
Object levels, depths and types, 100 Comparing memory node attributes for finding
hwloc_get_shared_cache_covering_obj where to allocate on, 176
Looking at Cache Objects, 141 hwloc_location, 228
hwloc_get_thread_cpubind location, 229
CPU binding, 108 type, 229
hwloc_get_type_depth hwloc_location::hwloc_location_u, 229
Object levels, depths and types, 100 cpuset, 229
hwloc_get_type_depth_e object, 229
Object levels, depths and types, 98 HWLOC_LOCATION_TYPE_CPUSET
hwloc_get_type_or_above_depth Comparing memory node attributes for finding
Object levels, depths and types, 101 where to allocate on, 177
hwloc_get_type_or_below_depth hwloc_location_type_e
Object levels, depths and types, 101
Generated by Doxygen
INDEX 257
Comparing memory node attributes for finding where to allocate on, 176
where to allocate on, 176 HWLOC_MEMATTR_ID_WRITE_BANDWIDTH
HWLOC_LOCATION_TYPE_OBJECT Comparing memory node attributes for finding
Comparing memory node attributes for finding where to allocate on, 178
where to allocate on, 177 HWLOC_MEMATTR_ID_WRITE_LATENCY
hwloc_memattr_flag_e Comparing memory node attributes for finding
Managing memory attributes, 182 where to allocate on, 178
HWLOC_MEMATTR_FLAG_HIGHER_FIRST hwloc_memattr_register
Managing memory attributes, 182 Managing memory attributes, 183
HWLOC_MEMATTR_FLAG_LOWER_FIRST hwloc_memattr_set_value
Managing memory attributes, 182 Managing memory attributes, 183
HWLOC_MEMATTR_FLAG_NEED_INITIATOR HWLOC_MEMBIND_BIND
Managing memory attributes, 182 Memory binding, 112
hwloc_memattr_get_best_initiator HWLOC_MEMBIND_BYNODESET
Comparing memory node attributes for finding Memory binding, 111
where to allocate on, 179 HWLOC_MEMBIND_DEFAULT
hwloc_memattr_get_best_target Memory binding, 111
Comparing memory node attributes for finding HWLOC_MEMBIND_FIRSTTOUCH
where to allocate on, 179 Memory binding, 111
hwloc_memattr_get_by_name hwloc_membind_flags_t
Comparing memory node attributes for finding Memory binding, 110
where to allocate on, 180 HWLOC_MEMBIND_INTERLEAVE
hwloc_memattr_get_flags Memory binding, 112
Managing memory attributes, 182 HWLOC_MEMBIND_MIGRATE
hwloc_memattr_get_initiators Memory binding, 111
Comparing memory node attributes for finding HWLOC_MEMBIND_MIXED
where to allocate on, 180 Memory binding, 112
hwloc_memattr_get_name HWLOC_MEMBIND_NEXTTOUCH
Managing memory attributes, 183 Memory binding, 112
hwloc_memattr_get_targets HWLOC_MEMBIND_NOCPUBIND
Comparing memory node attributes for finding Memory binding, 111
where to allocate on, 180 hwloc_membind_policy_t
hwloc_memattr_get_value Memory binding, 111
Comparing memory node attributes for finding HWLOC_MEMBIND_PROCESS
where to allocate on, 181 Memory binding, 111
HWLOC_MEMATTR_ID_BANDWIDTH HWLOC_MEMBIND_STRICT
Comparing memory node attributes for finding Memory binding, 111
where to allocate on, 177 HWLOC_MEMBIND_THREAD
HWLOC_MEMATTR_ID_CAPACITY Memory binding, 111
Comparing memory node attributes for finding HWLOC_MEMBIND_WEIGHTED_INTERLEAVE
where to allocate on, 177 Memory binding, 112
hwloc_memattr_id_e hwloc_nodeset_from_linux_libnuma_bitmask
Comparing memory node attributes for finding Interoperability with Linux libnuma bitmask, 190
where to allocate on, 177 hwloc_nodeset_from_linux_libnuma_ulongs
HWLOC_MEMATTR_ID_LATENCY Interoperability with Linux libnuma unsigned long
Comparing memory node attributes for finding masks, 188
where to allocate on, 178 hwloc_nodeset_t
HWLOC_MEMATTR_ID_LOCALITY Object Sets (hwloc_cpuset_t and hwloc_nodeset_t),
Comparing memory node attributes for finding 90
where to allocate on, 177 hwloc_nodeset_to_linux_libnuma_bitmask
HWLOC_MEMATTR_ID_READ_BANDWIDTH Interoperability with Linux libnuma bitmask, 190
Comparing memory node attributes for finding hwloc_nodeset_to_linux_libnuma_ulongs
where to allocate on, 177 Interoperability with Linux libnuma unsigned long
HWLOC_MEMATTR_ID_READ_LATENCY masks, 189
Comparing memory node attributes for finding hwloc_nvml_get_device_cpuset
where to allocate on, 178 Interoperability with the NVIDIA Management Li-
hwloc_memattr_id_t brary, 197
Comparing memory node attributes for finding hwloc_nvml_get_device_osdev
Generated by Doxygen
258 INDEX
Generated by Doxygen
INDEX 259
Generated by Doxygen
260 INDEX
Generated by Doxygen
INDEX 261
Generated by Doxygen
262 INDEX
Modifying a loaded Topology, 130 Changing the Source of Topology Discovery, 118
hwloc_topology_insert_misc_object hwloc_topology_set_xmlbuffer
Modifying a loaded Topology, 131 Changing the Source of Topology Discovery, 119
hwloc_topology_is_thissystem hwloc_topology_support, 247
Topology Detection Configuration and Query, 125 cpubind, 248
hwloc_topology_load discovery, 248
Topology Creation and Destruction, 97 membind, 248
hwloc_topology_membind_support, 245 misc, 248
alloc_membind, 246 hwloc_topology_t
bind_membind, 246 Topology Creation and Destruction, 95
firsttouch_membind, 246 HWLOC_TYPE_DEPTH_BRIDGE
get_area_membind, 246 Object levels, depths and types, 98
get_area_memlocation, 246 HWLOC_TYPE_DEPTH_MEMCACHE
get_proc_membind, 246 Object levels, depths and types, 98
get_thisproc_membind, 246 HWLOC_TYPE_DEPTH_MISC
get_thisthread_membind, 246 Object levels, depths and types, 98
interleave_membind, 246 HWLOC_TYPE_DEPTH_MULTIPLE
migrate_membind, 246 Object levels, depths and types, 98
nexttouch_membind, 246 HWLOC_TYPE_DEPTH_NUMANODE
set_area_membind, 247 Object levels, depths and types, 98
set_proc_membind, 247 HWLOC_TYPE_DEPTH_OS_DEVICE
set_thisproc_membind, 247 Object levels, depths and types, 98
set_thisthread_membind, 247 HWLOC_TYPE_DEPTH_PCI_DEVICE
weighted_interleave_membind, 247 Object levels, depths and types, 98
hwloc_topology_misc_support, 247 HWLOC_TYPE_DEPTH_UNKNOWN
imported_support, 247 Object levels, depths and types, 98
hwloc_topology_reconnect hwloc_type_filter_e
Components and Plugins: Core functions to be Topology Detection Configuration and Query, 124
used by components, 214 HWLOC_TYPE_FILTER_KEEP_ALL
hwloc_topology_refresh Topology Detection Configuration and Query, 124
Modifying a loaded Topology, 131 HWLOC_TYPE_FILTER_KEEP_IMPORTANT
hwloc_topology_restrict Topology Detection Configuration and Query, 124
Modifying a loaded Topology, 132 HWLOC_TYPE_FILTER_KEEP_NONE
hwloc_topology_set_all_types_filter Topology Detection Configuration and Query, 124
Topology Detection Configuration and Query, 126 HWLOC_TYPE_FILTER_KEEP_STRUCTURE
hwloc_topology_set_cache_types_filter Topology Detection Configuration and Query, 124
Topology Detection Configuration and Query, 126 hwloc_type_sscanf
hwloc_topology_set_components Converting between Object Types and Attributes,
Changing the Source of Topology Discovery, 117 and Strings, 103
hwloc_topology_set_flags hwloc_type_sscanf_as_depth
Topology Detection Configuration and Query, 126 Converting between Object Types and Attributes,
hwloc_topology_set_icache_types_filter and Strings, 103
Topology Detection Configuration and Query, 126 HWLOC_TYPE_UNORDERED
hwloc_topology_set_io_types_filter Object Types, 91
Topology Detection Configuration and Query, 127 hwloc_windows_get_nr_processor_groups
hwloc_topology_set_pid Windows-specific helpers, 191
Changing the Source of Topology Discovery, 117 hwloc_windows_get_processor_group_cpuset
hwloc_topology_set_synthetic Windows-specific helpers, 191
Changing the Source of Topology Discovery, 118
hwloc_topology_set_type_filter I/O Devices, 29
Topology Detection Configuration and Query, 127 imported_support
hwloc_topology_set_userdata hwloc_topology_misc_support, 247
Topology Detection Configuration and Query, 127 Importing and exporting topologies from/to XML files, 51
hwloc_topology_set_userdata_export_callback index
Exporting Topologies to XML, 164 hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_uint64_
hwloc_topology_set_userdata_import_callback 243
Exporting Topologies to XML, 164 infos
hwloc_topology_set_xml hwloc_obj, 233
infos_count
Generated by Doxygen
INDEX 263
Generated by Doxygen
264 INDEX
Generated by Doxygen
INDEX 265
hwloc_topology_diff_u::hwloc_topology_diff_too_complex_s,
HWLOC_OBJ_MACHINE, 93
243 HWLOC_OBJ_MEMCACHE, 94
object HWLOC_OBJ_MISC, 94
hwloc_location::hwloc_location_u, 229 HWLOC_OBJ_NUMANODE, 93
Object attributes, 37 HWLOC_OBJ_OS_DEVICE, 94
Object levels, depths and types, 97 HWLOC_OBJ_OSDEV_BLOCK, 92
hwloc_get_depth_type, 98 HWLOC_OBJ_OSDEV_COPROC, 92
hwloc_get_memory_parents_depth, 99 HWLOC_OBJ_OSDEV_DMA, 92
hwloc_get_nbobjs_by_depth, 99 HWLOC_OBJ_OSDEV_GPU, 92
hwloc_get_nbobjs_by_type, 99 HWLOC_OBJ_OSDEV_NETWORK, 92
hwloc_get_next_obj_by_depth, 99 HWLOC_OBJ_OSDEV_OPENFABRICS, 92
hwloc_get_next_obj_by_type, 99 hwloc_obj_osdev_type_e, 92
hwloc_get_obj_by_depth, 100 hwloc_obj_osdev_type_t, 91
hwloc_get_obj_by_type, 100 HWLOC_OBJ_PACKAGE, 93
hwloc_get_root_obj, 100 HWLOC_OBJ_PCI_DEVICE, 94
hwloc_get_type_depth, 100 HWLOC_OBJ_PU, 93
hwloc_get_type_depth_e, 98 hwloc_obj_type_t, 92
hwloc_get_type_or_above_depth, 101 HWLOC_TYPE_UNORDERED, 91
hwloc_get_type_or_below_depth, 101 objs
hwloc_topology_get_depth, 101 hwloc_distances_s, 227
HWLOC_TYPE_DEPTH_BRIDGE, 98 oldvalue
HWLOC_TYPE_DEPTH_MEMCACHE, 98 hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_string_
HWLOC_TYPE_DEPTH_MISC, 98 241
HWLOC_TYPE_DEPTH_MULTIPLE, 98 hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_uint64_
HWLOC_TYPE_DEPTH_NUMANODE, 98 243
HWLOC_TYPE_DEPTH_OS_DEVICE, 98 os_index
HWLOC_TYPE_DEPTH_PCI_DEVICE, 98 hwloc_obj, 234
HWLOC_TYPE_DEPTH_UNKNOWN, 98 osdev
Object Sets (hwloc_cpuset_t and hwloc_nodeset_t), 90 hwloc_obj_attr_u, 236
hwloc_const_cpuset_t, 90
hwloc_const_nodeset_t, 90 page_types
hwloc_cpuset_t, 90 hwloc_obj_attr_u::hwloc_numanode_attr_s, 230
hwloc_nodeset_t, 90 page_types_len
Object Structure and Attributes, 95 hwloc_obj_attr_u::hwloc_numanode_attr_s, 230
hwloc_obj_t, 95 parent
Object Types, 91 hwloc_obj, 235
hwloc_compare_types, 94 pci
HWLOC_OBJ_BRIDGE, 93 hwloc_obj_attr_u::hwloc_bridge_attr_s, 221
HWLOC_OBJ_BRIDGE_HOST, 92 pci_bus
HWLOC_OBJ_BRIDGE_PCI, 92 hwloc_cl_device_pci_bus_info_khr, 222
hwloc_obj_bridge_type_e, 92 pci_device
hwloc_obj_bridge_type_t, 91 hwloc_cl_device_pci_bus_info_khr, 222
HWLOC_OBJ_CACHE_DATA, 92 pci_domain
HWLOC_OBJ_CACHE_INSTRUCTION, 92 hwloc_cl_device_pci_bus_info_khr, 222
hwloc_obj_cache_type_e, 92 pci_function
hwloc_obj_cache_type_t, 91 hwloc_cl_device_pci_bus_info_khr, 222
HWLOC_OBJ_CACHE_UNIFIED, 92 pcidev
HWLOC_OBJ_CORE, 93 hwloc_obj_attr_u, 236
HWLOC_OBJ_DIE, 94 pcie
HWLOC_OBJ_GROUP, 93 hwloc_cl_device_topology_amd, 223
HWLOC_OBJ_L1CACHE, 93 phase
HWLOC_OBJ_L1ICACHE, 93 hwloc_disc_status, 226
HWLOC_OBJ_L2CACHE, 93 phases
HWLOC_OBJ_L2ICACHE, 93 hwloc_backend, 220
HWLOC_OBJ_L3CACHE, 93 hwloc_disc_component, 225
HWLOC_OBJ_L3ICACHE, 93 prev_cousin
HWLOC_OBJ_L4CACHE, 93 hwloc_obj, 235
HWLOC_OBJ_L5CACHE, 93 prev_sibling
hwloc_obj, 235
Generated by Doxygen
266 INDEX
Generated by Doxygen
INDEX 267
Generated by Doxygen
268 INDEX
hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_uint64_s,
243
hwloc_topology_diff_u::hwloc_topology_diff_generic_s,
240
hwloc_topology_diff_u::hwloc_topology_diff_obj_attr_s,
241
hwloc_topology_diff_u::hwloc_topology_diff_too_complex_s,
243
uint64
hwloc_topology_diff_obj_attr_u, 242
unused
hwloc_cl_device_topology_amd, 223
Upgrading to the hwloc 2.0 API, 79
upstream
hwloc_obj_attr_u::hwloc_bridge_attr_s, 221
upstream_type
hwloc_obj_attr_u::hwloc_bridge_attr_s, 221
userdata
hwloc_obj, 235
value
hwloc_info_s, 228
values
hwloc_distances_s, 227
vendor_id
hwloc_obj_attr_u::hwloc_pcidev_attr_s, 238
weighted_interleave_membind
hwloc_topology_membind_support, 247
Windows-specific helpers, 190
hwloc_windows_get_nr_processor_groups, 191
hwloc_windows_get_processor_group_cpuset,
191
Generated by Doxygen