4.2. sciexp2.exprun.cpu
¶
Source: sciexp2/exprun/cpu.py
Functions
get_cpus |
Get a set of all physical CPU indexes in the system. |
set_freq |
Set frequency scaling. |
set_irqs |
Make irqbalance ignore the given IRQs, and instead set their SMP affinity. |
4.2.1. get_cpus
¶
-
get_cpus
(shell, node=None, package=None, core=None, pu=None, cgroup=None)¶ Get a set of all physical CPU indexes in the system.
It uses the hwloc-calc program to report available CPUs.
Parameters: - shell
Target shell.
- node : int or str, optional
NUMA nodes to check. Defaults to all.
- package : int or str, optional
Core packages to check on selected NUMA nodes. Defaults to all.
- core : int or str, optional
Cores to check on selected core packages. Defaults to all.
- pu : int or str, optional
PUs to check on selected cores. Defaults to all.
- cgroup : str, optional
Cgroup path.
Returns: - set of int
Physical CPU indexes (as used by Linux).
Notes
The combination of all the arguments is a flexible way to get all the information in the system. Each of these arguments can have any of the forms described under “Hwloc Indexes” in manpage hwloc(7). A few examples.
Second thread of each core: >>> get_cpus(shell, pu=1)
First thread of each core in first NUMA node: >>> get_cpus(node=0, pu=0)
Hardware threads in first core of the entire system: >>> get_cpus(node=0, package=0, core=0)
4.2.2. set_freq
¶
-
set_freq
(shell, path='cpupower', ld_library_path='', freq='max')¶ Set frequency scaling.
Parameters: - shell
Target shell.
- path : str, optional
Path to cpupower tool. Default is use the cpupower tool in the PATH.
- ld_library_path : str, optional
Library path to run cpupower tool. Default is use the system’s library path.
- freq : str, optional
Frequency to set in GHz. Default is use maximum frequency.
Notes
In some systems it might be necessary to boot the Linux kernel with command line option “intel_pstate=disable” in order to support user frequency settings.
4.2.3. set_irqs
¶
-
set_irqs
(shell, *irqs, **kwargs)¶ Make irqbalance ignore the given IRQs, and instead set their SMP affinity.
Parameters: - shell
Target system.
- irqs
IRQ descriptors.
- ignore_errors : bool, optional
Ignore errors when manually setting an IRQ’s SMP affinity. Implies that irqbalance will manage that IRQ. Default is False.
- irqbalance_banned_cpus : list of int, optional
CPUs that irqbalance should not use for balancing.
- irqbalance_args : list of str, optional
Additional arguments to irqbalance.
- Each descriptor in `irqs` is a three-element tuple:
- * Type: either ``irq`` for the first column in /proc/interrupts, or
descr
for the interrupt description after the per-CPU counts.- * Regex: a regular expression to apply to the fields above, or `True` to
apply to all values (a shorthand to the regex “.*”), or an int (a shorthand to the regex “^int_value$”).
- * SMP affinity: list of cpu numbers to set as the IRQ’s affinity; if `True`
is used instead, let irqbalance manage this IRQ.
- All matching descriptors are applied in order for each IRQ. If no descriptor
- matches, or the last matching descriptor has `True` as its affinity value,
- the IRQ will be managed by irqbalance as before.
Returns: - The new irqbalance process.