CPU binding
- Provided by: libhwloc-doc (Version: 1.8-1ubuntu1.14.04.1)
- Source: hwloc
- Report a bug
int hwloc_set_cpubind (hwloc_topology_t topology,
hwloc_const_cpuset_t set, int flags)
int hwloc_get_cpubind (hwloc_topology_t topology,
hwloc_cpuset_t set, int flags)
int hwloc_set_proc_cpubind (hwloc_topology_t topology,
hwloc_pid_t pid, hwloc_const_cpuset_t set, int flags)
int hwloc_get_proc_cpubind (hwloc_topology_t topology,
hwloc_pid_t pid, hwloc_cpuset_t set, int flags)
int hwloc_set_thread_cpubind (hwloc_topology_t topology,
hwloc_thread_t thread, hwloc_const_cpuset_t set, int flags)
int hwloc_get_thread_cpubind (hwloc_topology_t topology,
hwloc_thread_t thread, hwloc_cpuset_t set, int flags)
int hwloc_get_last_cpu_location (hwloc_topology_t topology,
hwloc_cpuset_t set, int flags)
int hwloc_get_proc_last_cpu_location (hwloc_topology_t
topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags)
It is often useful to call hwloc_bitmap_singlify() first so that a single CPU remains in the set. This way, the process will not even migrate between different CPUs. Some operating systems also only support that kind of binding.
Note:
The most portable version that should be preferred over the others, whenever possible, is
hwloc_set_cpubind(topology, set, 0),
as it just binds the current program, assuming it is single-threaded, or
hwloc_set_cpubind(topology, set, HWLOC_CPUBIND_THREAD),
which binds the current thread of the current program (which may be multithreaded).
Note:
On some operating systems, CPU binding may have effects on memory binding, see HWLOC_CPUBIND_NOMEMBIND
Running lstopo --top can be a very convenient tool to check how binding actually happened.
Process/Thread binding flags. These bit flags can be used to refine the binding policy.
The default (0) is to bind the current process, assumed to be single-threaded, in a non-strict way. This is the most portable way to bind as all operating systems usually provide it.
Note:
Enumerator
Note:
When retrieving the binding of a process, this flag checks whether all its threads actually have the same binding. If the flag is not given, the binding of each thread will be accumulated.
Note:
This flag is only meaningful when used with functions that set the CPU binding. It is ignored when used with functions that get CPU binding information.
Get current process or thread binding. Writes into set the physical cpuset which the process or thread (according to flags) was last bound to.
Get the last physical CPU where the current process or thread ran. The operating system may move some tasks from one processor to another at any time according to their binding, so this function may return something that is already outdated.
flags can include either HWLOC_CPUBIND_PROCESS or HWLOC_CPUBIND_THREAD to specify whether the query should be for the whole process (union of all CPUs on which all threads are running), or only the current thread. If the process is single-threaded, flags can be set to zero to let hwloc use whichever method is available on the underlying OS.
Get the current physical binding of process pid.
Note:
HWLOC_CPUBIND_THREAD can not be used in flags.
As a special case on Linux, if a tid (thread ID) is supplied instead of a pid (process ID), the binding for that specific thread is returned.
Get the last physical CPU where a process ran. The operating system may move some tasks from one processor to another at any time according to their binding, so this function may return something that is already outdated.
Note:
As a special case on Linux, if a tid (thread ID) is supplied instead of a pid (process ID) and HWLOC_CPUBIND_THREAD is passed in flags, the binding for that specific thread is returned.
Get the current physical binding of thread tid.
Note:
HWLOC_CPUBIND_PROCESS can not be used in flags.
Bind current process or thread on cpus given in physical bitmap set.
Returns:
-1 with errno set to EXDEV if the binding cannot be enforced
Bind a process pid on cpus given in physical bitmap set.
Note:
HWLOC_CPUBIND_THREAD can not be used in flags.
Bind a thread thread on cpus given in physical bitmap set.
Note:
HWLOC_CPUBIND_PROCESS can not be used in flags.
Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code.