From 2b522adea22f77a1c03230f5c9865c00bedb5a5b Mon Sep 17 00:00:00 2001 From: "mrchebas@gmail.com" Date: Thu, 9 Nov 2006 07:57:46 +0000 Subject: [PATCH] Selection of PAPI events via RTS command line --- includes/RtsFlags.h | 15 +++++++++ rts/Papi.c | 90 ++++++++++++++++++++++++++++++++------------------- rts/RtsFlags.c | 35 ++++++++++++++++++++ 3 files changed, 107 insertions(+), 33 deletions(-) diff --git a/includes/RtsFlags.h b/includes/RtsFlags.h index 6c4b230..d2236b4 100644 --- a/includes/RtsFlags.h +++ b/includes/RtsFlags.h @@ -302,6 +302,18 @@ struct TRACE_FLAGS { /* Put them together: */ +#ifdef USE_PAPI +struct PAPI_FLAGS { + nat eventType; /* The type of events to count */ +}; + +#define PAPI_FLAG_CACHE_L1 1 +#define PAPI_FLAG_CACHE_L2 2 +#define PAPI_FLAG_BRANCH 3 +#define PAPI_FLAG_STALLS 4 + +#endif + typedef struct _RTS_FLAGS { /* The first portion of RTS_FLAGS is invariant. */ struct GC_FLAGS GcFlags; @@ -319,6 +331,9 @@ typedef struct _RTS_FLAGS { #ifdef GRAN struct GRAN_FLAGS GranFlags; #endif +#ifdef USE_PAPI + struct PAPI_FLAGS PapiFlags; +#endif } RTS_FLAGS; #ifdef COMPILING_RTS_MAIN diff --git a/rts/Papi.c b/rts/Papi.c index 8ce3cc2..5b4f785 100644 --- a/rts/Papi.c +++ b/rts/Papi.c @@ -1,9 +1,10 @@ - +#ifdef USE_PAPI /* ugly */ #include "Papi.h" #include "Rts.h" #include "RtsUtils.h" #include "Stats.h" +#include "RtsFlags.h" /* These constants specify which events to keep track of. @@ -23,7 +24,13 @@ struct _papi_events { char * event_name; }; -#define PAPI_ADD_EVENT(EVENT) { EVENT, #EVENT } +#define PAPI_ADD_EVENT(EVENT) \ + { \ + ASSERT(n_papi_events option.", +" Where X is one of:", +"", +/* " y - cycles", */ +" 1 - level 1 cache misses", +" 2 - level 2 cache misses", +" b - branch mispredictions", +" s - stalled cycles", +#endif "", "RTS options may also be specified using the GHCRTS environment variable.", "", @@ -647,6 +661,27 @@ error = rtsTrue; } break; +#ifdef USE_PAPI + case 'a': + switch(rts_argv[arg][2]) { + case '1': + RtsFlags.PapiFlags.eventType = PAPI_FLAG_CACHE_L1; + break; + case '2': + RtsFlags.PapiFlags.eventType = PAPI_FLAG_CACHE_L2; + break; + case 'b': + RtsFlags.PapiFlags.eventType = PAPI_FLAG_BRANCH; + break; + case 's': + RtsFlags.PapiFlags.eventType = PAPI_FLAG_STALLS; + break; + default: + bad_option( rts_argv[arg] ); + } + break; +#endif + case 'B': RtsFlags.GcFlags.ringBell = rtsTrue; break; -- 1.7.10.4