Configuring PAPI to support RAPL

When configuring PAPI, you need to provide the --with-components=rapl option. Basically, you need to install PAPI like this:

1
2
3
$ tar xzvf papi-5.3.2.tar.gz
$ cd papi-5.3.2/src
$ ./configure --with-components=rapl &&make &&make install

Checking the PAPI installation

Once PAPI is installed, make sure it is capable of reading RAPL information. For instance, you can run this rapl-read program. You may need to modify the Makefile in order to specify the installation directory of PAPI. Once compiled, running the rapl-read program should result in the following output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$ ./rapl_plot
Found rapl component at cid 2
Found: rapl:::THERMAL_SPEC_CNT:PACKAGE0
Found: rapl:::MINIMUM_POWER_CNT:PACKAGE0
Found: rapl:::MAXIMUM_POWER_CNT:PACKAGE0
Found: rapl:::MAXIMUM_TIME_WINDOW_CNT:PACKAGE0
Found: rapl:::PACKAGE_ENERGY_CNT:PACKAGE0
Found: rapl:::PP1_ENERGY_CNT:PACKAGE0
Found: rapl:::DRAM_ENERGY_CNT:PACKAGE0
Found: rapl:::PP0_ENERGY_CNT:PACKAGE0
Found: rapl:::THERMAL_SPEC:PACKAGE0
Found: rapl:::MINIMUM_POWER:PACKAGE0
Found: rapl:::MAXIMUM_POWER:PACKAGE0
Found: rapl:::MAXIMUM_TIME_WINDOW:PACKAGE0
Found: rapl:::PACKAGE_ENERGY:PACKAGE0
Found: rapl:::PP1_ENERGY:PACKAGE0
Found: rapl:::DRAM_ENERGY:PACKAGE0
Found: rapl:::PP0_ENERGY:PACKAGE0
[...]
4.7213 0.0 (* Average Power for rapl:::MAXIMUM_TIME_WINDOW:PACKAGE0 *)
4.7213 3.0 (* Average Power for rapl:::PACKAGE_ENERGY:PACKAGE0 *)
4.7213 0.2 (* Average Power for rapl:::PP1_ENERGY:PACKAGE0 *)
4.7213 0.8 (* Average Power for rapl:::DRAM_ENERGY:PACKAGE0 *)
4.7213 0.1 (* Average Power for rapl:::PP0_ENERGY:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::THERMAL_SPEC_CNT:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::MINIMUM_POWER_CNT:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::MAXIMUM_POWER_CNT:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::MAXIMUM_TIME_WINDOW_CNT:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::PACKAGE_ENERGY_CNT:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::PP1_ENERGY_CNT:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::DRAM_ENERGY_CNT:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::PP0_ENERGY_CNT:PACKAGE0 *)
4.8218 46156882941.9 (* Average Power for rapl:::THERMAL_SPEC:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::MINIMUM_POWER:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::MAXIMUM_POWER:PACKAGE0 *)
4.8218 0.0 (* Average Power for rapl:::MAXIMUM_TIME_WINDOW:PACKAGE0 *)
4.8218 2.9 (* Average Power for rapl:::PACKAGE_ENERGY:PACKAGE0 *)
4.8218 0.2 (* Average Power for rapl:::PP1_ENERGY:PACKAGE0 *)
4.8218 0.8 (* Average Power for rapl:::DRAM_ENERGY:PACKAGE0 *)

Can’t open fd for cpu0: No such file or director

However, You may have the following error:

1
2
3
$ ./rapl_plot
Found rapl component at cid 2
No rapl events found: Can't open fd for cpu0: No such file or director

This usually means that the msr kernel module that permits to read the energy counters is not loaded. This should be fixed by running modprobe:

1
$ sudo modprobe msr

Can’t open fd for cpu0: Operation not permitted

Another possible error is:

1
2
3
$  ./rapl_plot
Found rapl component at cid 2
No rapl events found: Can't open fd for cpu0: Operation not permitted

In that case, you may have to run the program as sudo:

1
2
$ sudo ./rapl_plot
[...]