Have you ever wanted to write the output of Intel© Performance Counter Monitor (Intel© PCM) to a file? Did you ever want to generate a graph that you can add to your report? In this blog, I walk you through how I usually do this when I use Intel© PCM.
Intel© Performance Counter Monitor offers the possibility to print the output as comma separated values (CSV format) – well, semicolon separated values to be exact. If you add the option “-csv” to your command line, the output format changes to one (very long) line per output:
./pcm.x 1 -csv
prints the counters every second. The one second interval is convenient because metrics like transferred data will then automatically be reported per second.
On systems with several sockets and many cores, the line can be very long as it contains a lot of values. I therefore usually suppress the output for individual cores using the “-nc” option. You can then redirect the output to a file using the normal pipes, e.g.
./pcm.x 1 -nc –csv > pcm.csv
In case you would like to monitor the output while it is generated, the little Unix utility “tee” will do the trick:
./pcm.x 1 -nc -csv | tee pcm.csv
Now, execute your workload in a different terminal. After the workload has finished, terminate Intel© PCM by pressing CTRL-C
2013-11-5;10:7:38;0.000;0.337;0.000;0.444;0.066;0.199;0.670;0.060;0.370;0.150;0.005;0.003;10.766;31.945;2579.957;0.674;16.851;0.000;0.004;0.737;0.094;1.322;0.058;0.179;0.000;99.763;0.000;45.118;0.000;52.975;0.000;33.748;3.176;0.000;0.221;0.000;0.444;0.021;0.043;0.510;0.049;0.392;0.084;0.003;0.001;59;0.000;0.388;0.000;0.444;0.044;0.155;0.715;0.063;0.360;0.179;0.002;0.002;66;0.126;0.144; 0%; 0%;0.222;0.244; 0%; 0%;0.395;0.376; 0%; 0%;0.291;0.260; 0%; 0%;0.035;0.162;0.000;99.803;0.000;45.925;0.000;52.875;0.000;0.081;0.196;0.000;99.724;0.000;44.312;0.000;53.074;0.000;17.050;16.698;1.600 ;1.576 ;^C
The CSV file can then be analyzed using a spreadsheet program like Apache OpenOffice Calc, KSpread, LibreOffice Calc, Gnumeric, or many others. For the purpose of this tutorial, we will use Microsoft Excel. First transfer the file to a Windows PC, e.g. by copying it using WinSCP. Open the file with Microsoft Excel on Windows by double-clicking it:
If you scroll down past the header of the spreadsheet with the general system information, each column contains one measured value, grouped together either for the whole system, each socket, and (if you haven’t diabled it) for each core. You can now easily select one or multiple columns and use the diagram tool to plot the values:
In my little experiment, I was binding the application to the first socket using memory from the second socket:
numactl --membind=1 --cpunodebind=0 ./test
This can be nicely seen when you plot the execution on each socket:
I also want to see the memory traffic on each socket. For doing so, I copy the name “socket0” to the whole group:
By selecing both header lines and the corresponding data, it is now easy to plot the data traffic:
As expected, there is no memory traffic on socket 0, but a lot of reads and some writes on socket 1. There are many more metrics to explore like c-states, temperature, cache misses, frequency, and so on. In fact, every metric that is displayed in the normal output, is also reported in the CSV output. However, their names are sometimes a little bit cryptic in order to avoid extra-long column headers. (If you have better suggestions for a column name, please let me know.)
Apart from plotting the values, it is also simple to compute the average or the maximum of the values, e.g. during the high-load phase. You can also put them in relation to each other or compute new, derived metrics using the power of your spreadsheet program.