From 7dd934a5d8a9902d54385ea775558e2e8551570d Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Thu, 3 Aug 2017 16:41:10 +0100 Subject: [PATCH] Instrumentation: Update to populate missing 'sample_rate_hz` attributes To conform with the Instrumentation API each instrument should populate the `sample_rate_hz` attribute with the relevant information. --- devlib/instrument/acmecape.py | 1 + devlib/instrument/frames.py | 1 + devlib/instrument/gem5power.py | 13 ++++++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/devlib/instrument/acmecape.py b/devlib/instrument/acmecape.py index abf6a19..103a9f8 100644 --- a/devlib/instrument/acmecape.py +++ b/devlib/instrument/acmecape.py @@ -46,6 +46,7 @@ class AcmeCapeInstrument(Instrument): self.host = host self.iio_device = iio_device self.buffer_size = buffer_size + self.sample_rate_hz = 100 if self.iio_capture is None: raise HostError('Missing iio-capture binary') self.command = None diff --git a/devlib/instrument/frames.py b/devlib/instrument/frames.py index d5a2147..d43977f 100644 --- a/devlib/instrument/frames.py +++ b/devlib/instrument/frames.py @@ -16,6 +16,7 @@ class FramesInstrument(Instrument): self.collector_target = collector_target self.period = period self.keep_raw = keep_raw + self.sample_rate_hz = 1 / self.period self.collector = None self.header = None self._need_reset = True diff --git a/devlib/instrument/gem5power.py b/devlib/instrument/gem5power.py index 7715ec1..534046e 100644 --- a/devlib/instrument/gem5power.py +++ b/devlib/instrument/gem5power.py @@ -28,10 +28,10 @@ class Gem5PowerInstrument(Instrument): mode = CONTINUOUS roi_label = 'power_instrument' - + def __init__(self, target, power_sites): ''' - Parameter power_sites is a list of gem5 identifiers for power values. + Parameter power_sites is a list of gem5 identifiers for power values. One example of such a field: system.cluster0.cores0.power_model.static_power ''' @@ -51,6 +51,9 @@ class Gem5PowerInstrument(Instrument): self.add_channel(field, 'power') self.target.gem5stats.book_roi(self.roi_label) self.sample_period_ns = 10000000 + # Sample rate must remain unset as gem5 does not provide samples + # at regular intervals therefore the reported timestamp should be used. + self.sample_rate_hz = None self.target.gem5stats.start_periodic_dump(0, self.sample_period_ns) self._base_stats_dump = 0 @@ -59,17 +62,17 @@ class Gem5PowerInstrument(Instrument): def stop(self): self.target.gem5stats.roi_end(self.roi_label) - + def get_data(self, outfile): active_sites = [c.site for c in self.active_channels] with open(outfile, 'wb') as wfh: writer = csv.writer(wfh) writer.writerow([c.label for c in self.active_channels]) # headers - for rec, rois in self.target.gem5stats.match_iter(active_sites, + for rec, rois in self.target.gem5stats.match_iter(active_sites, [self.roi_label], self._base_stats_dump): writer.writerow([float(rec[s]) for s in active_sites]) return MeasurementsCsv(outfile, self.active_channels) - + def reset(self, sites=None, kinds=None, channels=None): super(Gem5PowerInstrument, self).reset(sites, kinds, channels) self._base_stats_dump = self.target.gem5stats.next_dump_no()