solo.tcl
9.22 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#
# 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.
#
#source "tcl_support.tcl"
for {set i 0} {$i < $PARAM(CPU.Count)} {incr i} {
set locks($i) 0
set lockRetries($i) 0
set unlocks($i) 0
set barriers($i) 0
set barrStart($i) 0
statistics create lockTime_$i
statistics create unlockTime_$i
statistics create barrTime_$i
}
# I have to add 4 since the code creates a LL then uses bnezl
set barEnd1 [expr [symbol read soloApp::_Barrier:START] + 76]
set barEnd2 [expr [symbol read soloApp::_Barrier:START] + 92]
## REGULAR ANL LOCKS
annotation set pre-pc [expr [symbol read soloApp::_LockEnter:START]] {
# log "LockEnter $CPU $a0 START $CYCLES\n"
if {![info exists lockStart($CPU,$a0)] || $lockStart($CPU,$a0) == 0} {
incr locks($CPU)
set lockStart($CPU,$a0) $CYCLES
} else {
incr lockRetries($CPU)
}
## Lock profiling info
set currentLock($CPU) $a0
if {[info exists lockWaiters($a0)]} {
incr lockWaiters($a0)
} else {
set lockWaiters($a0) 1
}
log "Lock S $CPU $a0 $CYCLES\n"
}
annotation set pc [symbol read soloApp::_LockEnter:END] {
# log "LockEnter $CPU $a2 END $CYCLES\n"
if {[info exists lockStart($CPU,$a2)] && $lockStart($CPU,$a2) > 0} {
set time [expr $CYCLES - $lockStart($CPU,$a2)]
statistics entry lockTime_$CPU $time
}
## Lock profiling info
set temp $currentLock($CPU)
log "Lock E $CPU $temp $CYCLES\n"
}
annotation set pre-pc soloApp::_Unlock:START {
# log "Unlock $CPU $a0 START $CYCLES\n"
if {$lockStart($CPU,$a0) != 0} {
incr unlocks($CPU)
set lockStart($CPU,$a0) 0
set unlockStart($CPU,$a0) $CYCLES
}
## Lock profiling info
set currentLock($CPU) $a0
# All I do here is figure out what we're unlocking.
}
annotation set pc soloApp::_Unlock:END {
# log "Unlock $CPU $a0 END $CYCLES\n"
if {[info exists unlockStart($CPU,$a0)] && $unlockStart($CPU,$a0) > 0} {
set time [expr $CYCLES - $unlockStart($CPU,$a0)]
statistics entry unlockTime_$CPU $time
}
## Lock profiling info
set lockWaiters($a0) [expr $lockWaiters($a0) - 1]
log "Unlock $CPU $temp $CYCLES (W: $lockWaiters($a0))\n"
if {$lockWaiters($a0) < 0} {
log "ERROR! Lock count $lockWaiters($a0) for lock $a0!!\n";
}
}
## FLASH LOCKS
#Uncomment for paranoid mode
if [
catch {
annotation set pre-pc soloApp::FLASHLock:START {
## FL Stats stuff
incr locks($CPU)
set lockStart($CPU,$a0) $CYCLES
#log "\n\nLockEnter $CPU $a0 START $CYCLES\n"
## Lock profiling info
set currentLock($CPU) $a0
if {[info exists lockWaiters($a0)]} {
incr lockWaiters($a0)
} else {
set lockWaiters($a0) 1
}
log "FLASHLock S $CPU $a0 $CYCLES\n"
}
annotation set pc soloApp::FLASHLock:END {
set temp $currentLock($CPU)
## FL Stats stuff
#log "\n\nLockEnter $CPU $temp END $CYCLES\n"
if {[info exists lockStart($CPU,$temp)] && $lockStart($CPU,$temp) > 0} {
set time [expr $CYCLES - $lockStart($CPU,$temp)]
statistics entry lockTime_$CPU $time
}
## Lock profiling info
log "FLASHLock E $CPU $temp $CYCLES\n"
}
annotation set pre-pc soloApp::FLASHUnlock:START {
## FL Stats stuff
#log "\n\nUnlock $CPU $a0 START $CYCLES\n"
if {$lockStart($CPU,$a0) != 0} {
incr unlocks($CPU)
set lockStart($CPU,$a0) 0
set unlockStart($CPU,$a0) $CYCLES
}
## Lock profiling info
set currentLock($CPU) $a0
# All I do here is figure out what we're unlocking.
}
annotation set pc soloApp::FLASHUnlock:END {
set temp $currentLock($CPU)
## FL Stats stuff
# log "\n\nUnlock $CPU $temp END $CYCLES\n"
if {[info exists unlockStart($CPU,$temp)] && $unlockStart($CPU,$temp) > 0} {
set time [expr $CYCLES - $unlockStart($CPU,$temp)]
statistics entry unlockTime_$CPU $time
}
## Lock profiling info
set lockWaiters($temp) [expr $lockWaiters($temp) - 1]
log "FLASHUnlock $CPU $temp $CYCLES (W: $lockWaiters($temp))\n"
if {$lockWaiters($temp) < 0} {
log "ERROR! Lock count $lockWaiters($temp) for lock $temp!!\n";
}
}
} msg ] {
console "*** NOTE: FLASH locks not annotated: $msg\n"
}
## MCS LOCKS
if [
catch {
annotation set pre-pc soloApp::acquireMCSlock:START {
## FL Stats stuff
incr locks($CPU)
set lockStart($CPU,$a0) $CYCLES
#log "\n\nLockEnter $CPU $a0 START $CYCLES\n"
## Lock profiling info
set currentLock($CPU) $a0
if {[info exists lockWaiters($a0)]} {
incr lockWaiters($a0)
} else {
set lockWaiters($a0) 1
}
log "MCSLock S $CPU $a0 $CYCLES\n"
}
annotation set pc soloApp::acquireMCSlock:END {
set temp $currentLock($CPU)
## FL Stats stuff
#log "\n\nLockEnter $CPU $temp END $CYCLES\n"
if {[info exists lockStart($CPU,$temp)] && $lockStart($CPU,$temp) > 0} {
set time [expr $CYCLES - $lockStart($CPU,$temp)]
statistics entry lockTime_$CPU $time
}
## Lock profiling info
log "MCSLock E $CPU $temp $CYCLES\n"
}
annotation set pre-pc soloApp::releaseMCSlock:START {
## FL Stats stuff
#log "\n\nUnlock $CPU $a0 START $CYCLES\n"
if {$lockStart($CPU,$a0) != 0} {
incr unlocks($CPU)
set lockStart($CPU,$a0) 0
set unlockStart($CPU,$a0) $CYCLES
}
## Lock profiling info
set currentLock($CPU) $a0
# All I do here is figure out what we're unlocking.
}
annotation set pc soloApp::releaseMCSlock:END {
set temp $currentLock($CPU)
## FL Stats stuff
# log "\n\nUnlock $CPU $temp END $CYCLES\n"
if {[info exists unlockStart($CPU,$temp)] && $unlockStart($CPU,$temp) > 0} {
set time [expr $CYCLES - $unlockStart($CPU,$temp)]
statistics entry unlockTime_$CPU $time
}
## Lock profiling info
set lockWaiters($temp) [expr $lockWaiters($temp) - 1]
log "MCSUnlock $CPU $temp $CYCLES (W: $lockWaiters($temp))\n"
if {$lockWaiters($temp) < 0} {
log "ERROR! Lock count $lockWaiters($temp) for lock $temp!!\n";
}
}
} msg ] {
console "*** NOTE: MCS locks not annotated: $msg\n"
}
annotation set pre-pc soloApp::_Barrier:START {
incr barriers($CPU)
set barrStart($CPU) $CYCLES
}
## Heinrich's Tree Barriers
#Uncomment for paranoid mode
if [
catch {
annotation set pre-pc soloApp::TreeBarrier:START {
console "Enter TreeBarrier on CPU $CPU at cycle $CYCLES\n"
incr barriers($CPU)
set barrStart($CPU) $CYCLES
}
annotation set pc soloApp::TreeBarrier:END {
if {$barrStart($CPU) > 0} {
console "Exit TreeBarrier on CPU $CPU at cycle $CYCLES\n"
set time [expr $CYCLES - $barrStart($CPU)]
statistics entry barrTime_$CPU $time
set barrStart($CPU) 0
}
}
} msg ] {
console "*** NOTE: Tree barriers not annotated: $msg\n"
}
## FLASH Barriers
#Uncomment for paranoid mode
if [
catch {
annotation set pre-pc soloApp::FLASHBarrier:START {
console "Enter FLASHBarrier on CPU $CPU at cycle $CYCLES\n"
incr barriers($CPU)
set barrStart($CPU) $CYCLES
}
annotation set pc soloApp::FLASHBarrier:END {
if {$barrStart($CPU) > 0} {
set time [expr $CYCLES - $barrStart($CPU)]
console "Exit FLASHBarrier on CPU $CPU at cycle $CYCLES (time: $time)\n"
statistics entry barrTime_$CPU $time
set barrStart($CPU) 0
}
}
} msg ] {
console "*** NOTE: FLASH Barriers not annotated: $msg\n"
}
annotation set pre-pc $barEnd1 {
if {$barrStart($CPU) > 0} {
set time [expr $CYCLES - $barrStart($CPU)]
statistics entry barrTime_$CPU $time
set barrStart($CPU) 0
}
}
annotation set pre-pc $barEnd2 {
if {$barrStart($CPU) > 0} {
set time [expr $CYCLES - $barrStart($CPU)]
statistics entry barrTime_$CPU $time
set barrStart($CPU) 0
}
}
annotation type solo enum { resetStats }
annotation set solo resetStats {
for {set i 0} {$i < $PARAM(CPU.Count)} {incr i} {
set locks($i) 0
set lockRetries($i) 0
set unlocks($i) 0
set barriers($i) 0
# set barrStart($i) 0
statistics reset lockTime_$i
statistics reset unlockTime_$i
statistics reset barrTime_$i
}
# unset lockStart
# unset unlockStart
}
annotation set simos exit {
for {set i 0} {$i < $PARAM(CPU.Count)} {incr i} {
log "C$i locks $locks($i) retries $lockRetries($i) unlocks $unlocks($i) barriers $barriers($i)\n"
log "C$i lock [statistics list lockTime_$i]\n"
log "C$i unlock [statistics list unlockTime_$i]\n"
log "C$i barrier [statistics list barrTime_$i]\n"
}
}