diff --git a/place_and_route/private/benchmark.bzl b/place_and_route/private/benchmark.bzl index 73fa2937..1ebd6735 100644 --- a/place_and_route/private/benchmark.bzl +++ b/place_and_route/private/benchmark.bzl @@ -58,27 +58,48 @@ def benchmark(ctx, open_road_info): benchmark_path = benchmark_report.path cmds = [ - "echo \"# proto-file: synthesis/performance_power_area.proto\" >> {out};".format(out = benchmark_path), - "echo \"# proto-message: hdl.ppa.PerformancePowerAreaProto\n\" >> {out};".format(out = benchmark_path), + "echo \"# proto-file: synthesis/power_performance_area.proto\" >> {out};".format(out = benchmark_path), + "echo \"# proto-message: hdl.ppa.PowerPerformanceAreaProto\n\" >> {out};".format(out = benchmark_path), ] - prefix = "metric=$(cat {log} | awk ".format(log = command_output.log_file.path) - suffix = "; echo \"{field} $metric\" >> {out};" awk_cmds = [ - ("worst_slack_max:", "'/wns/ {{ print $2 }}')"), - ("total_negative_slack_max:", "'/tns/ {{ print $2 }}')"), - ("power_total {", "'')"), - (" internal_package_watts:", "'/^Total / {{ intern_power=$2 }} END {{ print intern_power }}')"), - (" switching_package_watts:", "'/^Total / {{ switch_power=$3 }} END {{ print switch_power }}')"), - (" total_package_watts:", "'/^Total / {{ total_power=$5 }} END {{ print total_power }}')"), - ("}", "'')"), - ("area_micro_meters_squared:", "'/Design area/ {{ print $3 }}')"), - ("area_utilization_percentage:", "-F '[ %]' '/Design area/ {{ print $5 }}')"), - ("num_combinational_gates:", "'/combinational cell/ {{ print 0 + $4 }}')"), - ("num_flops:", "'/Sequential cell/ {{ print 0 + $3 }}')"), - ("num_buffers:", "'/Buffer/ {{ buffer=$2; exit }} END {{ print 0 + buffers }}')"), - ("num_timing_buffers:", "'/Timing Repair/ {{ print 0 + $4 }}')"), + "area=$(cat {log} | awk '/Design area/ {{ print $3 }}');", + "util=$(cat {log} | awk -F '[ %]' '/Design area/ {{ print $5 }}');", + "combos=$(cat {log} | awk '/combinational cell/ {{ print 0 + $4 }}');", + "flops=$(cat {log} | awk '/Sequential cell/ {{ print 0 + $3 }}');", + "buffs=$(cat {log} | awk '/Buffer/ {{ buffer=$2; exit }} END {{ print 0 + buffers }}');", + "tbuffs=$(cat {log} | awk '/Timing Repair/ {{ print 0 + $4 }}');", + "wns=$(cat {log} | awk '/wns/ {{ print $2 }}');", + "tns=$(cat {log} | awk '/tns/ {{ print $2 }}');", + "tot_pow=$(cat {log} | awk '/^Total / {{ total_power=$5 }} END {{ print total_power }}');", + "int_pow=$(cat {log} | awk '/^Total / {{ intern_power=$2 }} END {{ print intern_power }}');", + "swi_pow=$(cat {log} | awk '/^Total / {{ switch_power=$3 }} END {{ print switch_power }}');", ] - cmds.extend([prefix + cmd + suffix.format(field = field, out = benchmark_path) for field, cmd in awk_cmds]) + cmds.extend([cmd.format(log = command_output.log_file.path) for cmd in awk_cmds]) + textproto = proto.encode_text( + struct( + area = struct( + cell_area_um2 = "$area", + cell_utilization_fraction = "$util", + num_total_cells = "$(($combos + $flops + $buffs + $tbuffs))", + num_sequential = "$flops", + num_combinational = "$combos", + num_buffers = "$buffs", + num_timing_buffers = "$tbuffs", + ), + performance = struct( + setup_wns_ps = "$(printf %.0f $(bc<<<$wns*1000))", + setup_tns_ps = "$(printf %.0f $(bc<<<$tns*1000))", + ), + power = struct( + total = struct( + internal_watts = "$int_pow", + switching_watts = "$swi_pow", + total_watts = "$tot_pow", + ), + ), + ), + ) + cmds.append("echo \"{textproto}\" >> {out}".format(textproto = textproto, out = benchmark_path)) ctx.actions.run_shell( outputs = [benchmark_report], diff --git a/synthesis/BUILD.bazel b/synthesis/BUILD.bazel index 1c2836bc..2c62718a 100644 --- a/synthesis/BUILD.bazel +++ b/synthesis/BUILD.bazel @@ -49,19 +49,3 @@ cc_proto_library( name = "power_performance_area_cc_proto", deps = [":power_performance_area_proto"], ) - -# Deprecated old version of the above. -proto_library( - name = "performance_power_area_proto", - srcs = ["performance_power_area.proto"], -) - -py_proto_library( - name = "performance_power_area_py_proto", - deps = [":performance_power_area_proto"], -) - -cc_proto_library( - name = "performance_power_area_cc_proto", - deps = [":performance_power_area_proto"], -) diff --git a/synthesis/build_defs.bzl b/synthesis/build_defs.bzl index 1305c3ee..9166d7aa 100644 --- a/synthesis/build_defs.bzl +++ b/synthesis/build_defs.bzl @@ -230,18 +230,27 @@ def _benchmark_synth(ctx, synth_log_file): cat = "zcat" if ("log.gz" in synth_log_file.path) else "cat" cmds = [ - "echo \"# proto-file: synthesis/performance_power_area.proto\" >> {out};".format(out = benchmark_path), - "echo \"# proto-message: hdl.ppa.PerformancePowerAreaProto\n\" >> {out};".format(out = benchmark_path), + "echo \"# proto-file: synthesis/power_performance_area.proto\" >> {out};".format(out = benchmark_path), + "echo \"# proto-message: hdl.ppa.PowerPerformanceAreaProto\n\" >> {out};".format(out = benchmark_path), ] - prefix = "metric=$({cat} {log} | awk ".format(cat = cat, log = synth_log_file.path) - suffix = "; echo \"{field} $metric\" >> {out};" awk_cmds = [ - ("area_micro_meters_squared:", "'/Chip area for/ {{ print $6 }}')"), - ("num_total_cells:", "'/Number of cells/ {{ cells = $4 }} END {{print cells}}')"), - ("num_flops:", "'/Flop count:/ {{ print $3 }}')"), - ("longest_topological_path:", "-F '[=)]' '/Longest topological path/ {{ print $2}}')"), + "area=$({cat} {log} | awk '/Chip area for/ {{ print $6; }}');", + "cells=$({cat} {log} | tac | awk '/Number of cells/ {{ print $4; exit }}');", + "flops=$({cat} {log} | awk '/Flop count:/ {{ print $3 }}');", + "ltp=$({cat} {log} | awk -F '[=)]' '/Longest topological path/ {{ print $2}}');", ] - cmds.extend([prefix + cmd + suffix.format(field = field, out = benchmark_path) for field, cmd in awk_cmds]) + cmds.extend([cmd.format(cat = cat, log = synth_log_file.path) for cmd in awk_cmds]) + textproto = proto.encode_text( + struct( + area = struct( + cell_area_um2 = "$area", + num_total_cells = "$cells", + num_sequential = "$flops", + ), + performance = struct(longest_topological_path = "$ltp"), + ), + ) + cmds.append("echo \"{textproto}\" >> {out}".format(textproto = textproto, out = benchmark_path)) ctx.actions.run_shell( outputs = [benchmark_file], diff --git a/synthesis/performance_power_area.proto b/synthesis/performance_power_area.proto deleted file mode 100644 index 6f7a2856..00000000 --- a/synthesis/performance_power_area.proto +++ /dev/null @@ -1,66 +0,0 @@ -syntax = "proto2"; - -package hdl.ppa; - -// Deprecated. Will go away. Have a look at -// PowerPerformanceArea proto in this same directory. - -message PerformancePowerAreaProto { - // ====== Performance ====== - // The worst slack min. - optional float worst_slack_min = 1; - // The worst slack max. - optional float worst_slack_max = 2; - // The total negative slack max. - optional float total_negative_slack_max = 3; - // The clock skew. - optional float clock_skew = 4; - // The number of cells in the longest topological path. - optional int32 longest_topological_path = 5; - // The count of max slew violations. - optional float max_slew_violations = 6; - // The count of max fanout violations. - optional float max_fanout_violations = 7; - // The count of max capacitance violations. - optional float max_capacitance_violations = 8; - - // ====== Power ====== - optional PowerElements power_total = 10; - optional PowerElements power_sqeuential = 11; - optional PowerElements power_combinational = 12; - optional PowerElements power_macro = 13; - optional PowerElements power_pad = 14; - - // ====== Area ====== - // The die area in um^2. - optional float area_micro_meters_squared = 20; - // The die area utilization percentage. - optional float area_utilization_percentage = 21; - // The die height in micro meters. - optional float die_height_micro_meters = 22; - // The die width in micro meters. - optional float die_width_micro_meters = 23; - // The total number of standard cells. - optional int32 num_total_cells = 24; - // The number of non-timing buffers. - optional int32 num_buffers = 25; - // The number of timing buffers. - optional int32 num_timing_buffers = 26; - // The number of flops. - optional int32 num_flops = 27; - // The number of combinational gates. - optional int32 num_combinational_gates = 28; -} - -message PowerElements { - // The unit scale such as micro (u), nano (n), etc. - optional string magnitude = 1; - // The internal power simulated - optional float internal_package_watts = 2; - // The switching power simulated - optional float switching_package_watts = 3; - // The leakage power simulated - optional float leakage_package_watts = 4; - // The total power simulated - optional float total_package_watts = 5; -}