|Version 5 (modified by 10 years ago) (diff),|
Measuring program performance using CPU events
The GHC runtime has been extended to support the use of the PAPI library to count occurrences of CPU events such as cache misses and branch mispredictions. The PAPI extension separates the events occurring in the garbage collector and mutator code for more accurate pinpointing of performance problems.
This page describes how to compile the RTS with PAPI enabled and explains the RTS options for CPU event selection. This page also contains patches to collect CPU event information in nofib runs and to allow their comparison using nofib-analyse. This is especially useful to measure the effects of optimisations accross a whole range of programs systematically.
Status of the implementation
GHC with PAPI support should compile on any platform where PAPI is installed. It should also be possible to monitor the cache miss events of a ghc compiled program.
At present, the monitoring of branch mispredictions and stalled cycles is AMD Opteron specific. In the case of branch mispredictions, the portable PAPI API only monitors conditional jumps. We would like to monitor all jumps, especially indirect jumps, that is why we used a native AMD PAPI counter. For strange reasons, the PAPI conditional jump counter maps to the native counter we are using, but we cannot rely on this behaviour on other platforms, so we use the native counter anyway.
Compiling and running programs with PAPI
First of all, make sure that you have installed the PAPI library.
Follow the instructions in Building/Hacking and add the following line to
build.mk before compiling the RTS:
GhcRtsWithPapi = YES
Now, to monitor and report level 1 cache misses, invoke a program compiled by ghc as follows:
./program +RTS -sstderr -a1 -RTS
The help screen provides options to monitor more events:
./program +RTS -h -RTS
Using PAPI with the nofib benchmarking suite
- http://icl.cs.utk.edu/papi/ PAPI home page.
- http://developer.amd.com/article_print.jsp?id=90 An article introducing the business of using CPU counters for performance measurement.
- http://developer.amd.com/articles.jsp?id=2&num=1 An article introducing AMD's code analyst. It even has pipeline simulation, though I haven't tried it out yet.
TestWithPAPI.diff (4.4 KB) - added by 10 years ago.
Additions to test script to collect PAPI numbers from the nofib suite
NoFib-Papi.darcs (1.4 KB) - added by 10 years ago.
Additional option to nofib suite to enable and select a PAPI event set
- NofibanalyseWithPAPI.diff (10.2 KB) - added by 10 years ago.
Download all attachments as: .zip