Skip to content

Commit e44f2e9

Browse files
committed
Avoid calling bc, to minimize binaries needed in bazel environment.
In minimal installations, bc might not be available. We already process the data with awk, so we have everything needed to do the calculations.
1 parent 5719d89 commit e44f2e9

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

place_and_route/private/benchmark.bzl

+10-11
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def benchmark(ctx, open_road_info):
7171
]
7272
awk_cmds = [
7373
"area=$(cat {log} | awk '/Design area/ {{ print $3 }}');",
74-
"util=$(cat {log} | awk -F '[ %]' '/Design area/ {{ print $5 }}');",
74+
"util_fraction=$(cat {log} | awk -F '[ %]' '/Design area/ {{ printf(\"%.3f\", $5 / 100.0); }}');",
7575
"combos=$(cat {log} | awk '/combinational cell/ {{ print $4 }}');",
7676
"combos_area=$(cat {log} | awk '/combinational cell/ {{ print $5 }}');",
7777
"seq=$(cat {log} | awk '/Sequential cell/ {{ print $3 }}');",
@@ -82,10 +82,10 @@ def benchmark(ctx, open_road_info):
8282
"tbuffs_area=$(cat {log} | awk '/Timing Repair Buffer/ {{ print $4 }}');",
8383
"inverters=$(cat {log} | awk '/Inverter/ {{ print $2 }}');",
8484
"inverters_area=$(cat {log} | awk '/Inverter/ {{ print $2 }}');",
85-
"wns=$(cat {log} | awk '/wns/ {{ print $2 }}');",
86-
"tns=$(cat {log} | awk '/tns/ {{ print $2 }}');",
87-
"period=$(cat {log} | awk '/clk / {{ period=$2; exit }} END {{ print period }}');",
88-
"cpl=$(cat {log} | awk '/period_min/ {{ cpl=$4; exit }} END {{ print cpl }}');",
85+
"wns_ps=$(cat {log} | awk '/wns/ {{ printf(\"%.0f\", $2 * 1000); }}');",
86+
"tns_ps=$(cat {log} | awk '/tns/ {{ printf(\"%.0f\", $2 * 1000); }}');",
87+
"period=$(cat {log} | awk '/clk / {{ period=$2; exit }} END {{ printf(\"%.0f\", period * 1000); }}');",
88+
"cpl=$(cat {log} | awk '/period_min/ {{ cpl=$4; exit }} END {{ printf(\"%.0f\", cpl * 1000); }}');",
8989
"fmax=$(cat {log} | awk '/fmax/ {{ fmax=$7; exit }} END {{ print fmax }}');",
9090
"tot_pow=$(cat {log} | awk '/^Total / {{ total_power=$5 }} END {{ print total_power }}');",
9191
"int_pow=$(cat {log} | awk '/^Total / {{ intern_power=$2 }} END {{ print intern_power }}');",
@@ -97,8 +97,7 @@ def benchmark(ctx, open_road_info):
9797
struct(
9898
area = struct(
9999
cell_area_um2 = "${area:=0}",
100-
# Use bc -l to set scale, otherwise XX/100 will evaluate to zero.
101-
cell_utilization_fraction = "$(printf %.3f $(bc -l<<<$util/100.0))",
100+
cell_utilization_fraction = "${util_fraction:=0}",
102101
area_sequentials_um2 = "${seq_area:=0}",
103102
area_combinationals_um2 = "${combos_area:=0}",
104103
area_buffers_um2 = "${buffs_area:=0}",
@@ -112,11 +111,11 @@ def benchmark(ctx, open_road_info):
112111
num_inverters = "${inverters:=0}",
113112
),
114113
performance = struct(
115-
clock_period_ps = "$(printf %.0f $(bc<<<$period*1000))",
116-
critical_path_ps = "$(printf %.0f $(bc<<<$cpl*1000))",
114+
clock_period_ps = "${period:=0}",
115+
critical_path_ps = "${cpl:=0}",
117116
fmax_ghz = "${fmax:=0}",
118-
setup_wns_ps = "$(printf %.0f $(bc<<<$wns*1000))",
119-
setup_tns_ps = "$(printf %.0f $(bc<<<$tns*1000))",
117+
setup_wns_ps = "${wns_ps:=0}",
118+
setup_tns_ps = "${tns_ps:=0}",
120119
),
121120
power = struct(
122121
total = struct(

0 commit comments

Comments
 (0)