Skip to content

Commit

Permalink
Merge pull request f4pga#1781 from antmicro/improve-print-qor
Browse files Browse the repository at this point in the history
print_qor: sorted tests by name and remove prefix
  • Loading branch information
litghost committed Nov 18, 2020
2 parents 991c74f + 541d046 commit 9453694
Showing 1 changed file with 79 additions and 19 deletions.
98 changes: 79 additions & 19 deletions utils/print_qor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@
import subprocess


def scan_runtime(fname):
def scan_runtime(step, fname):
""" Find runtime of VPR log (if any), else returns empty str. """
try:
with open(fname, 'r') as f:
step_runtime = 0
total_runtime = 0
for line in f:
pass
if line.startswith("# {} took".format(step)):
step_runtime = float(line.split()[3])

if not line.startswith('The entire flow of VPR took'):
return ""
if line.startswith('The entire flow of VPR took'):
total_runtime = float(line.split()[6])

return str(float(line.split()[6]))
step_overhead = total_runtime - step_runtime

return str(step_runtime), str(step_overhead)
except FileNotFoundError:
return ""

Expand All @@ -35,25 +40,52 @@ def scan_critical(fname):
"""
try:
with open(fname, 'r') as f:
final_cpd = 0.0
final_fmax = 0.0

final_cpd_geomean = 0.0
final_fmax_geomean = 0.0

for line in f:
if line.startswith('Final critical path delay'):
parts = line.split()
if len(parts) >= 9:
# Final critical path delay (least slack): 16.8182 ns, Fmax: 59.4592 MHz
critical_path = float(parts[6])
fmax = float(parts[9])
return str(critical_path), str(fmax)
final_cpd = float(parts[6])
final_fmax = float(parts[9])
elif len(parts) == 8 and parts[7].strip() == 'ns':
# Final critical path delay (least slack): 17.9735 ns
critical_path = float(parts[6])
fmax = 1000. / critical_path
return str(critical_path), str(fmax)
final_cpd = float(parts[6])
final_fmax = 1000. / final_cpd

if line.startswith(
'Final geomean non-virtual intra-domain period'):
parts = line.split()

final_cpd_geomean = parts[5]

if final_cpd_geomean == "nan":
final_cpd_geomean = "N/A"
final_fmax_geomean = "N/A"
continue

final_cpd_geomean = float(parts[5])
final_fmax_geomean = 1000. / final_cpd_geomean

return str(final_cpd), str(final_fmax), str(
final_cpd_geomean
), str(final_fmax_geomean)
except FileNotFoundError:
pass

return "", ""


def get_last_n_dirs(path, n):
dirs = path.split("/")
return "/".join(dirs[-n:])


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("build_dir")
Expand All @@ -63,10 +95,15 @@ def main():
fields = [
"path",
"pack time (sec)",
"pack overhead (sec)",
"place time (sec)",
"place overhead (sec)",
"route time (sec)",
"route overhead (sec)",
"t_crit (ns)",
"Fmax (MHz)",
"t_crit geomean (ns)",
"Fmax geomean (MHz)",
]

print(
Expand All @@ -78,23 +115,46 @@ def main():
)
w = csv.DictWriter(sys.stdout, fields)
w.writeheader()
rows = list()
for root, dirs, files in os.walk(args.build_dir):
if 'pack.log' in files:
d = {}

d['path'] = root
d['pack time (sec)'] = scan_runtime(os.path.join(root, 'pack.log'))
d['place time (sec)'] = scan_runtime(
os.path.join(root, 'place.log')
# Get step runtimes with the respective overhead
pack_time, pack_overhead = scan_runtime(
"Packing", os.path.join(root, 'pack.log')
)
d['route time (sec)'] = scan_runtime(
os.path.join(root, 'route.log')

place_time, place_overhead = scan_runtime(
"Placement", os.path.join(root, 'place.log')
)

route_time, route_overhead = scan_runtime(
"Routing", os.path.join(root, 'route.log')
)
d['t_crit (ns)'], d['Fmax (MHz)'] = scan_critical(

final_cpd, final_fmax, final_cpd_geomean, final_fmax_geomean = scan_critical(
os.path.join(root, 'route.log')
)

w.writerow(d)
d['path'] = get_last_n_dirs(root, 2)
d['pack time (sec)'] = pack_time
d['pack overhead (sec)'] = pack_overhead
d['place time (sec)'] = place_time
d['place overhead (sec)'] = place_overhead
d['route time (sec)'] = route_time
d['route overhead (sec)'] = route_overhead
d['t_crit (ns)'] = final_cpd
d['Fmax (MHz)'] = final_fmax
d['t_crit geomean (ns)'] = final_cpd_geomean
d['Fmax geomean (MHz)'] = final_fmax_geomean

rows.append(d)

rows = sorted(rows, key=lambda row: row['path'])

for row in rows:
w.writerow(row)


if __name__ == "__main__":
Expand Down

0 comments on commit 9453694

Please sign in to comment.