__init__.py (8295:221013f9fd2f) | __init__.py (8296:be7f03723412) |
---|---|
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; --- 13 unchanged lines hidden (view full) --- 22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 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 | 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; --- 13 unchanged lines hidden (view full) --- 22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 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 |
|
30from m5 import internal 31from m5.internal.stats import schedStatEvent as schedEvent 32from m5.objects import Root | 32from m5 import internal 33from m5.internal.stats import schedStatEvent as schedEvent 34from m5.objects import Root |
33from m5.util import attrdict | 35from m5.util import attrdict, fatal |
34 | 36 |
37outputList = [] |
|
35def initText(filename, desc=True): | 38def initText(filename, desc=True): |
36 internal.stats.initText(filename, desc) | 39 output = internal.stats.initText(filename, desc) 40 outputList.append(output) |
37 38def initMySQL(host, database, user='', passwd='', project='test', name='test', 39 sample='0'): 40 if not user: 41 import getpass 42 user = getpass.getuser() 43 | 41 42def initMySQL(host, database, user='', passwd='', project='test', name='test', 43 sample='0'): 44 if not user: 45 import getpass 46 user = getpass.getuser() 47 |
44 internal.stats.initMySQL(host, database, user, passwd, project, name, 45 sample) | 48 output = internal.stats.initMySQL(host, database, user, passwd, 49 project, name, sample) 50 outputList.append(output) |
46 47def initSimStats(): 48 internal.stats.initSimStats() 49 50names = [] 51stats_dict = {} 52stats_list = [] 53raw_stats_list = [] --- 11 unchanged lines hidden (view full) --- 65 val = cast(stat) 66 if val is not None: 67 stats_list.append(val) 68 raw_stats_list.append(val) 69 break 70 else: 71 fatal("unknown stat type %s", stat) 72 | 51 52def initSimStats(): 53 internal.stats.initSimStats() 54 55names = [] 56stats_dict = {} 57stats_list = [] 58raw_stats_list = [] --- 11 unchanged lines hidden (view full) --- 70 val = cast(stat) 71 if val is not None: 72 stats_list.append(val) 73 raw_stats_list.append(val) 74 break 75 else: 76 fatal("unknown stat type %s", stat) 77 |
78 for stat in stats_list: 79 if not stat.check() or not stat.baseCheck(): 80 fatal("stat check failed for '%s' %d\n", stat.name, stat.id) 81 82 if not (stat.flags & flags.display): 83 stat.name = "__Stat%06d" % stat.id 84 |
|
73 def less(stat1, stat2): 74 v1 = stat1.name.split('.') 75 v2 = stat2.name.split('.') 76 return v1 < v2 77 78 stats_list.sort(less) 79 for stat in stats_list: 80 stats_dict[stat.name] = stat | 85 def less(stat1, stat2): 86 v1 = stat1.name.split('.') 87 v2 = stat2.name.split('.') 88 return v1 < v2 89 90 stats_list.sort(less) 91 for stat in stats_list: 92 stats_dict[stat.name] = stat |
93 stat.enable() |
|
81 | 94 |
82 internal.stats.enable() | 95def prepare(): 96 '''Prepare all stats for data access. This must be done before 97 dumping and serialization.''' |
83 | 98 |
99 for stat in stats_list: 100 stat.prepare() 101 102lastDump = 0 |
|
84def dump(): | 103def dump(): |
85 # Currently prepare happens in the dump, but we should maybe move 86 # that out. | 104 '''Dump all statistics data to the registered outputs''' |
87 | 105 |
88 #internal.stats.prepare() 89 internal.stats.dump() | 106 curTick = m5.curTick() |
90 | 107 |
108 global lastDump 109 assert lastDump <= curTick 110 if lastDump == curTick: 111 return 112 lastDump = curTick 113 114 prepare() 115 116 for output in outputList: 117 if output.valid(): 118 output.begin() 119 for stat in stats_list: 120 output.visit(stat) 121 output.end() 122 |
|
91def reset(): | 123def reset(): |
124 '''Reset all statistics to the base state''' 125 |
|
92 # call reset stats on all SimObjects 93 root = Root.getInstance() 94 if root: 95 for obj in root.descendants(): obj.resetStats() 96 97 # call any other registered stats reset callbacks | 126 # call reset stats on all SimObjects 127 root = Root.getInstance() 128 if root: 129 for obj in root.descendants(): obj.resetStats() 130 131 # call any other registered stats reset callbacks |
98 internal.stats.reset() | 132 for stat in stats_list: 133 stat.reset() |
99 | 134 |
135 internal.stats.processResetQueue() 136 |
|
100flags = attrdict({ 101 'none' : 0x0000, 102 'init' : 0x0001, 103 'display' : 0x0002, 104 'total' : 0x0010, 105 'pdf' : 0x0020, 106 'cdf' : 0x0040, 107 'dist' : 0x0080, 108 'nozero' : 0x0100, 109 'nonan' : 0x0200, 110}) | 137flags = attrdict({ 138 'none' : 0x0000, 139 'init' : 0x0001, 140 'display' : 0x0002, 141 'total' : 0x0010, 142 'pdf' : 0x0020, 143 'cdf' : 0x0040, 144 'dist' : 0x0080, 145 'nozero' : 0x0100, 146 'nonan' : 0x0200, 147}) |