---
name: "hwloc_linux_parse_cpumap_file"
section: "3"
platform: "linux"
package: "libhwloc-doc"
version: "1.11.12-3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_linux"
---

# hwloc\_linux\_parse\_cpumap\_file(3)

Part of [hwlocality\_linux(3)](/hwlocality_linux/3.md).

## NAME

hwlocality\_linux

## SYNOPSIS

### Functions

int **hwloc\_linux\_parse\_cpumap\_file** (FILE \*file, **hwloc\_cpuset\_t** set)\
 int **hwloc\_linux\_set\_tid\_cpubind** (**hwloc\_topology\_t** topology, pid\_t tid, **hwloc\_const\_cpuset\_t** set)\
 int **hwloc\_linux\_get\_tid\_cpubind** (**hwloc\_topology\_t** topology, pid\_t tid, **hwloc\_cpuset\_t** set)\
 int **hwloc\_linux\_get\_tid\_last\_cpu\_location** (**hwloc\_topology\_t** topology, pid\_t tid, **hwloc\_bitmap\_t** set)\

## Detailed Description

This includes helpers for manipulating Linux kernel cpumap files, and hwloc equivalents of the Linux sched\_setaffinity and sched\_getaffinity system calls.

## Function Documentation

### 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 behavior is exactly the same as the Linux sched\_getaffinity system call, but uses a hwloc cpuset.

**Note:**

This is equivalent to calling **hwloc\_get\_proc\_cpubind()** with **HWLOC\_CPUBIND\_THREAD** as flags.

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

**Note:**

This is equivalent to calling **hwloc\_get\_proc\_last\_cpu\_location()** with **HWLOC\_CPUBIND\_THREAD** as flags.

### int hwloc\_linux\_parse\_cpumap\_file (FILE \* file, hwloc\_cpuset\_t set)

Convert a linux kernel cpumap file `file` into hwloc CPU set. Might be used when reading CPU set from sysfs attributes such as topology and caches for processors, or local\_cpus for devices.

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

**Note:**

This is equivalent to calling **hwloc\_set\_proc\_cpubind()** with HWLOC\_CPUBIND\_THREAD as flags.

## Author

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