mirror of
https://github.com/ARM-software/devlib.git
synced 2025-04-17 07:10:03 +01:00
utils/gem5: try to cast statistics dump values
All values in the gem5 statistics log file are numeric. This commit adds a cast on the strings read from the stats file to native numeric values when and logs a warning in case of a malformed entry.
This commit is contained in:
parent
3c8294c6eb
commit
34d73e6af1
@ -72,7 +72,7 @@ class Gem5PowerInstrument(Instrument):
|
|||||||
sites_to_match = [self.site_mapping.get(s, s) for s in active_sites]
|
sites_to_match = [self.site_mapping.get(s, s) for s in active_sites]
|
||||||
for rec, rois in self.target.gem5stats.match_iter(sites_to_match,
|
for rec, rois in self.target.gem5stats.match_iter(sites_to_match,
|
||||||
[self.roi_label], self._base_stats_dump):
|
[self.roi_label], self._base_stats_dump):
|
||||||
writer.writerow([float(rec[s]) for s in active_sites])
|
writer.writerow([rec[s] for s in active_sites])
|
||||||
return MeasurementsCsv(outfile, self.active_channels, self.sample_rate_hz)
|
return MeasurementsCsv(outfile, self.active_channels, self.sample_rate_hz)
|
||||||
|
|
||||||
def reset(self, sites=None, kinds=None, channels=None):
|
def reset(self, sites=None, kinds=None, channels=None):
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from devlib.utils.types import numeric
|
||||||
|
|
||||||
|
|
||||||
GEM5STATS_FIELD_REGEX = re.compile("^(?P<key>[^- ]\S*) +(?P<value>[^#]+).+$")
|
GEM5STATS_FIELD_REGEX = re.compile("^(?P<key>[^- ]\S*) +(?P<value>[^#]+).+$")
|
||||||
@ -20,6 +23,8 @@ GEM5STATS_DUMP_HEAD = '---------- Begin Simulation Statistics ----------'
|
|||||||
GEM5STATS_DUMP_TAIL = '---------- End Simulation Statistics ----------'
|
GEM5STATS_DUMP_TAIL = '---------- End Simulation Statistics ----------'
|
||||||
GEM5STATS_ROI_NUMBER = 8
|
GEM5STATS_ROI_NUMBER = 8
|
||||||
|
|
||||||
|
logger = logging.getLogger('gem5')
|
||||||
|
|
||||||
|
|
||||||
def iter_statistics_dump(stats_file):
|
def iter_statistics_dump(stats_file):
|
||||||
'''
|
'''
|
||||||
@ -38,6 +43,11 @@ def iter_statistics_dump(stats_file):
|
|||||||
res = GEM5STATS_FIELD_REGEX.match(line)
|
res = GEM5STATS_FIELD_REGEX.match(line)
|
||||||
if res:
|
if res:
|
||||||
k = res.group("key")
|
k = res.group("key")
|
||||||
v = res.group("value").split()
|
vtext = res.group("value")
|
||||||
cur_dump[k] = v[0] if len(v)==1 else set(v)
|
try:
|
||||||
|
v = map(numeric, vtext.split())
|
||||||
|
cur_dump[k] = v[0] if len(v)==1 else set(v)
|
||||||
|
except ValueError:
|
||||||
|
msg = 'Found non-numeric entry in gem5 stats ({}: {})'
|
||||||
|
logger.warning(msg.format(k, vtext))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user