X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FPapi.c;h=6bb0d08ea1c4f55998ac6a2b522f7ad631a90eeb;hb=485b8d1a00a65aa565e3b30ef8f63fa2880d4093;hp=5b4f7852db948d1fb4785101706486e0b283c376;hpb=2b522adea22f77a1c03230f5c9865c00bedb5a5b;p=ghc-hetmet.git diff --git a/rts/Papi.c b/rts/Papi.c index 5b4f785..6bb0d08 100644 --- a/rts/Papi.c +++ b/rts/Papi.c @@ -1,3 +1,17 @@ +/* ----------------------------------------------------------------------------- + * (c) The GHC Team 2006 + * + * Initialization and use of the PAPI performance monitoring library + * + * + * For adding events or add your processor counters modify + * + * init_countable_events + * papi_report + * + * ---------------------------------------------------------------------------*/ + + #ifdef USE_PAPI /* ugly */ #include "Papi.h" @@ -7,18 +21,6 @@ #include "RtsFlags.h" -/* These constants specify which events to keep track of. - * Probably it is better to count one set of events at a time. - * The reason is that processors have limited counters and - * multiplexing is not enabled (yet). - */ -#define PAPI_COUNT_BRANCHES 0 -/* The one below is Opteron specific. - */ -#define PAPI_COUNT_STALLS 0 -#define PAPI_COUNT_DCACHE1_MISSES 1 -#define PAPI_COUNT_DCACHE2_MISSES 0 - struct _papi_events { int event_code; char * event_name; @@ -32,15 +34,6 @@ struct _papi_events { n_papi_events++; \ } -/* Beware, these counters are Opteron specific */ -#define FR_BR 0x40000040 -#define FR_BR_MIS 0x40000041 -#define FR_BR_MISCOMPARE 0x40000048 -#define DC_ACCESS 0x40000019 -#define DC_MISS 0x4000001a -#define FR_DISPATCH_STALLS_BR 0x40000055 -#define FR_DISPATCH_STALLS_FULL_LS 0x4000005b - /* Report the value of a counter */ #define PAPI_REPORT(EVENTSET,EVENT) \ { \ @@ -53,6 +46,20 @@ struct _papi_events { statsPrintf(" (" #EVENT ") %% of (" #EVENTTOT ") : %.1f%%\n", \ papi_counter(EVENTSET,EVENT)*100.0/papi_counter(EVENTSET,EVENTTOT)) +/* Beware, these counters are Opteron specific + * I obtained the numbers using the papi_avail + * and papi_native_avail utilities. + * This is certainly not the official PAPI way + * of doing things. + */ +#define FR_BR 0x40000040 +#define FR_BR_MIS 0x40000041 +#define FR_BR_MISCOMPARE 0x40000048 +#define DC_ACCESS 0x40000019 +#define DC_MISS 0x4000001a +#define FR_DISPATCH_STALLS_BR 0x40000055 +#define FR_DISPATCH_STALLS_FULL_LS 0x4000005b + /* Number of counted events, computed from size of papi_events */ #define N_PAPI_EVENTS n_papi_events @@ -74,14 +81,19 @@ int papi_error; int n_papi_events = 0; -/* If you want to add events to count, extend the - * papi_events array and the papi_report function. - */ /* Events counted during GC and Mutator execution */ /* There's a trailing comma, do all C compilers accept that? */ static struct _papi_events papi_events[MAX_PAPI_EVENTS]; +long_long MutatorCounters[MAX_PAPI_EVENTS]; +long_long GCCounters[MAX_PAPI_EVENTS]; +/* If you want to add events to count, extend the + * init_countable_events and the papi_report function. + * Be aware that your processor can count a limited number + * of events simultaneously, you can turn on multiplexing + * to increase that number, though. + */ static void init_countable_events(void) { @@ -106,25 +118,6 @@ init_countable_events(void) } }; -long_long MutatorCounters[MAX_PAPI_EVENTS]; -long_long GCCounters[MAX_PAPI_EVENTS]; - - -/* Extract the value corresponding to an event */ -long_long -papi_counter(long_long values[],int event) -{ - int i; - for(i=0;i