summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/generate-dfa-benchmark.py13
-rw-r--r--lib/codegen.py16
2 files changed, 26 insertions, 3 deletions
diff --git a/bin/generate-dfa-benchmark.py b/bin/generate-dfa-benchmark.py
index 640f4a1..8489d40 100755
--- a/bin/generate-dfa-benchmark.py
+++ b/bin/generate-dfa-benchmark.py
@@ -12,6 +12,12 @@ definition, each symbol corresponds to a function call with a specific set of
arguments (so all argument combinations are present in the generated runs).
Options:
+--accounting=static_state|static_state_immediate|static_statetransition|static_statetransition_immedate
+ Select accounting method for dummy driver generation
+
+--dummy=<class name>
+ Generate and use a dummy driver for online energy model overhead evaluation
+
--depth=<depth> (default: 3)
Maximum number of function calls per run
@@ -174,6 +180,7 @@ if __name__ == '__main__':
try:
optspec = (
+ 'accounting= '
'arch= '
'app= '
'depth= '
@@ -244,7 +251,11 @@ if __name__ == '__main__':
pta.set_random_energy_model()
- drv = MultipassDriver(opt['dummy'], pta, repo.class_by_name[opt['dummy']], enum=enum, accounting=StaticStateOnlyAccounting(opt['dummy'], pta))
+ if 'accounting' in opt:
+ accounting_object = get_accountingmethod(opt['accounting'])(opt['dummy'], pta)
+ else:
+ accounting_object = None
+ drv = MultipassDriver(opt['dummy'], pta, repo.class_by_name[opt['dummy']], enum=enum, accounting=accounting_object)
with open('/home/derf/var/projects/multipass/src/driver/dummy.cc', 'w') as f:
f.write(drv.impl)
with open('/home/derf/var/projects/multipass/include/driver/dummy.h', 'w') as f:
diff --git a/lib/codegen.py b/lib/codegen.py
index 2d106df..30e79bb 100644
--- a/lib/codegen.py
+++ b/lib/codegen.py
@@ -63,8 +63,20 @@ class ClassFunction:
return ''
return '{} {}::{}({}) {{\n{}}}\n'.format(self.return_type, self.class_name, self.name, ', '.join(self.arguments), self.body)
+def get_accountingmethod(method):
+ """Return AccountingMethod class for method."""
+ if method == 'static_state_immediate':
+ return StaticStateOnlyAccountingImmediateCalculation
+ if method == 'static_state':
+ return StaticStateOnlyAccounting
+ if method == 'static_statetransition_immediate':
+ return StaticAccountingImmediateCalculation
+ if method == 'static_statetransition':
+ return StaticAccounting
+ raise ValueError('Unknown accounting method')
+
class AccountingMethod:
- def __init__(self, class_name: str, pta: PTA, ):
+ def __init__(self, class_name: str, pta: PTA):
self.class_name = class_name
self.pta = pta
self.include_paths = list()
@@ -228,7 +240,7 @@ class StaticAccountingImmediateCalculation(AccountingMethod):
))
get_energy_function = """
- return total_energy;
+ return totalEnergy;
""".format(energy_type = energy_type, num_states = len(pta.state), num_transitions = len(pta.get_unique_transitions()))
self.public_functions.append(ClassFunction(class_name, energy_type, 'getEnergy', list(), get_energy_function))