rts: Kill PAPI support
authorBen Gamari <bgamari.foss@gmail.com>
Wed, 18 Nov 2015 11:22:02 +0000 (12:22 +0100)
committerBen Gamari <ben@smart-cactus.org>
Wed, 18 Nov 2015 11:53:50 +0000 (12:53 +0100)
This hasn't been used for a very long time and will soon be superceded
by perf_events support.

Test Plan: validate

Reviewers: austin, simonmar

Reviewed By: austin, simonmar

Subscribers: thomie, erikd

Differential Revision: https://phabricator.haskell.org/D1493

15 files changed:
configure.ac
docs/users_guide/7.12.1-notes.rst
includes/rts/Flags.h
mk/config.mk.in
rts/Papi.c [deleted file]
rts/Papi.h [deleted file]
rts/RtsFlags.c
rts/RtsStartup.c
rts/Stats.c
rts/Stats.h
rts/ghc.mk
rts/package.conf.in
rts/posix/GetTime.c
rts/sm/GC.c
rts/sm/GCThread.h

index 84f381e..1e43896 100644 (file)
@@ -1006,12 +1006,6 @@ AC_COMPILE_IFELSE(
   ])
 
 
-dnl ** checking for PAPI
-AC_CHECK_LIB(papi, PAPI_library_init, HavePapiLib=YES, HavePapiLib=NO)
-AC_CHECK_HEADER([papi.h], [HavePapiHeader=YES], [HavePapiHeader=NO])
-AC_SUBST(HavePapiLib)
-AC_SUBST(HavePapiHeader)
-
 AC_CHECK_FUNCS(__mingw_vfprintf)
 
 if test "$HavePapiLib" = "YES" -a "$HavePapiHeader" = "YES"; then
index bd4f78b..10ed77e 100644 (file)
@@ -175,7 +175,7 @@ Template Haskell
 Runtime system
 ~~~~~~~~~~~~~~
 
--  TODO FIXME.
+-  Support for performance monitoring with PAPI has been dropped.
 
 Build system
 ~~~~~~~~~~~~
index 1440b14..878e0f1 100644 (file)
@@ -213,29 +213,6 @@ typedef struct _TICKY_FLAGS {
     FILE   *tickyFile;
 } TICKY_FLAGS;
 
-#ifdef USE_PAPI
-#define MAX_PAPI_USER_EVENTS 8
-
-/* See Note [Synchronization of flags and base APIs] */
-typedef struct _PAPI_FLAGS {
-    nat     eventType;          /* The type of events to count */
-    nat     numUserEvents;
-    char *  userEvents[MAX_PAPI_USER_EVENTS];
-    /* Allow user to enter either PAPI preset or native events */
-    nat     userEventsKind[MAX_PAPI_USER_EVENTS];
-} PAPI_FLAGS;
-
-#define PAPI_FLAG_CACHE_L1 1
-#define PAPI_FLAG_CACHE_L2 2
-#define PAPI_FLAG_BRANCH 3
-#define PAPI_FLAG_STALLS 4
-#define PAPI_FLAG_CB_EVENTS 5
-#define PAPI_USER_EVENTS 6
-#define PAPI_PRESET_EVENT_KIND 0
-#define PAPI_NATIVE_EVENT_KIND 1
-
-#endif
-
 /* Put them together: */
 
 /* See Note [Synchronization of flags and base APIs] */
@@ -253,9 +230,6 @@ typedef struct _RTS_FLAGS {
 #if defined(THREADED_RTS)
     PAR_FLAGS        ParFlags;
 #endif
-#ifdef USE_PAPI
-    PAPI_FLAGS        PapiFlags;
-#endif
 } RTS_FLAGS;
 
 #ifdef COMPILING_RTS_MAIN
index 035443a..f939442 100644 (file)
@@ -339,12 +339,6 @@ LAX_DEPENDENCIES = NO
 GhcRtsHcOpts=-O2
 GhcRtsCcOpts=-O2 -fomit-frame-pointer -g
 
-# Include support for CPU performance counters via the PAPI library in the RTS?
-# (PAPI: http://icl.cs.utk.edu/papi/)
-GhcRtsWithPapi = NO
-PapiLibDir=
-PapiIncludeDir=
-
 # Configuration for libffi
 UseSystemLibFFI=@UseSystemLibFFI@
 # Flags to go into package.conf for rts
diff --git a/rts/Papi.c b/rts/Papi.c
deleted file mode 100644 (file)
index a36157f..0000000
+++ /dev/null
@@ -1,396 +0,0 @@
-/* -----------------------------------------------------------------------------
- * (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>
-/* The posix symbols get defined in a header included from papi.h.
- * undefind them here to allow redefinition in PosixSource.h */
-#undef _POSIX_SOURCE
-#undef _POSIX_C_SOURCE
-#undef _XOPEN_SOURCE
-
-#include "PosixSource.h"
-#include "Rts.h"
-
-#include "RtsUtils.h"
-#include "Stats.h"
-#include "Papi.h"
-
-// used to protect the aggregated counters
-#ifdef THREADED_RTS
-static Mutex papi_counter_mutex;
-#endif
-
-struct _papi_events {
-  int event_code;
-  const char * event_name;
-};
-
-/* 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 0x40000054
-#define FR_DISPATCH_STALLS_BR 0x40000055
-#define FR_DISPATCH_STALLS_FULL_REORDER 0x40000058
-#define FR_DISPATCH_STALLS_FULL_RESERVATION 0x40000059
-#define FR_DISPATCH_STALLS_FULL_LS 0x4000005b
-#define DC_L2_REFILL_MOES 0x40001e1b
-#define DC_SYS_REFILL_MOES 0x40001e1c
-
-/* This is bad, it should be in a header */
-#define BIG_STRING_LEN 512
-
-
-#define PAPI_CHECK(CALL)                                                \
-  if((papi_error=(CALL)) != PAPI_OK) {                                  \
-    debugBelch("PAPI function failed in module %s at line %d "          \
-               "with error code %d\n",                                  \
-              __FILE__,__LINE__,papi_error);                            \
-  }
-
-/* While PAPI reporting is going on this flag is on */
-int papi_is_reporting;
-
-/* Event sets and counter arrays for GC and mutator */
-
-int MutatorEvents = PAPI_NULL;
-int GCEvents = PAPI_NULL;
-
-int papi_error;
-
-/* Arbitrary, to avoid using malloc */
-#define MAX_PAPI_EVENTS 10
-static char papiNativeEventNames[MAX_PAPI_EVENTS][PAPI_MAX_STR_LEN];
-
-static nat n_papi_events = 0;
-
-
-/* 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 GC0Counters[MAX_PAPI_EVENTS];
-long_long GC1Counters[MAX_PAPI_EVENTS];
-
-long_long start_mutator_cycles;
-long_long mutator_cycles = 0;
-long_long start_gc_cycles;
-long_long gc0_cycles = 0;
-long_long gc1_cycles = 0;
-
-
-
-static long_long papi_counter(long_long values[],int event);
-static void papi_add_events(int EventSet);
-
-static nat max_hardware_counters = 2;
-
-/* 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 papi_add_event(const char *name, int code)
-{
-    if (n_papi_events >= max_hardware_counters) {
-        errorBelch("too many PAPI events for this CPU (max: %d)",
-                   max_hardware_counters);
-        stg_exit(EXIT_FAILURE);
-    }
-    papi_events[n_papi_events].event_code = code;
-    papi_events[n_papi_events].event_name = name;
-    n_papi_events++;
-}
-
-static void
-init_countable_events(void)
-{
-    max_hardware_counters = PAPI_num_counters();
-
-#define PAPI_ADD_EVENT(EVENT) papi_add_event(#EVENT,EVENT)
-
-    if (RtsFlags.PapiFlags.eventType==PAPI_FLAG_BRANCH) {
-        PAPI_ADD_EVENT(FR_BR);
-        PAPI_ADD_EVENT(FR_BR_MIS);
-        // Docs are wrong? Opteron does not count indirect branch
-        // misses exclusively
-        PAPI_ADD_EVENT(FR_BR_MISCOMPARE);
-    } else if (RtsFlags.PapiFlags.eventType==PAPI_FLAG_STALLS) {
-        PAPI_ADD_EVENT(FR_DISPATCH_STALLS);
-        PAPI_ADD_EVENT(FR_DISPATCH_STALLS_BR);
-        PAPI_ADD_EVENT(FR_DISPATCH_STALLS_FULL_LS);
-    } else if (RtsFlags.PapiFlags.eventType==PAPI_FLAG_CACHE_L1) {
-        PAPI_ADD_EVENT(PAPI_L1_DCA);
-        PAPI_ADD_EVENT(PAPI_L1_DCM);
-    } else if (RtsFlags.PapiFlags.eventType==PAPI_FLAG_CACHE_L2) {
-        PAPI_ADD_EVENT(PAPI_L2_DCA);
-        PAPI_ADD_EVENT(PAPI_L2_DCM);
-    } else if (RtsFlags.PapiFlags.eventType==PAPI_FLAG_CB_EVENTS) {
-        PAPI_ADD_EVENT(DC_L2_REFILL_MOES);
-        PAPI_ADD_EVENT(DC_SYS_REFILL_MOES);
-        PAPI_ADD_EVENT(FR_BR_MIS);
-    } else if (RtsFlags.PapiFlags.eventType==PAPI_USER_EVENTS) {
-        nat i;
-        char *name;
-        char *asciiEventCode;
-        int code;
-        for (i = 0; i < RtsFlags.PapiFlags.numUserEvents; i++) {
-          if(RtsFlags.PapiFlags.userEventsKind[i] == PAPI_PRESET_EVENT_KIND) {
-            name = RtsFlags.PapiFlags.userEvents[i];
-            PAPI_CHECK(PAPI_event_name_to_code(name, &code))
-          }
-          else { // PAPI_NATIVE_EVENT_KIND
-            asciiEventCode = RtsFlags.PapiFlags.userEvents[i];
-            name = papiNativeEventNames[i];
-            code = strtol(asciiEventCode, NULL, 16 /* hex number expected */);
-            PAPI_CHECK(PAPI_event_code_to_name(code, name))
-          }
-          papi_add_event(name, code);
-        }
-    } else {
-        // PAPI_ADD_EVENT(PAPI_L1_DCA); // L1 data cache accesses
-        // PAPI_ADD_EVENT(PAPI_L1_ICR); // L1 instruction cache reads
-        // PAPI_ADD_EVENT(PAPI_L1_ICM); // L1 instruction cache misses
-        // PAPI_ADD_EVENT(PAPI_L1_STM); // L1 store misses
-        // PAPI_ADD_EVENT(PAPI_L1_DCM); // L1 data cache misses
-        // PAPI_ADD_EVENT(PAPI_L1_LDM); // L1 load misses
-        // PAPI_ADD_EVENT(PAPI_L2_TCM); // L2 cache misses
-        // PAPI_ADD_EVENT(PAPI_L2_STM); // L2 store misses
-        // PAPI_ADD_EVENT(PAPI_L2_DCW); // L2 data cache writes
-        // PAPI_ADD_EVENT(PAPI_L2_DCR); // L2 data cache reads
-        // PAPI_ADD_EVENT(PAPI_L2_TCW); // L2 cache writes
-        // PAPI_ADD_EVENT(PAPI_L2_TCR); // L2 cache reads
-        // PAPI_ADD_EVENT(PAPI_CA_CLN); // exclusive access to clean cache line
-        // PAPI_ADD_EVENT(PAPI_TLB_DM); // TLB misses
-        PAPI_ADD_EVENT(PAPI_TOT_INS); // Total instructions
-        PAPI_ADD_EVENT(PAPI_TOT_CYC); // Total instructions
-        // PAPI_ADD_EVENT(PAPI_CA_SHR); // exclusive access to shared cache line
-        // PAPI_ADD_EVENT(PAPI_RES_STL); // Cycles stalled on any resource
-
-    }
-
-    // We might also consider:
-    //  PAPI_BR_MSP     Conditional branch instructions mispredicted
-    //  PAPI_RES_STL    Cycles stalled on any resource
-};
-
-
-static void
-papi_report_event(const char *name, StgWord64 value)
-{
-    static char temp[BIG_STRING_LEN];
-    showStgWord64(value,temp,rtsTrue/*commas*/);
-    statsPrintf("  %15s  %15s\n", name, temp);
-}
-
-/* This function reports counters for GC and mutator */
-static void
-papi_report(long_long counters[])
-{
-    nat i;
-
-/* Report the value of a counter as a percentage of another counter */
-#define PAPI_REPORT_PCT(EVENTSET,EVENT,EVENTTOT) \
-    statsPrintf("   " #EVENT " %% of " #EVENTTOT " : %.1f%%\n",      \
-         papi_counter(EVENTSET,EVENT)*100.0/papi_counter(EVENTSET,EVENTTOT))
-
-    for (i = 0; i < n_papi_events; i++)
-    {
-        papi_report_event(papi_events[i].event_name, counters[i]);
-    }
-
-    if (RtsFlags.PapiFlags.eventType==PAPI_FLAG_BRANCH) {
-        PAPI_REPORT_PCT(counters,FR_BR_MIS,FR_BR);
-        PAPI_REPORT_PCT(counters,FR_BR_MISCOMPARE,FR_BR);
-    }
-
-    else if (RtsFlags.PapiFlags.eventType==PAPI_FLAG_CACHE_L1) {
-        PAPI_REPORT_PCT(counters,PAPI_L1_DCM,PAPI_L1_DCA);
-    }
-
-    else if (RtsFlags.PapiFlags.eventType==PAPI_FLAG_CACHE_L2) {
-        PAPI_REPORT_PCT(counters,PAPI_L2_DCM,PAPI_L2_DCA);
-    }
-}
-
-void
-papi_stats_report (void)
-{
-    statsPrintf("  Mutator CPU counters\n");
-    papi_report_event("CYCLES", mutator_cycles);
-    papi_report(MutatorCounters);
-
-    statsPrintf("\n  GC(0) CPU counters\n");
-    papi_report_event("CYCLES", gc0_cycles);
-    papi_report(GC0Counters);
-
-    statsPrintf("\n  GC(1) CPU counters\n");
-    papi_report_event("CYCLES", gc1_cycles);
-    papi_report(GC1Counters);
-}
-
-void
-papi_init_eventset (int *event_set)
-{
-    PAPI_register_thread();
-    PAPI_CHECK( PAPI_create_eventset(event_set));
-    papi_add_events(*event_set);
-}
-
-void
-papi_init (void)
-{
-    /* Initialise the performance tracking library */
-    int ver;
-    if ((ver = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) {
-        if (ver > 0) {
-            errorBelch("PAPI_library_init: wrong version: %x", ver);
-            stg_exit(EXIT_FAILURE);
-        } else {
-            sysErrorBelch("PAPI_library_init");
-            stg_exit(EXIT_FAILURE);
-        }
-    }
-
-#ifdef THREADED_RTS
-    {
-        int err;
-        if ((err = PAPI_thread_init(osThreadId)) < 0) {
-            barf("PAPI_thread_init: %d",err);
-        }
-
-        initMutex(&papi_counter_mutex);
-    }
-#endif
-
-    init_countable_events();
-
-    papi_init_eventset(&MutatorEvents);
-    papi_init_eventset(&GCEvents);
-}
-
-/* Extract the value corresponding to an event */
-static long_long
-papi_counter(long_long values[],int event)
-{
-  nat i;
-  for(i=0;i<n_papi_events;i++) {
-    if(papi_events[i].event_code==event) {
-      return values[i];
-    }
-  }
-  /* Passed a wrong event? */
-  debugBelch("Event %d is not part of event set\n",event);
-  return 0;
-}
-
-/* Add the events of papi_events into an event set */
-static void
-papi_add_events(int EventSet)
-{
-  nat i;
-  for(i=0;i<n_papi_events;i++) {
-    if((papi_error=PAPI_add_event(EventSet,
-                                  papi_events[i].event_code))
-       != PAPI_OK)
-      debugBelch("Failed adding %s to event set with error code %d\n",
-                 papi_events[i].event_name,papi_error);
-  }
-}
-
-/* We should be using elapsed cycles
- * to be consistent with time metric chosen in Stats.c (Elapsed time).
- * This is an approximation to the cycles that the program spends.
- * Note that the counters, in contrast, are virtual and user space.
- */
-#define PAPI_cycles PAPI_get_virt_cyc
-
-void
-papi_start_mutator_count(void)
-{
-    ACQUIRE_LOCK(&papi_counter_mutex);
-    PAPI_CHECK( PAPI_start(MutatorEvents));
-    start_mutator_cycles = PAPI_cycles();
-    RELEASE_LOCK(&papi_counter_mutex);
-}
-
-void
-papi_stop_mutator_count(void)
-{
-    ACQUIRE_LOCK(&papi_counter_mutex);
-    mutator_cycles += PAPI_cycles() - start_mutator_cycles;
-    PAPI_CHECK( PAPI_accum(MutatorEvents,MutatorCounters));
-    PAPI_CHECK( PAPI_stop(MutatorEvents,NULL));
-    RELEASE_LOCK(&papi_counter_mutex);
-}
-
-void
-papi_start_gc_count(void)
-{
-    ACQUIRE_LOCK(&papi_counter_mutex);
-    PAPI_CHECK( PAPI_start(GCEvents));
-    start_gc_cycles = PAPI_cycles();
-    RELEASE_LOCK(&papi_counter_mutex);
-}
-
-void
-papi_stop_gc0_count(void)
-{
-    ACQUIRE_LOCK(&papi_counter_mutex);
-    PAPI_CHECK( PAPI_accum(GCEvents,GC0Counters));
-    PAPI_CHECK( PAPI_stop(GCEvents,NULL));
-    gc0_cycles += PAPI_cycles() - start_gc_cycles;
-    RELEASE_LOCK(&papi_counter_mutex);
-}
-
-
-void
-papi_stop_gc1_count(void)
-{
-    ACQUIRE_LOCK(&papi_counter_mutex);
-    PAPI_CHECK( PAPI_accum(GCEvents,GC1Counters));
-    PAPI_CHECK( PAPI_stop(GCEvents,NULL));
-    gc1_cycles += PAPI_cycles() - start_gc_cycles;
-    RELEASE_LOCK(&papi_counter_mutex);
-}
-
-
-void
-papi_thread_start_gc1_count(int event_set)
-{
-    ACQUIRE_LOCK(&papi_counter_mutex);
-    PAPI_CHECK( PAPI_start(event_set));
-    RELEASE_LOCK(&papi_counter_mutex);
-}
-
-void
-papi_thread_stop_gc1_count(int event_set)
-{
-    ACQUIRE_LOCK(&papi_counter_mutex);
-    PAPI_CHECK( PAPI_accum(event_set,GC1Counters));
-    PAPI_CHECK( PAPI_stop(event_set,NULL));
-    RELEASE_LOCK(&papi_counter_mutex);
-}
-
-#endif /* USE_PAPI */
diff --git a/rts/Papi.h b/rts/Papi.h
deleted file mode 100644 (file)
index 97a9649..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -----------------------------------------------------------------------------
- * (c) The GHC Team 2006
- *
- * Initialization and use of the PAPI performance monitoring library
- *
- * ---------------------------------------------------------------------------*/
-
-#ifndef PAPI_H
-#define PAPI_H
-
-#include "BeginPrivate.h"
-
-/* Check the error value of a PAPI call, reporting an error, if needed */
-extern int papi_error;
-
-/* While PAPI reporting is going on this flag is on */
-extern int papi_is_reporting;
-
-void papi_stats_report(void);
-void papi_init_eventset(int * event_set);
-void papi_init(void);
-void papi_start_mutator_count(void);
-void papi_stop_mutator_count(void);
-
-void papi_start_gc_count(void);
-void papi_stop_gc0_count(void);
-void papi_stop_gc1_count(void);
-
-// for multithreaded GC, each sub-thread uses these functions to count
-// events and aggregate them into the main GC counters.
-void papi_thread_start_gc1_count(int event_set);
-void papi_thread_stop_gc1_count(int event_set);
-
-#include "EndPrivate.h"
-
-#endif /* PAPI_H */
index b9979bc..e305128 100644 (file)
@@ -103,10 +103,6 @@ static void read_debug_flags(const char *arg);
 static rtsBool read_heap_profiling_flag(const char *arg);
 #endif
 
-#ifdef USE_PAPI
-static void read_papi_flag(const char *arg);
-#endif
-
 #ifdef TRACING
 static void read_trace_flags(const char *arg);
 #endif
@@ -251,12 +247,6 @@ void initRtsFlagsDefaults(void)
     RtsFlags.TickyFlags.showTickyStats   = rtsFalse;
     RtsFlags.TickyFlags.tickyFile        = NULL;
 #endif
-
-#ifdef USE_PAPI
-    /* By default no special measurements taken */
-    RtsFlags.PapiFlags.eventType        = 0;
-    RtsFlags.PapiFlags.numUserEvents    = 0;
-#endif
 }
 
 static const char *
@@ -422,19 +412,6 @@ usage_text[] = {
 "  -xm       Base address to mmap memory in the GHCi linker",
 "            (hex; must be <80000000)",
 #endif
-#if defined(USE_PAPI)
-"  -aX       CPU performance counter measurements using PAPI",
-"            (use with the -s<file> option).  X is one of:",
-"",
-/* "            y - cycles", */
-"            1 - level 1 cache misses",
-"            2 - level 2 cache misses",
-"            b - branch mispredictions",
-"            s - stalled cycles",
-"            e - cache miss and branch misprediction events",
-"            +PAPI_EVENT   - collect papi preset event PAPI_EVENT",
-"            #NATIVE_EVENT - collect native event NATIVE_EVENT (in hex)",
-#endif
 "  -xq       The allocation limit given to a thread after it receives",
 "            an AllocationLimitExceeded exception. (default: 100k)",
 "",
@@ -790,13 +767,6 @@ error = rtsTrue;
                            / BLOCK_SIZE;
                   break;
 
-#ifdef USE_PAPI
-              case 'a':
-                OPTION_UNSAFE;
-                read_papi_flag(&rts_argv[arg])
-                break;
-#endif
-
               case 'B':
                 OPTION_UNSAFE;
                 RtsFlags.GcFlags.ringBell = rtsTrue;
@@ -1559,47 +1529,6 @@ static void read_debug_flags(const char* arg)
 }
 #endif
 
-#ifdef USE_PAPI
-static void read_papi_flags(const char *arg)
-{
-    // Already parsed "-a"
-    switch(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;
-    case 'e':
-        RtsFlags.PapiFlags.eventType = PAPI_FLAG_CB_EVENTS;
-        break;
-    case '+':
-    case '#':
-        if (RtsFlags.PapiFlags.numUserEvents >= MAX_PAPI_USER_EVENTS) {
-            errorBelch("maximum number of PAPI events reached");
-            stg_exit(EXIT_FAILURE);
-        }
-        nat eventNum  = RtsFlags.PapiFlags.numUserEvents++;
-        char kind     = arg[2];
-        nat eventKind =
-            kind == '+' ? PAPI_PRESET_EVENT_KIND : PAPI_NATIVE_EVENT_KIND;
-
-        RtsFlags.PapiFlags.userEvents[eventNum] = arg + 3;
-        RtsFlags.PapiFlags.eventType = PAPI_USER_EVENTS;
-        RtsFlags.PapiFlags.userEventsKind[eventNum] = eventKind;
-        break;
-    default:
-        bad_option( arg );
-    }
-}
-#endif
-
 #ifdef PROFILING
 // Parse a "-h" flag, returning whether the parse resulted in an error.
 static rtsBool read_heap_profiling_flag(const char *arg)
index 35e52aa..ac4460e 100644 (file)
@@ -6,11 +6,6 @@
  *
  * ---------------------------------------------------------------------------*/
 
-// PAPI uses caddr_t, which is not POSIX
-#ifndef USE_PAPI
-#include "PosixSource.h"
-#endif
-
 #include "Rts.h"
 #include "RtsAPI.h"
 #include "HsFFI.h"
 #include <locale.h>
 #endif
 
-#if USE_PAPI
-#include "Papi.h"
-#endif
-
 // Count of how many outstanding hs_init()s there have been.
 static int hs_init_count = 0;
 
@@ -168,10 +159,6 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config)
     /* Initialise the stats department, phase 1 */
     initStats1();
 
-#ifdef USE_PAPI
-    papi_init();
-#endif
-
     /* initTracing must be after setupRtsFlags() */
 #ifdef TRACING
     initTracing();
index 71cb29c..4c06b18 100644 (file)
 #include "sm/GCThread.h"
 #include "sm/BlockAlloc.h"
 
-#if USE_PAPI
-#include "Papi.h"
-#endif
-
 /* huh? */
 #define BIG_STRING_LEN              512
 
@@ -71,6 +67,7 @@ static Time *GC_coll_cpu = NULL;
 static Time *GC_coll_elapsed = NULL;
 static Time *GC_coll_max_pause = NULL;
 
+static void statsPrintf( char *s, ... ) GNUC3_ATTRIBUTE(format (PRINTF, 1, 2));
 static void statsFlush( void );
 static void statsClose( void );
 
@@ -210,17 +207,6 @@ void
 stat_endInit(void)
 {
     getProcessTimes(&end_init_cpu, &end_init_elapsed);
-
-#if USE_PAPI
-    /* We start counting events for the mutator
-     * when garbage collection starts
-     * we switch to the GC event set. */
-    papi_start_mutator_count();
-
-    /* This flag is needed to avoid counting the last GC */
-    papi_is_reporting = 1;
-
-#endif
 }
 
 /* -----------------------------------------------------------------------------
@@ -233,15 +219,6 @@ void
 stat_startExit(void)
 {
     getProcessTimes(&start_exit_cpu, &start_exit_elapsed);
-
-#if USE_PAPI
-    /* We stop counting mutator events
-     * GC events are not being counted at this point */
-    papi_stop_mutator_count();
-
-    /* This flag is needed, because GC is run once more after this function */
-    papi_is_reporting = 0;
-#endif
 }
 
 void
@@ -276,14 +253,6 @@ stat_startGC (Capability *cap, gc_thread *gct)
         }
     }
 
-#if USE_PAPI
-    if(papi_is_reporting) {
-      /* Switch to counting GC events */
-      papi_stop_mutator_count();
-      papi_start_gc_count();
-    }
-#endif
-
     getProcessTimes(&gct->gc_start_cpu, &gct->gc_start_elapsed);
 
     // Post EVENT_GC_START with the same timestamp as used for stats
@@ -432,18 +401,6 @@ stat_endGC (Capability *cap, gc_thread *gct,
         debugBelch("\b\b\b  \b\b\b");
         rub_bell = 0;
     }
-
-#if USE_PAPI
-    if(papi_is_reporting) {
-      /* Switch to counting mutator events */
-      if (gen == 0) {
-          papi_stop_gc0_count();
-      } else {
-          papi_stop_gc1_count();
-      }
-      papi_start_mutator_count();
-    }
-#endif
 }
 
 /* -----------------------------------------------------------------------------
@@ -759,9 +716,6 @@ stat_exit (void)
             TICK_PRINT_TOT(2);
             */
 
-#if USE_PAPI
-            papi_stats_report();
-#endif
 #if defined(THREADED_RTS) && defined(PROF_SPIN)
             {
                 nat g;
index 76b5222..b7ced97 100644 (file)
@@ -66,12 +66,8 @@ double    mut_user_time_during_heap_census(void);
 
 void      statDescribeGens( void );
 
-Time stat_getElapsedGCTime(void);
-Time stat_getElapsedTime(void);
-
-/* Only exported for Papi.c */
-void statsPrintf( char *s, ... ) 
-    GNUC3_ATTRIBUTE(format (PRINTF, 1, 2));
+Time      stat_getElapsedGCTime(void);
+Time      stat_getElapsedTime(void);
 
 #include "EndPrivate.h"
 
index 1f5f996..84b59d3 100644 (file)
@@ -463,33 +463,6 @@ rts/dist/build/sm/Evac_thr_CC_OPTS += -DPARALLEL_GC -Irts/sm
 rts/dist/build/sm/Scav_thr_CC_OPTS += -DPARALLEL_GC -Irts/sm
 
 #-----------------------------------------------------------------------------
-# Add PAPI library if needed
-
-ifeq "$(GhcRtsWithPapi)" "YES"
-
-rts_CC_OPTS            += -DUSE_PAPI
-
-rts_PACKAGE_CPP_OPTS   += -DUSE_PAPI
-rts_PACKAGE_CPP_OPTS    += -DPAPI_INCLUDE_DIR=$(PapiIncludeDir)
-rts_PACKAGE_CPP_OPTS    += -DPAPI_LIB_DIR=$(PapiLibDir)
-
-ifneq "$(PapiIncludeDir)" ""
-rts_HC_OPTS     += -I$(PapiIncludeDir)
-rts_CC_OPTS     += -I$(PapiIncludeDir)
-rts_HSC2HS_OPTS += -I$(PapiIncludeDir)
-endif
-ifneq "$(PapiLibDirs)" ""
-rts_LD_OPTS     += -L$(PapiLibDirs)
-endif
-
-else # GhcRtsWithPapi==YES
-
-rts_PACKAGE_CPP_OPTS += -DPAPI_INCLUDE_DIR=""
-rts_PACKAGE_CPP_OPTS += -DPAPI_LIB_DIR=""
-
-endif
-
-#-----------------------------------------------------------------------------
 # Use system provided libffi
 
 ifeq "$(UseSystemLibFFI)" "YES"
index fff645d..5c6d240 100644 (file)
@@ -17,9 +17,9 @@ hidden-modules:
 import-dirs:
 
 #ifdef INSTALLING
-library-dirs:           LIB_DIR"/rts" PAPI_LIB_DIR FFI_LIB_DIR
+library-dirs:           LIB_DIR"/rts" FFI_LIB_DIR
 #else /* !INSTALLING */
-library-dirs:           TOP"/rts/dist/build" PAPI_LIB_DIR FFI_LIB_DIR
+library-dirs:           TOP"/rts/dist/build" FFI_LIB_DIR
 #endif
 
 hs-libraries:   "HSrts" FFI_LIB
@@ -61,16 +61,13 @@ unresolved symbols. */
                               ,"mingwex"
 # endif
 #endif
-#if USE_PAPI
-                             , "papi"
-#endif
 #ifdef USE_LIBDW
                              , "elf"
                              , "dw"             /* for backtraces */
 #endif
 
 #ifdef INSTALLING
-include-dirs:           INCLUDE_DIR PAPI_INCLUDE_DIR FFI_INCLUDE_DIR
+include-dirs:           INCLUDE_DIR FFI_INCLUDE_DIR
 #else /* !INSTALLING */
 include-dirs:           TOP"/rts/dist/build" TOP"/includes" TOP"/includes/dist-derivedconstants/header" FFI_INCLUDE_DIR
 #endif
index 3e0e1ca..def78a4 100644 (file)
 # include <sys/times.h>
 #endif
 
-#ifdef USE_PAPI
-# include <papi.h>
-#endif
-
 #if ! ((defined(HAVE_GETRUSAGE) && !irix_HOST_OS) || defined(HAVE_TIMES))
 #error No implementation for getProcessCPUTime() available.
 #endif
@@ -130,17 +126,9 @@ void getProcessTimes(Time *user, Time *elapsed)
 
 Time getProcessCPUTime(void)
 {
-#if !defined(THREADED_RTS) && USE_PAPI
-    long long usec;
-    if ((usec = PAPI_get_virt_usec()) < 0) {
-        barf("PAPI_get_virt_usec: %lld", usec);
-    }
-    return USToTime(usec);
-#else
     Time user, elapsed;
     getProcessTimes(&user,&elapsed);
     return user;
-#endif
 }
 
 Time getProcessElapsedTime(void)
@@ -185,18 +173,11 @@ void getProcessTimes(Time *user, Time *elapsed)
 
 Time getThreadCPUTime(void)
 {
-#if USE_PAPI
-    long long usec;
-    if ((usec = PAPI_get_virt_usec()) < 0) {
-        barf("PAPI_get_virt_usec: %lld", usec);
-    }
-    return USToTime(usec);
-
-#elif !defined(BE_CONSERVATIVE)            &&  \
-       defined(HAVE_CLOCK_GETTIME)       &&  \
-       defined(_SC_CPUTIME)             &&  \
-       defined(CLOCK_PROCESS_CPUTIME_ID) &&  \
-       defined(HAVE_SYSCONF)
+#if !defined(BE_CONSERVATIVE)            &&  \
+     defined(HAVE_CLOCK_GETTIME)       &&  \
+     defined(_SC_CPUTIME)             &&  \
+     defined(CLOCK_PROCESS_CPUTIME_ID) &&  \
+     defined(HAVE_SYSCONF)
     {
         static int checked_sysconf = 0;
         static int sysconf_result = 0;
index e6a2339..95d9951 100644 (file)
@@ -45,7 +45,6 @@
 #include "RetainerProfile.h"
 #include "LdvProfile.h"
 #include "RaiseAsync.h"
-#include "Papi.h"
 #include "Stable.h"
 #include "CheckUnload.h"
 
@@ -792,10 +791,6 @@ new_gc_thread (nat n, gc_thread *t)
 
     init_gc_thread(t);
 
-#ifdef USE_PAPI
-    t->papi_events = -1;
-#endif
-
     for (g = 0; g < RtsFlags.GcFlags.generations; g++)
     {
         ws = &t->gens[g];
@@ -1028,14 +1023,6 @@ gcWorkerThread (Capability *cap)
     debugTrace(DEBUG_gc, "GC thread %d standing by...", gct->thread_index);
     ACQUIRE_SPIN_LOCK(&gct->gc_spin);
 
-#ifdef USE_PAPI
-    // start performance counters in this thread...
-    if (gct->papi_events == -1) {
-        papi_init_eventset(&gct->papi_events);
-    }
-    papi_thread_start_gc1_count(gct->papi_events);
-#endif
-
     init_gc_thread(gct);
 
     traceEventGcWork(gct->cap);
@@ -1057,11 +1044,6 @@ gcWorkerThread (Capability *cap)
     pruneSparkQueue(cap);
 #endif
 
-#ifdef USE_PAPI
-    // count events in this thread towards the GC totals
-    papi_thread_stop_gc1_count(gct->papi_events);
-#endif
-
     // Wait until we're told to continue
     RELEASE_SPIN_LOCK(&gct->gc_spin);
     gct->wakeup = GC_THREAD_WAITING_TO_CONTINUE;
index d42b89f..ca90717 100644 (file)
@@ -129,7 +129,7 @@ typedef struct gc_thread_ {
 
     bdescr * free_blocks;          // a buffer of free blocks for this thread
                                    //  during GC without accessing the block
-                                   //   allocators spin lock. 
+                                   //   allocators spin lock.
 
     // These two lists are chained through the STATIC_LINK() fields of static
     // objects.  Pointers are tagged with the current static_flag, so before
@@ -161,21 +161,17 @@ typedef struct gc_thread_ {
                                    // optimise it into a per-thread
                                    // variable).
 
-    rtsBool failed_to_evac;        // failure to evacuate an object typically 
-                                   // Causes it to be recorded in the mutable 
+    rtsBool failed_to_evac;        // failure to evacuate an object typically
+                                   // Causes it to be recorded in the mutable
                                    // object list
 
     rtsBool eager_promotion;       // forces promotion to the evac gen
                                    // instead of the to-space
                                    // corresponding to the object
 
-    W_ thunk_selector_depth;     // used to avoid unbounded recursion in 
+    W_ thunk_selector_depth;       // used to avoid unbounded recursion in
                                    // evacuate() for THUNK_SELECTOR
 
-#ifdef USE_PAPI
-    int papi_events;
-#endif
-
     // -------------------
     // stats