|
Packit |
577717 |
C From Dave McNamara at PSRV. Thanks!
|
|
Packit |
577717 |
C Ported to fortran by Kevin London
|
|
Packit |
577717 |
C If an event is countable but you've exhausted the counter resources
|
|
Packit |
577717 |
C and you try to add an event, it seems subsequent PAPI_start and/or
|
|
Packit |
577717 |
C PAPI_stop will causes a Seg. Violation.
|
|
Packit |
577717 |
|
|
Packit |
577717 |
C I got around this by calling PAPI to get the # of countable events,
|
|
Packit |
577717 |
C then making sure that I didn't try to add more than these number of
|
|
Packit |
577717 |
C events. I still have a problem if someone adds Level 2 cache misses
|
|
Packit |
577717 |
C and then adds FLOPS 'cause I didn't count FLOPS as actually requiring
|
|
Packit |
577717 |
C 2 counters.
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "fpapi_test.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
program case2
|
|
Packit |
577717 |
IMPLICIT integer (p)
|
|
Packit |
577717 |
|
|
Packit |
577717 |
REAL c,a,b
|
|
Packit |
577717 |
INTEGER n
|
|
Packit |
577717 |
INTEGER EventSet
|
|
Packit |
577717 |
INTEGER retval
|
|
Packit |
577717 |
INTEGER I,j
|
|
Packit |
577717 |
INTEGER*8 gl(3)
|
|
Packit |
577717 |
|
|
Packit |
577717 |
INTEGER last_char
|
|
Packit |
577717 |
EXTERNAL last_char
|
|
Packit |
577717 |
|
|
Packit |
577717 |
integer tests_quiet, get_quiet
|
|
Packit |
577717 |
external get_quiet
|
|
Packit |
577717 |
|
|
Packit |
577717 |
tests_quiet = get_quiet()
|
|
Packit |
577717 |
|
|
Packit |
577717 |
a=0.999
|
|
Packit |
577717 |
b=1.001
|
|
Packit |
577717 |
n=1000
|
|
Packit |
577717 |
i=0
|
|
Packit |
577717 |
j=0
|
|
Packit |
577717 |
EventSet = PAPI_NULL
|
|
Packit |
577717 |
|
|
Packit |
577717 |
retval = PAPI_VER_CURRENT
|
|
Packit |
577717 |
call PAPIf_library_init( retval )
|
|
Packit |
577717 |
if ( retval.NE.PAPI_VER_CURRENT) then
|
|
Packit |
577717 |
call ftest_fail(__FILE__, __LINE__,
|
|
Packit |
577717 |
. 'PAPI_library_init', retval)
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
|
|
Packit |
577717 |
call PAPIf_create_eventset( EventSet, retval)
|
|
Packit |
577717 |
if ( retval .NE. PAPI_OK ) then
|
|
Packit |
577717 |
call ftest_fail(__FILE__, __LINE__,
|
|
Packit |
577717 |
. 'PAPIf_create_eventset',
|
|
Packit |
577717 |
*retval)
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
|
|
Packit |
577717 |
call PAPIf_query_event(PAPI_BR_CN, retval)
|
|
Packit |
577717 |
if (retval .EQ. PAPI_OK) then
|
|
Packit |
577717 |
j = j + 1
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
if (j .NE. 0) then
|
|
Packit |
577717 |
call PAPIf_add_event( EventSet, PAPI_BR_CN, retval )
|
|
Packit |
577717 |
if ( retval .NE. PAPI_OK ) then
|
|
Packit |
577717 |
if (tests_quiet .EQ. 0) then
|
|
Packit |
577717 |
call PAPIf_perror( 'PAPIf_add_event' )
|
|
Packit |
577717 |
endif
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
|
|
Packit |
577717 |
i = j
|
|
Packit |
577717 |
|
|
Packit |
577717 |
call PAPIf_query_event(PAPI_TOT_CYC, retval)
|
|
Packit |
577717 |
if (retval .EQ. PAPI_OK) then
|
|
Packit |
577717 |
j = j + 1
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
if (j .EQ. i+1) then
|
|
Packit |
577717 |
call PAPIf_add_event( EventSet, PAPI_TOT_CYC, retval )
|
|
Packit |
577717 |
if ( retval .NE. PAPI_OK )then
|
|
Packit |
577717 |
if (tests_quiet .EQ. 0) then
|
|
Packit |
577717 |
call PAPIf_perror( 'PAPIf_add_event' )
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
|
|
Packit |
577717 |
i = j
|
|
Packit |
577717 |
call PAPIf_query_event(PAPI_FP_INS, retval)
|
|
Packit |
577717 |
if (retval .EQ. PAPI_OK) then
|
|
Packit |
577717 |
j = j + 1
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
if (j .EQ. i+1) then
|
|
Packit |
577717 |
call PAPIf_add_event(EventSet,PAPI_TOT_INS,retval)
|
|
Packit |
577717 |
if ( retval .NE. PAPI_OK )then
|
|
Packit |
577717 |
if ( retval .NE. PAPI_ECNFLCT ) then
|
|
Packit |
577717 |
if (tests_quiet .EQ. 0) then
|
|
Packit |
577717 |
call PAPIf_perror( 'PAPIf_add_event' )
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (J .GT. 0) then
|
|
Packit |
577717 |
call PAPIf_start(EventSet, retval )
|
|
Packit |
577717 |
if ( retval .NE. PAPI_OK ) then
|
|
Packit |
577717 |
call ftest_fail(__FILE__, __LINE__,
|
|
Packit |
577717 |
. 'PAPIf_start', retval)
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
|
|
Packit |
577717 |
do i=1,n
|
|
Packit |
577717 |
c = a * b
|
|
Packit |
577717 |
end do
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (J .GT. 0) then
|
|
Packit |
577717 |
call PAPIf_stop( EventSet, gl, retval)
|
|
Packit |
577717 |
if ( retval .NE. PAPI_OK ) then
|
|
Packit |
577717 |
call ftest_fail(__FILE__, __LINE__,
|
|
Packit |
577717 |
. 'PAPIf_stop', retval)
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
end if
|
|
Packit |
577717 |
|
|
Packit |
577717 |
call ftests_pass(__FILE__)
|
|
Packit |
577717 |
end
|