diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-03-13 10:58:56 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-03-13 10:58:56 +0100 |
commit | 0c132a304eb001dcd7ff9ee578854c92686fe15b (patch) | |
tree | 156615f7ffb4b9dc36fe5a648d5b919a836bc801 | |
parent | 28d33c2006b88c40d9ff068f2ea3baa8ed6db44f (diff) |
WiP
-rwxr-xr-x | bin/generate-dfa-benchmark.py | 6 | ||||
-rwxr-xr-x | lib/dfatool.py | 40 | ||||
-rw-r--r-- | lib/harness.py | 27 |
3 files changed, 31 insertions, 42 deletions
diff --git a/bin/generate-dfa-benchmark.py b/bin/generate-dfa-benchmark.py index d4e7996..3019a2e 100755 --- a/bin/generate-dfa-benchmark.py +++ b/bin/generate-dfa-benchmark.py @@ -94,9 +94,9 @@ if __name__ == '__main__': class_prefix = '{}.'.format(pta.codegen['instance']) num_transitions = 0 - for run in pta.dfs(opt['depth'], with_arguments = True): + for run in pta.dfs(opt['depth'], with_arguments = True, with_parameters = True): outbuf.write(harness.start_run()) - for transition, arguments in run: + for transition, arguments, parameter in run: num_transitions += 1 outbuf.write('// {} -> {}\n'.format(transition.origin.name, transition.destination.name)) if transition.is_interrupt: @@ -104,7 +104,7 @@ if __name__ == '__main__': transition_code = '// TODO add startTransition / stopTransition calls to interrupt routine' else: transition_code = '{}{}({});'.format(class_prefix, transition.name, ', '.join(map(str, arguments))) - outbuf.write(harness.pass_transition(pta.get_transition_id(transition), transition_code)) + outbuf.write(harness.pass_transition(pta.get_transition_id(transition), transition_code, parameter)) if 'sleep' in opt: outbuf.write('arch.delay_ms({:d});\n'.format(opt['sleep'])) diff --git a/lib/dfatool.py b/lib/dfatool.py index a089c1d..297cd71 100755 --- a/lib/dfatool.py +++ b/lib/dfatool.py @@ -1134,6 +1134,8 @@ class AnalyticModel: def _add_trace_data_to_aggregate(aggregate, key, element): + # Only cares about element['isa'], element['offline_aggregates'], and + # element['plan']['level'] if not key in aggregate: aggregate[key] = { 'isa' : element['isa'] @@ -1143,6 +1145,7 @@ def _add_trace_data_to_aggregate(aggregate, key, element): if element['isa'] == 'state': aggregate[key]['attributes'] = ['power'] else: + # TODO do not hardcode values aggregate[key]['attributes'] = ['duration', 'energy', 'rel_energy_prev', 'rel_energy_next'] if element['plan']['level'] == 'epilogue': aggregate[key]['attributes'].insert(0, 'timeout') @@ -1162,16 +1165,6 @@ def pta_trace_to_aggregate(traces, ignore_trace_indexes = []): - name: str Name - isa: str state // transition - parameter: { ... globaler Parameter: aktueller wert. null falls noch nicht eingestellt } - - plan: - Falls isa == 'state': - - power: int(uW?) - - time: int(us) geplante Dauer - - energy: int(pJ?) - Falls isa == 'transition': - - timeout: int(us) oder null - - energy: int (pJ?) - - level: str 'user' 'epilogue' - - offline_attributes: [ ... Namen der in offline_aggregates gespeicherten Modellattribute, z.B. param, duration, energy, timeout ] - offline_aggregates: - power: [float(uW)] Mittlere Leistung während Zustand/Transitions - power_std: [float(uW^2)] Standardabweichung der Leistung @@ -1184,33 +1177,6 @@ def pta_trace_to_aggregate(traces, ignore_trace_indexes = []): - timeout: [int(us)] Dauer des vorherigen Zustands - rel_energy_prev: [int(pJ)] - rel_energy_next: [int(pJ)] - - offline: [ ... Während der Messung von MIMOSA o.ä. gemessene Werte - -> siehe doc/MIMOSA analyze_states - - isa: 'state' oder 'transition' - - clip_rate: range(0..1) Anteil an Clipping im Energieverbrauch - - raw_mean: Mittelwert der Rohwerte - - raw_std: Standardabweichung der Rohwerte - - uW_mean: Mittelwert der (kalibrierten) Leistungsaufnahme - - uW_std: Standardabweichung der (kalibrierten) Leistungsaufnahme - - us: Dauer - Nur falls isa 'transition': - - timeout: Dauer des vorherigen Zustands - - uW_mean_delta_prev - - uW_mean_delta_next - ] - - online: [ ... Während der Messung vom Betriebssystem bestimmte Daten - Falls isa == 'state': - - power: int(uW?) - - time: int(us) geplante Dauer - - energy: int(pJ?) - Falls isa == 'transition': - - timeout: int(us) oder null - - energy: int (pJ?) - - level: str ('user' oder 'epilogue') - ] - Falls isa == 'transition': - - code: [str] Name und Argumente der aufgerufenen Funktion - - args: [str] Argumente der aufgerufenen Funktion ] ] ignore_trace_indexes -- list of trace indexes. The corresponding taces will be ignored. diff --git a/lib/harness.py b/lib/harness.py index 1eb294b..2705193 100644 --- a/lib/harness.py +++ b/lib/harness.py @@ -4,9 +4,15 @@ Harnesses for various types of benchmark logs. tbd """ +# TODO prepare benchmark log JSON with parameters etc. +# Should be independent of PTA class, as benchmarks may also be +# generated otherwise and it should also work with AnalyticModel (which does +# not have states) class TransitionHarness: def __init__(self, gpio_pin = None): self.gpio_pin = gpio_pin + self.traces = [] + self.trace_id = 1 pass def global_code(self): @@ -23,10 +29,27 @@ class TransitionHarness: def start_benchmark(self): return 'ptalog.startBenchmark(0);\n' + def start_trace(self): + self.traces.append({ + 'id' : self.trace_id, + 'trace' : [{ + 'name' : 'UNINITIALIZED', + 'isa' : 'state', + 'parameter' : dict(), + 'offline_aggregates' : list(), + }] + }) + self.trace_id += 1 + + #def append_state(self): + + #def append_transition(self, ): + def start_run(self): + self.start_trace() return 'ptalog.reset();\n' - def pass_transition(self, transition_id, transition_code): + def pass_transition(self, transition_id, transition_code, parameter = dict()): ret = 'ptalog.passTransition({:d});\n'.format(transition_id) ret += 'ptalog.startTransition();\n' ret += '{}\n'.format(transition_code) @@ -56,7 +79,7 @@ class OnboardTimerHarness(TransitionHarness): ret += super().start_benchmark() return ret - def pass_transition(self, transition_id, transition_code): + def pass_transition(self, transition_id, transition_code, parameter = dict()): ret = 'ptalog.passTransition({:d});\n'.format(transition_id) ret += 'ptalog.startTransition();\n' ret += 'counter.start();\n' |