test: update benchmark configuration generator

This commit is contained in:
Jędrzej Boczar 2020-02-12 14:21:50 +01:00
parent 4f613b5b00
commit 5cd33f490f
2 changed files with 886 additions and 204 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,49 +1,57 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys
import json import json
import pprint
import argparse import argparse
import datetime
import itertools import itertools
default_modules = [
'IS42S16160', defaults = {
'IS42S16320', '--sdram-module': [
'MT48LC4M16', 'IS42S16160',
'MT48LC16M16', 'IS42S16320',
'AS4C16M16', 'MT48LC4M16',
'AS4C32M16', 'MT48LC16M16',
'AS4C32M8', 'AS4C16M16',
'M12L64322A', 'AS4C32M16',
'M12L16161A', 'AS4C32M8',
'MT46V32M16', 'M12L64322A',
'MT46H32M16', 'M12L16161A',
'MT46H32M32', 'MT46V32M16',
'MT47H128M8', 'MT46H32M16',
'MT47H32M16', 'MT46H32M32',
'MT47H64M16', 'MT47H128M8',
'P3R1GE4JGF', 'MT47H32M16',
'MT41K64M16', 'MT47H64M16',
'MT41J128M16', 'P3R1GE4JGF',
'MT41K128M16', 'MT41K64M16',
'MT41J256M16', 'MT41J128M16',
'MT41K256M16', 'MT41K128M16',
'K4B1G0446F', 'MT41J256M16',
'K4B2G1646F', 'MT41K256M16',
'H5TC4G63CFR', 'K4B1G0446F',
'IS43TR16128B', 'K4B2G1646F',
'MT8JTF12864', 'H5TC4G63CFR',
'MT8KTF51264', 'IS43TR16128B',
# 'MT18KSF1G72HZ', 'MT8JTF12864',
# 'AS4C256M16D3A', 'MT8KTF51264',
# 'MT16KTF1G64HZ', # 'MT18KSF1G72HZ',
# 'EDY4016A', # 'AS4C256M16D3A',
# 'MT40A1G8', # 'MT16KTF1G64HZ',
# 'MT40A512M16', # 'EDY4016A',
] # 'MT40A1G8',
default_bist_alternatings = [True, False] # 'MT40A512M16',
default_data_widths = [32] ],
default_bist_lengths = [1, 1024, 8192] '--sdram-data-width': [32],
default_bist_randoms = [True, False] '--bist-alternating': [True, False],
default_access_patterns = ['access_pattern.csv'] '--bist-length': [1, 4096],
'--bist-random': [True, False],
'--num-generators': [1],
'--num-checkers': [1],
'--access-pattern': ['access_pattern.csv']
}
def convert_string_arg(args, arg, type): def convert_string_arg(args, arg, type):
@ -54,59 +62,76 @@ def convert_string_arg(args, arg, type):
setattr(args, arg, [map_func[type](val) if not isinstance(val, type) else val for val in getattr(args, arg)]) setattr(args, arg, [map_func[type](val) if not isinstance(val, type) else val for val in getattr(args, arg)])
def generate_header(args):
header = 'Auto-generated on {} by {}'.format(
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
sys.argv[0],
)
args_str = pprint.pformat(vars(args), sort_dicts=False)
arg_lines = args_str.split('\n')
lines = [60*'=', header, 60*'-', *arg_lines, 60*'=']
return '\n'.join('# ' + line for line in lines)
def main(): def main():
parser = argparse.ArgumentParser(description='Generate configuration for all possible argument combinations.', parser = argparse.ArgumentParser(description='Generate configuration for all possible argument combinations.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--sdram-modules', nargs='+', default=default_modules, help='--sdram-module options') parser.add_argument('--name-format', default='test_%d', help='Name format for i-th test')
parser.add_argument('--sdram-data-widths', nargs='+', default=default_data_widths, help='--sdram-data-width options') for name, default in defaults.items():
parser.add_argument('--bist-alternatings', nargs='+', default=default_bist_alternatings, help='--bist-alternating options') parser.add_argument(name, nargs='+', default=default, help='%s options' % name)
parser.add_argument('--bist-lengths', nargs='+', default=default_bist_lengths, help='--bist-length options')
parser.add_argument('--bist-randoms', nargs='+', default=default_bist_randoms, help='--bist-random options')
parser.add_argument('--access-patterns', nargs='+', default=default_access_patterns, help='--access-pattern options')
parser.add_argument('--name-format', default='test_%d', help='Name format for i-th test')
args = parser.parse_args() args = parser.parse_args()
# make sure not to write those as strings # make sure not to write those as strings
convert_string_arg(args, 'sdram_data_widths', int) convert_string_arg(args, 'sdram_data_width', int)
convert_string_arg(args, 'bist_alternatings', bool) convert_string_arg(args, 'bist_alternating', bool)
convert_string_arg(args, 'bist_lengths', int) convert_string_arg(args, 'bist_length', int)
convert_string_arg(args, 'bist_randoms', bool) convert_string_arg(args, 'bist_random', bool)
convert_string_arg(args, 'num_generators', int)
convert_string_arg(args, 'num_checkers', int)
bist_product = itertools.product(args.sdram_modules, args.sdram_data_widths, args.bist_alternatings, common_args = ('sdram_module', 'sdram_data_width', 'bist_alternating', 'num_generators', 'num_checkers')
args.bist_lengths, args.bist_randoms) generated_pattern_args = ('bist_length', 'bist_random')
pattern_product = itertools.product(args.sdram_modules, args.sdram_data_widths, args.bist_alternatings, custom_pattern_args = ('access_pattern', )
args.access_patterns)
def generated_pattern_configuration(values):
config = dict(zip(common_args + generated_pattern_args, values))
# move access pattern parameters deeper
config['access_pattern'] = {
'bist_length': config.pop('bist_length'),
'bist_random': config.pop('bist_random'),
}
return config
def custom_pattern_configuration(values):
config = dict(zip(common_args + custom_pattern_args, values))
# "rename" --access-pattern to access_pattern.pattern_file due to name difference between
# command line args and run_benchmarks.py configuration format
config['access_pattern'] = {
'pattern_file': config.pop('access_pattern'),
}
return config
# iterator over the product of given command line arguments
def args_product(names):
return itertools.product(*(getattr(args, name) for name in names))
generated_pattern_iter = zip(itertools.repeat(generated_pattern_configuration), args_product(common_args + generated_pattern_args))
custom_pattern_iter = zip(itertools.repeat(custom_pattern_configuration), args_product(common_args + custom_pattern_args))
i = 0 i = 0
configurations = {} configurations = {}
for module, data_width, bist_alternating, bist_length, bist_random in bist_product: for config_generator, values in itertools.chain(generated_pattern_iter, custom_pattern_iter):
if bist_random and not bist_alternating: config = config_generator(values)
# ignore unsupported case: bist_random=True and bist_alternating=False
if config['access_pattern'].get('bist_random', False) and not config['bist_alternating']:
continue continue
configurations[args.name_format % i] = { configurations[args.name_format % i] = config
'sdram_module': module,
'sdram_data_width': data_width,
'bist_alternating': bist_alternating,
'access_pattern': {
'bist_length': bist_length,
'bist_random': bist_random,
}
}
i += 1
for module, data_width, bist_alternating, access_pattern in pattern_product:
if bist_random and not bist_alternating:
continue
configurations[args.name_format % i] = {
'sdram_module': module,
'sdram_data_width': data_width,
'bist_alternating': bist_alternating,
'access_pattern': {
'pattern_file': access_pattern,
}
}
i += 1 i += 1
json_str = json.dumps(configurations, indent=4) json_str = json.dumps(configurations, indent=4)
print(generate_header(args))
print(json_str) print(json_str)
if __name__ == "__main__": if __name__ == "__main__":
main() main()