LIRRA  1.0.0
Loading...
Searching...
No Matches
rl_stl.evaluation.energy Namespace Reference

Classes

class  EnergyMeter
 
class  Measurement
 

Functions

dict[str, tuple[Path, int]] _domains ()
 
bool rapl_readable ()
 
dict[str, float] benchmark (Callable[[], object] fn, EnergyMeter meter, int repeats=1000, int warmup=10)
 

Variables

 RAPL_ROOT = Path("/sys/class/powercap")
 

Detailed Description

CPU energy measurement with Intel RAPL (the counters pyJoules reads).

``EnergyMeter`` reads ``/sys/class/powercap/intel-rapl:*/energy_uj`` directly (same source
as ``pyJoules``' ``RaplPackageDomain``/``RaplCoreDomain``), handles counter wraparound with
``max_energy_range_uj`` and subtracts an idle baseline:

    E_net = E_measured - P_idle * duration.

Recent kernels make ``energy_uj`` root-readable only. Run experiments through
``experiments/run_with_energy.sh``, which makes the counters world-readable once per boot
(``sudo chmod -R a+r /sys/class/powercap/intel-rapl``) and runs Python as the normal user.
Without readable counters the meter still records wall/CPU time and reports energy as NaN
(``backend == "none"``), so experiments never fail because of permissions.

Caveats recorded with every result (:meth:`EnergyMeter.describe`): RAPL measures the whole
package (all processes), the update interval is about 1 ms, so energy of sub-millisecond
calls (policy inference, plan check) is measured by :func:`benchmark` over many repetitions.

Function Documentation

◆ _domains()

dict[str, tuple[Path, int]] rl_stl.evaluation.energy._domains ( )
protected
``{name: (energy_uj path, max range)}`` for readable package/core/dram/psys domains.

◆ benchmark()

dict[str, float] rl_stl.evaluation.energy.benchmark ( Callable[[], object]  fn,
EnergyMeter  meter,
int   repeats = 1000,
int   warmup = 10 
)
Per-call wall time and energy of a short function, averaged over ``repeats``.

◆ rapl_readable()

bool rl_stl.evaluation.energy.rapl_readable ( )

Variable Documentation

◆ RAPL_ROOT

rl_stl.evaluation.energy.RAPL_ROOT = Path("/sys/class/powercap")