Skip to content

cpu

zeus.device.cpu

Abstraction layer for CPU devices.

The main function of this module is get_cpus, which returns a CPU Manager object specific to the platform.

get_cpus

get_cpus()

Initialize and return a singleton CPU monitoring object for INTEL CPUs.

The function returns a CPU management object that aims to abstract the underlying CPU monitoring libraries (RAPL for Intel CPUs).

This function attempts to initialize CPU mointoring using RAPL. If this attempt fails, it raises a ZeusErrorInit exception.

Source code in zeus/device/cpu/__init__.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def get_cpus() -> CPUs:
    """Initialize and return a singleton CPU monitoring object for INTEL CPUs.

    The function returns a CPU management object that aims to abstract the underlying CPU monitoring libraries
    (RAPL for Intel CPUs).

    This function attempts to initialize CPU mointoring using RAPL. If this attempt fails, it raises
    a ZeusErrorInit exception.
    """
    global _cpus
    if _cpus is not None:
        return _cpus
    if rapl_is_available():
        _cpus = RAPLCPUs()
        return _cpus
    else:
        raise ZeusCPUInitError(
            "RAPL unvailable Failed to initialize CPU management library."
        )