__init__.py (11788:342c0eaab188) __init__.py (11802:be62996c95d1)
1# Copyright (c) 2007 The Regents of The University of Michigan
2# Copyright (c) 2010 The Hewlett-Packard Development Company
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 15 unchanged lines hidden (view full) ---

24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28# Authors: Nathan Binkert
29
30import m5
31
1# Copyright (c) 2007 The Regents of The University of Michigan
2# Copyright (c) 2010 The Hewlett-Packard Development Company
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 15 unchanged lines hidden (view full) ---

24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28# Authors: Nathan Binkert
29
30import m5
31
32from m5 import internal
32import _m5.stats
33from m5.objects import Root
34from m5.util import attrdict, fatal
35
36# Stat exports
33from m5.objects import Root
34from m5.util import attrdict, fatal
35
36# Stat exports
37from m5.internal.stats import schedStatEvent as schedEvent
38from m5.internal.stats import periodicStatDump
37from _m5.stats import schedStatEvent as schedEvent
38from _m5.stats import periodicStatDump
39
40outputList = []
41def initText(filename, desc=True):
39
40outputList = []
41def initText(filename, desc=True):
42 output = internal.stats.initText(filename, desc)
42 output = _m5.stats.initText(filename, desc)
43 outputList.append(output)
44
45def initSimStats():
43 outputList.append(output)
44
45def initSimStats():
46 internal.stats.initSimStats()
47 internal.stats.registerPythonStatsHandlers()
46 _m5.stats.initSimStats()
47 _m5.stats.registerPythonStatsHandlers()
48
49names = []
50stats_dict = {}
51stats_list = []
52def enable():
53 '''Enable the statistics package. Before the statistics package is
54 enabled, all statistics must be created and initialized and once
55 the package is enabled, no more statistics can be created.'''
56
57 global stats_list
48
49names = []
50stats_dict = {}
51stats_list = []
52def enable():
53 '''Enable the statistics package. Before the statistics package is
54 enabled, all statistics must be created and initialized and once
55 the package is enabled, no more statistics can be created.'''
56
57 global stats_list
58 stats_list = list(internal.stats.statsList())
58 stats_list = list(_m5.stats.statsList())
59
60 for stat in stats_list:
61 if not stat.check() or not stat.baseCheck():
62 fatal("statistic '%s' (%d) was not properly initialized " \
63 "by a regStats() function\n", stat.name, stat.id)
64
65 if not (stat.flags & flags.display):
66 stat.name = "__Stat%06d" % stat.id
67
68 def less(stat1, stat2):
69 v1 = stat1.name.split('.')
70 v2 = stat2.name.split('.')
71 return v1 < v2
72
73 stats_list.sort(less)
74 for stat in stats_list:
75 stats_dict[stat.name] = stat
76 stat.enable()
77
59
60 for stat in stats_list:
61 if not stat.check() or not stat.baseCheck():
62 fatal("statistic '%s' (%d) was not properly initialized " \
63 "by a regStats() function\n", stat.name, stat.id)
64
65 if not (stat.flags & flags.display):
66 stat.name = "__Stat%06d" % stat.id
67
68 def less(stat1, stat2):
69 v1 = stat1.name.split('.')
70 v2 = stat2.name.split('.')
71 return v1 < v2
72
73 stats_list.sort(less)
74 for stat in stats_list:
75 stats_dict[stat.name] = stat
76 stat.enable()
77
78 internal.stats.enable();
78 _m5.stats.enable();
79
80def prepare():
81 '''Prepare all stats for data access. This must be done before
82 dumping and serialization.'''
83
84 for stat in stats_list:
85 stat.prepare()
86

--- 4 unchanged lines hidden (view full) ---

91 curTick = m5.curTick()
92
93 global lastDump
94 assert lastDump <= curTick
95 if lastDump == curTick:
96 return
97 lastDump = curTick
98
79
80def prepare():
81 '''Prepare all stats for data access. This must be done before
82 dumping and serialization.'''
83
84 for stat in stats_list:
85 stat.prepare()
86

--- 4 unchanged lines hidden (view full) ---

91 curTick = m5.curTick()
92
93 global lastDump
94 assert lastDump <= curTick
95 if lastDump == curTick:
96 return
97 lastDump = curTick
98
99 internal.stats.processDumpQueue()
99 _m5.stats.processDumpQueue()
100
101 prepare()
102
103 for output in outputList:
104 if output.valid():
105 output.begin()
106 for stat in stats_list:
107 stat.visit(output)

--- 6 unchanged lines hidden (view full) ---

114 root = Root.getInstance()
115 if root:
116 for obj in root.descendants(): obj.resetStats()
117
118 # call any other registered stats reset callbacks
119 for stat in stats_list:
120 stat.reset()
121
100
101 prepare()
102
103 for output in outputList:
104 if output.valid():
105 output.begin()
106 for stat in stats_list:
107 stat.visit(output)

--- 6 unchanged lines hidden (view full) ---

114 root = Root.getInstance()
115 if root:
116 for obj in root.descendants(): obj.resetStats()
117
118 # call any other registered stats reset callbacks
119 for stat in stats_list:
120 stat.reset()
121
122 internal.stats.processResetQueue()
122 _m5.stats.processResetQueue()
123
124flags = attrdict({
125 'none' : 0x0000,
126 'init' : 0x0001,
127 'display' : 0x0002,
128 'total' : 0x0010,
129 'pdf' : 0x0020,
130 'cdf' : 0x0040,
131 'dist' : 0x0080,
132 'nozero' : 0x0100,
133 'nonan' : 0x0200,
134})
123
124flags = attrdict({
125 'none' : 0x0000,
126 'init' : 0x0001,
127 'display' : 0x0002,
128 'total' : 0x0010,
129 'pdf' : 0x0020,
130 'cdf' : 0x0040,
131 'dist' : 0x0080,
132 'nozero' : 0x0100,
133 'nonan' : 0x0200,
134})