def option_performance(f):
"""Defines options for all aspects of performance tuning"""
_preset = {
# Fixed
'O1': {'autotune': True, 'dse': 'basic', 'dle': 'basic'},
'O2': {'autotune': True, 'dse': 'advanced', 'dle': 'advanced'},
'O3': {'autotune': True, 'dse': 'aggressive', 'dle': 'advanced'},
# Parametric
'dse': {'autotune': True,
'dse': ['basic', 'advanced', 'speculative', 'aggressive'],
'dle': 'advanced'},
'dle': {'autotune': True,
'dse': 'advanced',
'dle': ['basic', 'advanced']}
}
def from_preset(ctx, param, value):
"""Set all performance options according to bench-mode preset"""
ctx.params.update(_preset[value])
return value
def from_value(ctx, param, value):
"""Prefer preset values and warn for competing values."""
return ctx.params[param.name] or value
options = [
click.option('-bm', '--bench-mode', is_eager=True,
callback=from_preset, expose_value=False, default='O2',
type=click.Choice(['O1', 'O2', 'O3', 'dse', 'dle']),
help='Choose what to benchmark; ignored if execmode=run'),
click.option('--arch', default='unknown',
help='Architecture on which the simulation is/was run'),
click.option('--dse', callback=from_value,
type=click.Choice(['noop'] + configuration._accepted['dse']),
help='Devito symbolic engine (DSE) mode'),
click.option('--dle', callback=from_value,
type=click.Choice(['noop'] + configuration._accepted['dle']),
help='Devito loop engine (DLE) mode'),
click.option('-a', '--autotune', is_flag=True, callback=from_value,
help='Switch auto tuning on/off'),
]
for option in reversed(options):
f = option(f)
return f
评论列表
文章目录