HWLOCALITY_CONFIGURATION(3)
๐ hwlocality_configuration โ Topology Detection Configuration and Query
okay bestie, welcome to hwlocality_configuration(3) from the Library Functions Manual โ this is the page where hwloc lets you tune how it sniffs out your hardware before it actually commits. main character energy for your topology, fr fr ๐
โจ NAME โจ
hwlocality_configuration โ Topology Detection Configuration and Query ๐ธ
๐ฆ SYNOPSIS ๐ฆ
๐งฑ Data Structures
bestie, these are the little structs you'll be poking at โ lowkey the whole vibe check of your machine lives in here:
struct hwloc_topology_discovery_supportstruct hwloc_topology_cpubind_supportstruct hwloc_topology_membind_supportstruct hwloc_topology_misc_supportstruct hwloc_topology_support
๐ท๏ธ Enumerations
okay so there are two enums and honestly? iconic. first up, the flags โ note the exact bit values, do not come for them:
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_MEMBINDING = (1UL<<5),
HWLOC_TOPOLOGY_FLAG_DONT_CHANGE_BINDING = (1UL<<6),
HWLOC_TOPOLOGY_FLAG_NO_DISTANCES = (1UL<<7),
HWLOC_TOPOLOGY_FLAG_NO_MEMATTRS = (1UL<<8),
HWLOC_TOPOLOGY_FLAG_NO_CPUKINDS = (1UL<<9)
};
and then the type filters โ these ones decide which object types get to stay in the group chat ๐ซถ:
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
the whole cast, no skips, no cuts โ every single one:
int hwloc_topology_set_flags (hwloc_topology_t topology, unsigned long flags)
unsigned long hwloc_topology_get_flags (hwloc_topology_t topology)
int hwloc_topology_is_thissystem (hwloc_topology_t restrict topology)
const struct hwloc_topology_support * hwloc_topology_get_support
(hwloc_topology_t restrict topology)
int hwloc_topology_set_type_filter (hwloc_topology_t topology,
hwloc_obj_type_t type, enum hwloc_type_filter_e filter)
int hwloc_topology_get_type_filter (hwloc_topology_t topology,
hwloc_obj_type_t type, enum hwloc_type_filter_e *filter)
int hwloc_topology_set_all_types_filter (hwloc_topology_t topology, enum
hwloc_type_filter_e filter)
int hwloc_topology_set_cache_types_filter (hwloc_topology_t topology,
enum hwloc_type_filter_e filter)
int hwloc_topology_set_icache_types_filter (hwloc_topology_t topology,
enum hwloc_type_filter_e filter)
int hwloc_topology_set_io_types_filter (hwloc_topology_t topology, enum
hwloc_type_filter_e filter)
void hwloc_topology_set_userdata (hwloc_topology_t topology, const void
*userdata)
void * hwloc_topology_get_userdata (hwloc_topology_t topology)
๐ Detailed Description ๐
okay so here's the tea โ โ there are several functions you can optionally call between hwloc_topology_init() and hwloc_topology_load(), and what they do is configure how the detection itself should go down. like, you get to be the director of the whole operation before the cameras roll ๐ฌ
things you can do in that little window:
- ignore some object types (bye bestie ๐)
- define a synthetic topology (yes, you can just invent one, no cap)
- etc.
๐ง quick vibe check: this is all optional setup stuff, and it only makes sense betweenhwloc_topology_init()andhwloc_topology_load()โ that's your window, don't miss it ๐
๐ ENUMERATION TYPE DOCUMENTATION ๐
๐ enum hwloc_topology_flags_e
Okay so these are the flags you slap onto a topology context before you load it, bestie. Like, they go into hwloc_topology_set_flags(), and hwloc_topology_get_flags() can hand them right back to you. ๐
๐ซถ HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED
Detect the whole entire system, ignore reservations, and include disallowed objects. Basically gather all the online resources, even if the admin disabled some of them โ for instance, ignore Linux Cgroup/Cpusets and gather every processor and memory node. That said, offline PUs and NUMA nodes are still ignored. No cap. ๐
When this flag is not set, PUs and NUMA nodes that are disallowed are not added to the topology at all. Parent objects (package, core, cache, etc.) only get added if some of their children are allowed. All existing PUs and NUMA nodes in the topology are allowed. In that case hwloc_topology_get_allowed_cpuset() and hwloc_topology_get_allowed_nodeset() are equal to the root object cpuset and nodeset. โจ
When this flag is set, the actual sets of allowed PUs and NUMA nodes are given by hwloc_topology_get_allowed_cpuset() and hwloc_topology_get_allowed_nodeset(). They may be smaller than the root object cpuset and nodeset, iykyk. ๐ฆ
If your current topology gets exported to XML and reimported later, this flag should be set again in the reimported topology so that disallowed resources are reimported as well. Don't forget, bestie. ๐ญ
๐ง 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. it makes hwloc assume that the selected backend provides the topology for the system on which we're running โ even if it's not the OS-specific backend but the XML backend for instance. What that means: the binding functions actually call the OS-specific system calls and really do binding, while the XML backend would otherwise just hand you empty hooks returning success. ๐
Setting the environment variable HWLOC_THISSYSTEM may also result in the same behavior. ๐
This one's iconic for efficiency reasons: detect the topology once, save it to an XML file, quickly reload it later through the XML backend โ but still have binding functions actually do bind. Main character energy fr fr. โญ
๐ HWLOC_TOPOLOGY_FLAG_THISSYSTEM_ALLOWED_RESOURCES
Get the set of allowed resources from the local operating system even if the topology was loaded from XML or a synthetic description. If the topology was loaded from XML or from a synthetic string, restrict it by applying the current process restrictions such as Linux Cgroup/Cpuset. ๐
This is useful when the topology is not loaded directly from the local machine (e.g. for performance reason) and it comes with all resources, while the running process is restricted to only parts of the machine. Lowkey perfect for that. ๐ธ
This flag is ignored unless HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM is also set, since the loaded topology must match the underlying machine where restrictions will be gathered from. Periodt. ๐
Setting the environment variable HWLOC_THISSYSTEM_ALLOWED_RESOURCES would result in the same behavior. โจ
๐ HWLOC_TOPOLOGY_FLAG_IMPORT_SUPPORT
Import all support bits from the imported topology. When importing an XML topology from a remote machine, binding is disabled by default (see HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM). This disabling is also marked by putting zeroes in the corresponding supported feature bits reported by hwloc_topology_get_support(). ๐
The flag HWLOC_TOPOLOGY_FLAG_IMPORT_SUPPORT actually imports binding support bits from the remote machine. It also sets the flag imported_support in the struct hwloc_topology_misc_support array. If the imported XML did not contain any support information (exporter hwloc is too old), this flag is not set. ๐ญ
Note that non-binding support bits, e.g. the ability to discover NUMA nodes, are always imported. ๐ฆ
Note that these supported features are only relevant for the hwloc installation that actually exported the XML topology (it may vary with the operating system, or with how hwloc was compiled). ๐ง
Note that setting this flag however does not enable binding for the locally imported hwloc topology โ it only reports what the remote hwloc and machine support. Read that twice, bestie. ๐ซถ
๐ฅ HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
Do not consider resources outside of the process CPU binding. If the binding of the process is limited to a subset of cores, ignore the other cores during discovery. ๐
The resulting topology is identical to what a call to hwloc_topology_restrict() would generate, but this flag also prevents hwloc from ever touching other resources during the discovery. ๐
This flag especially tells the x86 backend to never temporarily rebind a thread on any excluded core. That's useful on Windows because such temporary rebinding can change the process binding. Another use-case is to avoid cores that would not be able to perform the hwloc discovery anytime soon because they're busy executing some high-priority real-time tasks. ๐ฎโ๐จ
If process CPU binding is not supported, the thread CPU binding is considered instead if supported, or the flag is ignored. ๐
This flag requires HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM as well, since binding support is required. ๐
๐ HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_MEMBINDING
Do not consider resources outside of the process memory binding. If the binding of the process is limited to a subset of NUMA nodes, ignore the other NUMA nodes during discovery. ๐
The resulting topology is identical to what a call to hwloc_topology_restrict() would generate, but this flag also prevents hwloc from ever touching other resources during the discovery. โญ
This flag is meant to be used together with HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING when both cores and NUMA nodes should be ignored outside of the process binding. ๐ซถ
If process memory binding is not supported, the thread memory binding is considered instead if supported, or the flag is ignored. ๐ธ
This flag requires HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM as well, since binding support is required. ๐ญ
๐ฆ HWLOC_TOPOLOGY_FLAG_DONT_CHANGE_BINDING
Do not ever modify the process or thread binding during discovery. This flag disables all hwloc discovery steps that require a change of the process or thread binding. This currently only affects the x86 backend, which gets entirely disabled. ๐
This is useful when hwloc_topology_load() is called while the application also creates additional threads or modifies the binding. ๐
This flag is also a strict way to make sure the process binding will not change due to thread binding changes on Windows (see HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING). ๐
๐ HWLOC_TOPOLOGY_FLAG_NO_DISTANCES
Ignore distances. Ignore distance information from the operating systems (and from XML) and hence do not use distances for grouping. Simple as that, bestie. โจ
๐ HWLOC_TOPOLOGY_FLAG_NO_MEMATTRS
Ignore memory attributes and tiers. Ignore memory attributes from the operating systems (and from XML). Hence also do not try to build memory tiers. ๐
๐ซถ HWLOC_TOPOLOGY_FLAG_NO_CPUKINDS
Ignore CPU Kinds. Ignore CPU kind information from the operating systems (and from XML). That's the whole vibe. ๐
๐ธ enum hwloc_type_filter_e
Type filtering flags, bestie โ this is how you tell hwloc which object types to keep around. 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. ๐
๐ HWLOC_TYPE_FILTER_KEEP_ALL
Keep all objects of this type. Cannot be set for HWLOC_OBJ_GROUP โ groups are designed only to add more structure to the topology, so like, that's a no. ๐ซ
๐ HWLOC_TYPE_FILTER_KEEP_NONE
Ignore all objects of this type. The bottom-level type HWLOC_OBJ_PU, the HWLOC_OBJ_NUMANODE type, and the top-level type HWLOC_OBJ_MACHINE may not be ignored. Those three are literally the main characters, sorry. ๐
๐ HWLOC_TYPE_FILTER_KEEP_STRUCTURE
Only ignore objects if their entire level does not bring any structure. Keep the entire level of objects if at least one of these objects adds structure to the topology. An object brings structure when it has multiple children and it is not the only child of its parent. ๐
If all objects in the level are the only child of their parent, or if all of them have a single child, the entire level may be removed. A common example is caches that are private to each core. ๐
This filter cannot be used for I/O and Misc objects since the topology structure does not matter there. ๐
๐ฅ HWLOC_TYPE_FILTER_KEEP_IMPORTANT
Only keep likely-important objects of the given type. It is only useful for I/O object types. For HWLOC_OBJ_PCI_DEVICE and HWLOC_OBJ_OS_DEVICE, it means that only objects of major/common kinds are kept (storage, network, OpenFabrics, CUDA, OpenCL, RSMI, NVML, and displays). Also, only OS devices directly attached on PCI (e.g. no USB) are reported. For HWLOC_OBJ_BRIDGE, it means that bridges are kept only if they have children. ๐ซถ
This flag is equivalent to HWLOC_TYPE_FILTER_KEEP_ALL for Normal, Memory and Misc types since they are likely important. Slay. โญ
โจ FUNCTION DOCUMENTATION โจ
okay bestie, this is the part where we meet every single function in this crew ๐ no skipping, no skimming, we're doing all of them. Let's go ๐ซถ
๐ hwloc_topology_get_flags
unsigned long hwloc_topology_get_flags (hwloc_topology_t topology)
Grabs the OR'ed flags of a topology โ literally the OR'ed set of hwloc_topology_flags_e that this topology is carrying around.
Lowkey important: if hwloc_topology_set_flags() was never called earlier, no flags are set at all (0 is what you get back). So a zero isn't a bug, it's just a fresh little topology with nothing switched on ๐ฆ
Returns: the flags that were previously set with hwloc_topology_set_flags().
๐ก Note: this function may also be called after hwloc_topology_load(). You're not locked out post-load, bestie.
๐ธ hwloc_topology_get_support
const struct hwloc_topology_support * hwloc_topology_get_support
(hwloc_topology_t restrict topology)
Retrieves the topology support ๐ Each flag is basically a vibe check on one feature: if it's 0, that feature is not supported. If it's 1, the feature is supported โ but heads up, the corresponding call may still fail in some corner cases ๐ญ so 1 is not a pinky promise, it's a strong maybe.
These features are also listed by hwloc-info --support โจ
The reported features are what the current topology supports on the current machine. And if the topology was exported to XML from another machine and later imported here, support still describes what is supported for this imported topology after import. In that case, binding is reported as unsupported by default (see HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM).
But wait ๐ the topology flag HWLOC_TOPOLOGY_FLAG_IMPORT_SUPPORT may be used to report all supported features of the original remote machine instead โ binding included. If they were successfully imported, imported_support will be set in the struct hwloc_topology_misc_support array.
Returns: a pointer to a support structure.
๐ Note, and read this twice, bestie: - The function cannot return NULL. Ever. - The returned pointer should not be freed โ it belongs to the hwloc library, it is not yours to yeet. - This function may be called before or after hwloc_topology_load(), but the support structure only contains valid information after.
๐ฆ 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)
Gets the current filtering for the given object type.
Returns: 0 on success, -1 on error.
๐ซ hwloc_topology_get_userdata
void * hwloc_topology_get_userdata (hwloc_topology_t topology)
Retrieves the topology-specific userdata pointer โ aka that application-given private data pointer you previously set with hwloc_topology_set_userdata() ๐
Returns: a pointer to the private-data if anyโฆ or NULL if no private-data was previously set ๐
๐ hwloc_topology_is_thissystem
int hwloc_topology_is_thissystem (hwloc_topology_t restrict topology)
The big question: does this topology context come from this system? ๐
Returns:
1if this topology context was built using the system running this program.0instead โ for instance if you're using another file-system root, an XML topology file, or a synthetic topology.
โญ Note: this function may also be called after hwloc_topology_load().
๐งน hwloc_topology_set_all_types_filter
int hwloc_topology_set_all_types_filter (hwloc_topology_t topology, enum
hwloc_type_filter_e filter)
Sets the filtering for all object types in one big swoop. If some types don't support this filtering, they are silently ignored โ no drama, no error, they just quietly opt out ๐
Returns: 0 on success, -1 on error.
๐ hwloc_topology_set_cache_types_filter
int hwloc_topology_set_cache_types_filter (hwloc_topology_t topology, enum
hwloc_type_filter_e filter)
Sets the filtering for all CPU cache object types. Memory-side caches are not involved, since they are not CPU caches. Periodt.
Returns: 0 on success, -1 on error.
๐ฅ hwloc_topology_set_flags
int hwloc_topology_set_flags (hwloc_topology_t topology, unsigned long
flags)
Sets an OR'ed set of hwloc_topology_flags_e onto a topology that was not yet loaded โ this is a pre-load move, bestie, timing matters ๐
If this function is called multiple times, the last invocation will erase and replace the set of flags that was previously set. No stacking, no accumulating, last one wins, no cap.
By default, no flags are set (0) ๐ฆ
The flags set in a topology may be retrieved with hwloc_topology_get_flags().
Returns:
0on success.-1on error, for instance if flags are invalid.
โญ hwloc_topology_set_icache_types_filter
int hwloc_topology_set_icache_types_filter (hwloc_topology_t topology, enum
hwloc_type_filter_e filter)
Sets the filtering for all CPU instruction cache object types. Memory-side caches are not involved since they are not CPU caches โ same energy as the cache one, just instruction-flavoured ๐
Returns: 0 on success, -1 on error.
๐ hwloc_topology_set_io_types_filter
int hwloc_topology_set_io_types_filter (hwloc_topology_t topology, enum
hwloc_type_filter_e filter)
Sets the filtering for all I/O object types.
Returns: 0 on success, -1 on error.
๐ 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)
Sets the filtering for the given object type.
Returns: 0 on success, -1 on error.
๐ง hwloc_topology_set_userdata
void hwloc_topology_set_userdata (hwloc_topology_t topology, const void *
userdata)
Sets the topology-specific userdata pointer ๐ Each topology may store one application-given private data pointer. It is initialized to NULL, and hwloc will never modify it. Never ever. It's yours.
Use it as you wish, after hwloc_topology_init() and until hwloc_topolog_destroy() ๐ธ (and yes, that's exactly how it's spelled up there โ don't come for me, I'm just the messenger ๐)
๐ Heads up bestie: this pointer is not exported to XML.
๐ AUTHOR ๐
Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code. Iconic behaviour, honestly. No notes.
and that's the whole page, bestie ๐ซถ this was Hardware Locality (hwloc), Version 2.15.0, page hwlocality_configuration(3) โ go forth and configure your topology with main character energy โจ๐
๐ฆ where this page comes from
- arch rolling: hwloc 2.15.0-1 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms