1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-02-07 05:30:44 +00: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:
Quentin Perret 2017-08-17 10:40:10 +01:00
parent 3c8294c6eb
commit 34d73e6af1
2 changed files with 13 additions and 3 deletions

View File

@ -72,7 +72,7 @@ class Gem5PowerInstrument(Instrument):
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,
[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)
def reset(self, sites=None, kinds=None, channels=None):

View File

@ -13,6 +13,9 @@
# limitations under the License.
import re
import logging
from devlib.utils.types import numeric
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_ROI_NUMBER = 8
logger = logging.getLogger('gem5')
def iter_statistics_dump(stats_file):
'''
@ -38,6 +43,11 @@ def iter_statistics_dump(stats_file):
res = GEM5STATS_FIELD_REGEX.match(line)
if res:
k = res.group("key")
v = res.group("value").split()
cur_dump[k] = v[0] if len(v)==1 else set(v)
vtext = res.group("value")
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))