Skip to content

Flop Counts using perf

Parsa Amini edited this page Jan 25, 2019 · 7 revisions

List Available Events on PowerPC or x86

git clone git://perfmon2.git.sourceforge.net/gitroot/perfmon2/libpfm4
cd lilibpfm4
make
./examples/showevtinfo 

Take any event you want to track from the output. For example the Double precision vector instructions:

#-----------------------------
IDX     : 228590604
PMU name : power8 (POWER8)
Name     : PM_VSU0_VECTOR_DP_ISSUED
Equiv     : None
Flags    : None
Desc     : Double Precision vector instruction issued on Pipe0
Code     : 0xb080

Extract the event id 0xb080 and pass it to perf

perf stat -e rb080 -e rb084 -e ra0a6 -e ra082 -e ra09a -e ra09e -e ra0a2  $1/octotiger --config_file=sphere.ini 

This will result:

Performance counter stats for '../../build/octotiger --config_file=sphere.ini':

       848,444,038      rb080:u                                                       (57.28%)
                 0      rb084:u                                                       (57.43%)
                 0      ra0a6:u                                                       (57.34%)
    13,235,369,526      ra082:u                                                       (57.17%)
     9,972,900,638      ra09a:u                                                       (56.93%)
       160,635,405      ra09e:u                                                       (57.00%)
                 0      ra0a2:u                                                       (57.07%)

       7.125094970 seconds time elapsed

with following events

#-----------------------------
IDX     : 228590604
PMU name : power8 (POWER8)
Name     : PM_VSU0_VECTOR_DP_ISSUED
Equiv     : None
Flags    : None
Desc     : Double Precision vector instruction issued on Pipe0
Code     : 0xb080
#-----------------------------
IDX     : 228590605
PMU name : power8 (POWER8)
Name     : PM_VSU0_VECTOR_SP_ISSUED
Equiv     : None
Flags    : None
Desc     : Single Precision vector instruction issued (executed)
Code     : 0xb084
#-----------------------------
IDX     : 228590606
PMU name : power8 (POWER8)
Name     : PM_VSU1_16FLOP
Equiv     : None
Flags    : None
Desc     : Sixteen flops operation (SP vector versions of fdiv,fsqrt)
Code     : 0xa0a6
#-----------------------------
IDX     : 228590607
PMU name : power8 (POWER8)
Name     : PM_VSU1_1FLOP
Equiv     : None
Flags    : None
Desc     : one flop (fadd, fmul, fsub, fcmp, fsel, fabs, fnabs, fres, fsqrte, fneg) operation finished
Code     : 0xa082
#-----------------------------
IDX     : 228590608
PMU name : power8 (POWER8)
Name     : PM_VSU1_2FLOP
Equiv     : None
Flags    : None
Desc     : two flops operation (scalar fmadd, fnmadd, fmsub, fnmsub and DP vector versions of single flop instructions)
Code     : 0xa09a
#-----------------------------
IDX     : 228590609
PMU name : power8 (POWER8)
Name     : PM_VSU1_4FLOP
Equiv     : None
Flags    : None
Desc     : four flops operation (scalar fdiv, fsqrt, DP vector version of fmadd, fnmadd, fmsub, fnmsub, SP vector versions of single flop instructions)
Code     : 0xa09e
#-----------------------------
#-----------------------------
IDX     : 228590610
PMU name : power8 (POWER8)
Name     : PM_VSU1_8FLOP
Equiv     : None
Flags    : None
Desc     : eight flops operation (DP vector versions of fdiv,fsqrt and SP vector versions of fmadd,fnmadd,fmsub,fnmsub)
Code     : 0xa0a2
#-----------------------------

Note that the event ids are different for x86 and we would need to extract them.