Skip to content

Commit

Permalink
Fix throughput unit, reported by a netizen
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Oct 27, 2024
1 parent a49426a commit ba4f358
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion code/measure-3A6000.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name,latency,throughput(cpi),throughput(ipc)
name,latency,throughput(ipc),throughput(cpi)
vabsd_b,2.00,2.00,0.50
vabsd_bu,2.00,2.00,0.50
vabsd_d,2.00,2.00,0.50
Expand Down
2 changes: 1 addition & 1 deletion code/measure-3C5000.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name,latency,throughput(cpi),throughput(ipc)
name,latency,throughput(ipc),throughput(cpi)
vabsd_b,2.00,2.00,0.50
vabsd_bu,2.00,2.00,0.50
vabsd_d,2.00,2.00,0.50
Expand Down
8 changes: 4 additions & 4 deletions code/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ int main(int argc, char *argv[]) {
base_name = name.substr(0, tp_index);
printf("%s: throughput 1/%.2lf=%.2lf instructions\n", it.name, cycles,
1.0 / cycles);
info[base_name].throughput_cpi = 1.0 / cycles;
info[base_name].throughput_ipc = cycles;
info[base_name].throughput_ipc = 1.0 / cycles;
info[base_name].throughput_cpi = cycles;
} else {
base_name = name;

Expand Down Expand Up @@ -258,7 +258,7 @@ int main(int argc, char *argv[]) {
FILE *fp = fopen("measure-3A6000.csv", "w");
#endif
assert(fp);
fprintf(fp, "name,latency,throughput(cpi),throughput(ipc)\n");
fprintf(fp, "name,latency,throughput(ipc),throughput(cpi)\n");
for (auto pair : info) {
std::string latency;
auto entry = pair.second;
Expand All @@ -271,7 +271,7 @@ int main(int argc, char *argv[]) {
latency += buffer;
}
fprintf(fp, "%s,%s,%.2lf,%.2lf\n", pair.first.c_str(), latency.c_str(),
entry.throughput_cpi, entry.throughput_ipc);
entry.throughput_ipc, entry.throughput_cpi);
}
printf("Result written to measure.csv\n");
}
2 changes: 1 addition & 1 deletion docs/latency_throughput.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Latency and Throughput of Instructions

Latency and throughput (CPI) of each instruction:
Latency and throughput (IPC) of each instruction:

{{ latency_throughput_table() }}
28 changes: 14 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@
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)
throughput_ipc = float(row["throughput(ipc)"])
if abs(throughput_ipc - round(throughput_ipc)) < 0.03:
throughput_ipc = round(throughput_ipc)

# handle small cpi better by 1/ipc
if throughput_cpi < 1.0:
throughput_ipc = float(row["throughput(ipc)"])
if abs(throughput_ipc - round(throughput_ipc)) < 0.03:
throughput_ipc = round(throughput_ipc)
# handle small ipc better by 1/cpi
if throughput_ipc < 1.0:
throughput_cpi = float(row["throughput(cpi)"])
if abs(throughput_cpi - round(throughput_cpi)) < 0.03:
throughput_cpi = round(throughput_cpi)

throughput_cpi = f"{throughput_cpi}(1/{throughput_ipc})"
throughput_ipc = f"{throughput_ipc}(1/{throughput_cpi})"

measure[cpu][row["name"]] = {
"latency": ", ".join(map(str, latency)),
"throughput(cpi)": throughput_cpi,
"throughput(ipc)": throughput_ipc,
}

# read examples
Expand Down Expand Up @@ -154,13 +154,13 @@ def instruction(intrinsic, instr, desc):
if instr_name in measure[cpu]:
show_cpus.append(cpu)
latencies.append(measure[cpu][instr_name]["latency"])
throughputs.append(measure[cpu][instr_name]["throughput(cpi)"])
throughputs.append(measure[cpu][instr_name]["throughput(ipc)"])

if len(show_cpus) > 0:
latency_throughput = f"""
### Latency and Throughput
| CPU | Latency | Throughput (CPI) |
| CPU | Latency | Throughput (IPC) |
|-----|---------|------------------|
"""
for i in range(len(show_cpus)):
Expand Down Expand Up @@ -1929,7 +1929,7 @@ def latency_throughput_table():
result += f"<th colspan=2>{cpu}</th>"
result += f"</tr><tr>"
for cpu in cpus:
result += f"<th>Latency</th><th>Throughput (CPI)</th>"
result += f"<th>Latency</th><th>Throughput (IPC)</th>"
result += f"</tr></thead>"

result += "<tbody>"
Expand All @@ -1944,7 +1944,7 @@ def latency_throughput_table():
result += f"<td>{inst.replace('_', '.')}</td>"
for cpu in cpus:
result += f"<td>{measure[cpu][inst]['latency']}</td>"
result += f"<td>{measure[cpu][inst]['throughput(cpi)']}</td>"
result += f"<td>{measure[cpu][inst]['throughput(ipc)']}</td>"
result += "</tr>"

result += "</tbody>"
Expand Down

0 comments on commit ba4f358

Please sign in to comment.