-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.stats
71 lines (57 loc) · 2.49 KB
/
README.stats
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
#!/usr/bin/python
# zsim stats README
# Author: Daniel Sanchez <[email protected]>
# Date: May 3 2011
#
# Stats are now saved in HDF5, and you should never need to write a stats
# parser. This README explains how to access them in python using h5py. It
# doubles as a python script, so you can just execute it with "python
# README.stats" and see how everything works (after you have generated a stats
# file).
#
import h5py # presents HDF5 files as numpy arrays
import numpy as np
# Open stats file
f = h5py.File('zsim-ev.h5', 'r')
# Get the single dataset in the file
dset = f["stats"]["root"]
# Each dataset is first indexed by record. A record is a snapshot of all the
# stats taken at a specific time. All stats files have at least two records,
# at beginning (dest[0])and end of simulation (dset[-1]). Inside each record,
# the format follows the structure of the simulated objects. A few examples:
# Phase count at end of simulation
endPhase = dset[-1]['phase']
print endPhase
# If your L2 has a single bank, this is all the L2 hits. Otherwise it's the
# hits of the first L2 bank
l2_0_hits = dset[-1]['l2'][0]['hGETS'] + dset[-1]['l2'][0]['hGETX']
print l2_0_hits
# Hits into all L2s
l2_hits = np.sum(dset[-1]['l2']['hGETS'] + dset[-1]['l2']['hGETX'])
print l2_hits
# Total number of instructions executed, counted by adding per-core counts
# (you could also look at procInstrs)
totalInstrs = np.sum(dset[-1]['simpleCore']['instrs'])
print totalInstrs
# You can also focus on one sample, or index over multiple steps, e.g.,
lastSample = dset[-1]
allHitsS = lastSample['l2']['hGETS']
firstL2HitsS = allHitsS[0]
print firstL2HitsS
# There is a certain slack in the positions of numeric and non-numeric indices,
# so the following are equivalent:
print dset[-1]['l2'][0]['hGETS']
#print dset[-1][0]['l2']['hGETS'] # can't do
print dset[-1]['l2']['hGETS'][0]
print dset['l2']['hGETS'][-1,0]
print dset['l2'][-1,0]['hGETS']
print dset['l2']['hGETS'][-1,0]
# However, you can't do things like dset[-1][0]['l2']['hGETS'], because the [0]
# indexes a specific element in array 'l2'. The rule of thumb seems to be that
# numeric indices can "flow up", i.e., you can index them later than you should.
# This introduces no ambiguities.
# Slicing works as in numpy, e.g.,
print dset['l2']['hGETS'] # a 2D array with samples*per-cache data
print dset['l2']['hGETS'][-1] # a 1D array with per-cache numbers, for the last sample
print dset['l2']['hGETS'][:,0] # 1D array with all samples, for the first L2 cache
# OK, now go bananas!