Skip to content

Commit

Permalink
wns_report: include stats from on instances
Browse files Browse the repository at this point in the history
  • Loading branch information
oharboe committed Oct 29, 2024
1 parent 1f20597 commit f336860
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 38 deletions.
6 changes: 3 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,10 @@ BOOMTILE_SOURCES = {
name = "BoomTile_" + variant + "_report",
src = ":BoomTile_" + ("" if variant == "base" else variant + "_") + SWEEP_JSON["stage"],
outs = [
"BoomTile_" + variant + ".yaml",
"BoomTile_" + variant + ".txt",
],
extra_args = "> $WORK_HOME/BoomTile_" + variant + ".txt",
arguments = {
"OUTFILE": "$(location :BoomTile_" + variant + ".yaml)",
"ODB_FILE": "$(location :BoomTile_" + variant + "_odb)",
},
data = [":BoomTile_" + variant + "_odb"],
Expand All @@ -484,7 +484,7 @@ genrule(
srcs = [
"wns_report.py",
"sweep.json",
] + [":BoomTile_" + variant + ".yaml" for variant in WNS_REPORT_SWEEP] +
] + [":BoomTile_" + variant + ".txt" for variant in WNS_REPORT_SWEEP] +
[":BoomTile_" + variant + "_logs" for variant in WNS_REPORT_SWEEP],
outs = ["BoomTile_wns_report.md"],
cmd = (
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
norecursedirs = bazel-bin/ bazel-megaboom/ bazel-out/ bazel-testlogs/ build/

33 changes: 5 additions & 28 deletions report-wns.tcl
Original file line number Diff line number Diff line change
@@ -1,35 +1,12 @@
# Test this on some simple design in ORFS:
#
# ODB_FILE=results/asap7/base/2_floorplan.odb OUTFILE=blah.txt make run RUN_SCRIPT=~/megaboom/report-wns.tcl
# make floorplan
# ODB_FILE=results/nangate45/gcd/base/2_floorplan.odb make run RUN_SCRIPT=~/megaboom/report-wns.tcl
source $::env(SCRIPTS_DIR)/open.tcl

set paths [find_timing_paths -path_group reg2reg -sort_by_slack -group_count 1]
set path [lindex $paths 0]
set slack [get_property $path slack]

report_clock_skew >reports.txt
report_tns >>reports.txt
set fp [open reports.txt r]
set crpr ""
set skew ""
set tns ""
while {[gets $fp line] != -1} {
if {[regexp {([0-9.]+)\s+CRPR} $line match crpr_value]} {
set crpr $crpr_value
}
if {[regexp {([0-9.]+)\s+setup\s+skew} $line match skew_value]} {
set skew $skew_value
}
if {[regexp {tns (.*)} $line match tns_value]} {
set tns $tns_value
}
}
close $fp

set fp [open $::env(OUTFILE) w]
puts $fp "slack: $slack"
puts $fp "crpr: $crpr"
puts $fp "skew: $skew"
puts $fp "tns: $tns"
close $fp

puts "slack: $slack"
report_tns
report_cell_usage
69 changes: 62 additions & 7 deletions wns_report.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
import os
import yaml
import json
import re
import pathlib
import sys
from tabulate import tabulate
Expand All @@ -11,6 +10,60 @@ def transpose_table(table_data):
return list(map(list, zip(*table_data)))


# slack: 0.039060
# Clock core_clock
# 0.00 source latency ctrl.state.out[0]$_DFF_P_/CK ^
# 0.00 target latency ctrl.state.out[0]$_DFF_P_/CK ^
# 0.00 CRPR
# --------------
# 0.00 setup skew


# tns 0.00
# Cell type report: Count Area
# Tap cell 48 12.77
# Buffer 14 19.95
# Inverter 85 51.34
# Sequential cell 35 158.27
# Multi-Input combinational cell 369 420.55
# Total 551 662.87
def parse_stats(report):
"""Create a dictionary with the values above"""
stats = {}
report_start = False
for line in report.split("\n"):
if "slack" in line:
stats["slack"] = float(line.split()[1])
if "setup skew" in line:
stats["skew"] = line.split()[0]
# First line is "Cell type report", last line is "Total",
# fish out the values in between
if "Cell type report" in line:
report_start = True
continue
if report_start:
# fish out using regex first number column and use the label as key
# and the first number as the value.
#
# use regex, because split() would get confused by space
# in the label
# use regex, but don't get confused by one or more spaces in the label
# Sequentialcell 35 158.27
# Tap cell 48 12.77
# Multi-Input combinational cell 369 420.55
# some labels have spaces, some don't
m = re.match(r"\s*(\D+)(\d+)\s+(\d+\.\d+)", line)
if m:
stats[m.group(1).strip()] = int(m.group(2))
if "Total" in line:
report_start = False
continue

print(str(stats))

return stats


# Extract Elapsed Time line from log file
# Elapsed time: 0:04.26[h:]min:sec. CPU time: user 4.08 sys 0.17 (99%). \
# Peak memory: 671508KB.
Expand Down Expand Up @@ -86,11 +139,13 @@ def main():

table_data = None
for variant in sweep:
slack_file = os.path.join(
os.path.dirname(sweep_file), "BoomTile_" + variant + ".yaml"
)
with open(slack_file, "r") as file:
stats = yaml.safe_load(file)
with open(
os.path.join(os.path.dirname(sweep_file), "BoomTile_" + variant + ".txt"),
"r",
) as file:
report = file.read()
stats = parse_stats(report)
print(str(stats))
names = sorted(stats.keys())
if table_data is None:
table_data = [
Expand Down
35 changes: 35 additions & 0 deletions wns_report_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
import wns_report


def test_parse_stats():
report = """
slack: 0.039060
Clock core_clock
0.00 source latency ctrl.state.out[0]$_DFF_P_/CK ^
0.00 target latency ctrl.state.out[0]$_DFF_P_/CK ^
0.00 CRPR
--------------
0.00 setup skew
tns 0.00
Cell type report: Count Area
Tap cell 48 12.77
Buffer 14 19.95
Inverter 85 51.34
Sequential cell 35 158.27
Multi-Input combinational cell 369 420.55
Total 551 662.87
"""
expected_stats = {
"slack": 0.03906,
"skew": "0.00",
"Tap cell": 48,
"Inverter": 85,
"Buffer": 14,
"Sequential cell": 35,
"Multi-Input combinational cell": 369,
"Total": 551,
}

assert wns_report.parse_stats(report) == expected_stats

0 comments on commit f336860

Please sign in to comment.