Skip to content

PowerAmdCpu ¤

PowerAmdCpu()
Source code in ea2p/src/amd.py
def __init__(self):
    self.logging_process = None

parse_log ¤

parse_log()

Parse the AMD CPU power log file to energy values per package and per nodes. Returns: DataFrame containing energy data.

Source code in ea2p/src/amd.py
def parse_log(self):
    """
    Parse the AMD CPU power log file to energy values per package and per nodes.
    Returns:
    	DataFrame containing energy data.
    """
    with open(r"%s" % AMDPOWERLOG_FILENAME, 'r') as fp:
        data = fp.read()
    data = data.replace(",", ".")
    p = re.compile(r'([\d]+.+[\d.]+)\s+Joules power/energy-pkg/')
    data = p.findall(data)
    data = [d.replace(" ", "") for d in data]
    for i in range(len(data)):
        # Count the total number of periods
        total_periods = data[i].count('.')
        # If there are more than one periods, replace all but the last one
        if total_periods > 1:
            # Remove all periods except the last one
            data[i] = data[i].replace('.', '', total_periods - 1)
    cols = ["package " + str(i) for i in range(len(data))]
    energy = pd.DataFrame(np.array([data]), columns=cols)
    energy = energy.astype("float32")
    energy = energy / 3600
    return energy

start ¤

start()

Start the measure process using Linux Perf Tools through perf stat system wide sampling

Source code in ea2p/src/amd.py
def start(self):
    """
    Start the measure process using Linux Perf Tools through perf stat system wide sampling
    """
    if self.logging_process is not None:
        self.stop()

    self.logging_process = subprocess.Popen(
        [
            "perf",
            "stat",
            "-e",
            "power/energy-pkg/",
            "-a",
            "--per-node",
            "-o",
            str(AMDPOWERLOG_FILENAME),
        ]
    )

stop ¤

stop()

Stop the measure process if started. A signal is send to the logging process to stop measurements

Source code in ea2p/src/amd.py
def stop(self):
    """
    Stop the measure process if started. A signal is send to the logging process to stop measurements
    """
    self.logging_process.send_signal(signal.SIGINT)
    self.logging_process = None

PowerAmdCpu ¤

PowerAmdCpu()
Source code in ea2p/src/amd.py
def __init__(self):
    self.logging_process = None

parse_log ¤

parse_log()

Parse the AMD CPU power log file to energy values per package and per nodes. Returns: DataFrame containing energy data.

Source code in ea2p/src/amd.py
def parse_log(self):
    """
    Parse the AMD CPU power log file to energy values per package and per nodes.
    Returns:
    	DataFrame containing energy data.
    """
    with open(r"%s" % AMDPOWERLOG_FILENAME, 'r') as fp:
        data = fp.read()
    data = data.replace(",", ".")
    p = re.compile(r'([\d]+.+[\d.]+)\s+Joules power/energy-pkg/')
    data = p.findall(data)
    data = [d.replace(" ", "") for d in data]
    for i in range(len(data)):
        # Count the total number of periods
        total_periods = data[i].count('.')
        # If there are more than one periods, replace all but the last one
        if total_periods > 1:
            # Remove all periods except the last one
            data[i] = data[i].replace('.', '', total_periods - 1)
    cols = ["package " + str(i) for i in range(len(data))]
    energy = pd.DataFrame(np.array([data]), columns=cols)
    energy = energy.astype("float32")
    energy = energy / 3600
    return energy

start ¤

start()

Start the measure process using Linux Perf Tools through perf stat system wide sampling

Source code in ea2p/src/amd.py
def start(self):
    """
    Start the measure process using Linux Perf Tools through perf stat system wide sampling
    """
    if self.logging_process is not None:
        self.stop()

    self.logging_process = subprocess.Popen(
        [
            "perf",
            "stat",
            "-e",
            "power/energy-pkg/",
            "-a",
            "--per-node",
            "-o",
            str(AMDPOWERLOG_FILENAME),
        ]
    )

stop ¤

stop()

Stop the measure process if started. A signal is send to the logging process to stop measurements

Source code in ea2p/src/amd.py
def stop(self):
    """
    Stop the measure process if started. A signal is send to the logging process to stop measurements
    """
    self.logging_process.send_signal(signal.SIGINT)
    self.logging_process = None