/usr/share/doc/papi-examples/ftests/flops.F is in papi-examples 5.3.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | C A simple example for the use of PAPI, the number of flops you should
C get is about INDEX^3 on machines that consider add and multiply one flop
C such as SGI, and 2*(INDEX^3) that don't consider it 1 flop such as INTEL
C -Kevin London
#include "fpapi_test.h"
program flops
implicit integer (p)
integer index
PARAMETER(index=100)
REAL*4 matrixa(index,index),matrixb(index,index),mres(index,index)
REAL*4 proc_time, mflops, real_time
INTEGER*8 flpins
INTEGER i,j,k, retval
integer tests_quiet, get_quiet
external get_quiet
tests_quiet = get_quiet()
retval = PAPI_VER_CURRENT
call PAPIf_library_init(retval)
if ( retval.NE.PAPI_VER_CURRENT) then
call ftest_fail(__FILE__, __LINE__,
. 'PAPI_library_init', retval)
end if
call PAPIf_query_event(PAPI_FP_INS, retval)
if (retval .NE. PAPI_OK) then
call ftest_skip(__FILE__, __LINE__, 'PAPI_FP_INS', PAPI_ENOEVNT)
end if
C Initialize the Matrix arrays
do i=1,index
do j=1,index
matrixa(i,j) = i+j
matrixb(i,j) = j-i
mres(i,j) = 0.0
end do
end do
C Setup PAPI library and begin collecting data from the counters
call PAPIf_flips( real_time, proc_time, flpins, mflops, retval )
if ( retval.NE.PAPI_OK) then
call ftest_fail(__FILE__, __LINE__, 'PAPIf_flips', retval)
end if
C Matrix-Matrix Multiply
do i=1,index
do j=1,index
do k=1,index
mres(i,j) = mres(i,j) + matrixa(i,k)*matrixb(k,j)
end do
end do
end do
C Collect the data into the Variables passed in
call PAPIf_flips( real_time, proc_time, flpins, mflops, retval)
if ( retval.NE.PAPI_OK) then
call ftest_fail(__FILE__, __LINE__, 'PAPIf_flips', retval)
end if
if (tests_quiet .EQ. 0) then
print *, 'Real_time: ', real_time
print *, ' Proc_time: ', proc_time
print *, ' Total flpins: ', flpins
print *, ' MFLOPS: ', mflops
end if
call dummy(mres)
call ftests_pass(__FILE__)
end
|