---
name: "hwloc_cpuset_to_nodeset"
section: "3"
platform: "linux"
package: "hwloc"
version: "2.15.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_helper_nodeset_convert"
---

# hwloc\_cpuset\_to\_nodeset(3)

Converting between CPU sets and node sets

Part of [hwlocality\_helper\_nodeset\_convert(3)](/hwlocality_helper_nodeset_convert/3.md).

## NAME

hwlocality\_helper\_nodeset\_convert - Converting between CPU sets and node sets

## SYNOPSIS

### Functions

int **hwloc\_cpuset\_to\_nodeset** (**hwloc\_topology\_t** topology, **hwloc\_const\_cpuset\_t** \_cpuset, **hwloc\_nodeset\_t** nodeset)\
 int **hwloc\_cpuset\_from\_nodeset** (**hwloc\_topology\_t** topology, **hwloc\_cpuset\_t** \_cpuset, **hwloc\_const\_nodeset\_t** nodeset)\

## Detailed Description

## Function Documentation

### int hwloc\_cpuset\_from\_nodeset (hwloc\_topology\_t topology, hwloc\_cpuset\_t \_cpuset, hwloc\_const\_nodeset\_t nodeset) \[inline\]

Convert a NUMA node set into a CPU set. For each NUMA node included in the input nodeset, set the corresponding local PUs in the output \_cpuset.

If some CPUs have no local NUMA nodes, this function never sets their indexes in the output CPU set, even if a full node set is given in input.

Hence the entire topology node set is converted into the set of all CPUs that have some local NUMA nodes.

**Returns**

0 on success.

\-1 with errno set to ENOMEM on internal reallocation failure.

### int hwloc\_cpuset\_to\_nodeset (hwloc\_topology\_t topology, hwloc\_const\_cpuset\_t \_cpuset, hwloc\_nodeset\_t nodeset) \[inline\]

Convert a CPU set into a NUMA node set. For each PU included in the input \_cpuset, set the corresponding local NUMA node(s) in the output nodeset.

If some NUMA nodes have no CPUs at all, this function never sets their indexes in the output node set, even if a full CPU set is given in input.

Hence the entire topology CPU set is converted into the set of all nodes that have some local CPUs.

**Returns**

0 on success.

\-1 with errno set to ENOMEM on internal reallocation failure.

## Author

Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code.
