mirror of
https://github.com/ARM-software/devlib.git
synced 2025-09-04 19:11:53 +01:00
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.
This commit is contained in:
@@ -46,6 +46,7 @@ class AcmeCapeInstrument(Instrument):
|
|||||||
self.host = host
|
self.host = host
|
||||||
self.iio_device = iio_device
|
self.iio_device = iio_device
|
||||||
self.buffer_size = buffer_size
|
self.buffer_size = buffer_size
|
||||||
|
self.sample_rate_hz = 100
|
||||||
if self.iio_capture is None:
|
if self.iio_capture is None:
|
||||||
raise HostError('Missing iio-capture binary')
|
raise HostError('Missing iio-capture binary')
|
||||||
self.command = None
|
self.command = None
|
||||||
|
@@ -16,6 +16,7 @@ class FramesInstrument(Instrument):
|
|||||||
self.collector_target = collector_target
|
self.collector_target = collector_target
|
||||||
self.period = period
|
self.period = period
|
||||||
self.keep_raw = keep_raw
|
self.keep_raw = keep_raw
|
||||||
|
self.sample_rate_hz = 1 / self.period
|
||||||
self.collector = None
|
self.collector = None
|
||||||
self.header = None
|
self.header = None
|
||||||
self._need_reset = True
|
self._need_reset = True
|
||||||
|
@@ -28,10 +28,10 @@ class Gem5PowerInstrument(Instrument):
|
|||||||
|
|
||||||
mode = CONTINUOUS
|
mode = CONTINUOUS
|
||||||
roi_label = 'power_instrument'
|
roi_label = 'power_instrument'
|
||||||
|
|
||||||
def __init__(self, target, power_sites):
|
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:
|
One example of such a field:
|
||||||
system.cluster0.cores0.power_model.static_power
|
system.cluster0.cores0.power_model.static_power
|
||||||
'''
|
'''
|
||||||
@@ -51,6 +51,9 @@ class Gem5PowerInstrument(Instrument):
|
|||||||
self.add_channel(field, 'power')
|
self.add_channel(field, 'power')
|
||||||
self.target.gem5stats.book_roi(self.roi_label)
|
self.target.gem5stats.book_roi(self.roi_label)
|
||||||
self.sample_period_ns = 10000000
|
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.target.gem5stats.start_periodic_dump(0, self.sample_period_ns)
|
||||||
self._base_stats_dump = 0
|
self._base_stats_dump = 0
|
||||||
|
|
||||||
@@ -59,17 +62,17 @@ class Gem5PowerInstrument(Instrument):
|
|||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.target.gem5stats.roi_end(self.roi_label)
|
self.target.gem5stats.roi_end(self.roi_label)
|
||||||
|
|
||||||
def get_data(self, outfile):
|
def get_data(self, outfile):
|
||||||
active_sites = [c.site for c in self.active_channels]
|
active_sites = [c.site for c in self.active_channels]
|
||||||
with open(outfile, 'wb') as wfh:
|
with open(outfile, 'wb') as wfh:
|
||||||
writer = csv.writer(wfh)
|
writer = csv.writer(wfh)
|
||||||
writer.writerow([c.label for c in self.active_channels]) # headers
|
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):
|
[self.roi_label], self._base_stats_dump):
|
||||||
writer.writerow([float(rec[s]) for s in active_sites])
|
writer.writerow([float(rec[s]) for s in active_sites])
|
||||||
return MeasurementsCsv(outfile, self.active_channels)
|
return MeasurementsCsv(outfile, self.active_channels)
|
||||||
|
|
||||||
def reset(self, sites=None, kinds=None, channels=None):
|
def reset(self, sites=None, kinds=None, channels=None):
|
||||||
super(Gem5PowerInstrument, self).reset(sites, kinds, channels)
|
super(Gem5PowerInstrument, self).reset(sites, kinds, channels)
|
||||||
self._base_stats_dump = self.target.gem5stats.next_dump_no()
|
self._base_stats_dump = self.target.gem5stats.next_dump_no()
|
||||||
|
Reference in New Issue
Block a user