Added option to filter results after parsing
This commit is contained in:
parent
5116aa2ae1
commit
8f8707ff98
|
@ -20,7 +20,7 @@ supported_flows = standard,vtr,vtr_standard,yosys_vpr
|
|||
|
||||
[DEFAULT_PARSE_RESULT_VPR]
|
||||
# parser format <name of variable> = <regex string>, <lambda function/type>
|
||||
clb_blocks = "Netlist clb blocks: ([0-9]+)", int
|
||||
clb_blocks = "Netlist clb blocks: ([0-9]+)", str
|
||||
logic_delay = "Total logic delay: ([0-9.]+)", str
|
||||
total_net_delay = "total net delay: ([0-9.]+)", str
|
||||
total_routing_area = "Total routing area: ([0-9.]+)", str
|
||||
|
@ -30,18 +30,18 @@ packing_time = "Packing took ([0-9.]+) seconds", str
|
|||
placement_time = "Placement took ([0-9.]+) seconds", str
|
||||
routing_time = "Routing took ([0-9.]+) seconds", str
|
||||
average_net_length = "average net length: ([0-9.]+)", str
|
||||
critical_path = "Final critical path: ([0-9.]+) ns", float
|
||||
critical_path = "Final critical path: ([0-9.]+) ([a-z])s", scientific
|
||||
total_time_taken = "Routing took ([0-9.]+) seconds", float
|
||||
|
||||
[DEFAULT_PARSE_RESULT_POWER]
|
||||
pb_type_power="PB Types\s+([0-9]+)", float
|
||||
routing_power="Routing\s+([0-9]+)", float
|
||||
switch_box_power="Switch Box\s+([0-9]+)", float
|
||||
connection_box_power="Connection Box\s+([0-9]+)", float
|
||||
primitives_power="Primitives\s+([0-9]+)", float
|
||||
interc_structures_power="Interc Structures\s+([0-9]+)", float
|
||||
lut6_power="^\s+lut6\s+([0-9]+)", float
|
||||
ff_power="^\s+ff\s+([0-9]+)", float
|
||||
pb_type_power="PB Types\s+([0-9]+)", str
|
||||
routing_power="Routing\s+([0-9]+)", str
|
||||
switch_box_power="Switch Box\s+([0-9]+)", str
|
||||
connection_box_power="Connection Box\s+([0-9]+)", str
|
||||
primitives_power="Primitives\s+([0-9]+)", str
|
||||
interc_structures_power="Interc Structures\s+([0-9]+)", str
|
||||
lut6_power="^\s+lut6\s+([0-9]+)", str
|
||||
ff_power="^\s+ff\s+([0-9]+)", str
|
||||
|
||||
[INTERMIDIATE_FILE_PREFIX]
|
||||
|
||||
|
|
|
@ -674,43 +674,46 @@ def run_standard_vpr(bench_blif, fixed_chan_width, logfile, route_only=False):
|
|||
return chan_width
|
||||
|
||||
|
||||
def extract_vpr_stats(logfile):
|
||||
# TODO: Sloppy code need improovement
|
||||
# Without changing config input format
|
||||
|
||||
def extract_vpr_stats(logfile, r_filename="vpr_stat", parse_section="vpr"):
|
||||
section = "DEFAULT_PARSE_RESULT_POWER" if parse_section == "power" \
|
||||
else "DEFAULT_PARSE_RESULT_VPR"
|
||||
vpr_log = open(logfile).read()
|
||||
resultDict = {}
|
||||
for name, value in config.items("DEFAULT_PARSE_RESULT_VPR"):
|
||||
reg_string, _ = value.split(",")
|
||||
for name, value in config.items(section):
|
||||
reg_string, filt_function = value.split(",")
|
||||
match = re.search(reg_string[1:-1], vpr_log)
|
||||
if match:
|
||||
try:
|
||||
if "lambda" in filt_function.strip():
|
||||
eval("ParseFunction = "+filt_function.strip())
|
||||
extract_val = ParseFunction(**match.groups())
|
||||
elif filt_function.strip() == "int":
|
||||
extract_val = int(match.group(1))
|
||||
elif filt_function.strip() == "float":
|
||||
extract_val = float(match.group(1))
|
||||
elif filt_function.strip() == "str":
|
||||
extract_val = str(match.group(1))
|
||||
elif filt_function.strip() == "scientific":
|
||||
try:
|
||||
mult = {"m":1E-3, "u":1E-6, "n":1E-9,
|
||||
"K":1E-3, "M":1E-6, "G":1E-9,}.get(match.group(2)[0], 1)
|
||||
except:
|
||||
mult = 1
|
||||
extract_val = float(match.group(1))*mult
|
||||
else:
|
||||
extract_val = match.group(1)
|
||||
except:
|
||||
logger.exception("Filter failed")
|
||||
extract_val= "Filter Failed"
|
||||
resultDict[name] = extract_val
|
||||
|
||||
dummyparser = ConfigParser()
|
||||
dummyparser.read_dict({"RESULTS": resultDict})
|
||||
|
||||
with open('vpr_stat.result', 'w') as configfile:
|
||||
with open(r_filename+'.result', 'w') as configfile:
|
||||
dummyparser.write(configfile)
|
||||
logger.info("VPR statistics is extracted in file vpr_stat.result")
|
||||
|
||||
|
||||
def extract_vpr_power_esti(logfile):
|
||||
vpr_log = open(logfile).read()
|
||||
resultDict = {}
|
||||
for name, value in config.items("DEFAULT_PARSE_RESULT_VPR"):
|
||||
reg_string, _ = value.split(",")
|
||||
match = re.search(reg_string[1:-1], vpr_log)
|
||||
if match:
|
||||
extract_val = match.group(1)
|
||||
resultDict[name] = extract_val
|
||||
|
||||
dummyparser = ConfigParser()
|
||||
dummyparser.read_dict({args.top_module+"_RESULTS": resultDict})
|
||||
|
||||
with open('vpr_power_stat.result', 'w') as configfile:
|
||||
dummyparser.write(configfile)
|
||||
logger.info("VPR_Power statistics are extracted vpr_power_stat.result")
|
||||
logger.info("%s result extracted in file %s" %
|
||||
(parse_section,r_filename+'.result'))
|
||||
|
||||
|
||||
def run_rewrite_verilog():
|
||||
|
|
Loading…
Reference in New Issue