mirror of
https://github.com/enjoy-digital/litedram.git
synced 2025-01-04 09:52:25 -05:00
test: calculate benchmark bandwidth and efficiency
This commit is contained in:
parent
804a9b3727
commit
e822e6be9f
1 changed files with 68 additions and 26 deletions
|
@ -8,14 +8,31 @@ import subprocess
|
||||||
|
|
||||||
from litedram.common import Settings
|
from litedram.common import Settings
|
||||||
|
|
||||||
|
from benchmark import LiteDRAMBenchmarkSoC
|
||||||
|
|
||||||
|
|
||||||
# constructs python regex named group
|
# constructs python regex named group
|
||||||
def ng(name, regex):
|
def ng(name, regex):
|
||||||
return r'(?P<{}>{})'.format(name, regex)
|
return r'(?P<{}>{})'.format(name, regex)
|
||||||
|
|
||||||
|
|
||||||
|
def human_readable(value):
|
||||||
|
binary_prefixes = ['', 'k', 'M', 'G', 'T']
|
||||||
|
for prefix in binary_prefixes:
|
||||||
|
if value < 1024:
|
||||||
|
break
|
||||||
|
value /= 1024
|
||||||
|
return value, prefix
|
||||||
|
|
||||||
|
|
||||||
|
def run_benchmark(args):
|
||||||
|
command = ['python3', 'benchmark.py', *args]
|
||||||
|
proc = subprocess.run(command, capture_output=True, text=True, check=True)
|
||||||
|
return proc.stdout
|
||||||
|
|
||||||
|
|
||||||
class BenchmarkConfiguration(Settings):
|
class BenchmarkConfiguration(Settings):
|
||||||
def __init__(self, sdram_module, sdram_data_width, bist_base, bist_length, bist_random):
|
def __init__(self, sdram_module, sdram_data_width, bist_length, bist_random):
|
||||||
self.set_attributes(locals())
|
self.set_attributes(locals())
|
||||||
self._settings = {k: v for k, v in locals().items() if v != self}
|
self._settings = {k: v for k, v in locals().items() if v != self}
|
||||||
|
|
||||||
|
@ -35,6 +52,8 @@ class BenchmarkResult:
|
||||||
def __init__(self, config, output):
|
def __init__(self, config, output):
|
||||||
self.config = config
|
self.config = config
|
||||||
self.parse_output(output)
|
self.parse_output(output)
|
||||||
|
# instantiate the benchmarked soc to check its configuration
|
||||||
|
self.benchmark_soc = LiteDRAMBenchmarkSoC(**self.config._settings)
|
||||||
|
|
||||||
def parse_output(self, output):
|
def parse_output(self, output):
|
||||||
bist_pattern = r'{stage}\s+{var}:\s+{value}'
|
bist_pattern = r'{stage}\s+{var}:\s+{value}'
|
||||||
|
@ -53,37 +72,60 @@ class BenchmarkResult:
|
||||||
self.checker_errors = find('BIST-CHECKER', 'errors')
|
self.checker_errors = find('BIST-CHECKER', 'errors')
|
||||||
self.checker_ticks = find('BIST-CHECKER', 'ticks')
|
self.checker_ticks = find('BIST-CHECKER', 'ticks')
|
||||||
|
|
||||||
|
def cmd_count(self):
|
||||||
|
data_width = self.benchmark_soc.sdram.controller.interface.data_width
|
||||||
|
return self.config.bist_length / (data_width // 8)
|
||||||
|
|
||||||
def run_benchmark(args):
|
def clk_period(self):
|
||||||
command = ['python3', 'benchmark.py', *args]
|
clk_freq = self.benchmark_soc.sdrphy.module.clk_freq
|
||||||
proc = subprocess.run(command, capture_output=True, text=True, check=True)
|
return 1 / clk_freq
|
||||||
return proc.stdout
|
|
||||||
|
def write_bandwidth(self):
|
||||||
|
return (8 * self.config.bist_length) / (self.generator_ticks * self.clk_period())
|
||||||
|
|
||||||
|
def read_bandwidth(self):
|
||||||
|
return (8 * self.config.bist_length) / (self.checker_ticks * self.clk_period())
|
||||||
|
|
||||||
|
def write_efficiency(self):
|
||||||
|
return self.cmd_count() / self.generator_ticks
|
||||||
|
|
||||||
|
def read_efficiency(self):
|
||||||
|
return self.cmd_count() / self.checker_ticks
|
||||||
|
|
||||||
|
|
||||||
configurations = [
|
configurations = [
|
||||||
BenchmarkConfiguration('MT48LC16M16', 32, 0, 4096, True),
|
BenchmarkConfiguration('MT48LC16M16', 32, 4096, True),
|
||||||
BenchmarkConfiguration('MT48LC16M16', 32, 0, 4096, False),
|
BenchmarkConfiguration('MT48LC16M16', 32, 512, False),
|
||||||
BenchmarkConfiguration('MT48LC16M16', 32, 0, 512, False),
|
BenchmarkConfiguration('MT46V32M16', 32, 512, False),
|
||||||
BenchmarkConfiguration('MT41K128M16', 8, 0, 1024, False),
|
BenchmarkConfiguration('MT46V32M16', 32, 2048, False),
|
||||||
BenchmarkConfiguration('MT41K128M16', 16, 0, 1024, False),
|
BenchmarkConfiguration('MT47H64M16', 32, 1024, False),
|
||||||
BenchmarkConfiguration('MT41K128M16', 32, 0, 1024, False),
|
BenchmarkConfiguration('MT47H64M16', 16, 1024, False),
|
||||||
|
BenchmarkConfiguration('MT41K128M16', 16, 1024, False),
|
||||||
|
BenchmarkConfiguration('MT41K128M16', 32, 1024, False),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
results = []
|
def main():
|
||||||
for config in configurations:
|
results = []
|
||||||
args = config.as_args()
|
for config in configurations:
|
||||||
print('Benchmark: %s' % ' '.join(args))
|
args = config.as_args()
|
||||||
|
print('Benchmark: %s' % ' '.join(args))
|
||||||
|
|
||||||
result = BenchmarkResult(config, run_benchmark(args))
|
result = BenchmarkResult(config, run_benchmark(args))
|
||||||
results.append(result)
|
results.append(result)
|
||||||
|
|
||||||
print("""\
|
print("""\
|
||||||
generator_ticks = {:d}
|
write_bandwidth = {:6.3f} {}bps
|
||||||
checker_ticks = {:d}
|
read_bandwidth = {:6.3f} {}bps
|
||||||
checker_errors = {:d}
|
write_efficiency = {:6.2f} %
|
||||||
""".rstrip().format(
|
read_efficiency = {:6.2f} %
|
||||||
result.generator_ticks,
|
""".rstrip().format(
|
||||||
result.checker_ticks,
|
*human_readable(result.write_bandwidth()),
|
||||||
result.checker_errors,
|
*human_readable(result.read_bandwidth()),
|
||||||
))
|
result.write_efficiency() * 100,
|
||||||
|
result.read_efficiency() * 100,
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in a new issue