Skip to content

Commit

Permalink
Merge pull request #35 from joular/develop
Browse files Browse the repository at this point in the history
Version 0.7.0
  • Loading branch information
adelnoureddine authored Oct 20, 2023
2 parents e2b8a8e + bd1cd87 commit 92d4a0e
Show file tree
Hide file tree
Showing 14 changed files with 174 additions and 14 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ PowerJoular supports RAPL package domain (core, including integrated graphics, a

On Raspberry Pi and Asus Tinker Board, PowerJoular uses its own research-based empirical regression models to estimate the power consumption of the ARM processor.

We currently support the following Raspberry Pi models and Asus Tinker Board:
The supported list of Raspberry Pi and Asus Tinker Board models are listed below.
We support all revisions of each model lineup. However, the model is generated and trained on a specific revision (listed between brackets), and the accuracy is best on this particular revision.

We currently support the following Raspberry Pi and Asus Tinker Board models:
- Model Zero W (rev 1.1), for 32 bits OS
- Model 1 B (rev 2), for 32 bits OS
- Model 1 B+ (rev 1.2), for 32 bits OS
Expand Down Expand Up @@ -62,11 +65,13 @@ The difference (increase or decrease) of power consumption from last metric will

The following options are available:
- ```-h```: show the help message
- ```-h```: show version number
- ```-p pid```: specifiy a particular PID to monitor
- ```-a appName```: specifiy a particular application name to monitor (will monitor all PIDs of the application)
- ```-f filename```: save monitoring data to the given filename path
- ```-o filename```: save only last monitoring data to the given filename path (file overwritten with only latest power measures)
- ```-t```: print data to the terminal
- ```-t```: print energy data to the terminal
- ```-d```: print debug info to the terminal
- ```-l```: use linear regression models (less accurate than the default polynomial models) for Raspberry Pi energy models

You can mix options, i.e., ```powerjoular -tp 144``` will monitor PID 144 and will print to the terminal.
Expand Down Expand Up @@ -162,4 +167,4 @@ PowerJoular is licensed under the GNU GPL 3 license only (GPL-3.0-only).
Copyright (c) 2020-2023, Adel Noureddine, Université de Pau et des Pays de l'Adour.
All rights reserved. This program and the accompanying materials are made available under the terms of the GNU General Public License v3.0 only (GPL-3.0-only) which accompanies this distribution, and is available at: https://www.gnu.org/licenses/gpl-3.0.en.html

Author : Adel Noureddine
Author : Adel Noureddine
2 changes: 1 addition & 1 deletion alire.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "powerjoular"
description = "Monitoring the power consumption of multiple platforms and processes"
version = "0.6.2"
version = "0.7.0"

authors = ["Adel Noureddine"]
maintainers = ["Adel Noureddine <adel.noureddine@univ-pau.fr>"]
Expand Down
17 changes: 17 additions & 0 deletions installer/create-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# Create folders for pacakge formats
mkdir deb

# Create folder structure for debian
mkdir -p deb/powerjoular/usr/bin deb/powerjoular/etc/systemd/system deb/powerjoular/DEBIAN

# Copy binary files for deb package
cp ../obj/powerjoular ./deb/powerjoular/usr/bin/
cp ../systemd/powerjoular.service ./deb/powerjoular/etc/systemd/system/
cp ./debian-control-$1.txt ./deb/powerjoular/DEBIAN/control

# Create deb package
cd deb
dpkg-deb --build powerjoular
cd ..
5 changes: 5 additions & 0 deletions installer/debian-control-amd64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: powerjoular
Version: 0.7
Maintainer: Adel Noureddine
Architecture: amd64
Description: PowerJoular allows monitoring power consumption of multiple platforms and processes.
5 changes: 5 additions & 0 deletions installer/debian-control-arm64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: powerjoular
Version: 0.7
Maintainer: Adel Noureddine
Architecture: arm64
Description: PowerJoular allows monitoring power consumption of multiple platforms and processes.
5 changes: 5 additions & 0 deletions installer/debian-control-armhf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: powerjoular
Version: 0.7
Maintainer: Adel Noureddine
Architecture: armhf
Description: PowerJoular allows monitoring power consumption of multiple platforms and processes.
11 changes: 11 additions & 0 deletions installer/debian/create_deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

# Create folder structure
mkdir -p powerjoular/usr/bin powerjoular/etc/systemd/system powerjoular/DEBIAN

# Copy binary files for deb package
cp ../../obj/powerjoular ./powerjoular/usr/bin/
cp ../../systemd/powerjoular.service ./powerjoular/etc/systemd/system/

# Create deb package
dpkg-deb --build powerjoular
5 changes: 5 additions & 0 deletions installer/debian/powerjoular/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: powerjoular
Version: 0.7
Maintainer: Adel Noureddine
Architecture: amd64
Description: PowerJoular allows monitoring power consumption of multiple platforms and processes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=PowerJoular service

[Service]
Type=simple
Restart=always
User=root
ExecStart=/usr/bin/powerjoular -o /tmp/powerjoular-service.csv

[Install]
WantedBy=multi-user.target
Binary file added installer/debian/powerjoular/usr/bin/powerjoular
Binary file not shown.
8 changes: 7 additions & 1 deletion src/help_info.adb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
package body Help_Info is

procedure Show_Help is
Version_Number : constant String := "0.6.2";
Version_Number : constant String := "0.7.0";
begin
Put_Line (ESC & "[93m" & "~~ PowerJoular ~~" & ESC & "[0m");
Put_Line ("Version " & Version_Number);
Expand Down Expand Up @@ -51,4 +51,10 @@ package body Help_Info is
Put_Line ("Copyright (c) 2020-2023, Adel Noureddine. PowerJoular is licensed under the GNU GPL 3 license only (GPL-3.0-only)");
end;

procedure Show_Version is
Version_Number : constant String := "0.7.0";
begin
Put_Line (Version_Number);
end;

end Help_Info;
3 changes: 3 additions & 0 deletions src/help_info.ads
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ package Help_Info is
-- Print help information on the terminal
procedure Show_Help;

-- Print version number
procedure Show_Version;

end Help_Info;
75 changes: 75 additions & 0 deletions src/os_utils.adb
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@ package body OS_Utils is
while not End_Of_File (F_Name) loop
Line_String := To_Unbounded_String (Get_Line (F_Name));

-- Specific model used to train the energy models

-- Raspberry Pi 400 1.0
Index_Search := Index (To_String (Line_String), "Raspberry Pi 400 Rev 1.0");
if (Index_Search > 0) then
if (Architecture_Name = "aarch64") then
return "rbp4001.0-64";
end if;
end if;

-- Raspberry Pi 4B 1.2
Index_Search := Index (To_String (Line_String), "Raspberry Pi 4 Model B Rev 1.2");
if (Index_Search > 0) then
if (Architecture_Name = "aarch64") then
Expand All @@ -82,6 +86,7 @@ package body OS_Utils is
end if;
end if;

-- Raspberry Pi 4B 1.1
Index_Search := Index (To_String (Line_String), "Raspberry Pi 4 Model B Rev 1.1");
if (Index_Search > 0) then
if (Architecture_Name = "aarch64") then
Expand All @@ -91,40 +96,110 @@ package body OS_Utils is
end if;
end if;

-- Raspberry Pi 3B+ 1.3
Index_Search := Index (To_String (Line_String), "Raspberry Pi 3 Model B Plus Rev 1.3");
if (Index_Search > 0) then
return "rbp3b+1.3";
end if;

-- Raspberry Pi 3B 1.2
Index_Search := Index (To_String (Line_String), "Raspberry Pi 3 Model B Rev 1.2");
if (Index_Search > 0) then
return "rbp3b1.2";
end if;

-- Raspberry Pi 2B 1.1
Index_Search := Index (To_String (Line_String), "Raspberry Pi 2 Model B Rev 1.1");
if (Index_Search > 0) then
return "rbp2b1.1";
end if;

-- Raspberry Pi B+ 1.2
Index_Search := Index (To_String (Line_String), "Raspberry Pi Model B Plus Rev 1.2");
if (Index_Search > 0) then
return "rbp1b+1.2";
end if;

-- Raspberry Pi B 2
Index_Search := Index (To_String (Line_String), "Raspberry Pi Model B Rev 2");
if (Index_Search > 0) then
return "rbp1b2";
end if;

-- Raspberry Pi Zero W 1.1
Index_Search := Index (To_String (Line_String), "Raspberry Pi Zero W Rev 1.1");
if (Index_Search > 0) then
return "rbpzw1.1";
end if;

-- Asus Tinker Board (S)
Index_Search := Index (To_String (Line_String), "ASUS Tinker Board (S)");
if (Index_Search > 0) then
return "asustbs";
end if;

-- Supporting other revisions where specific energy models were not generated
-- In this case, we use the model of the same RPi model but different revision

-- Raspberry Pi 400
Index_Search := Index (To_String (Line_String), "Raspberry Pi 400");
if (Index_Search > 0) then
if (Architecture_Name = "aarch64") then
return "rbp4001.0-64";
end if;
end if;

-- Raspberry Pi 4B
Index_Search := Index (To_String (Line_String), "Raspberry Pi 4 Model B");
if (Index_Search > 0) then
if (Architecture_Name = "aarch64") then
return "rbp4b1.2-64";
else
return "rbp4b1.2";
end if;
end if;

-- Raspberry Pi 3B+
Index_Search := Index (To_String (Line_String), "Raspberry Pi 3 Model B Plus");
if (Index_Search > 0) then
return "rbp3b+1.3";
end if;

-- Raspberry Pi 3B
Index_Search := Index (To_String (Line_String), "Raspberry Pi 3 Model B");
if (Index_Search > 0) then
return "rbp3b1.2";
end if;

-- Raspberry Pi 2B
Index_Search := Index (To_String (Line_String), "Raspberry Pi 2 Model B");
if (Index_Search > 0) then
return "rbp2b1.1";
end if;

-- Raspberry Pi B+
Index_Search := Index (To_String (Line_String), "Raspberry Pi Model B Plus");
if (Index_Search > 0) then
return "rbp1b+1.2";
end if;

-- Raspberry Pi B
Index_Search := Index (To_String (Line_String), "Raspberry Pi Model B");
if (Index_Search > 0) then
return "rbp1b2";
end if;

-- Raspberry Pi Zero W
Index_Search := Index (To_String (Line_String), "Raspberry Pi Zero W");
if (Index_Search > 0) then
return "rbpzw1.1";
end if;

-- Asus Tinker Board
Index_Search := Index (To_String (Line_String), "ASUS Tinker Board");
if (Index_Search > 0) then
return "asustbs";
end if;
end loop;

Close (F_Name);
Expand Down
30 changes: 21 additions & 9 deletions src/powerjoular.adb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ procedure Powerjoular is

-- Settings
Show_Terminal : Boolean := False; -- Show power data on terminal
Show_Debug : Boolean := False; -- Show debug info on terminal
Print_File: Boolean := False; -- Save power data in file
Monitor_PID : Boolean := False; -- Monitor a specific PID
Monitor_App : Boolean := False; -- Monitor a specific application by its name
Expand Down Expand Up @@ -115,12 +116,17 @@ begin

-- Loop over command line options
loop
case Getopt ("h t f: p: a: o: u l") is
case Getopt ("h v t d f: p: a: o: u l") is
when 'h' => -- Show help
Show_Help;
return;
when 'v' => -- Show help
Show_Version;
return;
when 't' => -- Show power data on terminal
Show_Terminal := True;
when 'd' => -- Show debug info on terminal
Show_Debug := True;
when 'p' => -- Monitor a particular PID
-- PID_Number := Integer'Value (Parameter);
CPU_PID_Monitor.PID_Number := Integer'Value (Parameter);
Expand Down Expand Up @@ -153,23 +159,25 @@ begin
return;
end if;

Put_Line ("System info:");
Put_Line (Ada.Characters.Latin_1.HT & "Platform: " & Platform_Name);
if Show_Debug then
Put_Line ("System info:");
Put_Line (Ada.Characters.Latin_1.HT & "Platform: " & Platform_Name);
end if;

if Check_Intel_Supported_System (Platform_Name) then
-- For Intel RAPL, check and populate supported packages first
Check_Supported_Packages (RAPL_Before, "psys");
if RAPL_Before.psys_supported then
if RAPL_Before.psys_supported and Show_Debug then
Put_Line (Ada.Characters.Latin_1.HT & "Intel RAPL psys: " & Boolean'Image (RAPL_Before.Psys_Supported));
end if;

if (not RAPL_Before.psys_supported) then -- Only check for pkg and dram if psys is not supported
Check_Supported_Packages (RAPL_Before, "pkg");
Check_Supported_Packages (RAPL_Before, "dram");
if RAPL_Before.Pkg_Supported then
if RAPL_Before.Pkg_Supported and Show_Debug then
Put_Line (Ada.Characters.Latin_1.HT & "Intel RAPL pkg: " & Boolean'Image (RAPL_Before.pkg_supported));
end if;
if RAPL_Before.Dram_Supported then
if RAPL_Before.Dram_Supported and Show_Debug then
Put_Line (Ada.Characters.Latin_1.HT & "Intel RAPL dram: " & Boolean'Image (RAPL_Before.Dram_Supported));
end if;
end if;
Expand All @@ -178,21 +186,25 @@ begin
-- Check if Nvidia card is supported
-- For now, Nvidia support requiers a PC/server, thus Intel support
Nvidia_Supported := Check_Nvidia_Supported_System;
if Nvidia_Supported then
if Nvidia_Supported and Show_Debug then
Put_Line (Ada.Characters.Latin_1.HT & "Nvidia supported: " & Boolean'Image (Nvidia_Supported));
end if;
end if;

-- Amend PID CSV file with PID number
if Monitor_PID then
PID_Or_App_CSV_Filename := CSV_Filename & "-" & Trim(Integer'Image (CPU_PID_Monitor.PID_Number), Ada.Strings.Left) & ".csv";
Put_Line ("Monitoring PID: " & Integer'Image (CPU_PID_Monitor.PID_Number));
if Show_Debug then
Put_Line ("Monitoring PID: " & Integer'Image (CPU_PID_Monitor.PID_Number));
end if;
end if;

-- Amend App CSV file with App name
if Monitor_App then
PID_Or_App_CSV_Filename := CSV_Filename & "-" & CPU_App_Monitor.App_Name & ".csv";
Put_Line ("Monitoring application: " & To_String (CPU_App_Monitor.App_Name));
if Show_Debug then
Put_Line ("Monitoring application: " & To_String (CPU_App_Monitor.App_Name));
end if;
end if;

-- Main monitoring loop
Expand Down

0 comments on commit 92d4a0e

Please sign in to comment.