diff --git a/SOURCES/papi-bz1263666.patch b/SOURCES/papi-bz1263666.patch new file mode 100644 index 0000000..7942c3a --- /dev/null +++ b/SOURCES/papi-bz1263666.patch @@ -0,0 +1,50 @@ +commit ba5ef24a0c27c667a7de6d40eb396aeaa0f1cc41 +Author: Asim YarKhan +Date: Wed Oct 22 13:35:43 2014 -0400 + + PPC64, fix L1 data cache read, write and all access equations. + + Thanks to Carl Love for this patch and the following documentation: + + The current POWER 7 equations for all accesses over counts because it + includes non load accesses to the cache. The equation was changed to + be the sum of the reads and the writes. The read accesses to the two + units, can be counted with the single event PM_LD_REF_L1 rather then + counting the events to the two LSU units independently. The number of + reads to the L1 must be adjusted by subtracting the misses as these + become writes. + + Power 8 has four LSU units. The same equations can be used since + PM_LD_REF_L1 counts across all four LSU units. + +diff --git a/src/papi_events.csv b/src/papi_events.csv +index 73a72e7..d27a41d 100644 +--- a/src/papi_events.csv ++++ b/src/papi_events.csv +@@ -1307,10 +1307,9 @@ CPU,power7 + PRESET,PAPI_L1_DCM,DERIVED_ADD,PM_LD_MISS_L1,PM_ST_MISS_L1 + PRESET,PAPI_L1_LDM,NOT_DERIVED,PM_LD_MISS_L1 + PRESET,PAPI_L1_STM,NOT_DERIVED,PM_ST_MISS_L1 +-PRESET,PAPI_L1_DCW,DERIVED_POSTFIX,N0|N1|-|,PM_ST_FIN,PM_ST_MISS_L1 +-PRESET,PAPI_L1_DCA,NOT_DERIVED,PM_LSU_FIN +-#PRESET,PAPI_L1_DCA,DERIVED_POSTFIX,N0|N1|-|N2|+|,PM_ST_FIN,PM_ST_MISS_L1,PM_LD_REF_L1 +-PRESET,PAPI_L1_DCR,DERIVED_ADD,PM_LD_REF_L1_LSU0,PM_LD_REF_L1_LSU1 ++PRESET,PAPI_L1_DCW,DERIVED_SUB,PM_ST_FIN,PM_ST_MISS_L1 ++PRESET,PAPI_L1_DCR,DERIVED_SUB,PM_LD_REF_L1,PM_LD_MISS_L1 ++PRESET,PAPI_L1_DCA,DERIVED_POSTFIX,N0|N1|+|N2|+|N3|+,PM_ST_FIN,PM_ST_MISS_L1,PM_LD_REF_L1,PM_LD_MISS_L1 + PRESET,PAPI_L2_DCM,NOT_DERIVED,PM_DATA_FROM_L2MISS + PRESET,PAPI_L2_LDM,NOT_DERIVED,PM_L2_LD_MISS + PRESET,PAPI_L2_STM,NOT_DERIVED,PM_L2_ST_MISS +@@ -1357,9 +1356,9 @@ CPU,power8 + PRESET,PAPI_L1_DCM,DERIVED_ADD,PM_LD_MISS_L1,PM_ST_MISS_L1 + PRESET,PAPI_L1_LDM,NOT_DERIVED,PM_LD_MISS_L1 + PRESET,PAPI_L1_STM,NOT_DERIVED,PM_ST_MISS_L1 +-PRESET,PAPI_L1_DCW,DERIVED_POSTFIX,N0|N1|-|,PM_ST_FIN,PM_ST_MISS_L1 +-#n/aPRESET,PAPI_L1_DCA,DERIVED_POSTFIX,N0|N1|-|N2|+|,PM_ST_FIN,PM_ST_MISS_L1,PM_LD_REF_L1 +-#n/aPRESET,PAPI_L1_DCR,DERIVED_ADD,PM_LD_REF_L1_LSU0,PM_LD_REF_L1_LSU1 ++PRESET,PAPI_L1_DCW,DERIVED_SUB,PM_ST_FIN,PM_ST_MISS_L1 ++PRESET,PAPI_L1_DCR,DERIVED_SUB,PM_LD_REF_L1,PM_LD_MISS_L1 ++PRESET,PAPI_L1_DCA,DERIVED_POSTFIX,N0|N1|+|N2|+|N3|+,PM_ST_FIN,PM_ST_MISS_L1,PM_LD_REF_L1,PM_LD_MISS_L1 + PRESET,PAPI_L2_DCM,NOT_DERIVED,PM_DATA_FROM_L2MISS + #n/aPRESET,PAPI_L2_LDM,NOT_DERIVED,PM_L2_LD_MISS + #n/aPRESET,PAPI_L2_STM,NOT_DERIVED,PM_L2_ST_MISS diff --git a/SOURCES/papi-bz1277931.patch b/SOURCES/papi-bz1277931.patch new file mode 100644 index 0000000..b42eb40 --- /dev/null +++ b/SOURCES/papi-bz1277931.patch @@ -0,0 +1,19 @@ +commit 8914dcfcfdc013efcf44a242048ae94c82639fef +Author: sangamesh +Date: Thu Apr 16 16:38:15 2015 -0400 + + Bug reported by William Cohen in papi_events.csv for the event PAPI_L1_TCM + +diff --git a/src/papi_events.csv b/src/papi_events.csv +index e339f0e..07cbc4f 100644 +--- a/src/papi_events.csv ++++ b/src/papi_events.csv +@@ -649,7 +649,7 @@ PRESET,PAPI_L1_ICM,NOT_DERIVED,L2_RQSTS:ALL_CODE_RD + PRESET,PAPI_L1_DCM,NOT_DERIVED,L1D:REPLACEMENT + PRESET,PAPI_L1_LDM,NOT_DERIVED,L2_TRANS:DEMAND_DATA_RD + PRESET,PAPI_L1_STM,NOT_DERIVED,L2_TRANS:L1D_WB +-PRESET,PAPI_L1_TCM,DERIVED_ADD,L2_RQSTS:ALL_DEMAND_REFERENCES,L2_RQSTS:ALL_CODE_RD ++PRESET,PAPI_L1_TCM,DERIVED_ADD,L1D:REPLACEMENT,L2_RQSTS:ALL_CODE_RD + # L2 cache + PRESET,PAPI_L2_DCA,NOT_DERIVED,L2_RQSTS:ALL_DEMAND_REFERENCES + #PRESET,PAPI_L2_DCH,NOT_DERIVED,L2_RQSTS:DEMAND_DATA_RD_HIT diff --git a/SOURCES/papi-bz1313088.patch b/SOURCES/papi-bz1313088.patch new file mode 100644 index 0000000..5f5d5a3 --- /dev/null +++ b/SOURCES/papi-bz1313088.patch @@ -0,0 +1,68 @@ +From 88f6669fa358bf4670d91e379f469e3cd3016543 Mon Sep 17 00:00:00 2001 +From: William Cohen +Date: Tue, 21 Jun 2016 10:53:32 -0400 +Subject: [PATCH 1/2] Have Fortran test support code report errors more clearly + +When a Fortran test called the ftest_skip or ftest_fail the support +code would attempt to print out error strings. However, this support +code would print out gibberish because the string was not properly +initialized. There doesn't seem to be a easy way in Fortran to get +the error string, for the time being just print out the error number +and people will need to manually map it back to the string. + +Signed-off-by: William Cohen +--- + src/ftests/ftests_util.F | 14 ++++++-------- + 1 file changed, 6 insertions(+), 8 deletions(-) + +diff --git a/src/ftests/ftests_util.F b/src/ftests/ftests_util.F +index 83433f9..8de2bd1 100644 +--- a/src/ftests/ftests_util.F ++++ b/src/ftests/ftests_util.F +@@ -108,7 +108,6 @@ C And also to make the test code read cleaner + integer line + character*(*) callstr + integer retval,ilen +- character*(PAPI_MAX_STR_LEN) papi_errstr + integer last_char + external last_char + +@@ -134,10 +133,10 @@ C And also to make the test code read cleaner + else if(retval.eq.0)then + write(*,*) 'SGI requires root permissions for this test' + else +- call PAPIF_perror( ) ++C Just printing the error number because of difficulty getting error string. + ilen=last_char(callstr) +- write(*,'(T2,3a)') 'PAPI error in ', callstr(1:ilen), +- * ': '// papi_errstr(1:last_char(papi_errstr)) ++ write(*,'(T2,3a,I3)') 'PAPI error in ', callstr(1:ilen), ++ * ': ', retval + end if + call pause() + stop +@@ -153,7 +152,6 @@ C And also to make the test code read cleaner + integer quiet + common quiet + +- character*(PAPI_MAX_STR_LEN) papi_errstr + integer last_char + external last_char + +@@ -165,10 +163,10 @@ C And also to make the test code read cleaner + else if (retval.gt.0) then + write(*,*) "Error calculating: ", callstr + else +- call PAPIF_perror( ) ++C Just printing the error number because of difficulty getting error string. + ilen=last_char(callstr) +- write(*,'(T2,3a)') 'Error in ', callstr(1:ilen), +- * ': ' // papi_errstr(1:last_char(papi_errstr)) ++ write(*,'(T2,3a,I3)') 'Error in ', callstr(1:ilen), ++ * ': ', retval + end if + end if + call pause() +-- +1.8.3.1 + diff --git a/SOURCES/papi-bz1326977.patch b/SOURCES/papi-bz1326977.patch new file mode 100644 index 0000000..73d23cd --- /dev/null +++ b/SOURCES/papi-bz1326977.patch @@ -0,0 +1,73 @@ +commit 547f44124e1a38b8c5c635f673d88054ce6ff0d3 +Author: Asim YarKhan +Date: Thu Oct 16 12:19:34 2014 -0400 + + byte_profile.c: PPC64 add support for PPC64 Little Endian to byte_profile.c + + Thanks to Carl Love for this patch and the following description: + The POWER 8 platform is Little Endian. It uses ELF + version 2 which does not use function descriptors. This + patch adds the needed #ifdef support to correctly compile + the test case for Big Endian or Little Endian. + + This patch is untested by the PAPI developers (hardware not easily accessible). + +diff --git a/src/ctests/byte_profile.c b/src/ctests/byte_profile.c +index 0f33c0d..f693e9f 100644 +--- a/src/ctests/byte_profile.c ++++ b/src/ctests/byte_profile.c +@@ -213,9 +213,14 @@ main( int argc, char **argv ) + /* Itanium and PowerPC64 processors return function descriptors instead + * of function addresses. You must dereference the descriptor to get the address. + */ +-#if defined(ITANIUM1) || defined(ITANIUM2) || defined(__powerpc64__) ++#if defined(ITANIUM1) || defined(ITANIUM2) \ ++ || (defined(__powerpc64__) && (_CALL_ELF != 2)) + start = ( caddr_t ) ( ( ( struct fdesc * ) start )->ip ); + end = ( caddr_t ) ( ( ( struct fdesc * ) end )->ip ); ++ /* PPC64 Big Endian is ELF version 1 which uses function descriptors. ++ * PPC64 Little Endian is ELF version 2 which does not use ++ * function descriptors ++ */ + #endif + + /* call dummy so it doesn't get optimized away */ +commit 14f70ebc77deaad4a3fc3f808613772ef1165137 +Author: Asim YarKhan +Date: Wed Oct 15 14:48:05 2014 -0400 + + PPC64 add support for PPC64 Little Endian to sprofile.c + + Thanks to Carl Love for this patch and the following description: + The POWER 8 platform is Little Endian. It uses ELF + version 2 which does not use function descriptors. This + patch adds the needed #ifdef support to correctly compile + the test case for Big Endian or Little Endian. + +diff --git a/src/ctests/sprofile.c b/src/ctests/sprofile.c +index e7ee47a..4bd7cc7 100644 +--- a/src/ctests/sprofile.c ++++ b/src/ctests/sprofile.c +@@ -1,4 +1,4 @@ +-/* ++/* + * File: sprofile.c + * Author: Philip Mucci + * mucci@cs.utk.edu +@@ -10,10 +10,15 @@ + + /* These architectures use Function Descriptors as Function Pointers */ + +-#if (defined(linux) && defined(__ia64__)) || (defined(_AIX)) ||(defined(__powerpc64__)) ++#if (defined(linux) && defined(__ia64__)) || (defined(_AIX)) \ ++ || ((defined(__powerpc64__) && (_CALL_ELF != 2))) ++/* PPC64 Big Endian is ELF version 1 which uses function descriptors */ + #define DO_READS (unsigned long)(*(void **)do_reads) + #define DO_FLOPS (unsigned long)(*(void **)do_flops) + #else ++/* PPC64 Little Endian is ELF version 2 which does not use ++ * function descriptors ++ */ + #define DO_READS (unsigned long)(do_reads) + #define DO_FLOPS (unsigned long)(do_flops) + #endif diff --git a/SOURCES/papi-errmsg.patch b/SOURCES/papi-errmsg.patch new file mode 100644 index 0000000..88841e9 --- /dev/null +++ b/SOURCES/papi-errmsg.patch @@ -0,0 +1,242 @@ +commit a37160c18eb8106a2b61ed181e2479a83381f3dc +Author: James Ralph +Date: Fri Jul 25 15:59:41 2014 -0400 + + perf_event.c: cleanup error messages + + Thanks to Gary Mohr + ------------------- + This patch contains general cleanup code. Calls to PAPIERROR pass a string which does + not need to end with a new line because this function will always add one. New lines at + the end of strings passed to this function have been removed. These changes also add + some additional debug messages. + +diff --git a/src/components/perf_event/perf_event.c b/src/components/perf_event/perf_event.c +index 049c810..3eea38d 100644 +--- a/src/components/perf_event/perf_event.c ++++ b/src/components/perf_event/perf_event.c +@@ -300,11 +300,10 @@ sys_perf_event_open( struct perf_event_attr *hw_event, pid_t pid, int cpu, + { + int ret; + +- SUBDBG("sys_perf_event_open(%p,%d,%d,%d,%lx\n",hw_event,pid,cpu,group_fd,flags); ++ SUBDBG("sys_perf_event_open(hw_event: %p, pid: %d, cpu: %d, group_fd: %d, flags: %lx\n", hw_event, pid, cpu, group_fd, flags); + SUBDBG(" type: %d\n",hw_event->type); + SUBDBG(" size: %d\n",hw_event->size); +- SUBDBG(" config: %"PRIx64" (%"PRIu64")\n",hw_event->config, +- hw_event->config); ++ SUBDBG(" config: %"PRIx64" (%"PRIu64")\n",hw_event->config, hw_event->config); + SUBDBG(" sample_period: %"PRIu64"\n",hw_event->sample_period); + SUBDBG(" sample_type: %"PRIu64"\n",hw_event->sample_type); + SUBDBG(" read_format: %"PRIu64"\n",hw_event->read_format); +@@ -323,6 +322,21 @@ sys_perf_event_open( struct perf_event_attr *hw_event, pid_t pid, int cpu, + SUBDBG(" enable_on_exec: %d\n",hw_event->enable_on_exec); + SUBDBG(" task: %d\n",hw_event->task); + SUBDBG(" watermark: %d\n",hw_event->watermark); ++ SUBDBG(" precise_ip: %d\n",hw_event->precise_ip); ++ SUBDBG(" mmap_data: %d\n",hw_event->mmap_data); ++ SUBDBG(" sample_id_all: %d\n",hw_event->sample_id_all); ++ SUBDBG(" exclude_host: %d\n",hw_event->exclude_host); ++ SUBDBG(" exclude_guest: %d\n",hw_event->exclude_guest); ++ SUBDBG(" exclude_callchain_kernel: %d\n",hw_event->exclude_callchain_kernel); ++ SUBDBG(" exclude_callchain_user: %d\n",hw_event->exclude_callchain_user); ++ SUBDBG(" wakeup_events: %"PRIx32" (%"PRIu32")\n", hw_event->wakeup_events, hw_event->wakeup_events); ++ SUBDBG(" bp_type: %"PRIx32" (%"PRIu32")\n", hw_event->bp_type, hw_event->bp_type); ++ SUBDBG(" config1: %"PRIx64" (%"PRIu64")\n", hw_event->config1, hw_event->config1); ++ SUBDBG(" config2: %"PRIx64" (%"PRIu64")\n", hw_event->config2, hw_event->config2); ++ SUBDBG(" branch_sample_type: %"PRIx64" (%"PRIu64")\n", hw_event->branch_sample_type, hw_event->branch_sample_type); ++ SUBDBG(" sample_regs_user: %"PRIx64" (%"PRIu64")\n", hw_event->sample_regs_user, hw_event->sample_regs_user); ++ SUBDBG(" sample_stack_user: %"PRIx32" (%"PRIu32")\n", hw_event->sample_stack_user, hw_event->sample_stack_user); ++ + ret = + syscall( __NR_perf_event_open, hw_event, pid, cpu, group_fd, flags ); + SUBDBG("Returned %d %d %s\n",ret, +@@ -470,14 +484,14 @@ check_scheduability( pe_context_t *ctx, pe_control_t *ctl, int idx ) + /* start the event */ + retval = ioctl( group_leader_fd, PERF_EVENT_IOC_ENABLE, NULL ); + if (retval == -1) { +- PAPIERROR("ioctl(PERF_EVENT_IOC_ENABLE) failed.\n"); ++ PAPIERROR("ioctl(PERF_EVENT_IOC_ENABLE) failed"); + return PAPI_ESYS; + } + + /* stop the event */ + retval = ioctl(group_leader_fd, PERF_EVENT_IOC_DISABLE, NULL ); + if (retval == -1) { +- PAPIERROR( "ioctl(PERF_EVENT_IOC_DISABLE) failed.\n" ); ++ PAPIERROR( "ioctl(PERF_EVENT_IOC_DISABLE) failed" ); + return PAPI_ESYS; + } + +@@ -514,7 +528,7 @@ check_scheduability( pe_context_t *ctx, pe_control_t *ctl, int idx ) + retval=ioctl( ctl->events[i].event_fd, PERF_EVENT_IOC_RESET, NULL ); + if (retval == -1) { + PAPIERROR( "ioctl(PERF_EVENT_IOC_RESET) #%d/%d %d " +- "(fd %d)failed.\n", ++ "(fd %d)failed", + i,ctl->num_events,idx,ctl->events[i].event_fd); + return PAPI_ESYS; + } +@@ -794,7 +808,7 @@ close_pe_events( pe_context_t *ctx, pe_control_t *ctl ) + if (ctl->num_events!=num_closed) { + if (ctl->num_events!=(num_closed+events_not_opened)) { + PAPIERROR("Didn't close all events: " +- "Closed %d Not Opened: %d Expected %d\n", ++ "Closed %d Not Opened: %d Expected %d", + num_closed,events_not_opened,ctl->num_events); + return PAPI_EBUG; + } +@@ -824,9 +838,7 @@ _pe_set_domain( hwd_control_state_t *ctl, int domain) + int i; + pe_control_t *pe_ctl = ( pe_control_t *) ctl; + +- SUBDBG("old control domain %d, new domain %d\n", +- pe_ctl->domain,domain); +- ++ SUBDBG("old control domain %d, new domain %d\n", pe_ctl->domain,domain); + pe_ctl->domain = domain; + + /* Force the domain on all events */ +@@ -915,6 +927,8 @@ int + _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl, + long long **events, int flags ) + { ++ SUBDBG("ENTER: ctx: %p, ctl: %p, events: %p, flags: %#x\n", ctx, ctl, events, flags); ++ + ( void ) flags; /*unused */ + int i, ret = -1; + pe_context_t *pe_ctx = ( pe_context_t *) ctx; +@@ -964,7 +978,7 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl, + + /* We should read 3 64-bit values from the counter */ + if (ret<(signed)(3*sizeof(long long))) { +- PAPIERROR("Error! short read!\n"); ++ PAPIERROR("Error! short read"); + return PAPI_ESYS; + } + +@@ -1020,8 +1034,8 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl, + + /* we should read one 64-bit value from each counter */ + if (ret!=sizeof(long long)) { +- PAPIERROR("Error! short read!\n"); +- PAPIERROR("read: fd: %2d, tid: %ld, cpu: %d, ret: %d\n", ++ PAPIERROR("Error! short read"); ++ PAPIERROR("read: fd: %2d, tid: %ld, cpu: %d, ret: %d", + pe_ctl->events[i].event_fd, + (long)pe_ctl->tid, pe_ctl->cpu, ret); + return PAPI_ESYS; +@@ -1042,7 +1056,7 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl, + + else { + if (pe_ctl->events[0].group_leader_fd!=-1) { +- PAPIERROR("Was expecting group leader!\n"); ++ PAPIERROR("Was expecting group leader"); + } + + ret = read( pe_ctl->events[0].event_fd, papi_pe_buffer, +@@ -1056,7 +1070,7 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl, + /* we read 1 64-bit value (number of events) then */ + /* num_events more 64-bit values that hold the counts */ + if (ret<(signed)((1+pe_ctl->num_events)*sizeof(long long))) { +- PAPIERROR("Error! short read!\n"); ++ PAPIERROR("Error! short read"); + return PAPI_ESYS; + } + +@@ -1072,7 +1086,7 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl, + + /* Make sure the kernel agrees with how many events we have */ + if (papi_pe_buffer[0]!=pe_ctl->num_events) { +- PAPIERROR("Error! Wrong number of events!\n"); ++ PAPIERROR("Error! Wrong number of events"); + return PAPI_ESYS; + } + +@@ -1106,6 +1120,7 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl, + /* point PAPI to the values we read */ + *events = pe_ctl->counts; + ++ SUBDBG("EXIT: *events: %p\n", *events); + return PAPI_OK; + } + +@@ -1134,7 +1149,7 @@ _pe_start( hwd_context_t *ctx, hwd_control_state_t *ctl ) + + /* ioctls always return -1 on failure */ + if (ret == -1) { +- PAPIERROR("ioctl(PERF_EVENT_IOC_ENABLE) failed.\n"); ++ PAPIERROR("ioctl(PERF_EVENT_IOC_ENABLE) failed"); + return PAPI_ESYS; + } + +@@ -1143,7 +1158,7 @@ _pe_start( hwd_context_t *ctx, hwd_control_state_t *ctl ) + } + + if (!did_something) { +- PAPIERROR("Did not enable any counters.\n"); ++ PAPIERROR("Did not enable any counters"); + return PAPI_EBUG; + } + +@@ -1157,6 +1172,7 @@ _pe_start( hwd_context_t *ctx, hwd_control_state_t *ctl ) + int + _pe_stop( hwd_context_t *ctx, hwd_control_state_t *ctl ) + { ++ SUBDBG( "ENTER: ctx: %p, ctl: %p\n", ctx, ctl); + + int ret; + int i; +@@ -1178,6 +1194,7 @@ _pe_stop( hwd_context_t *ctx, hwd_control_state_t *ctl ) + + pe_ctx->state &= ~PERF_EVENTS_RUNNING; + ++ SUBDBG( "EXIT:\n"); + return PAPI_OK; + } + +@@ -1190,6 +1207,7 @@ _pe_update_control_state( hwd_control_state_t *ctl, + NativeInfo_t *native, + int count, hwd_context_t *ctx ) + { ++ SUBDBG( "ENTER: ctl: %p, native: %p, count: %d, ctx: %p\n", ctl, native, count, ctx); + int i = 0, ret; + pe_context_t *pe_ctx = ( pe_context_t *) ctx; + pe_control_t *pe_ctl = ( pe_control_t *) ctl; +@@ -1202,7 +1220,7 @@ _pe_update_control_state( hwd_control_state_t *ctl, + /* Calling with count==0 should be OK, it's how things are deallocated */ + /* when an eventset is destroyed. */ + if ( count == 0 ) { +- SUBDBG( "Called with count == 0\n" ); ++ SUBDBG( "EXIT: Called with count == 0\n" ); + return PAPI_OK; + } + +@@ -1236,15 +1254,16 @@ _pe_update_control_state( hwd_control_state_t *ctl, + pe_ctl->num_events = count; + _pe_set_domain( ctl, pe_ctl->domain ); + +- /* actuall open the events */ ++ /* actually open the events */ + /* (why is this a separate function?) */ + ret = open_pe_events( pe_ctx, pe_ctl ); + if ( ret != PAPI_OK ) { +- SUBDBG("open_pe_events failed\n"); ++ SUBDBG("EXIT: open_pe_events returned: %d\n", ret); + /* Restore values ? */ + return ret; + } + ++ SUBDBG( "EXIT:\n" ); + return PAPI_OK; + } + +@@ -1914,7 +1933,7 @@ _pe_dispatch_timer( int n, hwd_siginfo_t *info, void *uc) + } + + if (ioctl( fd, PERF_EVENT_IOC_DISABLE, NULL ) == -1 ) { +- PAPIERROR("ioctl(PERF_EVENT_IOC_DISABLE) failed.\n"); ++ PAPIERROR("ioctl(PERF_EVENT_IOC_DISABLE) failed"); + } + + if ( ( thread->running_eventset[cidx]->state & PAPI_PROFILING ) && diff --git a/SOURCES/papi-postfixcalc.patch b/SOURCES/papi-postfixcalc.patch new file mode 100644 index 0000000..eb9b4ea --- /dev/null +++ b/SOURCES/papi-postfixcalc.patch @@ -0,0 +1,181 @@ +diff -up papi-5.2.0/src/papi_internal.c.postfix papi-5.2.0/src/papi_internal.c +--- papi-5.2.0/src/papi_internal.c.postfix 2016-07-25 14:25:09.331487358 -0400 ++++ papi-5.2.0/src/papi_internal.c 2016-07-25 14:27:17.271715363 -0400 +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + + #include "papi.h" + #include "papi_internal.h" +@@ -1840,89 +1841,90 @@ handle_derived_add_ps( int *position, lo + /* this function implement postfix calculation, it reads in a string where I use: + | as delimiter + N2 indicate No. 2 native event in the derived preset +- +, -, *, /, % as operator ++ +, -, *, / as operator + # as MHZ(million hz) got from _papi_hwi_system_info.hw_info.cpu_max_mhz*1000000.0 + + Haihang (you@cs.utk.edu) + */ +-static long long +-_papi_hwi_postfix_calc( EventInfo_t * evi, long long *hw_counter ) +-{ +- char *point = evi->ops, operand[16]; +- double stack[PAPI_EVENTS_IN_DERIVED_EVENT]; +- int i, top = 0; +- +- memset(&stack,0,PAPI_EVENTS_IN_DERIVED_EVENT*sizeof(double)); +- +- while ( *point != '\0' ) { +- if ( *point == 'N' ) { /* to get count for each native event */ +- i = 0; +- point++; +- do { +- operand[i] = *point; +- point++; +- i++; +- } while ( *point != '|' ); +- operand[i] = '\0'; +- stack[top] = ( double ) hw_counter[evi->pos[atoi( operand )]]; +- top++; +- point++; +- } else if ( *point == '#' ) { /* to get mhz, ignore the rest char's */ +- stack[top] = _papi_hwi_system_info.hw_info.cpu_max_mhz * 1000000.0; +- top++; +- do { +- point++; +- } while ( *point != '|' ); +- point++; +- } else if ( isdigit( *point ) ) { /* to get integer, I suppose only integer will be used, +- no error check here, please only use integer */ +- i = 0; +- do { +- operand[i] = *point; +- point++; +- i++; +- } while ( *point != '|' ); +- operand[i] = '\0'; +- stack[top] = atoi( operand ); +- top++; +- point++; +- } else if ( *point == '+' ) { /* + calculation */ +- stack[top - 2] += stack[top - 1]; +- top--; +- do { +- point++; +- } while ( *point != '|' ); +- point++; +- } else if ( *point == '-' ) { /* - calculation */ +- stack[top - 2] -= stack[top - 1]; +- top--; +- do { +- point++; +- } while ( *point != '|' ); +- point++; +- } else if ( *point == '*' ) { /* * calculation */ +- stack[top - 2] *= stack[top - 1]; +- top--; +- do { +- point++; +- } while ( *point != '|' ); +- point++; +- } else if ( *point == '/' ) { /* / calculation */ +- stack[top - 2] /= stack[top - 1]; +- top--; +- do { +- point++; +- } while ( *point != '|' ); +- point++; +- } else { /* do nothing */ +- do { +- point++; +- } while ( *point != '|' ); +- point++; +- } +- } +- return ( long long ) stack[0]; +-} ++ static long long ++ _papi_hwi_postfix_calc( EventInfo_t * evi, long long *hw_counter ) ++ { ++ char *point = evi->ops, operand[16]; ++ double stack[PAPI_EVENTS_IN_DERIVED_EVENT]; ++ int i, val, top = 0; ++ ++ INTDBG("ENTER: evi: %p, evi->ops: %p (%s), evi->pos[0]: %d, evi->pos[1]: %d, hw_counter: %p (%lld %lld)\n", ++ evi, evi->ops, evi->ops, evi->pos[0], evi->pos[1], hw_counter, hw_counter[0], hw_counter[1]); ++ ++ memset(&stack,0,PAPI_EVENTS_IN_DERIVED_EVENT*sizeof(double)); ++ ++ while ( *point != '\0' ) { ++ if ( *point == '|' ) { /* consume '|' characters */ ++ point++; ++ } else if ( *point == 'N' ) { /* to get count for each native event */ ++ point++; ++ i = 0; ++ while ( isdigit(*point) ) { ++ assert(i<16); ++ operand[i] = *point; ++ point++; ++ i++; ++ } ++ assert(0pos[val]]; ++ top++; ++ } else if ( *point == '#' ) { /* to get mhz */ ++ point++; ++ assert( top < PAPI_EVENTS_IN_DERIVED_EVENT ); ++ stack[top] = _papi_hwi_system_info.hw_info.cpu_max_mhz * 1000000.0; ++ top++; ++ } else if ( isdigit( *point ) ) { ++ i = 0; ++ while ( isdigit(*point) ) { ++ assert(i<16); ++ operand[i] = *point; ++ point++; ++ i++; ++ } ++ assert(0= 2); ++ stack[top - 2] += stack[top - 1]; ++ top--; ++ } else if ( *point == '-' ) { /* - calculation */ ++ point++; ++ assert(top >= 2); ++ stack[top - 2] -= stack[top - 1]; ++ top--; ++ } else if ( *point == '*' ) { /* * calculation */ ++ point++; ++ assert(top >= 2); ++ stack[top - 2] *= stack[top - 1]; ++ top--; ++ } else if ( *point == '/' ) { /* / calculation */ ++ point++; ++ assert(top >= 2); ++ /* FIXME should handle runtime divide by zero */ ++ stack[top - 2] /= stack[top - 1]; ++ top--; ++ } else { /* flag an error parsing the preset */ ++ PAPIERROR( "BUG! Unable to parse \"%s\"", evi->ops ); ++ return ( long long ) stack[0]; ++ } ++ } ++ assert(top == 1); ++ INTDBG("EXIT: stack[0]: %lld\n", (long long)stack[0]); ++ return ( long long ) stack[0]; ++ } + + static long long + handle_derived( EventInfo_t * evi, long long *from ) diff --git a/SOURCES/papi-schedule.patch b/SOURCES/papi-schedule.patch new file mode 100644 index 0000000..9c79623 --- /dev/null +++ b/SOURCES/papi-schedule.patch @@ -0,0 +1,198 @@ +commit 4718b4816fbb891c0adfca6412c99257c216e925 +Author: William Cohen +Date: Thu May 19 14:28:42 2016 -0400 + + Force all processors to check event schedulability by reading the counters + + There are situations where the perf_event_open syscall will return a + file descriptor for a set of events even when they cannot be scheduled + together. This occurs on 32-bit and 64-bit ARM processors and MIPS + processors. This problem also occurs on linux kernels older than + 2.6.33 and when the watchdog timer steals a performance counter. To + check that the performance counters are properly setup PAPI needs to + check that the counter values can be successfully read. Rather than + trying to avoid this test PAPI will now always do it. + + Signed-off-by: William Cohen + +diff --git a/src/components/perf_event/perf_event.c b/src/components/perf_event/perf_event.c +index d9c2c77..5698173 100644 +--- a/src/components/perf_event/perf_event.c ++++ b/src/components/perf_event/perf_event.c +@@ -58,9 +58,6 @@ + #define PERF_EVENTS_OPENED 0x01 + #define PERF_EVENTS_RUNNING 0x02 + +-/* Static globals */ +-int nmi_watchdog_active; +- + /* Forward declaration */ + papi_vector_t _perf_event_vector; + +@@ -180,34 +177,6 @@ pe_vendor_fixups(papi_vector_t *vector) + /******** Kernel Version Dependent Routines **********************/ + /******************************************************************/ + +-/* KERNEL_CHECKS_SCHEDUABILITY_UPON_OPEN is a work-around for kernel arch +- * implementations (e.g. x86) which don't do a static event scheduability +- * check in sys_perf_event_open. +- * This was fixed for x86 in the 2.6.33 kernel +- * +- * Also! Kernels newer than 2.6.34 will fail in a similar way +- * if the nmi_watchdog has stolen a performance counter +- * and we try to use the maximum number of counters. +- * A sys_perf_event_open() will seem to succeed but will fail +- * at read time. So re-use this work around code. +- */ +-static int +-bug_check_scheduability(void) { +- +-#if defined(__powerpc__) +- /* PowerPC not affected by this bug */ +-#elif defined(__mips__) +- /* MIPS as of kernel 3.1 does not properly detect schedulability */ +- return 1; +-#else +- if (_papi_os_info.os_version < LINUX_VERSION(2,6,33)) return 1; +-#endif +- +- if (nmi_watchdog_active) return 1; +- +- return 0; +-} +- + /* PERF_FORMAT_GROUP allows reading an entire group's counts at once */ + /* before 2.6.34 PERF_FORMAT_GROUP did not work when reading results */ + /* from attached processes. We are lazy and disable it for all cases */ +@@ -508,68 +477,65 @@ check_scheduability( pe_context_t *ctx, pe_control_t *ctl, int idx ) + long long papi_pe_buffer[READ_BUFFER_SIZE]; + int i,group_leader_fd; + +- if (bug_check_scheduability()) { ++ /* If the kernel isn't tracking scheduability right */ ++ /* Then we need to start/stop/read to force the event */ ++ /* to be scheduled and see if an error condition happens. */ ++ ++ /* get the proper fd to start */ ++ group_leader_fd=ctl->events[idx].group_leader_fd; ++ if (group_leader_fd==-1) group_leader_fd=ctl->events[idx].event_fd; ++ ++ /* start the event */ ++ retval = ioctl( group_leader_fd, PERF_EVENT_IOC_ENABLE, NULL ); ++ if (retval == -1) { ++ PAPIERROR("ioctl(PERF_EVENT_IOC_ENABLE) failed"); ++ return PAPI_ESYS; ++ } + +- /* If the kernel isn't tracking scheduability right */ +- /* Then we need to start/stop/read to force the event */ +- /* to be scheduled and see if an error condition happens. */ ++ /* stop the event */ ++ retval = ioctl(group_leader_fd, PERF_EVENT_IOC_DISABLE, NULL ); ++ if (retval == -1) { ++ PAPIERROR( "ioctl(PERF_EVENT_IOC_DISABLE) failed" ); ++ return PAPI_ESYS; ++ } + +- /* get the proper fd to start */ +- group_leader_fd=ctl->events[idx].group_leader_fd; +- if (group_leader_fd==-1) group_leader_fd=ctl->events[idx].event_fd; ++ /* See if a read returns any results */ ++ cnt = read( group_leader_fd, papi_pe_buffer, sizeof(papi_pe_buffer)); ++ if ( cnt == -1 ) { ++ SUBDBG( "read returned an error! Should never happen.\n" ); ++ return PAPI_ESYS; ++ } + +- /* start the event */ +- retval = ioctl( group_leader_fd, PERF_EVENT_IOC_ENABLE, NULL ); +- if (retval == -1) { +- PAPIERROR("ioctl(PERF_EVENT_IOC_ENABLE) failed"); +- return PAPI_ESYS; +- } ++ if ( cnt == 0 ) { ++ /* We read 0 bytes if we could not schedule the event */ ++ /* The kernel should have detected this at open */ ++ /* but various bugs (including NMI watchdog) */ ++ /* result in this behavior */ + +- /* stop the event */ +- retval = ioctl(group_leader_fd, PERF_EVENT_IOC_DISABLE, NULL ); +- if (retval == -1) { +- PAPIERROR( "ioctl(PERF_EVENT_IOC_DISABLE) failed" ); +- return PAPI_ESYS; +- } ++ return PAPI_ECNFLCT; + +- /* See if a read returns any results */ +- cnt = read( group_leader_fd, papi_pe_buffer, sizeof(papi_pe_buffer)); +- if ( cnt == -1 ) { +- SUBDBG( "read returned an error! Should never happen.\n" ); +- return PAPI_ESYS; +- } ++ } else { + +- if ( cnt == 0 ) { +- /* We read 0 bytes if we could not schedule the event */ +- /* The kernel should have detected this at open */ +- /* but various bugs (including NMI watchdog) */ +- /* result in this behavior */ +- +- return PAPI_ECNFLCT; +- +- } else { +- +- /* Reset all of the counters (opened so far) back to zero */ +- /* from the above brief enable/disable call pair. */ +- +- /* We have to reset all events because reset of group leader */ +- /* does not reset all. */ +- /* we assume that the events are being added one by one and that */ +- /* we do not need to reset higher events (doing so may reset ones */ +- /* that have not been initialized yet. */ +- +- /* Note... PERF_EVENT_IOC_RESET does not reset time running */ +- /* info if multiplexing, so we should avoid coming here if */ +- /* we are multiplexing the event. */ +- for( i = 0; i < idx; i++) { +- retval=ioctl( ctl->events[i].event_fd, PERF_EVENT_IOC_RESET, NULL ); +- if (retval == -1) { +- PAPIERROR( "ioctl(PERF_EVENT_IOC_RESET) #%d/%d %d " +- "(fd %d)failed", +- i,ctl->num_events,idx,ctl->events[i].event_fd); +- return PAPI_ESYS; +- } +- } ++ /* Reset all of the counters (opened so far) back to zero */ ++ /* from the above brief enable/disable call pair. */ ++ ++ /* We have to reset all events because reset of group leader */ ++ /* does not reset all. */ ++ /* we assume that the events are being added one by one and that */ ++ /* we do not need to reset higher events (doing so may reset ones */ ++ /* that have not been initialized yet. */ ++ ++ /* Note... PERF_EVENT_IOC_RESET does not reset time running */ ++ /* info if multiplexing, so we should avoid coming here if */ ++ /* we are multiplexing the event. */ ++ for( i = 0; i < idx; i++) { ++ retval=ioctl( ctl->events[i].event_fd, PERF_EVENT_IOC_RESET, NULL ); ++ if (retval == -1) { ++ PAPIERROR( "ioctl(PERF_EVENT_IOC_RESET) #%d/%d %d " ++ "(fd %d)failed", ++ i,ctl->num_events,idx,ctl->events[i].event_fd); ++ return PAPI_ESYS; ++ } + } + } + return PAPI_OK; +@@ -1658,8 +1624,7 @@ _pe_init_component( int cidx ) + } + + /* Detect NMI watchdog which can steal counters */ +- nmi_watchdog_active=_linux_detect_nmi_watchdog(); +- if (nmi_watchdog_active) { ++ if (_linux_detect_nmi_watchdog()) { + SUBDBG("The Linux nmi_watchdog is using one of the performance " + "counters, reducing the total number available.\n"); + } diff --git a/SPECS/papi.spec b/SPECS/papi.spec index b01a73b..f31f8b6 100644 --- a/SPECS/papi.spec +++ b/SPECS/papi.spec @@ -2,7 +2,7 @@ Summary: Performance Application Programming Interface Name: papi Version: 5.2.0 -Release: 14%{?dist} +Release: 19%{?dist} License: BSD Group: Development/System URL: http://icl.cs.utk.edu/papi/ @@ -17,6 +17,13 @@ Patch401: papi-kvmrapl.patch Patch500: papi-sys_mem_info.patch Patch700: papi-krentel.patch Patch900: papi-inficonst.patch +Patch1000: papi-bz1263666.patch +Patch1001: papi-bz1326977.patch +Patch1002: papi-bz1277931.patch +Patch1003: papi-bz1313088.patch +Patch1004: papi-postfixcalc.patch +Patch1005: papi-errmsg.patch +Patch1006: papi-schedule.patch BuildRequires: autoconf BuildRequires: doxygen BuildRequires: ncurses-devel @@ -75,6 +82,13 @@ the PAPI user-space libraries and interfaces. %patch500 -p1 %patch700 -p1 %patch900 -p1 +%patch1000 -p1 +%patch1001 -p1 +%patch1002 -p1 +%patch1003 -p1 +%patch1004 -p1 +%patch1005 -p1 +%patch1006 -p1 %build %if %{without bundled_libpfm} @@ -156,6 +170,25 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/*.a %changelog +* Tue Aug 2 2016 William Cohen - 5.2.0-19 +- Rebuild with libpfm-4.7.0. + +* Wed Jul 27 2016 William Cohen - 5.2.0-18 +- Check schedulability on aarch64. + +* Tue Jul 26 2016 William Cohen - 5.2.0-17 +- Eliminate possible stack smashing. + +* Tue Jun 21 2016 William Cohen - 5.2.0-16 +- Correct ftests/tenth test behavior on power. rhbz1313088 + +* Thu May 12 2016 William Cohen - 5.2.0-15 +- Update papi L1 cache events on POWER7 +- Prevent papi-testsuite segfaults +- Identify kernels that support rdpmc +- Correct papi-testsuite byte_profile and sprofile tests on ppc64le +- Update PAPI_L1_TCM event on Haswells + * Mon Aug 10 2015 William Cohen - 5.2.0-14 - Fix build for newer infiband libs. rhbz1251645