count_user_insts.tcl 1.55 KB
#
# Copyright (C) 1996-1998 by the Board of Trustees
#    of Leland Stanford Junior University.
# 
# This file is part of the SimOS distribution. 
# See LICENSE file for terms of the license. 
#

###
### count_user_insts.tcl
###
### $Author: blythe $
### $Date: 2002/05/29 01:09:09 $
###
###
### Cool way to count and print out how many user instructions go
### to each user process. This prints them periodically and at the
### end of the run.
###

for {set i 0} {$i < 16400} {incr i} {
    set countStartInstsPid($i)  0
    set countTotalPidInsts($i)  0
}

annotation set osEvent startUser {
    set pid $currentPid($CPU)
    if {$pid >= $IDLE_PID} {
        console "COUNT: START USER is idle $pid\n"
    }
    set countStartInstsPid($pid) $INSTS
}
#    log "COUNT: Starting $pid at $CYCLES and $INSTS insts\n"

annotation set osEvent endUser {
    set pid $currentPid($CPU)
    if {$pid >= $IDLE_PID} {
        console "COUNT: END USER is idle $pid\n"
    }
    set countInstsRun [expr $INSTS - $countStartInstsPid($pid)]
    set countTotalPidInsts($pid) [expr $countTotalPidInsts($pid) + $countInstsRun]
}
#    log "COUNT: Ending $pid at $CYCLES and $INSTS => $countInstsRun\n"

annotation set simos exit {
    for {set i 0} {$i < $IDLE_PID} {incr i} {
        if {$countTotalPidInsts($i) != 0} {
            log "COUNT: Pid $i => $countTotalPidInsts($i)\n"
        }
    }
}

annotation set simos periodic {
    for {set i 0} {$i < $IDLE_PID} {incr i} {
        if {$countTotalPidInsts($i) != 0} {
            log "COUNT: Pid $i => $countTotalPidInsts($i)\n"
        }
    }
}