I have a simple program in fortran that uses PAPI APIs to read performance counter values. All APIs (PAPIF_start, PAPIF_stop etc.) all work correctly (meaning, returns PAPI_OK). However, the values that PAPIF_stop reads are always 0. I tried another profiling software on BG/Q to ensure that these values should not be 0. Any idea why this might be the case? This is my first ever attempt at writing a fortran code. So it may very well be a fortran issue that is not evident to me. Will appreciate any help. Thanks! --DE
c-----------------------------------------------------------------------
subroutine papi_add_events(event_set)
integer, intent(inout) :: event_set
include 'f77papi.h'
c create the eventset
integer check
integer*8 event_code
event_set = PAPI_NULL
call PAPIF_create_eventset(event_set, check)
if (check .ne. PAPI_OK) then
print *, 'Error in subroutine PAPIF_create_eventset'
call abort
end if
!event_code = PAPI_L1_DCM ! Total L1 Data Cache misses
call PAPIF_event_name_to_code('PAPI_FP_INS', event_code, check)
if (check .NE. PAPI_OK) then
print *, 'Abort After PAPIF_event_name_to_code: ', check
call abort
endif
call PAPIF_add_event(event_set, event_code, check)
if (check .NE. PAPI_OK) then
print *, 'Abort PAPIF_add_events1: ', check, ' ', event_code
call abort
endif
!event_code = PAPI_MEM_RCY ! Cycle stalled waiting for memory reads
call PAPIF_event_name_to_code('PAPI_TOT_CYC', event_code, check)
call PAPIF_add_event(event_set, event_code, check)
if (check .NE. PAPI_OK) then
print *, 'Abort PAPIF_add_events2: ', check, ' ', event_code
call abort
endif
call PAPIF_start(event_set, check)
if(check .ne. PAPI_OK) then
print *, 'Abort after PAPIF_start: ', check
call abort
endif
return
end
c-----------------------------------------------------------------------
subroutine papi_stop_counting(event_set, values)
integer, intent(in) :: event_set
integer*8, intent(inout) :: values(*) !shows an array
c Local variable
integer check
include 'f77papi.h'
! stop counting
call PAPIF_stop(event_set, values(1), check) !*Not sure if it should be values(1) or values*
if (check .ne. PAPI_OK) then
print *, 'Abort after PAPIF_stop: ', check
call abort
endif
return
end
c-----------------------------------------------------------------------
I am calling these subroutines from another function like this:
subroutine myfunction
integer event_set ! For papi
integer*8 values(50) !For reading papi values
call papi_lib_init ! *Not shown, but is present and works. *
call papi_add_events(event_set)
do_flops()
call papi_stop_counting(event_set, values)
print *, 'Value 1: ', values(1)
print *, 'Value 2: ', values(2)
return
end
The output I get is:
Value 1: 0
Value 2: 0
http://www.cisl.ucar.edu/css/staff/rory/papi/papi.php?p=bas
plz PAPIF_create_eventset first!