Timadey / appower

A software program that measure the energy and power consumed by a single application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Power Consumption Measurement Mini-Program (Appower)

Overview

Appower uses the Intel Running Application Power Limit (RAPL) through the raplcap library, which provides a C interface for interacting with RAPL. However, RAPL only provides the energy consumption of the entire CPU. Appower is developed to measure the specific power consumption of a single software application running on a Linux computer with an Intel processor.

Prerequisites

Before using Appower, ensure you have the following prerequisites installed on your Linux environment (Ubuntu focal):

  • Linux environment (Ubuntu focal) with Intel processor
  • Python 3
  • Pip
  • CMake

Installation

To install Appower on your system, follow change to project root and run installation script

cd appower
source ./install

Always activate virtual environment with source .venv/bin/activate before using, because required libraries were installed there

Usage

To use Appower, you can run it from the terminal and specify the path to the executable and its arguments:

./appower /path/to/executable arg1 arg2 arg3

Note: Appower uses RAPL, which requires elevated permissions (sudo). Therefore, root user permission will be required.

Example

An example program has been provided at the project level directory to demonstrate how to use Appower:

(.venv)$: ./appower
Please enter the full path of the application/program (must be an executable):
/home/your_username/projects/test_appower 30

Implementation Details

TL;DR (Too Long; Didn't Read)

  • Power consumed by the CPU while the application is not running: x
  • Power consumed by the CPU while the application is running: x + a (where a is the additional power consumed by the application)
  • Power consumed by the application alone: a (obtained by subtracting x from x + a)

Steps to Measure Application Power Consumption

  1. CPU Selection: The application process and its children processes' CPU affinity are set to a single processor to ensure proper energy reading from a specific CPU.

  2. Energy Monitoring: The initial energy reading (before application execution) of the RAPL PACKAGE ZONE is recorded.

  3. Application Execution: The target application is executed with the provided arguments.

  4. Energy Monitoring (After Execution): The final energy reading is obtained after the application completes.

  5. Power Consumption Calculation: The energy consumed by the application is calculated as the difference between the final and initial energy readings.

  6. Baseline Power Consumption: To exclude background application data, the power consumption of the CPU during normal operation is measured over a specific period (default: 60 seconds).

  7. Final Power Consumption: The power consumed by the application alone is obtained by subtracting the baseline power consumption from the total power consumption.

About

A software program that measure the energy and power consumed by a single application


Languages

Language:C 77.9%Language:Python 11.2%Language:CMake 7.0%Language:Roff 3.3%Language:Shell 0.5%