count_user_insts.tcl
1.55 KB
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
#
# 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"
}
}
}