diff -uNr --exclude=CVS vprof-0.12/README.NCSA vprof-0.12-patched/README.NCSA --- vprof-0.12/README.NCSA Wed Dec 31 18:00:00 1969 +++ vprof-0.12-patched/README.NCSA Tue Dec 14 16:47:06 2004 @@ -0,0 +1,41 @@ +Files added: + ++ genpapi.c - A C program that generates an include file for VProf + to use (see below). This replaces the getpapi.pl + script in the VProf 0.12 distribution. To build the + program, compile as follows: + + gcc -I/path/to/papi/include -L/path/to/papi/lib \ + -o genpapi genpapi.c -lpapi + + Running the resulting executable "genpapi" should + produce the file "vmonpapi.h". + + You can optionally supply the flag "-n" to "genpapi" + if using PAPI 3. This will cause native events to be + included in the event lists that VProf recognizes. + Note that this may significantly increase compilation + time for Pentium 4 family systems. If you don't supply + this flag, only PAPI preset events will be used. + +Files changed: + ++ events.c - PAPI events are hard-coded in the distribution and do + not include all events. Replaced the hard-coded events + with an include file "vmonpapi.h" that can be created + with the above genpapi program. + ++ vmon.c - Added the ability to set threshold for hardware interrupt + on overflow through the environment variable VMON_FREQ. + Left the default at 1000. + - Adapted for compilation with either PAPI 2 or 3. + ++ configure.in - minor changes to use a more recent autoconf. You + may not need to concern yourself with this unless you + regenerate the configure script. + +The build process should be the same except for the need to generate +vmonpapi.h as described above. + +Rick Kufrin +NCSA/University of Illinois diff -uNr --exclude=CVS vprof-0.12/configure.in vprof-0.12-patched/configure.in --- vprof-0.12/configure.in Tue Feb 26 17:47:51 2002 +++ vprof-0.12-patched/configure.in Fri Aug 27 11:29:48 2004 @@ -5,7 +5,7 @@ define([CXX_CLEAN_REPOSITORY], [/bin/rm -rf cxx_repository]) AC_INIT(vconfig.h.in) -AC_PREREQ(2.12) +AC_PREREQ(2.57) AC_CONFIG_HEADER(vconfig.h) AC_CONFIG_AUX_DIR(bin) @@ -339,15 +339,21 @@ AC_CHECK_HEADER(bfd.h,AC_CHECK_LIB(bfd,bfd_openr)) AC_CHECK_HEADER(ldfcn.h,AC_CHECK_LIB(ld,ldopen)) -dnl check for mon.h, be careful that unistd.h and mon.h are compatible -AC_CHECK_HEADER(mon.h,[ -AC_TRY_LINK([ +# dnl check for mon.h, be careful that unistd.h and mon.h are compatible +# AC_CHECK_HEADER(mon.h,[ +# AC_TRY_LINK([ +# #include +# #include +# ],[ +# ],[ +# AC_SUBST(HAVE_MON_H) +# ]) +# ]) +AC_CHECK_HEADERS(unistd.h) +AC_CHECK_HEADERS(mon.h,[],[],[ +#if HAVE_UNISTD_H #include -#include -],[ -],[ -AC_SUBST(HAVE_MON_H) -]) +#endif ]) AC_MSG_CHECKING(profil data type) diff -uNr --exclude=CVS vprof-0.12/events.c vprof-0.12-patched/events.c --- vprof-0.12/events.c Wed Feb 6 18:25:26 2002 +++ vprof-0.12-patched/events.c Tue Feb 18 17:28:36 2003 @@ -30,134 +30,7 @@ static vmon_event_t vmon_events[] = { {VMON_PROF, 0, "PROF", "SVr4 profil"}, -{VMON_PAPI, PAPI_E(PAPI_L1_DCM), "PAPI_L1_DCM", - "Level 1 data cache misses"}, -{VMON_PAPI, PAPI_E(PAPI_L1_ICM), "PAPI_L1_ICM", - "Level 1 instruction cache misses"}, -{VMON_PAPI, PAPI_E(PAPI_L2_DCM), "PAPI_L2_DCM", - "Level 2 data cache misses"}, -{VMON_PAPI, PAPI_E(PAPI_L2_ICM), "PAPI_L2_ICM", - "Level 2 instruction cache misses"}, -{VMON_PAPI, PAPI_E(PAPI_L3_DCM), "PAPI_L3_DCM", - "Level 3 data cache misses"}, -{VMON_PAPI, PAPI_E(PAPI_L3_ICM), "PAPI_L3_ICM", - "Level 3 instruction cache misses"}, -{VMON_PAPI, PAPI_E(PAPI_L1_TCM), "PAPI_L1_TCM", - "Level 1 total cache misses"}, -{VMON_PAPI, PAPI_E(PAPI_L2_TCM), "PAPI_L2_TCM", - "Level 2 total cache misses"}, -{VMON_PAPI, PAPI_E(PAPI_L3_TCM), "PAPI_L3_TCM", - "Level 3 total cache misses"}, -{VMON_PAPI, PAPI_E(PAPI_CA_SNP), "PAPI_CA_SNP", - "Snoops"}, -{VMON_PAPI, PAPI_E(PAPI_CA_SHR), "PAPI_CA_SHR", - "Request access to shared cache line (SMP)"}, -{VMON_PAPI, PAPI_E(PAPI_CA_CLN), "PAPI_CA_CLN", - "Request access to clean cache line (SMP)"}, -{VMON_PAPI, PAPI_E(PAPI_CA_INV), "PAPI_CA_INV", - "Cache Line Invalidation (SMP)"}, -{VMON_PAPI, PAPI_E(PAPI_CA_ITV), "PAPI_CA_ITV", - "Cache Line Intervention (SMP)"}, -{VMON_PAPI, PAPI_E(PAPI_L3_LDM), "PAPI_L3_LDM", - "Level 3 load misses "}, -{VMON_PAPI, PAPI_E(PAPI_L3_STM), "PAPI_L3_STM", - "Level 3 store misses "}, -{VMON_PAPI, PAPI_E(PAPI_BRU_IDL), "PAPI_BRU_IDL", - "Cycles branch units are idle"}, -{VMON_PAPI, PAPI_E(PAPI_FXU_IDL), "PAPI_FXU_IDL", - "Cycles integer units are idle"}, -{VMON_PAPI, PAPI_E(PAPI_FPU_IDL), "PAPI_FPU_IDL", - "Cycles floating point units are idle"}, -{VMON_PAPI, PAPI_E(PAPI_LSU_IDL), "PAPI_LSU_IDL", - "Cycles load/store units are idle"}, -{VMON_PAPI, PAPI_E(PAPI_TLB_DM), "PAPI_TLB_DM", - "Data translation lookaside buffer misses"}, -{VMON_PAPI, PAPI_E(PAPI_TLB_IM), "PAPI_TLB_IM", - "Instr translation lookaside buffer misses"}, -{VMON_PAPI, PAPI_E(PAPI_TLB_TL), "PAPI_TLB_TL", - "Total translation lookaside buffer misses"}, -{VMON_PAPI, PAPI_E(PAPI_L1_LDM), "PAPI_L1_LDM", - "Level 1 load misses "}, -{VMON_PAPI, PAPI_E(PAPI_L1_STM), "PAPI_L1_STM", - "Level 1 store misses "}, -{VMON_PAPI, PAPI_E(PAPI_L2_LDM), "PAPI_L2_LDM", - "Level 2 load misses "}, -{VMON_PAPI, PAPI_E(PAPI_L2_STM), "PAPI_L2_STM", - "Level 2 store misses "}, -{VMON_PAPI, PAPI_E(PAPI_L1_DCH), "PAPI_L1_DCH", - "Level 1 D cache hits"}, -{VMON_PAPI, PAPI_E(PAPI_L2_DCH), "PAPI_L2_DCH", - "Level 2 D cache hits"}, -{VMON_PAPI, PAPI_E(PAPI_L3_DCH), "PAPI_L3_DCH", - "Level 3 D cache hits"}, -{VMON_PAPI, PAPI_E(PAPI_TLB_SD), "PAPI_TLB_SD", - "Xlation lookaside buffer shootdowns (SMP)"}, -{VMON_PAPI, PAPI_E(PAPI_CSR_FAL), "PAPI_CSR_FAL", - "Failed store conditional instructions"}, -{VMON_PAPI, PAPI_E(PAPI_CSR_SUC), "PAPI_CSR_SUC", - "Successful store conditional instructions"}, -{VMON_PAPI, PAPI_E(PAPI_CSR_TOT), "PAPI_CSR_TOT", - "Total store conditional instructions"}, -{VMON_PAPI, PAPI_E(PAPI_MEM_SCY), "PAPI_MEM_SCY", - "Cycles Stalled Waiting for Memory Access"}, -{VMON_PAPI, PAPI_E(PAPI_MEM_RCY), "PAPI_MEM_RCY", - "Cycles Stalled Waiting for Memory Read"}, -{VMON_PAPI, PAPI_E(PAPI_MEM_WCY), "PAPI_MEM_WCY", - "Cycles Stalled Waiting for Memory Write"}, -{VMON_PAPI, PAPI_E(PAPI_STL_ICY), "PAPI_STL_ICY", - "Cycles with No Instruction Issue"}, -{VMON_PAPI, PAPI_E(PAPI_FUL_ICY), "PAPI_FUL_ICY", - "Cycles with Maximum Instruction Issue"}, -{VMON_PAPI, PAPI_E(PAPI_STL_CCY), "PAPI_STL_CCY", - "Cycles with No Instruction Completion"}, -{VMON_PAPI, PAPI_E(PAPI_FUL_CCY), "PAPI_FUL_CCY", - "Cycles with Maximum Instruction Completion"}, -{VMON_PAPI, PAPI_E(PAPI_HW_INT), "PAPI_HW_INT", - "Hardware interrupts "}, -{VMON_PAPI, PAPI_E(PAPI_BR_UCN), "PAPI_BR_UCN", - "Unconditional branch instructions executed"}, -{VMON_PAPI, PAPI_E(PAPI_BR_CN), "PAPI_BR_CN", - "Conditional branch instructions executed"}, -{VMON_PAPI, PAPI_E(PAPI_BR_TKN), "PAPI_BR_TKN", - "Conditional branch instructions taken"}, -{VMON_PAPI, PAPI_E(PAPI_BR_NTK), "PAPI_BR_NTK", - "Conditional branch instructions not taken"}, -{VMON_PAPI, PAPI_E(PAPI_BR_MSP), "PAPI_BR_MSP", - "Conditional branch instructions mispred"}, -{VMON_PAPI, PAPI_E(PAPI_BR_PRC), "PAPI_BR_PRC", - "Conditional branch instructions corr. pred"}, -{VMON_PAPI, PAPI_E(PAPI_FMA_INS), "PAPI_FMA_INS", - "FMA instructions completed"}, -{VMON_PAPI, PAPI_E(PAPI_TOT_IIS), "PAPI_TOT_IIS", - "Total instructions issued"}, -{VMON_PAPI, PAPI_E(PAPI_TOT_INS), "PAPI_TOT_INS", - "Total instructions executed"}, -{VMON_PAPI, PAPI_E(PAPI_INT_INS), "PAPI_INT_INS", - "Integer instructions executed"}, -{VMON_PAPI, PAPI_E(PAPI_FP_INS), "PAPI_FP_INS", - "Floating point instructions executed"}, -{VMON_PAPI, PAPI_E(PAPI_LD_INS), "PAPI_LD_INS", - "Load instructions executed"}, -{VMON_PAPI, PAPI_E(PAPI_SR_INS), "PAPI_SR_INS", - "Store instructions executed"}, -{VMON_PAPI, PAPI_E(PAPI_BR_INS), "PAPI_BR_INS", - "Total branch instructions executed"}, -{VMON_PAPI, PAPI_E(PAPI_VEC_INS), "PAPI_VEC_INS", - "Vector/SIMD instructions executed"}, -{VMON_PAPI, PAPI_E(PAPI_FLOPS), "PAPI_FLOPS", - "Floating Point instructions per second"}, -{VMON_PAPI, PAPI_E(PAPI_RES_STL), "PAPI_RES_STL", - "Any resource stalls"}, -{VMON_PAPI, PAPI_E(PAPI_FP_STAL), "PAPI_FP_STAL", - "FP units are stalled "}, -{VMON_PAPI, PAPI_E(PAPI_TOT_CYC), "PAPI_TOT_CYC", - "Total cycles"}, -{VMON_PAPI, PAPI_E(PAPI_IPS), "PAPI_IPS", - "Instructions executed per second"}, -{VMON_PAPI, PAPI_E(PAPI_LST_INS), "PAPI_LST_INS", - "Total load/store inst. executed"}, -{VMON_PAPI, PAPI_E(PAPI_SYC_INS), "PAPI_SYC_INS", - "Sync. inst. executed "}, +#include "vmonpapi.h" {VMON_P6, PERFCTR_E(P6_DATA_MEM_REFS), "P6_DATA_MEM_REFS", "all memory references, cachable and noncachable"}, {VMON_P6, PERFCTR_E(P6_DCU_LINES_IN), "P6_DCU_LINES_IN", diff -uNr --exclude=CVS vprof-0.12/genpapi.c vprof-0.12-patched/genpapi.c --- vprof-0.12/genpapi.c Wed Dec 31 18:00:00 1969 +++ vprof-0.12-patched/genpapi.c Tue Dec 14 16:37:23 2004 @@ -0,0 +1,107 @@ +/* + * genpapi.c : generate VProf definitions for all PAPI standard + * events. If using PAPI 3 and the optional flag "-n" + * is given, also generate definitions for native events. + * + * This program should be run before compiling VProf. + * It writes a header file that is included in events.c, + * which is in turn included by vmon.c. + * + * Only compile and run if you have PAPI on your + * system and be sure to include the proper "-I", + * "-L" directories for PAPI as well as -lpapi. + * + * Author: Rick Kufrin + * University of Illinois/NCSA + * + * Date: 2/18/2003 + * + * Modified: 8/27/2004 - PAPI 3 support + * 12/14/2004 - Added support for native events + * + */ + +#include +#include + +#define VMONPAPI_HEADER "vmonpapi.h" + +#if defined(PAPI_VERSION) +# define PAPI3 1 +#endif + +int +main(int argc, char **argv) +{ + FILE *fp; + int papi_ret, i; +#ifdef PAPI3 + PAPI_event_info_t info; + int do_native = 0; +#else + const PAPI_preset_info_t *info; +#endif + +#ifdef PAPI3 + if ( argc > 1 ) { + if ( strcmp(argv[1], "-n") == 0 ) { + do_native = 1; + } + else { + fprintf(stderr, "Usage: %s [-n]\n", argv[0]); + exit(1); + } + } +#endif + + fp = fopen(VMONPAPI_HEADER, "w"); + if ( fp == NULL ) { + perror(VMONPAPI_HEADER); + exit(1); + } + + papi_ret = PAPI_library_init(PAPI_VER_CURRENT); + + if ( papi_ret != PAPI_VER_CURRENT ) { + fputs("Error: PAPI library version mismatch.\n", stderr); + exit(1); + } + +#ifdef PAPI3 + i = PAPI_PRESET_MASK; + do { + if ( PAPI_get_event_info(i, &info) == PAPI_OK ) { + fprintf(fp, "{VMON_PAPI, PAPI_E(%s), \"%s\",\n", + info.symbol, info.symbol); + fprintf(fp, "%25s\"%s\"},\n", "", info.long_descr); + } + } while ( PAPI_enum_event(&i, 0) == PAPI_OK ); + + if ( do_native ) { + i = PAPI_NATIVE_MASK; + do { + if ( PAPI_get_event_info(i, &info) == PAPI_OK ) { + fprintf(fp, "{VMON_PAPI, %u, \"%s\",\n", + info.event_code, info.symbol); + fprintf(fp, "%25s\"(native event)\"},\n", ""); + } + } while ( PAPI_enum_event(&i, 0) == PAPI_OK ); + } +#else + info = PAPI_query_all_events_verbose(); + if ( info == NULL ) { + fputs("Error: could not retrieve PAPI event information.\n", stderr); + exit(1); + } + + for ( i = 0; info[i].event_name; i++ ) { + fprintf(fp, "{VMON_PAPI, PAPI_E(%s), \"%s\",\n", + info[i].event_name, info[i].event_name); + fprintf(fp, "%25s\"%s\"},\n", "", info[i].event_descr); + } +#endif + + fclose(fp); + + exit(0); +} diff -uNr --exclude=CVS vprof-0.12/qprof.cc vprof-0.12-patched/qprof.cc --- vprof-0.12/qprof.cc Tue Feb 26 18:07:52 2002 +++ vprof-0.12-patched/qprof.cc Tue Dec 14 17:03:50 2004 @@ -273,7 +273,7 @@ { if (!item) return; int ncountdisp = summary_.nvisible(); - string name(item->text(ncountdisp)); + string name(item->text(ncountdisp).ascii()); namemap::const_iterator in; in = n.find(name); if (in == n.end()) return; @@ -531,7 +531,7 @@ string exec; vector vmons; get_gui_values(exec,vmons); - vmons.push_back(string(filename)); + vmons.push_back(string(filename.ascii())); set_gui_values(exec,vmons); } } @@ -563,10 +563,10 @@ void ProfileFiles::get_gui_values(string &exec,vector& vmons) { - exec = execfield_->text(); + exec = execfield_->text().ascii(); vmons.clear(); for (int i=0; i < vmonlist_->count(); i++) { - vmons.push_back(string(vmonlist_->text(i))); + vmons.push_back(string(vmonlist_->text(i).ascii())); } sort(vmons.begin(),vmons.end()); } diff -uNr --exclude=CVS vprof-0.12/vmon.c vprof-0.12-patched/vmon.c --- vprof-0.12/vmon.c Wed Feb 6 18:22:56 2002 +++ vprof-0.12-patched/vmon.c Tue Dec 14 16:37:08 2004 @@ -18,6 +18,9 @@ #ifdef HAVE_PAPI static int eventset = PAPI_NULL; static int n_papi = 0; +# if defined(PAPI_VERSION) +# define PAPI3 1 +# endif #endif static void @@ -89,6 +92,8 @@ static void begin_papi(vmon_event_data_t *event_data) { + const char *envfreq; + int freq = 1000; unsigned int scale = 0x8000; vmon_begin_generic(event_data); @@ -98,6 +103,10 @@ abort(); } + if ((envfreq = getenv("VMON_FREQ")) != NULL) { + freq = atoi(envfreq); + } + if (PAPI_num_counters() <= n_papi) return; @@ -107,13 +116,23 @@ if (PAPI_create_eventset(&eventset) != PAPI_OK) return; +#ifdef PAPI3 + if (PAPI_add_event(eventset, event_data->event->event_type) != PAPI_OK) +#else if (PAPI_add_event(&eventset, event_data->event->event_type) != PAPI_OK) +#endif return; - if (PAPI_profil(event_data->buffer, sizeof(unsigned short)*event_data->size, - event_data->offset, scale, + if (PAPI_profil((void *) event_data->buffer, + sizeof(unsigned short) * event_data->size, +#ifdef PAPI3 + (caddr_t) event_data->offset, +#else + event_data->offset, +#endif + scale, eventset, event_data->event->event_type, - 1000, PAPI_PROFIL_POSIX) != PAPI_OK) + freq, PAPI_PROFIL_POSIX) != PAPI_OK) return; if (PAPI_start(eventset) != PAPI_OK) return; @@ -254,9 +273,17 @@ PAPI_stop(eventset, ct); +#ifdef PAPI3 + PAPI_remove_event(eventset, event_data->event->event_type); +#else PAPI_rem_event(&eventset, event_data->event->event_type); +#endif +#ifdef PAPI3 + PAPI_cleanup_eventset(eventset); +#else PAPI_cleanup_eventset(&eventset); +#endif PAPI_destroy_eventset(&eventset);