Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v2.0.4

  |   Home   |   Support   |   FAQ   |  
Components and plugins

hwloc is organized in components that are responsible for discovering objects. Depending on the topology configuration, some components will be used, some will be ignored. The usual default is to enable the native operating system component, (e.g. linux or solaris) and the pci miscellaneous component. If available, an architecture-specific component (such as x86) may also improve the topology detection.

If a XML topology is loaded, the xml discovery component will be used instead of all other components. It internally uses a specific class of components for the actual XML import/export routines (xml_libxml and xml_nolibxml) but these will not be discussed here (see libxml2 and minimalistic XML backends).

Components enabled by default

The hwloc core contains a list of components sorted by priority. Each one is enabled as long as it does not conflict with the previously enabled ones. This includes native operating system components, architecture-specific ones, and if available, I/O components such as pci.

Usually the native operating system component (when it exists, e.g. linux or aix) is enabled first. Then hwloc looks for an architecture specific component (e.g. x86). Finally there also exist a basic component (no_os) that just tries to discover the number of PUs in the system.

Each component discovers as much topology information as possible. Most of them, including most native OS components, do nothing unless the topology is still empty. Some others, such as x86 and pci, can complete and annotate what other backends found earlier.

Default priorities ensure that clever components are invoked first. Native operating system components have higher priorities, and are therefore invoked first, because they likely offer very detailed topology information. If needed, it will be later extended by architecture-specific information (e.g. from the x86 component).

If any configuration function such as hwloc_topology_set_xml() is used before loading the topology, the corresponding component is enabled first. Then, as usual, hwloc enables any other component (based on priorities) that does not conflict.

Certain components that manage a virtual topology, for instance XML topology import or synthetic topology description, conflict with all other components. Therefore, one of them may only be loaded (e.g. with hwloc_topology_set_xml()) if no other component is enabled.

The environment variable HWLOC_COMPONENTS_VERBOSE may be set to get verbose messages about component registration (including their priority) and enabling.

Selecting which components to use

If no topology configuration functions such as hwloc_topology_set_synthetic() have been called, plugins may be selected with environment variables such as HWLOC_XMLFILE, HWLOC_SYNTHETIC, HWLOC_FSROOT, or HWLOC_CPUID_PATH (see Environment Variables).

Finally, the environment variable HWLOC_COMPONENTS resets the list of selected components. If the variable is set and empty (or set to a single comma separating nothing, since some operating systems do not accept empty variables), the normal plugin priority order is used.

If the variable is set to x86 in this variable will cause the x86 component to take precedence over any other component, including the native operating system component. It is therefore loaded first, before hwloc tries to load all remaining non-conflicting components. In this case, x86 would take care of discovering everything it supports, 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.

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.

Loading components from plugins

Components may optionally be built as plugins so that the hwloc core library does not directly depend on their dependencies (for instance the libpciaccess library). Plugin support may be enabled with the --enable-plugins configure option. All components buildable as plugins will then be built as plugins. The configure option may be given a comma-separated list of component names to specify the exact list of components to build as plugins.

Plugins are built as independent dynamic libraries that are installed in $libdir/hwloc. All plugins found in this directory are loaded during topology_init() (unless blacklisted in HWLOC_PLUGINS_BLACKLIST, see Environment Variables). A specific list of directories (colon-separated) to scan may be specified in the HWLOC_PLUGINS_PATH environment variable.

Note that loading a plugin just means that the corresponding component is registered to the hwloc core. Components are then only enabled if the topology configuration requests it, as explained in the previous sections.

Also note that plugins should carefully be enabled and used when embedding hwloc in another project, see Embedding hwloc in Other Software for details.

Adding new discovery components and plugins

The types and functions cited below are declared in the hwloc/plugins.h header. Components are supposed to only use hwloc public headers (hwloc.h and anything under the include/hwloc subdirectory) and nothing from the include/private subdirectory in the source tree.

Basics of discovery components

Each discovery component is defined by a hwloc_disc_component structure which contains an instantiate() callback. This function is invoked when this component is actually used by a topology. It fills a new hwloc_backend structure that usually contains a discover() callback taking care of the actual topology discovery.

Note
If two discovery components have the same name, only the highest priority one is actually made available. This offers a way for third-party plugins to override existing components.

Registering a new discovery component

Registering components to the hwloc core relies on a hwloc_component structure. Its data field points to the previously defined hwloc_disc_component structure while its type should be HWLOC_COMPONENT_TYPE_DISC. This structure should be named hwloc_<name>_component.

The configure script should be modified to add <name> to its hwloc_components shell variable so that the component is actually available.

Note
The symbol name of the hwloc_component structure is independent of the name of the discovery component mentioned in the previous section.

When the component is statically built inside the hwloc library, the symbol hwloc_<name>_component is added by configure to the src/static-components.h. The core then registers all components listed in this file.

If the new component may be built as a plugin, the configure script should also define the shell variable hwloc_<name>_component_maybeplugin=1. When the configure script actually enables the component as a plugin, it will set the variable hwloc_<name>_component to plugin. The build system may then use this variable to change the way the component is built. It should create a hwloc_<name>.so shared object. All these files are loaded in alphabetic order, and the components they contain are registered to the hwloc core.

Existing components and plugins

All components distributed within hwloc are listed below. The list of actually available components may be listed at running with the HWLOC_COMPONENTS_VERBOSE environment variable (see Environment Variables).

aix, darwin, freebsd, hpux, linux, 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 pciaccess library (aka libpciaccess); see I/O Devices. It may be built as a plugin.
linuxio (former linuxpci)
This component can probe I/O devices on Linux. It discovers PCI devices without the help of external libraries such as libpciaccess. Its priority is lower than the pci component because it misses device names. It also discovers many kinds of Linux-specific OS devices.
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 OpenCL implementation currently offers locality information. It may be built as a plugin.
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 statically. It internally uses one of the XML backends (see libxml2 and minimalistic XML backends).
  • xml_nolibxml is a basic and hwloc-specific XML import/export. It is always statically built.
  • xml_libxml relies on the external libxml2 library for provinding a feature-complete XML import/export. It may be built as a plugin.
fake
A dummy plugin that does nothing but is used for debugging plugin support.