Skip to content

Likwid Powermeter

Thomas Roehl edited this page Apr 25, 2016 · 6 revisions

likwid-powermeter: Tool for accessing RAPL counters on Intel processor

Introduction

Intel introduced with the SandyBridge architecture an interface to configure and readout energy consumption of processors and memory. This so called RAPL interface is controlled through MSR registers. likwid-powermeter is a small tool which allows you to query the energy consumed within a package for a given time period and computes the resulting power consumption.

Additionally you can query the supported Turbo Mode steps of all Turbo mode equipped processors (except the EX variants). This information is also queried from MSR registers.

The RAPL counters are also available as events in likwid-perfctr. There is a ENERGY group on recent Intel systems to measure common metrics.

NOTICE You have to setup access to the msr device files to use likwid-powermeter.

Options

-h, --help	 Help message
-v, --version	 Version information
-V, --verbose <level>	 Verbose output, 0 (only errors), 1 (info), 2 (details), 3 (developer)
-M <0|1>		 Set how MSR registers are accessed, 0=direct, 1=accessDaemon
-c <list>		 Specify sockets to measure
-i, --info	 Print information from MSR_PKG_POWER_INFO register and Turbo mode
-s <duration>	 Set measure duration in us, ms or s. (default 2s)
-p		 Print dynamic clocking and CPI values, uses likwid-perfctr
-t		 Print current temperatures of all CPU cores
-f		 Print current temperatures in Fahrenheit

Examples

As usual you can get a short help message with

$ likwid-powermeter -h

Do get info about RAPL and Turbo Mode call

$ likwid-powermeter -i

Output should be something like the following:

--------------------------------------------------------------------------------
CPU name:	Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz
CPU type:	Intel Xeon IvyBridge EN/EP/EX processor
CPU clock:	3.00 GHz
--------------------------------------------------------------------------------
Base clock:	3000.00 MHz
Minimal clock:	1200.00 MHz
Turbo Boost Steps:
C0 3600.00 MHz
C1 3500.00 MHz
C2 3400.00 MHz
C3 3300.00 MHz
C4 3300.00 MHz
C5 3300.00 MHz
C6 3300.00 MHz
C7 3300.00 MHz
C8 3300.00 MHz
C9 3300.00 MHz
--------------------------------------------------------------------------------
Info for RAPL domain PKG:
Thermal Spec Power: 130 Watt
Minimum Power: 68 Watt
Maximum Power: 130 Watt
Maximum Time Window: 31232 micro sec

Info for RAPL domain DRAM:
Thermal Spec Power: 68.5 Watt
Minimum Power: 36 Watt
Maximum Power: 68.5 Watt
Maximum Time Window: 31232 micro sec
--------------------------------------------------------------------------------

This means the processor has a TDP of 130 Watt, the memory modules have a TDP of 68.5 Watt. With 1 Core active it can overclock up to 3.6 GHz. With all cores active it still may overclock to 3.3 GHz.

LIKWID offers no stand-alone tool to get the temperature of the CPU cores. The functionality is embedded into likwid-powermeter but can also be retrieved through likwid-perfctr. In order to print the temperatures call:

$ likwid-powermeter -t

This prints something like this:

--------------------------------------------------------------------------------
CPU name:	Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz
CPU type:	Intel Xeon IvyBridge EN/EP/EX processor
CPU clock:	3.00 GHz
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Current core temperatures:
Socket 0 Core 0: 47 C
Socket 0 Core 20: 47 C
Socket 0 Core 1: 46 C
Socket 0 Core 21: 46 C
Socket 0 Core 2: 37 C
Socket 0 Core 22: 37 C
Socket 0 Core 3: 48 C
Socket 0 Core 23: 48 C
Socket 0 Core 4: 44 C
Socket 0 Core 24: 44 C
Socket 0 Core 5: 44 C
Socket 0 Core 25: 44 C
Socket 0 Core 6: 40 C
Socket 0 Core 26: 40 C
Socket 0 Core 7: 41 C
Socket 0 Core 27: 41 C
Socket 0 Core 8: 45 C
Socket 0 Core 28: 45 C
Socket 0 Core 9: 42 C
Socket 0 Core 29: 42 C
Socket 1 Core 10: 42 C
Socket 1 Core 30: 42 C
Socket 1 Core 11: 43 C
Socket 1 Core 31: 43 C
Socket 1 Core 12: 40 C
Socket 1 Core 32: 40 C
Socket 1 Core 13: 41 C
Socket 1 Core 33: 41 C
Socket 1 Core 14: 43 C
Socket 1 Core 34: 43 C
Socket 1 Core 15: 42 C
Socket 1 Core 35: 42 C
Socket 1 Core 16: 43 C
Socket 1 Core 36: 43 C
Socket 1 Core 17: 42 C
Socket 1 Core 37: 42 C
Socket 1 Core 18: 41 C
Socket 1 Core 38: 41 C
Socket 1 Core 19: 41 C
Socket 1 Core 39: 41 C
--------------------------------------------------------------------------------

If you use -f instead of -t or set it additional to -t, the temperatures are printed in Fahrenheit instead of Celsius.

To measure power in a given duration (Stethoscope mode) use

$ likwid-powermeter -s 3s

which gives you something like

--------------------------------------------------------------------------------
CPU name:	Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz
CPU type:	Intel Xeon IvyBridge EN/EP/EX processor
CPU clock:	3.00 GHz
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Runtime: 3.0001 s
Measure for socket 0 on CPU 0
Energy consumed: 51.6108 Joules
Power consumed: 17.203 Watts
Energy consumed: 13.0334 Joules
Power consumed: 4.34432 Watts
Energy consumed: 52.5634 Joules
Power consumed: 17.5206 Watts

Measure for socket 1 on CPU 10
Energy consumed: 50.9223 Joules
Power consumed: 16.9735 Watts
Energy consumed: 12.5721 Joules
Power consumed: 4.19057 Watts
Energy consumed: 42.3462 Joules
Power consumed: 14.1149 Watts
--------------------------------------------------------------------------------

Next you can use likwid-powermeter as a wrapper:

$ likwid-powermeter  ./a.out

Finally you can also output the clock and CPI values for the socket you are currently measuring:

$ likwid-powermeter -c 0 -p ./a.out

It uses likwid-perfctr to get the clock and CPI values (performance group CLOCK):

--------------------------------------------------------------------------------
CPU name:	Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz
CPU type:	Intel Xeon IvyBridge EN/EP/EX processor
CPU clock:	3.00 GHz
--------------------------------------------------------------------------------
YOUR PROGRAM OUTPUT
--------------------------------------------------------------------------------
Group 1:
+-----------------------+---------+--------------+-------------+-------------+-------------+
|         Event         | Counter |    Core 0    |    Core 1   |    Core 2   |    Core 3   |
+-----------------------+---------+--------------+-------------+-------------+-------------+
|   INSTR_RETIRED_ANY   |  FIXC0  |  11724451762 | 10842844517 | 10561467656 | 10280194250 |
| CPU_CLK_UNHALTED_CORE |  FIXC1  |  25944160048 | 25515554594 | 25261453331 | 25175563204 |
|  CPU_CLK_UNHALTED_REF |  FIXC2  |  23562189510 | 23196392160 | 22965415440 | 22887349770 |
|     PWR_PKG_ENERGY    |   PWR0  | 7.988363e+02 |      0      |      0      |      0      | 
+-----------------------+---------+--------------+-------------+-------------+-------------+

+----------------------------+---------+--------------+------------+-------------+----------------+
|            Event           | Counter |      Sum     |     Min    |     Max     |       Avg      | 
+----------------------------+---------+--------------+------------+-------------+----------------+
|   INSTR_RETIRED_ANY STAT   |  FIXC0  | 226186141729 |  155188041 | 11724451762 | 5654653543.225 | 
| CPU_CLK_UNHALTED_CORE STAT |  FIXC1  | 683928549398 | 1795236569 | 25944160048 | 17098213734.95 | 
|  CPU_CLK_UNHALTED_REF STAT |  FIXC2  | 622578115140 | 1683415500 | 23562189510 |  15564452878.5 | 
|     PWR_PKG_ENERGY STAT    |   PWR0  |   1326.3737  |      0     |   798.8363  |   33.1593425   | 
+----------------------------+---------+--------------+------------+-------------+----------------+

+----------------------+--------------+--------------+--------------+--------------+
|        Metric        |    Core 0    |    Core 1    |    Core 2    |    Core 3    | 
+----------------------+--------------+--------------+--------------+--------------+
|  Runtime (RDTSC) [s] | 1.318434e+01 | 1.318434e+01 | 1.318434e+01 | 1.318434e+01 |
| Runtime unhalted [s] | 8.648601e+00 | 8.505723e+00 | 8.421018e+00 | 8.392386e+00 |
|      Clock [MHz]     | 3.303070e+03 | 3.299729e+03 | 3.299725e+03 | 3.299723e+03 | 
|          CPI         | 2.212825e+00 | 2.353216e+00 | 2.391851e+00 | 2.448938e+00 | 
|      Energy [J]      | 7.988363e+02 |       0      |       0      |       0      | 
|       Power [W]      | 6.058979e+01 |       0      |       0      |       0      |
+----------------------+--------------+--------------+--------------+--------------+

+---------------------------+-------------+-----------+----------+--------------+
|           Metric          |     Sum     |    Min    |    Max   |      Avg     | 
+---------------------------+-------------+-----------+----------+--------------+
|  Runtime (RDTSC) [s] STAT |   527.3736  |  13.18434 | 13.18434 |   13.18434   | 
| Runtime unhalted [s] STAT | 227.9906161 | 0.5984501 | 8.648601 | 5.6997654025 | 
|      Clock [MHz] STAT     |  131573.127 |  3199.073 |  3303.07 |  3289.328175 | 
|          CPI STAT         |  152.276829 |  2.212825 | 11.56814 |  3.806920725 | 
|      Energy [J] STAT      |  1326.3737  |     0     | 798.8363 |  33.1593425  | 
|       Power [W] STAT      |  100.60221  |     0     | 60.58979 |  2.51505525  | 
+---------------------------+-------------+-----------+----------+--------------+

--------------------------------------------------------------------------------
Runtime: 14.8027 s
Measure for socket 0 on CPU 0
Energy consumed: 854.958 Joules
Power consumed: 57.7567 Watts
Energy consumed: 611.597 Joules
Power consumed: 41.3165 Watts
Energy consumed: 403.18 Joules
Power consumed: 27.2369 Watts

Measure for socket 1 on CPU 10
Energy consumed: 573.944 Joules
Power consumed: 38.7729 Watts
Energy consumed: 368.422 Joules
Power consumed: 24.8888 Watts
Energy consumed: 235.443 Joules
Power consumed: 15.9054 Watts
--------------------------------------------------------------------------------

The output was truncated to 4 cores, the sum, min, max and average values are calculated using all cores. The system is clocked (in average) at 3.3 GHz.

The likwid-powermeter application always runs executables on all CPUs of the selected sockets. If you want to pin your application, you can use likwid-pin:

$ likwid-powermeter likwid-pin -c S0:0-3 ./a.out

likwid-powermeter still measures all CPU sockets but the application runs only on the first four physical cores of socket 0. You can limit likwid-powermeter by setting a socket with the -c commandline switch

$ likwid-powermeter -c 0 likwid-pin -c S0:0-3 ./a.out
Clone this wiki locally