Commit 130783fc authored by Valentin Reis's avatar Valentin Reis

type drafts

parent f0d1f9ea
Pipeline #7882 failed with stages
in 5 minutes and 6 seconds
from nrm.types import TemperatureSample
class coretemp_reader:
def sample(self) -> TemperatureSample:
...
......@@ -208,24 +208,22 @@ class rapl_reader:
self.totalenergy[k] += de[k]
self.lastpower[k] = de[k] / de["time"] / 1000.0 / 1000.0
self.prev_e = e
caps = self.get_powerlimits()
return PowerSample(
energy={
self.shortenkey(k): v
for k, v in sorted(e.keys())
if k != "time"
self.shortenkey(k): e[k] for k in sorted(e) if k != "time"
},
power={
self.shortenkey(k): v
for k, v in sorted(self.lastpower.keys())
self.shortenkey(k): self.lastpower[k]
for k in sorted(self.lastpower)
if k != "time"
},
power_total=sum(
[k for k in self.lastpower.keys() if (k.find("core") == -1)]
),
powercap={
self.shortenkey(k): v["curW"]
for k, v in sorted(self.get_powerlimits())
self.shortenkey(k): caps[k]["curW"] for k in sorted(caps)
},
)
......
from nrm.types import RAPLConfig, PackageEnergySample
class rapl_reader:
def sample(self) -> PackageEnergySample:
...
def read_config(self) -> RAPLConfig:
...
###############################################################################
# Copyright 2019 UChicago Argonne, LLC.
# (c.f. AUTHORS, LICENSE)
#
# This file is part of the NRM project.
# For more info, see https://xgitlab.cels.anl.gov/argo/nrm
#
# SPDX-License-Identifier: BSD-3-Clause
###############################################################################
"""Sensor Module:
provide the core functionalities related to measuring power, energy,
temperature and other information about the local node, using our internal
version of the coolr code.
This module should be the only one interfacing with coolr.
"""
from __future__ import print_function
import time
import nrm.coolr
import nrm.coolr.clr_rapl
import nrm.coolr.clr_hwmon
import nrm.coolr.clr_nodeinfo
import nrm.coolr.clr_cpufreq
import nrm.coolr.clr_misc
from typing import Any, Dict, NamedTuple
from nrm.types import MachineInfo
class NodeManager:
"""Performs sensor reading and basic data aggregation."""
def __init__(self) -> None:
self.nodename = self.nodeconfig.nodename
self.cputopology = nrm.coolr.clr_nodeinfo.cputopology()
self._nodeconfig = nrm.coolr.clr_nodeinfo.nodeconfig()
self._coretemp = nrm.coolr.clr_hwmon.coretemp_reader()
self._rapl = nrm.coolr.clr_rapl.rapl_reader()
self._rapl.start_energy_counter()
def stop(self) -> None:
self._rapl.stop_energy_counter()
def sample(self) -> MachineInfo:
return MachineInfo(
energySamples=self._rapl.sample(),
tempSamples=self._coretemp.sample(),
time=time.time()
)
def read_config(self):
self._rapl.read_config()
def do_control_pcap(self, PcapControl) -> None:
self._rapl.setpcaps()
pass
def do_control_ddcm(self, control: FreqControl) -> None:
self._rapl.setfrequencies()
pass
from nrm.types import PcapControl, FreqControl, MachineInfo, RAPLConfig
import nrm.coolr
class NodeManager:
nodename: str
cputopology: nrm.coolr.clr_nodeinfo.cputopology
def __init__(self) -> None:
...
def stop(self) -> None:
...
def do_control_pcap(self, control: PcapControl) -> None:
...
def do_control_ddcm(self, control: FreqControl) -> None:
...
def read_config(self) -> RAPLConfig:
...
def sample(self) -> MachineInfo:
...
......@@ -53,9 +53,16 @@ class SensorManager:
def do_update(self) -> MachineInfo:
return MachineInfo(
self.rapl.sample(accflag=True), self.coretemp.sample(), time.time()
energy=self.rapl.sample(accflag=True),
temperature=self.coretemp.sample(),
time=time.time(),
)
# energy: Dict[str, Any]
# power: Dict[str, Any]
# power_total: float
# powercap: Dict[str, Union[bool, float]]
def get_powerlimits(self):
pl = self.rapl.get_powerlimits()
# only return enabled domains
......
from typing import Any, Dict, Union, NamedTuple
from typing import Any, Dict, Union, NamedTuple, Set, List, NewType
PackageID = NewType("PackageID", int)
CoreID = NewType("CoreID", int)
AppID = NewType("AppID", int)
ContainerID = NewType("ContainerID", int)
class PowerSample(NamedTuple):
energy: Dict[str, Any]
power: Dict[str, Any]
power_total: float
powercap: Dict[str, Union[bool, float]]
# configuration(RAPL specific)
class RAPLPackageConfig(NamedTuple):
constraint_0_max_power_uw: int
constraint_0_name: int
constraint_0_time_window_us: int
constraint_1_max_power_uw: int
constraint_1_name: int
constraint_1_time_window_us: int
class RAPLConfig(NamedTuple):
packageConfig: Dict[PackageID, RAPLPackageConfig]
# control
class PcapControl(NamedTuple):
max_power_uw: Dict[PackageID, int]
class FreqControl(NamedTuple):
freq_hz: Dict[CoreID, int]
# sensing
class PackageEnergySamples(NamedTuple):
e_uj: Dict[PackageID, int]
class TemperatureSamples(NamedTuple):
t_celcius: Dict[CoreID, int]
class MachineInfo(NamedTuple):
energy: PowerSample
temperature: float
energySamples: PackageEnergySamples
tempSamples: TemperatureSamples
time: int
# apps
class ProgressSample(NamedTuple):
work: int
class ProgressInfo(NamedTuple):
progressSamples: Dict[AppID, ProgressSample]
time: int
# containers
class PerfSample(NamedTuple):
work: int
class PerfInfo(NamedTuple):
perfSamples: Dict[ContainerID, PerfSample]
time: int
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment