Also, here are similar scripts for the cpu memory hierarchy.

Richard.

On Thu, Nov 03, 2005 at 11:16:25AM -0500, Matty wrote:
> On Wed, 2 Nov 2005, Richard McDougall wrote:
> 
> >
> >Hi Matty,
> >
> >We use some scripts to post-process busstat into what you are looking
> >for: bandwidth per sbus and device. It's a two phase operation now,
> >collect and report. See below for the report and collect scripts...
> >
> 
> Hi Richard,
> 
> I reviewed the scripts, and noticed the following headings in 
> "print_ac_gigaplane_stats":
> 
> print "AbUtil   DbUtil  RTS     RTSA    RTO     WB\n";
> [...]
> print "RIO      WIO     RBIO    WBIO    RS      WS\n";
> 
> Any idea what the columns stand for? Do you happen to know what the size 
> of a pkt would be? Do you or anyone on the list happen to know where I can 
> get descriptions for the busstat column headers?
> 
> Thanks for the reply and the awesome scripts,
> - Ryan
> 
> --
> UNIX Administrator
> http://daemons.net/~matty
> 
> 
> 
> >Regards,
> >
> >Richard.
> >
> >
> >
> >
> >
> >
> >On Wed, Nov 02, 2005 at 01:48:49PM -0500, Matty wrote:
> >>
> >>Howdy,
> >>
> >>I have been playing around with busstat, and must say that this is a
> >>really really cool utility! To get an idea of what the event counters
> >>mean, I started reading through a PCI reference and the following website:
> >>
> >>http://www.readol.net/books/computer/system/System.Performance.Tuning.Second.Edition/059600284x/spt2-CHP-3-SECT-6.html
> >>
> >>This website mentions that the value "dvma_bytes_xfr" could be used to get
> >>the number of bytes transferred on SBUS-based machines. Upon inspecting
> >>the busstat events on a Sun 280R, I didn't notice a similar event:
> >>
> >>$ busstat -e pcis0
> >>pic0
> >>dvma_stream_rd
> >>dvma_stream_wr
> >>dvma_const_rd
> >>dvma_const_wr
> >>dvma_stream_buf_mis
> >>dvma_cycles
> >>dvma_wd_xfr
> >>pio_cycles
> >>dvma_tlb_misses
> >>interrupts
> >>saf_inter_nack
> >>pio_reads
> >>pio_writes
> >>dvma_rd_buf_timeout
> >>dvma_rd_rtry_stc
> >>dvma_wr_rtry_stc
> >>dvma_rd_rtry_nonstc
> >>dvma_wr_rtry_nonstc
> >>E*_slow_transitions
> >>E*_slow_cycles_per_64
> >>
> >>Are the events documented anywhere by any chance? Is there anything
> >>equivalent to "dvma_bytes_xfr" to get the number of bytes transmitted
> >>on a PCI bus?
> >>
> >>Thanks for any insight,
> >>- Ryan
> >>
> >>--
> >>UNIX Administrator
> >>http://daemons.net/~matty
> >>_______________________________________________
> >>perf-discuss mailing list
> >>perf-discuss@opensolaris.org
> >
> >-- 
> >
> >
> >:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:
> > Richard Mc Dougall                 : [EMAIL PROTECTED]
> > Performance and Availability       : x31542
> > Engineering                        : http://blogs.sun.com/rmc
> > Sun Microsystems Inc               : +1 650 352 6438
> >:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:
> >
> 
> --
> _______________________________________________
> perf-discuss mailing list
> perf-discuss@opensolaris.org

-- 


:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:
  Richard Mc Dougall                 : [EMAIL PROTECTED]
  Performance and Availability       : x31542  
  Engineering                        : http://blogs.sun.com/rmc
  Sun Microsystems Inc               : +1 650 352 6438
:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:
/usr/sbin/cpustat  \
        -c pic0=Cycle_cnt,pic1=Instr_cnt \
        -c pic0=Cycle_cnt,pic1=Instr_cnt,sys \
        -c pic0=Cycle_cnt,pic1=Instr_cnt,sys,nouser \
        -c pic0=Dispatch0_IC_miss,pic1=Dispatch0_mispred \
        -c pic0=Dispatch0_IC_miss,pic1=Dispatch0_mispred,sys \
        -c pic0=Dispatch0_IC_miss,pic1=Dispatch0_mispred,sys,nouser \
        -c pic0=IC_ref,pic1=IC_miss \
        -c pic0=IC_ref,pic1=IC_miss,sys  \
        -c pic0=IC_ref,pic1=IC_miss,sys,nouser  \
        -c pic0=DC_rd,pic1=DC_rd_miss  \
        -c pic0=DC_rd,pic1=DC_rd_miss,sys  \
        -c pic0=DC_rd,pic1=DC_rd_miss,sys,nouser  \
        -c pic0=DC_wr,pic1=DC_wr_miss  \
        -c pic0=DC_wr,pic1=DC_wr_miss,sys  \
        -c pic0=DC_wr,pic1=DC_wr_miss,sys,nouser  \
        -c pic0=Rstall_storeQ,pic1=Re_RAW_miss  \
        -c pic0=Rstall_storeQ,pic1=Re_RAW_miss,sys  \
        -c pic0=Rstall_storeQ,pic1=Re_RAW_miss,sys,nouser  \
        -c pic0=EC_ref,pic1=EC_misses  \
        -c pic0=EC_ref,pic1=EC_misses,sys  \
        -c pic0=EC_ref,pic1=EC_misses,sys,nouser  \
        -c pic0=EC_write_hit_RTO,pic1=EC_wb  \
        -c pic0=EC_write_hit_RTO,pic1=EC_wb,sys  \
        -c pic0=EC_write_hit_RTO,pic1=EC_wb,sys,nouser  \
        -c pic0=EC_snoop_inv,pic1=EC_snoop_cb  \
        -c pic0=EC_snoop_inv,pic1=EC_snoop_cb,sys  \
        -c pic0=EC_snoop_inv,pic1=EC_snoop_cb,sys,nouser  \
        -c pic0=EC_rd_miss,pic1=EC_ic_miss \
        -c pic0=EC_rd_miss,pic1=EC_ic_miss,sys  \
        -c pic0=EC_rd_miss,pic1=EC_ic_miss,sys,nouser  \
        -c pic0=Dispatch0_br_target,pic1=Re_EC_miss \
        -c pic0=Dispatch0_br_target,pic1=Re_EC_miss,sys \
        -c pic0=Dispatch0_br_target,pic1=Re_EC_miss,sys,nouser \
        -c pic0=Rstall_IU_use,pic1=Re_PC_miss \
        -c pic0=Rstall_IU_use,pic1=Re_PC_miss,sys \
        -c pic0=Rstall_IU_use,pic1=Re_PC_miss,sys,nouser \
        -c pic0=PC_port0_rd,pic1=ITLB_miss \
        -c pic0=PC_port0_rd,pic1=ITLB_miss,sys \
        -c pic0=PC_port0_rd,pic1=ITLB_miss,sys,nouser \
        -c pic0=SI_snoop,pic1=DTLB_miss \
        -c pic0=SI_snoop,pic1=DTLB_miss,sys \
        -c pic0=SI_snoop,pic1=DTLB_miss,sys,nouser \
        -c pic0=SI_ciq_flow,pic1=WC_miss \
        -c pic0=SI_ciq_flow,pic1=WC_miss,sys \
        -c pic0=SI_ciq_flow,pic1=WC_miss,sys,nouser \
        -c pic0=SI_owned,pic1=WC_snoop_cb \
        -c pic0=SI_owned,pic1=WC_snoop_cb,sys \
        -c pic0=SI_owned,pic1=WC_snoop_cb,sys,nouser \
        -c pic0=SW_count_0,pic1=WC_scrubbed \
        -c pic0=SW_count_0,pic1=WC_scrubbed,sys \
        -c pic0=SW_count_0,pic1=WC_scrubbed,sys,nouser \
        -c pic0=IU_Stat_Br_miss_taken,pic1=WC_wb_wo_read \
        -c pic0=IU_Stat_Br_miss_taken,pic1=WC_wb_wo_read,sys \
        -c pic0=IU_Stat_Br_miss_taken,pic1=WC_wb_wo_read,sys,nouser \
        -c pic0=IU_Stat_Br_count_taken,pic1=SW_count_1 \
        -c pic0=IU_Stat_Br_count_taken,pic1=SW_count_1,sys \
        -c pic0=IU_Stat_Br_count_taken,pic1=SW_count_1,sys,nouser \
        -c pic0=Dispatch_rs_mispred,pic1=IU_Stat_Br_miss_untaken \
        -c pic0=Dispatch_rs_mispred,pic1=IU_Stat_Br_miss_untaken,sys \
        -c pic0=Dispatch_rs_mispred,pic1=IU_Stat_Br_miss_untaken,sys,nouser \
        -c pic0=FA_pipe_completion,pic1=PC_soft_hit \
        -c pic0=FA_pipe_completion,pic1=PC_soft_hit,sys \
        -c pic0=FA_pipe_completion,pic1=PC_soft_hit,sys,nouser \
        -c pic0=Dispatch0_2nd_br,pic1=PC_hard_hit \
        -c pic0=Dispatch0_2nd_br,pic1=PC_hard_hit,sys \
        -c pic0=Dispatch0_2nd_br,pic1=PC_hard_hit,sys,nouser \
        -c pic0=MC_reads_0,pic1=MC_writes_0 \
        -c pic0=MC_reads_0,pic1=MC_writes_0,sys \
        -c pic0=MC_reads_0,pic1=MC_writes_0,sys,nouser \
        -c pic0=MC_reads_1,pic1=MC_writes_1 \
        -c pic0=MC_reads_1,pic1=MC_writes_1,sys \
        -c pic0=MC_reads_1,pic1=MC_writes_1,sys,nouser \
        -c pic0=MC_reads_2,pic1=MC_writes_2 \
        -c pic0=MC_reads_2,pic1=MC_writes_2,sys \
        -c pic0=MC_reads_2,pic1=MC_writes_2,sys,nouser \
        -c pic0=MC_reads_3,pic1=MC_writes_3 \
        -c pic0=MC_reads_3,pic1=MC_writes_3,sys \
        -c pic0=MC_reads_3,pic1=MC_writes_3,sys,nouser \
        -c pic0=MC_stalls_0,pic1=MC_stalls_1 \
        -c pic0=MC_stalls_0,pic1=MC_stalls_1,sys \
        -c pic0=MC_stalls_0,pic1=MC_stalls_1,sys,nouser \
        -c pic0=MC_stalls_2,pic1=MC_stalls_3 \
        -c pic0=MC_stalls_2,pic1=MC_stalls_3,sys \
        -c pic0=MC_stalls_2,pic1=MC_stalls_3,sys,nouser \
        -c pic0=EC_wb_remote,pic1=Re_DC_miss \
        -c pic0=EC_wb_remote,pic1=Re_DC_miss,sys \
        -c pic0=EC_wb_remote,pic1=Re_DC_miss,sys,nouser \
        -c pic0=EC_wb_remote,pic1=Re_DC_missovhd \
        -c pic0=EC_wb_remote,pic1=Re_DC_missovhd,sys \
        -c pic0=EC_wb_remote,pic1=Re_DC_missovhd,sys,nouser \
        -c pic0=EC_miss_mtag_remote,pic1=EC_miss_remote \
        -c pic0=EC_miss_mtag_remote,pic1=EC_miss_remote,sys \
        -c pic0=EC_miss_mtag_remote,pic1=EC_miss_remote,sys,nouser \
        -c pic0=EC_miss_local,pic1=Re_FPU_bypass \
        -c pic0=EC_miss_local,pic1=Re_FPU_bypass,sys \
        -c pic0=EC_miss_local,pic1=Re_FPU_bypass,sys,nouser \
        -c pic0=Instr_cnt,pic1=PC_MS_misses \
        -c pic0=Instr_cnt,pic1=PC_MS_misses,sys \
        -c pic0=Instr_cnt,pic1=PC_MS_misses,sys,nouser \
        -c pic0=Cycle_cnt,pic1=PC_snoop_inv \
        -c pic0=Cycle_cnt,pic1=PC_snoop_inv,sys \
        -c pic0=Cycle_cnt,pic1=PC_snoop_inv,sys,nouser \
        -c pic0=Instr_cnt,pic1=PC_hard_hit \
        -c pic0=Instr_cnt,pic1=PC_hard_hit,sys \
        -c pic0=Instr_cnt,pic1=PC_hard_hit,sys,nouser \
        -c pic0=Cycle_cnt,pic1=Rstall_FP_use \
        -c pic0=Cycle_cnt,pic1=Rstall_FP_use,sys \
        -c pic0=Cycle_cnt,pic1=Rstall_FP_use,sys,nouser \
        -c pic0=Instr_cnt,pic1=FM_pipe_completion \
        -c pic0=Instr_cnt,pic1=FM_pipe_completion,sys \
        -c pic0=Instr_cnt,pic1=FM_pipe_completion,sys,nouser \
        -c pic0=Cycle_cnt,pic1=IU_Stat_Br_count_untaken \
        -c pic0=Cycle_cnt,pic1=IU_Stat_Br_count_untaken,sys \
        -c pic0=Cycle_cnt,pic1=IU_Stat_Br_count_untaken,sys,nouser \
        -c pic0=Instr_cnt,pic1=IC_miss_cancelled \
        -c pic0=Instr_cnt,pic1=IC_miss_cancelled,sys \
        -c pic0=Instr_cnt,pic1=IC_miss_cancelled,sys,nouser 1 600 \
#!/ws/on81-tools/SUNWspro/SC6.1/bin/perl

# Tunables

$debug = 0;
$CpuExp = 5;
$SysioExp = 5;
$AcExp = 4;
$SSMNodes = 4;
$MC_CAP = 8.33;
$MC_BDCAP = 11.9;



# Get options 

if ($#ARGV == -1) {&usage();}

while ($#ARGV > -1) {
        $arg = shift @ARGV;
        if ( $arg =~ /^-(.)(.*)$/ ) {
                $flag=$1; $val=$2;
                $flag2=$flag.$val;
                if ( $flag eq "i" ) {
                        if ( $val eq "" ) { $val = shift @ARGV;}
                        if ( $val eq "" ) { &usage();}
                        $infile = $val;
                } elsif ($flag eq "o") {
                        if ( $val eq "" ) { $val = shift @ARGV;}
                        if ( $val eq "" ) { &usage();}
                        $outfile = $val;
                } elsif ($flag eq "v") {
                        if ( $val ne "")  { &usage();}
                        $verbose = 1;
                } elsif ($flag2 eq "ac") {
                        $aconly = 1;
                } elsif ($flag2 eq "sysio") {
                        $sysioonly = 1;
                } elsif ($flag2 eq "cpu") {
                        $cpuonly = 1;
                } elsif ($flag2 eq "uk") {
                        $ukonly = 1;
                } elsif ($flag2 eq "wfi") {
                        $wfionly = 1;
                } elsif ($flag2 eq "avg") {
                        $avgonly = 1;
                } elsif ($flag2 eq "eavg") {
                        $eavgonly = 1;
                } else { &usage(); }
        } elsif ( $arg =~ /^(.*)$/ ) {
                $infile = $1;
        }
}

# if no flags are set or if verbose flag is set  then  set all flags.

if ( !($aconly || $sysioonly || $cpuonly || $wfionly || $avgonly || $eavgonly) 
|| $verbose ) {
        $aconly = $sysioonly = $cpuonly = $wfionly =$avgonly = $eavgonly = 1;
}

if (defined $infile) {
        open(STDIN, "<$infile") || die "Could not open $infile\n";
}

if (defined $outfile) {
        open(STDOUT, ">$outfile") || die "Could not open $outfile\n";
}


$word = "[a-zA-Z,=0-9_-]+";
$smallword = "[a-zA-Z]+";
$num = "[0-9]+";
$dec = "[0-9]+\.[0-9]+|[0-9]+|\.[0-9]+|[0-9]+\.";
$time = 0;
$total_tx = `grep "Total number of transactions" summary | awk '{print \$6}'`;
$runtime = `grep "^Run-time" summary | awk '{print \$3}'`;
$tps = $total_tx/$runtime;
[EMAIL PROTECTED] = `psrinfo`;
@psr_list = `grep since report|grep -v off-line`;
if ($debug) {
        print   
        "
        Assumptions:
        The counts are in millions and not mill/sec or percents
        Process ID in the output ignored.
        ", 2 ** $CpuExp," processors per SSM node.
        ", 2 ** $SysioExp," I/O boards per SSM node.
        ", 2 ** $AcExp," address controllers per SSM node.

";
        print "X" x 80,"\n";
        print "The following lines in the input were ignored\n";
        print "X" x 80,"\n";
}

# ++++++++++++++changed by ZYF(cpustat)
while ($line = <STDIN>) {
        chop $line;
        if ( $line =~ 
/^\s*($dec)\s*($num)\s*($smallword)\s*($num)\s*($num)\s*\x23\s*($word)\s*$/ ){
        #if ( $line =~ 
/^($dec)\s*($num)\s*($smallword)\s*($num)\s*($num)\s*($word)\s*$/ ){

                #Pprint " $1,  $2, $3, $4, $5, $6 \n";
                if ( $time == 0 ) { $time = $1;}
                if ( $3 =~/total/ ) { last;}
                $ctr_set = "cpu";
                $instance = $2;
                $cnt_a = ($4/1000000);
                @list=split(",",$6);
                @a=split("=",$list[0]);
                @b=split("=",$list[1]);
                $ctr_a = $a[1];
                $ctr_b = $b[1];
                $mode=$list[2];
                if ($mode eq "")
                  {$mode = "u";}
                if ($mode eq "sys")
                  {$mode = "uk";}
                if ($mode eq "nouser")
                  {$mode = "k";}
                $cnt_b = ($5/1000000);
                $hash_a = join(",", ("cpu",$2,$mode, $ctr_a));
                $hash_b = join(",", ("cpu",$2,$mode, $ctr_b));
                $time{$hash_a} += $time;
                $count{$hash_a} += $cnt_a;
                $time{$hash_b} += $time;
                $count{$hash_b} += $cnt_b;
        
        }else {print "\n";}  

}
# ++++++++++++++changed by ZYF(cpustat)

if ($debug) { print "X" x 80,"\n";}

foreach $ind (keys %time) {
        ($ctr_set, $part_num, $mode, $ctr) = split(",",$ind);
        $persec{$ind} = $count{$ind}/$time{$ind};

# take this out for V8
#       if ($ctr_set eq "SPITFIRE" || $ctr_set eq "CPU") {
#               $cpu_total{$ctr} += $persec{$ind};
#               $cpu_total_count{$ctr} += 1;
#               $node = $part_num >> $CpuExp;
#               $cpu_pernode{$node.",".$ctr} += $persec{$ind};
#               $cpu_pernode_count{$node.",".$ctr} += 1;
#       }

        if ($ctr_set eq "cpu" && $mode eq "uk") {
                $cpu_total{$ctr} += $persec{$ind};
                $cpu_total_count{$ctr} += 1;
                $node = $part_num >> $CpuExp;
                $cpu_pernode{$node.",".$ctr} += $persec{$ind};
                $cpu_pernode_count{$node.",".$ctr} += 1;
                $cpu_per_part_num{$part_num.",".$ctr} += $persec{$ind};
                $cpu_per_part_num_count{$part_num.",".$ctr} += 1;

        }

        if ($ctr_set eq "cpu" && $mode eq "u") {
                $user_cpu_total{$ctr} += $persec{$ind};
                $user_cpu_total_count{$ctr} += 1;
                $node = $part_num >> $CpuExp;
                $user_cpu_pernode{$node.",".$ctr} += $persec{$ind};
                $user_cpu_pernode_count{$node.",".$ctr} += 1;
                $user_per_part_num{$part_num.",".$ctr} += $persec{$ind};
                $user_per_part_num_count{$part_num.",".$ctr} += 1;
       #         print "$ctr, $user_cpu_total{$ctr} \n";
        }

        if ($ctr_set eq "cpu" && $mode eq "k") {
                $kernel_cpu_total{$ctr} += $persec{$ind};
                $kernel_cpu_total_count{$ctr} += 1;
                $node = $part_num >> $CpuExp;
                $kernel_cpu_pernode{$node.",".$ctr} += $persec{$ind};
                $kernel_cpu_pernode_count{$node.",".$ctr} += 1;
                $kernel_per_part_num{$part_num.",".$ctr} += $persec{$ind};
                $kernel_per_part_num_count{$part_num.",".$ctr} += 1;
        }

        if ($ctr_set eq "WFI") {
                $wfi_total{$ctr} += $persec{$ind};
                $wfi_total_count{$ctr} += 1;
        }

        if ($ctr_set eq "SYSIO" || $ctr_set eq "sbus") {
                $sysio_total{$ctr} += $persec{$ind};
                $sysio_total_count{$ctr} += 1;
                $node = $part_num >> $SysioExp;
                $sysio_pernode{$node.",".$ctr} += $persec{$ind};
                $sysio_pernode_count{$node.",".$ctr} += 1;
        }

        if ($ctr_set eq "AC" || $ctr_set eq "ac") {
                $ac_total{$ctr} += $persec{$ind};
                $ac_total_count{$ctr} += 1;
                $node = $part_num >> $AcExp;
                $ac_pernode{$node.",".$ctr} += $persec{$ind};
                $ac_pernode_count{$node.",".$ctr} += 1;
        }
}

if ($eavgonly) {
        &print_event_averages();
        print "\n";
}

if ($avgonly) {
        &print_all_averages();
}

if ($cpuonly) {
        printf "CPU statistics\n";
        printf "--------------\n";
        &print_cpu_cpi_breakdown();
        printf "\n";
        &print_cpu_mips();
        printf "\n";
        &print_cpu_cache_stats();
        printf "\n";
        printf "\n";
}

if ($ukonly) {
        printf "CPU user mode statistics\n";
        printf "------------------------\n";
        &print_user_cpu_cpi_breakdown();
        printf "\n";
        &print_user_cpu_mips();
        printf "\n";
        &print_user_cpu_cache_stats();
        printf "\n";
        printf "CPU kernel mode statistics\n";
        printf "--------------------------\n";
        &print_kernel_cpu_cpi_breakdown();
        printf "\n";
        &print_kernel_cpu_mips();
        printf "\n";
        &print_kernel_cpu_cache_stats();
        printf "\n";
        &print_ac_membank_stats();
        print "\n";
}

if ($aconly) {
        #printf "Gigaplane Bus Statistics\n";
        #printf "------------------------\n";
        #&print_ac_gigaplane_stats();
        print "\n";
        printf "Memory Banks Statistics\n";
        printf "-----------------------\n";
        &print_ac_membank_stats();
        print "\n";
}

if ($sysioonly) {
        printf "Sbus I/O Bus Statistics\n";
        printf "-----------------------\n";
        &print_sysio_stats();
        print "\n";
}

if ($wfionly) {
        &print_wfi_total_tx();
        &print_wfi_ratios();
        print "\n";
}


sub print_event_averages
{
        local ($ctr);

        print "Event_Name #events/sec #instances #events/sec/instance\n";
        
        #print "CPU\n";
        print "\n";
        foreach $ctr (sort (keys %cpu_total)) {
                printf("%s %.4f %d %.4f\n",
                                                        $ctr,
                                                        $cpu_total{$ctr},
                                                        $cpu_total_count{$ctr},
                                                        
$cpu_total{$ctr}/$cpu_total_count{$ctr});
        }
        #print "AC\n";
        print "\n";
        foreach $ctr (sort (keys %ac_total)) {
                printf("%s %.4f %d %.4f\n",
                                                        $ctr,
                                                        $ac_total{$ctr},
                                                        $ac_total_count{$ctr},
                                                        
$ac_total{$ctr}/$ac_total_count{$ctr});
        }
        #print "SYSIO\n";
        print "\n";
        foreach $ctr (sort (keys %sysio_total)) {
                printf("%s %.4f %d %.4f\n",
                                                        $ctr,
                                                        $sysio_total{$ctr},
                                                        
$sysio_total_count{$ctr},
                                                        
$sysio_total{$ctr}/$sysio_total_count{$ctr});
        }
        #print "WFI\n";
        print "\n";
        foreach $ctr (sort (keys %wfi_total)) {
                printf("%s %.4f %d %.4f\n",
                                                        $ctr,
                                                        $wfi_total{$ctr},
                                                        $wfi_total_count{$ctr},
                                                        
$wfi_total{$ctr}/$wfi_total_count{$ctr});
        }
}

sub print_all_averages 
{
        local ($before, %part_name, $key, $ctr_set, $part_num, $mode, $ctr);
        $before = "none";
        print "Event_name #events/sec Instance_Type Instance_number\n";
        foreach $key (sort mycmp (keys %time)) {
                ($ctr_set, $part_num, $ctr) = split(",",$key);
                if ( $before ne $ctr_set ) { print "\n";}
                printf("%s %.4f %s %d\n",
                                        $ctr,
                                        $persec{$key},
                                        $ctr_set,
                                        $part_num);
                $before = $ctr_set;
        }
}



sub mycmp 
{
        ($ctr_set_a, $part_num_a, $mode_a, $ctr_a) = split(",", $a);
        ($ctr_set_b, $part_num_b, $mode_b, $ctr_b) = split(",", $b);

        $ctr_set_a cmp $ctr_set_b ||
        $part_num_a <=> $part_num_b ||
        $ctr_a cmp $ctr_b;
}


sub print_cpu_cpi_breakdown
{
        print "CPI     Data_Stall   IcMiss     BrMiss  FpUse  \n";
        &print_one_cpu_ratio_tab("Cycle_cnt", "Instr_cnt");
        &print_cpu_dstall;
        &print_one_cpu_ratio_tab("Dispatch0_IC_miss", "Instr_cnt");
        &print_cpu_brmiss;
        &print_one_cpu_ratio_tab("Rstall_FP_use", "Instr_cnt");
        printf "\n";
        print "\nData_stall components\n";
        print "----------------------\n";
        print "Dmiss_emiss Dmiss_stall  IU_use     StBuf   RAW \n"; 
#       &print_cpu_dmiss_ehit;
        &print_cpu_emiss;
        &print_one_cpu_ratio_tab("Re_DC_miss", "Instr_cnt");
        print "     ";
        &print_one_cpu_ratio_tab("Rstall_IU_use", "Instr_cnt");
        &print_one_cpu_ratio_tab("Rstall_storeQ", "Instr_cnt");
        &print_one_cpu_ratio_tab("Re_RAW_miss", "Instr_cnt");
        printf "\n";
        printf "\n";

        #print "CPI     IcMiss  FpUse  Dmiss_stall  IU_use  StBuf    RAW \n";
        print "CPI     IcMiss  Dmiss_stall  IU_use   StBuf    RAW \n";
foreach $psr (@psr_list) {
                @pnum = split(/\t/, $psr);
                &print_one_indiv_cpu_ratio_tab("Cycle_cnt", 
"Instr_cnt",@pnum[0]);
                &print_one_indiv_cpu_ratio_tab("Dispatch0_IC_miss", 
"Instr_cnt",@pnum[0]) ;
#                &print_one_indiv_cpu_ratio_tab("Rstall_FP_use", "Instr_cnt", 
@pnum[0]);
        #print "----------------------\n";
        #print "Dmiss_stall  IU_use     StBuf   RAW \n"; 
        print "   ";
                &print_one_indiv_cpu_ratio_tab("Re_DC_miss", "Instr_cnt", 
@pnum[0]);
        print "   ";
                &print_one_indiv_cpu_ratio_tab("Rstall_IU_use", "Instr_cnt" 
,@pnum[0]);
                &print_one_indiv_cpu_ratio_tab("Rstall_storeQ", 
"Instr_cnt",@pnum [0]);
                &print_one_indiv_cpu_ratio_tab("Re_RAW_miss", 
"Instr_cnt",@pnum[0]);
                printf "(%d)\n",@pnum[0];
        }

        printf "\n";

}

sub print_user_cpu_cpi_breakdown
{
        print "CPI     Data_Stall   IcMiss     BrMiss  FpUse  \n";
        &print_one_user_cpu_ratio_tab("Cycle_cnt", "Instr_cnt");
        &print_user_cpu_dstall;
        &print_one_user_cpu_ratio_tab("Dispatch0_IC_miss", "Instr_cnt");
        &print_user_cpu_brmiss;
        &print_one_user_cpu_ratio_tab("Rstall_FP_use", "Instr_cnt");
        printf "\n";
        print "\nData_stall components\n";
        print "----------------------\n";
        print "Dmiss_emiss Dmiss_stall  IU_use     StBuf   RAW \n"; 
#       &print_user_cpu_dmiss_ehit;
        &print_user_cpu_emiss;
        &print_one_user_cpu_ratio_tab("Re_DC_miss", "Instr_cnt");
        print "     ";
        &print_one_user_cpu_ratio_tab("Rstall_IU_use", "Instr_cnt");
        &print_one_user_cpu_ratio_tab("Rstall_storeQ", "Instr_cnt");
        &print_one_user_cpu_ratio_tab("Re_RAW_miss", "Instr_cnt");
        printf "\n";
        printf "\n";

        #print "CPI     IcMiss  FpUse  Dmiss_stall  IU_use  StBuf    RAW \n";
        print "CPI     IcMiss  Dmiss_stall  IU_use   StBuf    RAW \n";
foreach $psr (@psr_list) {
                @pnum = split(/\t/, $psr);
                &print_one_indiv_user_cpu_ratio_tab("Cycle_cnt", 
"Instr_cnt",@pnum[0]);
                &print_one_indiv_user_cpu_ratio_tab("Dispatch0_IC_miss", 
"Instr_cnt",@pnum[0]) ;
#                &print_one_indiv_user_cpu_ratio_tab("Rstall_FP_use", 
"Instr_cnt", @pnum[0]);
        #print "----------------------\n";
        #print "Dmiss_stall  IU_use     StBuf   RAW \n"; 
        print "   ";
                &print_one_indiv_user_cpu_ratio_tab("Re_DC_miss", "Instr_cnt", 
@pnum[0]);
        print "   ";
                &print_one_indiv_user_cpu_ratio_tab("Rstall_IU_use", 
"Instr_cnt" ,@pnum[0]);
                &print_one_indiv_user_cpu_ratio_tab("Rstall_storeQ", 
"Instr_cnt",@pnum [0]);
                &print_one_indiv_user_cpu_ratio_tab("Re_RAW_miss", 
"Instr_cnt",@pnum[0]);
                printf "(%d)\n",@pnum[0];
        }

        printf "\n";
}

sub print_kernel_cpu_cpi_breakdown
{
        print "CPI     Data_Stall   IcMiss     BrMiss  FpUse  \n";
        &print_one_kernel_cpu_ratio_tab("Cycle_cnt", "Instr_cnt");
        &print_kernel_cpu_dstall;
        &print_one_kernel_cpu_ratio_tab("Dispatch0_IC_miss", "Instr_cnt");
        &print_kernel_cpu_brmiss;
        &print_one_kernel_cpu_ratio_tab("Rstall_FP_use", "Instr_cnt");
        printf "\n";
        print "\nData_stall components\n";
        print "----------------------\n";
        print "Dmiss_emiss Dmiss_stall  IU_use     StBuf   RAW \n"; 
#       &print_kernel_cpu_dmiss_ehit;
        &print_kernel_cpu_emiss;
        &print_one_kernel_cpu_ratio_tab("Re_DC_miss", "Instr_cnt");
        print "     ";
        &print_one_kernel_cpu_ratio_tab("Rstall_IU_use", "Instr_cnt");
        &print_one_kernel_cpu_ratio_tab("Rstall_storeQ", "Instr_cnt");
        &print_one_kernel_cpu_ratio_tab("Re_RAW_miss", "Instr_cnt");
        printf "\n";
        printf "\n";
        #print "CPI     IcMiss  FpUse  Dmiss_stall  IU_use  StBuf    RAW \n";
        print "CPI     IcMiss  Dmiss_stall  IU_use   StBuf    RAW \n";
foreach $psr (@psr_list) {
                @pnum = split(/\t/, $psr);
                &print_one_indiv_kernel_cpu_ratio_tab("Cycle_cnt", 
"Instr_cnt",@pnum[0]);
                &print_one_indiv_kernel_cpu_ratio_tab("Dispatch0_IC_miss", 
"Instr_cnt",@pnum[0]) ;
#                &print_one_indiv_kernel_cpu_ratio_tab("Rstall_FP_use", 
"Instr_cnt", @pnum[0]);
        #print "----------------------\n";
        #print "Dmiss_stall  IU_use     StBuf   RAW \n"; 
        print "   ";
                &print_one_indiv_kernel_cpu_ratio_tab("Re_DC_miss", 
"Instr_cnt", @pnum[0]);
        print "   ";
                &print_one_indiv_kernel_cpu_ratio_tab("Rstall_IU_use", 
"Instr_cnt" ,@pnum[0]);
                &print_one_indiv_kernel_cpu_ratio_tab("Rstall_storeQ", 
"Instr_cnt",@pnum [0]);
                &print_one_indiv_kernel_cpu_ratio_tab("Re_RAW_miss", 
"Instr_cnt",@pnum[0]);
                printf "(%d)\n",@pnum[0];
        }

        printf "\n";
}

sub print_cpu_mips
{
        local ($node, $key);

        print "MIPS\t";
        printf("%.0f    ", $cpu_total{"Instr_cnt"});
        print "TPS\t";
        printf("%.2f    ", ${tps});
        print "M-Instr/Txn \t";
        printf("%.4f    ", $cpu_total{"Instr_cnt"}/${tps});
        printf "\n";
        printf "\n";
        foreach $ind (keys %cpu_per_part_num) {
        ($part_num,$ctr) = split(",",$ind);
        if ($ctr eq "Instr_cnt") {
                printf("CPU %d \t %.0f    \n", $part_num, 
$cpu_per_part_num{$ind});
                }
        }
        printf "\n";
}

sub print_user_cpu_mips
{
        local ($node, $key);

        print "MIPS\t";
        printf("%.0f    ", $user_cpu_total{"Instr_cnt"});
        print "TPS\t";
        printf("%.2f    ", ${tps});
        print "M-Instr/Txn \t";
        printf("%.4f    ", $user_cpu_total{"Instr_cnt"}/${tps});
        printf "\n";
        printf "\n";
        foreach $ind (keys %user_per_part_num) {
        ($part_num,$ctr) = split(",",$ind);
        if ($ctr eq "Instr_cnt") {
                printf("CPU %d \t %.0f    \n", $part_num, 
$user_per_part_num{$ind});
                }
        }
        printf "\n";
}

sub print_kernel_cpu_mips
{
        local ($node, $key);

        print "MIPS\t";
        printf("%.0f    ", $kernel_cpu_total{"Instr_cnt"});
        print "TPS\t";
        printf("%.2f    ", ${tps});
        print "M-Instr/Txn \t";
        printf("%.4f    ", $kernel_cpu_total{"Instr_cnt"}/${tps});
        printf "\n";
        printf "\n";
        foreach $ind (keys %kernel_per_part_num) {
        ($part_num,$ctr) = split(",",$ind);
        if ($ctr eq "Instr_cnt") {
                printf("CPU %d \t %.0f    \n", $part_num, 
$kernel_per_part_num{$ind});
                }
        }
        printf "\n";
}

sub print_cpu_cache_stats
{
        print "IcMissTotal  IcMiss  DcMiss  Dc_rd_Miss  EcMiss  Ec_ic_miss  
Ec_rd_miss   EcWB\n";
        if ( $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%       ",
                        ($cpu_total{"IC_miss"} * 100 ) /
                        $cpu_total{"Instr_cnt"});
        }  else { printf(" empty  "); }
        &print_cpu_icmiss();
        &print_cpu_dcmiss();
        &print_cpu_dc_rd_miss();
        &print_cpu_ecmiss();
        if ( $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%       ",
                        ($cpu_total{"EC_ic_miss"} * 100 ) /
                        $cpu_total{"Instr_cnt"});
        }  else { printf(" empty  "); }
        if ( $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%    ",
                        ($cpu_total{"EC_rd_miss"} * 100 ) /
                        $cpu_total{"Instr_cnt"});
        }  else { printf(" empty  "); }

        &print_one_cpu_ratio_pct("EC_wb", "Instr_cnt");
        if (defined $cpu_total{"EC_snoop_cb"} &&
            defined $ac_total{"addr_pkts"} && 
            $ac_total{"addr_pkts"} != 0 ) {
                printf("%.2f%%  ", 
$cpu_total{"EC_snoop_cb"}/($ac_total{"addr_pkts"}/$ac_total_count{"addr_pkts"}) 
* 100 );
        } else { return; }
        printf "\n";
}

sub print_user_cpu_cache_stats
{
        print "IcMissTotal  IcMiss  DcMiss  Dc_rd_Miss  EcMiss  Ec_ic_miss  
Ec_rd_miss   EcWB\n";
        if ( $user_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%       ",
                        ($user_cpu_total{"IC_miss"} * 100 ) /
                        $user_cpu_total{"Instr_cnt"});
        }  else { printf(" empty  "); }
        &print_user_cpu_icmiss();
        &print_user_cpu_dcmiss();
        &print_user_cpu_dc_rd_miss();
        &print_user_cpu_ecmiss();
        if ( $user_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%       ",
                        ($user_cpu_total{"EC_ic_miss"} * 100 ) /
                        $user_cpu_total{"Instr_cnt"});
        }  else { printf(" empty  "); }
        if ( $user_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%    ",
                        ($user_cpu_total{"EC_rd_miss"} * 100 ) /
                        $user_cpu_total{"Instr_cnt"});
        }  else { printf(" empty  "); }
        
        &print_one_user_cpu_ratio_pct("EC_wb", "Instr_cnt");
        printf "\n";
}

sub print_kernel_cpu_cache_stats
{
        print "IcMissTotal  IcMiss  DcMiss  Dc_rd_Miss  EcMiss  Ec_ic_miss  
Ec_rd_miss   EcWB\n";
        if ( $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%       ",
                        ($kernel_cpu_total{"IC_miss"} * 100 ) /
                        $kernel_cpu_total{"Instr_cnt"});
        }  else { printf(" empty  "); }
        &print_kernel_cpu_icmiss();
        &print_kernel_cpu_dcmiss();
        &print_kernel_cpu_dc_rd_miss();
        &print_kernel_cpu_ecmiss();
        if ( $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%       ",
                        ($kernel_cpu_total{"EC_ic_miss"} * 100 ) /
                        $kernel_cpu_total{"Instr_cnt"});
        }  else { printf(" empty  "); }
        if ( $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%    ",
                        ($kernel_cpu_total{"EC_rd_miss"} * 100 ) /
                        $kernel_cpu_total{"Instr_cnt"});
        }  else { printf(" empty  "); }
        &print_one_kernel_cpu_ratio_pct("EC_wb", "Instr_cnt");
        printf "\n";
}

                
sub print_wfi_total_tx
{
        local($node, $k1, $k2, $k3, $k4, $k5);

        print "million tx per second on the wfi interconnect\n";
        printf("Overall : %.3f\n",$wfi_total{"remote_NUMA_coherent_transacti"}+
                                  $wfi_total{"remote_non-coherent_transactio"}+
                                  $wfi_total{"MTAG_miss_transactions"}+
                                  $wfi_total{"remote_interrupt_transactions"}+
                                  $wfi_total{"WFI_generated_transactions"});
        printf("Per Node : ");
        for ($node=0; $node<$SSMNodes; $node++) {
                $k1=join(",", ("WFI",$node,"remote_NUMA_coherent_transacti"));
                $k2=join(",", ("WFI",$node,"remote_non-coherent_transactio"));
                $k3=join(",", ("WFI",$node,"MTAG_miss_transactions"));
                $k4=join(",", ("WFI",$node,"remote_interrupt_transactions"));
                $k5=join(",", ("WFI",$node,"WFI_generated_transactions"));

                if ( !defined $persec{$k1} ) { next;}

                printf("%.3f(%d) ", $persec{$k1} + $persec{$k2} +
                                    $persec{$k3} + $persec{$k4} +
                                    $persec{$k5}, $node);
        }
        printf("\n\n");
}


sub print_wfi_ratios 
{

        print "remote/local coherent tx ratio\n";
        &print_one_wfi_ratio("remote_NUMA_coherent_transacti",
                            "local_coherent_transactions");
        printf("\n\n");

        print "mtag miss-shared/ mtag miss ratio\n";
        &print_one_wfi_ratio("MTAG_miss_shared_transactions",
                             "MTAG_miss_transactions");
        printf("\n\n");

        print "GA2LPA cache hit ratio\n";
        &print_one_wfi_ratio("GA2LPA_cache_hits",
                             "GA2LPA_cache_total_accesses");
        printf("\n\n");
        
        print "Directory cache hit ratio\n";
        &print_one_wfi_ratio("directory_cache_hits",
                             "directory_cache_total_accesses");
        printf("\n\n");
        
        print "NUMA excess miss/remote NUMA coherent tx ratio\n";
        &print_one_wfi_ratio("NUMA_excess_misses",
                             "remote_NUMA_coherent_transacti");
        printf("\n\n");
        
        print "MTAG misses/local coherent tx ratio\n";
        &print_one_wfi_ratio("MTAG_miss_transactions",
                             "local_coherent_transactions");
        printf("\n\n");
}

sub print_one_wfi_ratio
{
        local ($ctr1, $ctr2) = ($_[0], $_[1]);
        local ($node, $key1, $key2);

        if (defined $wfi_total{$ctr1} && defined $wfi_total{$ctr2} && 
            $wfi_total{$ctr2} != 0 ) {
                printf("Overall : %.3f\n",$wfi_total{$ctr1}/ $wfi_total{$ctr2});
        } else { return;}

        printf("Per Node : ");
        for ($node=0; $node < $SSMNodes; $node++) {
                $key1="WFI".",".$node.","."$ctr1";
                $key2="WFI".",".$node.","."$ctr2";
                if (defined $persec{$key1} && defined $persec{$key2} &&
                    $persec{$key2} != 0 ) {
                        printf("%.3f(%d) ",$persec{$key1}/$persec{$key2},$node);
                }
        }
}

sub print_one_cpu_ratio_tab
{
        local ($ctr1, $ctr2) = ($_[0], $_[1]);
        local ($node, $key1, $key2);
        #print "$cpu_total{$ctr1}, $cpu_total{$ctr2} \n";  
        if (defined $cpu_total{$ctr1} && defined $cpu_total{$ctr2} && 
            $cpu_total{$ctr2} != 0 ) {
                printf("%.3f    ", $cpu_total{$ctr1}/$cpu_total{$ctr2});
        } else { printf(" empty  "); }
}

sub print_one_user_cpu_ratio_tab
{
        local ($ctr1, $ctr2) = ($_[0], $_[1]);
        local ($node, $key1, $key2);
       # print "$ctr1, ctr2 \n";  

        if (defined $user_cpu_total{$ctr1} && defined $user_cpu_total{$ctr2} && 
            $user_cpu_total{$ctr2} != 0 ) {
                printf("%.3f    ", 
$user_cpu_total{$ctr1}/$user_cpu_total{$ctr2});
        } else { printf(" empty  "); }
}

sub print_one_kernel_cpu_ratio_tab
{
        local ($ctr1, $ctr2) = ($_[0], $_[1]);
        local ($node, $key1, $key2);
       # print "$kernel_cpu_total{Dispatch0_mispred}, 
$kernel_cpu_total{Instr_cnt} \n";
        if (defined $kernel_cpu_total{$ctr1} && defined 
$kernel_cpu_total{$ctr2} && 
            $kernel_cpu_total{$ctr2} != 0 ) {
                printf("%.3f    ", 
$kernel_cpu_total{$ctr1}/$kernel_cpu_total{$ctr2});
        } else { printf(" empty  "); }
}

sub print_one_cpu_ratio_pct
{
        local ($ctr1, $ctr2) = ($_[0], $_[1]);
        local ($node, $key1, $key2);

        if (defined $cpu_total{$ctr1} && defined $cpu_total{$ctr2} && 
            $cpu_total{$ctr2} != 0 ) {
                printf("%.2f%%  ", $cpu_total{$ctr1}/$cpu_total{$ctr2}* 100);
        } else { return; }
}

sub print_one_user_cpu_ratio_pct
{
        local ($ctr1, $ctr2) = ($_[0], $_[1]);
        local ($node, $key1, $key2);

        if (defined $user_cpu_total{$ctr1} && defined $user_cpu_total{$ctr2} && 
            $user_cpu_total{$ctr2} != 0 ) {
                printf("%.2f%%  ", 
$user_cpu_total{$ctr1}/$user_cpu_total{$ctr2}* 100);
        } else { return; }
}

sub print_one_kernel_cpu_ratio_pct
{
        local ($ctr1, $ctr2) = ($_[0], $_[1]);
        local ($node, $key1, $key2);

        if (defined $kernel_cpu_total{$ctr1} && defined 
$kernel_cpu_total{$ctr2} && 
            $kernel_cpu_total{$ctr2} != 0 ) {
                printf("%.2f%%  ", 
$kernel_cpu_total{$ctr1}/$kernel_cpu_total{$ctr2}* 100);
        } else { return; }
}

sub print_cpu_dmiss_ehit
{
       local($node, $k1, $k2, $k3);

       if ( $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f        ",
                        ($cpu_total{"Re_DC_miss"}-$cpu_total{"Re_EC_miss"} ) /
                        $cpu_total{"Instr_cnt"});
       }  else { printf(" empty  "); }
}

sub print_user_cpu_dmiss_ehit
{
       local($node, $k1, $k2, $k3);

       if ( $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f        ",
                        
($user_cpu_total{"Re_DC_miss"}-$user_cpu_total{"Re_EC_miss"}) /
                        $user_cpu_total{"Instr_cnt"});
       }  else { printf(" empty  "); }
}

sub print_kernel_cpu_dmiss_ehit
{
       local($node, $k1, $k2, $k3);

       if ( $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f         ",
                        
($kernel_cpu_total{"Re_DC_miss"}-$kernel_cpu_total{"Re_EC_miss"}) /
                        $kernel_cpu_total{"Instr_cnt"});
       }  else { printf(" empty  "); }
}

sub print_cpu_emiss
{
       local($node, $k1, $k2);

       if ( $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f       ",
                        ($cpu_total{"Re_EC_miss"}+($cpu_total{"Re_DC_missovhd"}*
                        $cpu_total{"EC_rd_miss"}/$cpu_total{"DC_rd_miss"})) /
                        $cpu_total{"Instr_cnt"});
       }  else { printf(" empty  "); }
}

sub print_user_cpu_emiss
{
       local($node, $k1, $k2);

       if ( $user_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f       ",
                        
($user_cpu_total{"Re_EC_miss"}+($user_cpu_total{"Re_DC_missovhd"}*
                        
$user_cpu_total{"EC_rd_miss"}/$user_cpu_total{"DC_rd_miss"})) /
                        $user_cpu_total{"Instr_cnt"});
       }  else { printf(" empty  "); }
}

sub print_kernel_cpu_emiss
{
       local($node, $k1, $k2);

       if ( $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f       ",
                        
($kernel_cpu_total{"Re_EC_miss"}+($kernel_cpu_total{"Re_DC_missovhd"}*
                        
$kernel_cpu_total{"EC_rd_miss"}/$kernel_cpu_total{"DC_rd_miss"})) /
                        $kernel_cpu_total{"Instr_cnt"});
       }  else { printf(" empty  "); }
}


sub print_cpu_brmiss
{
        local($node, $k1, $k2, $k3,$k4);

        if ( $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f    ",
                        
($cpu_total{"Dispatch0_mispred"}+$cpu_total{"Dispatch0_br_target"}+
                         
$cpu_total{"Dispatch_rs_mispred"}+$cpu_total{"Dispatch0_2nd_br"})  /
                        $cpu_total{"Instr_cnt"});
        } else { return; }
}

sub print_user_cpu_brmiss
{
        local($node, $k1, $k2, $k3,$k4);

        if ( $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f    ",
                        
($user_cpu_total{"Dispatch0_mispred"}+$user_cpu_total{"Dispatch0_br_target"}+
                         
$user_cpu_total{"Dispatch_rs_mispred"}+$user_cpu_total{"Dispatch0_2nd_br"})  /
                        $user_cpu_total{"Instr_cnt"});
        } else { return; }
}

sub print_kernel_cpu_brmiss
{
        local($node, $k1, $k2, $k3,$k4);

        if ( $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f    ",
                        ($kernel_cpu_total{"Dispatch0_mispred"}+
                         $kernel_cpu_total{"Dispatch0_br_target"}+
                         $kernel_cpu_total{"Dispatch_rs_mispred"}+
                         $kernel_cpu_total{"Dispatch0_2nd_br"})  /
                        $kernel_cpu_total{"Instr_cnt"});
        } else { return; }
}

sub print_cpu_icmiss
{
        local($node, $k1, $k2, $k3);

        if (defined $cpu_total{"IC_ref"} &&
            defined $cpu_total{"IC_miss"} &&
                defined $cpu_total{"Instr_cnt"} &&
            $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%   ",
                        ($cpu_total{"IC_miss"}-$cpu_total{"IC_miss_cancelled"}) 
 /
                        $cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub print_user_cpu_icmiss
{
        local($node, $k1, $k2, $k3);

        if (defined $user_cpu_total{"IC_ref"} &&
            defined $user_cpu_total{"IC_miss"} &&
                defined $user_cpu_total{"Instr_cnt"} &&
            $user_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%   ",
                        
($user_cpu_total{"IC_miss"}-$user_cpu_total{"IC_miss_cancelled"})  /
                        $user_cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub print_kernel_cpu_icmiss
{
        local($node, $k1, $k2, $k3);

        if (defined $kernel_cpu_total{"IC_ref"} &&
            defined $kernel_cpu_total{"IC_miss"} &&
                defined $kernel_cpu_total{"Instr_cnt"} &&
            $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%   ",
                        
($kernel_cpu_total{"IC_miss"}-$kernel_cpu_total{"IC_miss_cancelled"})  /
                        $kernel_cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub print_user_cpu_dstall
{
       local($node, $k1, $k2, $k3,$k4,$k5,$k6,$k7,$k8);

       if ( $user_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f       ",
                        
(($user_cpu_total{"Re_DC_miss"}+$user_cpu_total{"Rstall_storeQ"}+ 
                         $user_cpu_total{"Rstall_IU_use"} +
                         $user_cpu_total{"Re_RAW_miss"})+ 12 * 
($user_cpu_total{"Re__PC_miss"} + 
                         $user_cpu_total{"Re_FPU_bypass"}+ 
$user_cpu_total{"Re_endian_miss"})) /
                         $user_cpu_total{"Instr_cnt"});
       }  else { printf(" empty  "); }
}

sub print_kernel_cpu_dstall
{
       local($node, $k1, $k2, $k3,$k4,$k5,$k6,$k7,$k8);

       if ( $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f       ",
                        
(($kernel_cpu_total{"Re_DC_miss"}+$kernel_cpu_total{"Rstall_storeQ"}+ 
                         $kernel_cpu_total{"Rstall_IU_use"} +
                         $kernel_cpu_total{"Re_RAW_miss"})+ 12 * 
($kernel_cpu_total{"Re__PC_miss"} + 
                         $kernel_cpu_total{"Re_FPU_bypass"}+ 
$kernel_cpu_total{"Re_endian_miss"})) /
                         $kernel_cpu_total{"Instr_cnt"});
       }  else { printf(" empty  "); }
}

sub print_cpu_dstall
{
       local($node, $k1, $k2, $k3,$k4,$k5,$k6,$k7,$k8);

       if ( $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.3f       ",
                        (($cpu_total{"Re_DC_miss"}+$cpu_total{"Rstall_storeQ"}+ 
$cpu_total{"Rstall_IU_use"} +
                         $cpu_total{"Re_RAW_miss"})+ 12 * 
($cpu_total{"Re__PC_miss"} + 
                         $cpu_total{"Re_FPU_bypass"}+ 
$cpu_total{"Re_endian_miss"})) /
                         $cpu_total{"Instr_cnt"});
       }  else { printf(" empty  "); }
}

sub print_cpu_ecmiss
{
        local($node, $k1, $k2, $k3);

        if (defined $cpu_total{"EC_ref"} &&
            defined $cpu_total{"EC_misses"} &&
                defined $cpu_total{"Instr_cnt"} &&
            $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%   ",
                        ($cpu_total{"EC_misses"})  /
                        $cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub print_user_cpu_ecmiss
{
        local($node, $k1, $k2, $k3);

        if (defined $user_cpu_total{"EC_ref"} &&
            defined $user_cpu_total{"EC_misses"} &&
                defined $user_cpu_total{"Instr_cnt"} &&
            $user_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%   ",
                        ($user_cpu_total{"EC_misses"})  /
                        $user_cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub print_kernel_cpu_ecmiss
{
        local($node, $k1, $k2, $k3);

        if (defined $kernel_cpu_total{"EC_ref"} &&
            defined $kernel_cpu_total{"EC_misses"} &&
                defined $kernel_cpu_total{"Instr_cnt"} &&
            $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%   ",
                        ($kernel_cpu_total{"EC_misses"})  /
                        $kernel_cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub  print_cpu_dcmiss
{
        local($node, $k1, $k2, $k3, $k4, $k5);

        if (defined $cpu_total{"DC_rd_miss"} &&
            defined $cpu_total{"DC_wr_miss"} &&
            defined $cpu_total{"DC_rd"} &&
            defined $cpu_total{"DC_wr"} &&
                defined $cpu_total{"Instr_cnt"} &&
            $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%   ",
                        ($cpu_total{"DC_rd_miss"} + $cpu_total{"DC_wr_miss"}) / 
                        $cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub  print_cpu_dc_rd_miss
{
        local($node, $k1, $k2);

        if (defined $cpu_total{"DC_rd_miss"} &&
                defined $cpu_total{"Instr_cnt"} &&
            $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%       ",
                        ($cpu_total{"DC_rd_miss"}) / 
                        $cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub  print_user_cpu_dc_rd_miss
{
        local($node, $k1, $k2);

        if (defined $user_cpu_total{"DC_rd_miss"} &&
                defined $user_cpu_total{"Instr_cnt"} &&
            $user_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%       ",
                        ($user_cpu_total{"DC_rd_miss"}) / 
                        $user_cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub  print_kernel_cpu_dc_rd_miss
{
        local($node, $k1, $k2);

        if (defined $kernel_cpu_total{"DC_rd_miss"} &&
                defined $kernel_cpu_total{"Instr_cnt"} &&
            $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%      ",
                        ($kernel_cpu_total{"DC_rd_miss"}) / 
                        $kernel_cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub  print_cpu_dc_wr_miss
{
        local($node, $k1, $k2);

        if (defined $cpu_total{"DC_wr_miss"} &&
                defined $cpu_total{"Instr_cnt"} &&
            $cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%       ",
                        ($cpu_total{"DC_wr_miss"}) / 
                        $cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub  print_user_cpu_dc_wr_miss
{
        local($node, $k1, $k2);

        if (defined $user_cpu_total{"DC_wr_miss"} &&
                defined $user_cpu_total{"Instr_cnt"} &&
            $user_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%      ",
                        ($user_cpu_total{"DC_wr_miss"}) / 
                        $user_cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub  print_kernel_cpu_dc_wr_miss
{
        local($node, $k1, $k2);

        if (defined $kernel_cpu_total{"DC_wr_miss"} &&
                defined $kernel_cpu_total{"Instr_cnt"} &&
            $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%       ",
                        ($kernel_cpu_total{"DC_wr_miss"}) / 
                        $kernel_cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub  print_user_cpu_dcmiss
{
        local($node, $k1, $k2, $k3, $k4, $k5);

        if (defined $user_cpu_total{"DC_rd_miss"} &&
            defined $user_cpu_total{"DC_wr_miss"} &&
            defined $user_cpu_total{"DC_rd"} &&
            defined $user_cpu_total{"DC_wr"} &&
                defined $user_cpu_total{"Instr_cnt"} &&
            $user_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%   ",
                        ($user_cpu_total{"DC_rd_miss"} + 
$user_cpu_total{"DC_wr_miss"}) / 
                        $user_cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}

sub  print_kernel_cpu_dcmiss
{
        local($node, $k1, $k2, $k3, $k4, $k5);

        if (defined $kernel_cpu_total{"DC_rd_miss"} &&
            defined $kernel_cpu_total{"DC_wr_miss"} &&
            defined $kernel_cpu_total{"DC_rd"} &&
            defined $kernel_cpu_total{"DC_wr"} &&
                defined $kernel_cpu_total{"Instr_cnt"} &&
            $kernel_cpu_total{"Instr_cnt"} != 0 ) {
                printf("%.2f%%   ",
                        ($kernel_cpu_total{"DC_rd_miss"} + 
$kernel_cpu_total{"DC_wr_miss"}) / 
                        $kernel_cpu_total{"Instr_cnt"} * 100 );
        } else { return; }
}


sub usage
{
        print "
        usage : $0 [-i <infile>] [-o <outfile>] [-v] [<infile>]
        -i <name>: input file name
        -o <name>: output file name
        -uk:  print PCU user and kernel related data
        -v : turn on verbose 
        
        -cpu   : print only CPU related data
        -ac    : print only AC related data
        -sysio : print only SYSIO related data
        -wfi   : print only WFI related data\n
        -avg   : print only the per second counter values
        -eavg  : print only the per second event counts \n";

        exit 1;
}

sub print_ac_gigaplane_stats
{
        print "AbUtil   DbUtil  RTS     RTSA    RTO     WB\n";
        &print_ac_abutil();
        &print_ac_dbutil();
        &print_ac_getone("rts_pkts");
        &print_ac_getone("rtsa_pkts");
        &print_ac_getone("rto_pkts");
        &print_ac_getone("wb_pkts");
        print "\n";
        print "RIO      WIO     RBIO    WBIO    RS      WS\n";
        &print_ac_getone("rio_pkts");
        &print_ac_getone("wio_pkts");
        &print_ac_getone("rbio_pkts");
        &print_ac_getone("wbio_pkts");
        &print_ac_getone("rs_pkts");
        &print_ac_getone("ws_pkts");
        print "\n";
}

sub print_ac_getone
{
        local($ctr) = ($_[0]);
        local(%val, $node, $key, $oval);

        if (!defined $ac_total{$ctr}) { return;}
        for ($node=0; $node < $SSMNodes; $node++) {
                $key = $node.",".$ctr;
                if (defined $ac_pernode{$key}) {
                        $val{$node} = $ac_pernode{$key}/$ac_pernode_count{$key};
                        $oval += $val{$node};
                }
        }
        printf("%.3f    ", $oval);
}

sub print_ac_abutil
{
        local ($node, $key1, $key2, $str, $sum, $cnt, $val);

        if (!defined $ac_total{"addr_pkts"} ||
            !defined $ac_total{"Cycle_cnt"} ) { 
                return;
        }
        for ($node=0; $node < $SSMNodes; $node++) {
                $key1 = $node.","."addr_pkts";
                $key2 = $node.","."Cycle_cnt";
                if (defined $ac_pernode{$key1} &&
                    defined $ac_pernode{$key2} ) {
                        $val = (($ac_pernode{$key1}/$ac_pernode_count{$key1}) * 
2) /
                               ($ac_pernode{$key2}/$ac_pernode_count{$key2});
                        $str = $str . sprintf("%.3f(%d) ", $val, $node);
                $sum += $val;
                $cnt += 1;
                }
        }
        printf("%.1f%%  ", $sum/$cnt * 100);
}


sub print_ac_dbutil
{
        local ($node, $key1, $key2, $str, $sum, $cnt, $val);

        if (!defined $ac_total{"data_pkts"} ||
            !defined $ac_total{"Cycle_cnt"} ) { 
                return;
        }
        for ($node=0; $node < $SSMNodes; $node++) {
                $key1 = $node.","."data_pkts";
                $key2 = $node.","."Cycle_cnt";
                if (defined $ac_pernode{$key1} &&
                    defined $ac_pernode{$key2} ) {
                        $val = (($ac_pernode{$key1}/$ac_pernode_count{$key1}) * 
2) /
                               ($ac_pernode{$key2}/$ac_pernode_count{$key2});
                        $str = $str . sprintf("%.3f(%d) ", $val, $node);
                $sum += $val;
                $cnt += 1;
                }
        }
        printf("%.1f%%  ", $sum/$cnt * 100);
}

sub print_ac_membank_stats
{
        local ($i);
        local($key_r0, $key_w0, $key_r1, $key_w1);
        local($key_r2, $key_w2, $key_r3, $key_w3);
        local ($r_total, $w_total) = 0;

        print "CPUid Bank   Mrd/sec  Mwr/sec\n";
        for ($i=0; $i < (1 << $AcExp) * $SSMNodes; $i++) {
        $key_r0 = join(",",("cpu",$i,"uk","MC_reads_0"));
        $key_w0 = join(",",("cpu",$i,"uk","MC_writes_0"));
        $key_r1 = join(",",("cpu",$i,"uk","MC_reads_1"));
        $key_w1 = join(",",("cpu",$i,"uk","MC_writes_1"));
        $key_r2 = join(",",("cpu",$i,"uk","MC_reads_2"));
        $key_w2 = join(",",("cpu",$i,"uk","MC_writes_2"));
        $key_r3 = join(",",("cpu",$i,"uk","MC_reads_3"));
        $key_w3 = join(",",("cpu",$i,"uk","MC_writes_3"));
        if (defined $persec{$key_r0} &&
            defined $persec{$key_w0} &&
            defined $persec{$key_r1} &&
            defined $persec{$key_w1} &&
                defined $persec{$key_r2} &&
                defined $persec{$key_w2} &&
            defined $persec{$key_r3} &&
            defined $persec{$key_w3} ) {
                        printf("%d      %d      %.3f    %.3f\n",
                        $i, 0, $persec{$key_r0}, $persec{$key_w0});
                        printf("%d      %d      %.3f    %.3f\n",
                        $i, 1, $persec{$key_r1}, $persec{$key_w1});
                        printf("%d      %d      %.3f    %.3f\n",
                        $i, 2, $persec{$key_r2}, $persec{$key_w2});
                        printf("%d      %d      %.3f    %.3f\n",
                        $i, 3, $persec{$key_r3}, $persec{$key_w3});
                        $r_total += ($persec{$key_r0} + $persec{$key_r1} + 
$persec{$key_r2} + $persec{$key_r3});
                        $w_total += ($persec{$key_w0} + $persec{$key_w1} + 
$persec{$key_w2} + $persec{$key_w3});
                        }
        }
        printf("Total         %.3f   %.3f\n", $r_total, $w_total);
        print "\n";

}

sub print_sysio_stats
{
        local ($i);
        local($key_x, $key_i, $val_x, $val_i);
        local($total_x, $total_i) = 0;
        
        print "Ctl#     MB/sec  Kintr/sec\n";
        for ($i=0; $i < (1<<$SysioExp) * $SSMNodes; $i++) {
                $key_x = join(",",("sbus",$i,"NA","dvma_bytes_xfrd"));
                $key_i = join(",",("sbus",$i,"NA","interrupts"));
                if (defined $persec{$key_x} || defined $persec{$key_i}) { 
                        if (defined $persec{$key_x}) 
                                { $val_x = $persec{$key_x}; }
                        else 
                                { $val_x = -1.0; }
                        if (defined $persec{$key_i}) 
                                { $val_i = $persec{$key_i}; }
                        else     
                                { $val_i = -1.0; }

                        printf("%d      %.3f    %.1f\n", $i, $val_x, $val_i * 
1000);
                        $total_x += $val_x; 
                        $total_i += $val_i;
                        }
                }

        printf("Total   %.3f    %.1f\n", $total_x, $total_i * 1000);
}

sub print_one_indiv_cpu_ratio_tab
{
        local ($ctr1, $ctr2, $part_num) = ($_[0], $_[1], $_[2]);
        local ($node, $key1, $key2);
if ($cpu_per_part_num{$part_num.",".$ctr2} != 0) {
                printf("%.3f   ", 
$cpu_per_part_num{$part_num.",".$ctr1}/$cpu_per_part_num{$part_num.",".$ctr2});
        } else { return; }

}

sub print_one_indiv_user_cpu_ratio_tab
{

        local ($ctr1, $ctr2, $part_num) = ($_[0], $_[1], $_[2]);
        local ($node, $key1, $key2);


if ($user_per_part_num{$part_num.",".$ctr2} != 0) {
                printf("%.3f   ", 
$user_per_part_num{$part_num.",".$ctr1}/$user_per_part_num{$part_num.",".$ctr2});
        } else { return; }
}

sub print_one_indiv_kernel_cpu_ratio_tab
{

        local ($ctr1, $ctr2, $part_num) = ($_[0], $_[1], $_[2]);
        local ($node, $key1, $key2);


if ($kernel_per_part_num{$part_num.",".$ctr2} != 0) {
                printf("%.3f   ", 
$kernel_per_part_num{$part_num.",".$ctr1}/$kernel_per_part_num{$part_num.",".$ctr2});
        } else { return; }
}

_______________________________________________
perf-discuss mailing list
perf-discuss@opensolaris.org

Reply via email to