# Configure Topology Detection

## Data Structures

struct | hwloc_topology_discovery_support
| Flags describing actual discovery support for this topology. More...
struct | hwloc_topology_cpubind_support
| Flags describing actual binding support for this topology. More...
struct | hwloc_topology_support
| Set of flags describing actual support for this topology. More...

## Enumerations

enum | hwloc_topology_flags_e { HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM, HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM }
| Flags to be set onto a topology context before load. More...

## Functions

HWLOC_DECLSPEC int | hwloc_topology_ignore_type (hwloc_topology_t topology, hwloc_obj_type_t type)
| Ignore an object type.
HWLOC_DECLSPEC int | hwloc_topology_ignore_type_keep_structure (hwloc_topology_t topology, hwloc_obj_type_t type)
| Ignore an object type if it does not bring any structure.
HWLOC_DECLSPEC int | hwloc_topology_ignore_all_keep_structure (hwloc_topology_t topology)
| Ignore all objects that do not bring any structure.
HWLOC_DECLSPEC int | hwloc_topology_set_flags (hwloc_topology_t topology, unsigned long flags)
| Set OR'ed flags to non-yet-loaded topology.
HWLOC_DECLSPEC int | hwloc_topology_set_fsroot (hwloc_topology_t __hwloc_restrict topology, const char *__hwloc_restrict fsroot_path)
| Change the file-system root path when building the topology from sysfs/procfs.
HWLOC_DECLSPEC int | hwloc_topology_set_pid (hwloc_topology_t __hwloc_restrict topology, hwloc_pid_t pid)
| Change which pid the topology is viewed from.
HWLOC_DECLSPEC int | hwloc_topology_set_synthetic (hwloc_topology_t __hwloc_restrict topology, const char *__hwloc_restrict description)
| Enable synthetic topology.
HWLOC_DECLSPEC int | hwloc_topology_set_xml (hwloc_topology_t __hwloc_restrict topology, const char *__hwloc_restrict xmlpath)
| Enable XML-file based topology.
HWLOC_DECLSPEC struct hwloc_topology_support * | hwloc_topology_get_support (hwloc_topology_t __hwloc_restrict topology)
| Retrieve the topology support.

## Detailed Description

These functions can optionally be called between hwloc_topology_init() and hwloc_topology_load() to configure how the detection should be performed, e.g. to ignore some objects types, define a synthetic topology, etc.

If none of them is called, the default is to detect all the objects of the machine that the caller is allowed to access.

This default behavior may also be modified through environment variables if the application did not modify it already. Setting HWLOC_XMLFILE in the environment enforces the discovery from a XML file as if hwloc_topology_set_xml() had been called. HWLOC_FSROOT switches to reading the topology from the specified Linux filesystem root as if hwloc_topology_set_fsroot() had been called. Finally, HWLOC_THISSYSTEM enforces the return value of hwloc_topology_is_thissystem().

## Enumeration Type Documentation

enum hwloc_topology_flags_e

Flags to be set onto a topology context before load.

Flags should be given to hwloc_topology_set_flags().

Enumerator:

  HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM | Detect the whole system, ignore reservations and offline settings. Gather all resources, even if some were disabled by the administrator. For instance, ignore Linux Cpusets and gather all processors and memory nodes, and ignore the fact that some resources may be offline.

  HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM

  Assume that the selected backend provides the topology for the system on which we are running.

  This forces hwloc_topology_is_thissystem to return 1, i.e. makes hwloc assume that the selected backend provides the topology for the system on which we are running, even if it is not the OS-specific backend but the XML backend for instance. This means making the binding functions actually call the OS-specific system calls and really do binding, while the XML backend would otherwise provide empty hooks just returning success.

  Setting the environment variable HWLOC_THISSYSTEM may also result in the same behavior.

  This can be used for efficiency reasons to first detect the topology once, save it to an XML file, and quickly reload it later through the XML backend, but still having binding functions actually do bind.

## Function Documentation

HWLOC_DECLSPEC struct hwloc_topology_support* hwloc_topology_get_support | ( | hwloc_topology_t __hwloc_restrict | topology | ) | `[read]`

Retrieve the topology support.

HWLOC_DECLSPEC int hwloc_topology_ignore_all_keep_structure | ( | hwloc_topology_t | topology | ) |

Ignore all objects that do not bring any structure.

Ignore all objects that do not bring any structure: Each ignored object should have a single children or be the only child of its parent.

HWLOC_DECLSPEC int hwloc_topology_ignore_type | ( | hwloc_topology_t | topology,
|  | hwloc_obj_type_t | type |
| ) |  |  |

Ignore an object type.

Ignore all objects from the given type. The bottom-level type HWLOC_OBJ_PU may not be ignored. The top-level object of the hierarchy will never be ignored, even if this function succeeds.

HWLOC_DECLSPEC int hwloc_topology_ignore_type_keep_structure | ( | hwloc_topology_t | topology,
|  | hwloc_obj_type_t | type |
| ) |  |  |

Ignore an object type if it does not bring any structure.

Ignore all objects from the given type as long as they do not bring any structure: Each ignored object should have a single children or be the only child of its parent. The bottom-level type HWLOC_OBJ_PU may not be ignored.

HWLOC_DECLSPEC 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.

HWLOC_DECLSPEC int hwloc_topology_set_fsroot | ( | hwloc_topology_t __hwloc_restrict | topology,
|  | const char *__hwloc_restrict | fsroot_path |
| ) |  |  |

Change the file-system root path when building the topology from sysfs/procfs.

On Linux system, use sysfs and procfs files as if they were mounted on the given `fsroot_path` instead of the main file-system root. Setting the environment variable HWLOC_FSROOT may also result in this behavior. Not using the main file-system root causes hwloc_topology_is_thissystem() to return 0.

Note:
  For conveniency, this backend provides empty binding hooks which just return success. To have hwloc still actually call OS-specific hooks, the HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM has to be set to assert that the loaded file is really the underlying system.

HWLOC_DECLSPEC int hwloc_topology_set_pid | ( | hwloc_topology_t __hwloc_restrict | topology,
|  | hwloc_pid_t | pid |
| ) |  |  |

Change which pid 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.

Note:
  hwloc_pid_t is pid_t on unix platforms, and HANDLE on native Windows platforms
  The ENOSYS error is returned on platforms that does not support this feature.

HWLOC_DECLSPEC int hwloc_topology_set_synthetic | ( | hwloc_topology_t __hwloc_restrict | topology,
|  | const char *__hwloc_restrict | description |
| ) |  |  |

Enable synthetic topology.

Gather topology information from the given `description` which should be a comma separated string of numbers describing the arity of each level. Each number may be prefixed with a type and a colon to enforce the type of a level. If only some level types are enforced, hwloc will try to choose the other types according to usual topologies, but it may fail and you may have to specify more level types manually.

Note:
  For conveniency, this backend provides empty binding hooks which just return success.

HWLOC_DECLSPEC int hwloc_topology_set_xml | ( | hwloc_topology_t __hwloc_restrict | topology,
|  | const char *__hwloc_restrict | xmlpath |
| ) |  |  |

Enable XML-file based topology.

Gather topology information 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 lstopo file.xml.

Note:
  For conveniency, this backend provides empty binding hooks which just return success. To have hwloc still actually call OS-specific hooks, the HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM has to be set to assert that the loaded file is really the underlying system.