
Hi,
The GHC head can currently build against PAPI[1], a library for gathering CPU statistics.
I did not know that. I know PAPI, though I prefer using perfctr directly, at least for what I'm doing (stuff in a JVM) [1], [2], [3].
At the moment you can only gather such statistics for AMD Opteron but it shouldn't be difficult to port it to other CPUs after a bit of browsing around the PAPI docs. Installing PAPI requires installing a linux kernel driver though, so it is not for the faint hearted.
Well, AFAIK, PAPI abstracts away the platform dependencies quite well, so I guess your code can be run straightforward on all IA-32 platforms (depending on the events you wish to measure, which may or may not be present on all platforms). PowerPC, Itanium, Mips, Alpha should work as well, IIRC. If the GHC backend can generate code there, that is.
We have used this library to find bottlenecks in the current code generation and we have implemented ways of correcting them, so expect some good news about this in the future.
Have you published anything about that?
I should get around to start a wiki page about using PAPI these days, but meanwhile feel free to contact me if you need further information or help.
I've been toying with this idea for a while [4], but never had the time to do something with it. If you have some cool stuff, let us know. I'm very interested. -- Andy [1] Eeckhout, L.; Georges, A.; De Bosschere, K. How Java Programs Interact with Virtual Machines at the Microarchitectural Level. Proceedings of the 18th Annual ACM SIGPLAN Conference on Object- Oriented Programming, Systems, Languages and Applications (OOPSLA 2003). ACM. 2003. pp. 169-186 [2] Georges, A.; Buytaert, D.; Eeckhout, L.; De Bosschere, K. Method- Level Phase Behavior in Java Workloads. Proceedings of the 19th ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications. ACM Press. 2004. pp. 270-287 [3] Georges, A.; Eeckhout, L.; De Bosschere, K. Comparing Low-Level Behavior of SPEC CPU and Java Workloads. Proceedings of the Advances in Computer Systems Architecture: 10th Asia-Pacific Conference, ACSAC 2005. Springer-Verlag GmbH. Lecture Notes in Computer Science. Vol. 3740. 2005. pp. 669-679 [4] http://sequence.complete.org/node/68