diff --git a/docs/latency_throughput.md b/docs/latency_throughput.md new file mode 100644 index 00000000..2ee1539a --- /dev/null +++ b/docs/latency_throughput.md @@ -0,0 +1,3 @@ +# Latency and Throughput of Instructions + +{{ latency_throughput_table() }} diff --git a/main.py b/main.py index c6f6f052..111da56d 100644 --- a/main.py +++ b/main.py @@ -20,7 +20,31 @@ with open(f'code/measure-{cpu}.csv', newline='') as csvfile: reader = csv.DictReader(csvfile) for row in reader: - measure[cpu][row['name']] = row + latency = [] + for part in row['latency'].split('/'): + if part == "": + lat = "N/A" + else: + lat = float(part) + if abs((lat - round(lat)) / lat) < 0.02: + lat = round(lat) + latency.append(lat) + latency = sorted(list(set(latency))) + + throughput_cpi = float(row['throughput(cpi)']) + if abs(throughput_cpi - round(throughput_cpi)) < 0.03: + throughput_cpi = round(throughput_cpi) + + # TODO: handle small cpi better by 1/ipc + throughput_ipc = float(row['throughput(ipc)']) + if abs(throughput_ipc - round(throughput_ipc)) < 0.03: + throughput_ipc = round(throughput_ipc) + + measure[cpu][row['name']] = { + 'latency': ", ".join(map(str, latency)), + 'throughput(cpi)': throughput_cpi, + 'throughput(ipc)': throughput_ipc, + } # depends on implementation of env.macro() def my_macro(env): @@ -103,29 +127,9 @@ def instruction(intrinsic, instr, desc): throughputs = [] for cpu in cpus: if instr_name in measure[cpu]: - latency = [] - for part in measure[cpu][instr_name]['latency'].split('/'): - if part == "": - lat = "N/A" - else: - lat = float(part) - if abs((lat - round(lat)) / lat) < 0.02: - lat = round(lat) - latency.append(lat) - latency = sorted(list(set(latency))) - - throughput_cpi = float(measure[cpu][instr_name]['throughput(cpi)']) - if abs(throughput_cpi - round(throughput_cpi)) < 0.03: - throughput_cpi = round(throughput_cpi) - - # TODO: handle small cpi better by 1/ipc - throughput_ipc = float(measure[cpu][instr_name]['throughput(ipc)']) - if abs(throughput_ipc - round(throughput_ipc)) < 0.03: - throughput_ipc = round(throughput_ipc) - show_cpus.append(cpu) - latencies.append(", ".join(map(str, latency))) - throughputs.append(throughput_cpi) + latencies.append(measure[cpu][instr_name]['latency']) + throughputs.append(measure[cpu][instr_name]['throughput(cpi)']) if len(show_cpus) > 0: latency_throughput = f""" @@ -1844,3 +1848,31 @@ def all_groups(): result.append(title) break return json.dumps(sorted(list(set(result)))) + + @env.macro + def latency_throughput_table(): + result = "
Instructino | " + for cpu in cpus: + result += f"{cpu} | " + result += f"|
---|---|---|
Latency | Throughput (CPI) | " + result += f"|
{inst} | " + for cpu in cpus: + result += f"{measure[cpu][inst]['latency']} | " + result += f"{measure[cpu][inst]['throughput(cpi)']} | " + result += "