Skip to content

[vtr_flow] Changed Triggers for Second Run #2923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

AlexandreSinger
Copy link
Contributor

Currently, when running the VPR stage of the vtr_flow script, if you are routing at a fixed channel width and you have "--route" or "--analysis" in the command, it will run the VPR stage twice with the exact same arguments. This is unnecessary and can make some of the runs 2x longer than they need to be.

The purpose of running the VPR flow twice is that the second time would load in the temporary files produced by the first run to ensure they are the same values. It appears as though route and analysis used to be part of this check; however it is no longer being used. I checked the second run code and having the --route or --analysis flag set has no affect on the second run's arguments; so the exact same run is dispatched.

I looked through all the regression tests and only found one testcase that used either of these options; which may be the reason this was never caught.

This is useful for the AP flow since, to use the AP flow, we need to specify the --analytical_place flow which inherently does not perfrom routing. So we have to add --route to our arguments. I noticed that these runs took 2x longer than they should and found this issue.

The code that triggers the second run can be found here:

do_second_run = False
second_run_args = vpr_args
if (
"write_rr_graph" in vpr_args
or "analysis" in vpr_args
or "route" in vpr_args
or "write_router_lookahead" in vpr_args
or "write_intra_cluster_router_lookahead" in vpr_args
):
do_second_run = True
if no_second_run:
do_second_run = False
vtr.vpr.run(
architecture_copy,
pre_vpr_netlist,
circuit_copy.stem,
command_runner=command_runner,
temp_dir=temp_dir,
vpr_args=vpr_args,
)
if do_second_run:
# Run vpr again with additional parameters.
# This is used to ensure that files generated by VPR can be re-loaded by it
rr_graph_ext = (
Path(second_run_args["write_rr_graph"]).suffix
if "write_rr_graph" in second_run_args
else ".xml"
)
if check_place:
second_run_args["route"] = True
if check_route:
second_run_args["analysis"] = True
vtr.vpr.run_second_time(
architecture_copy,
pre_vpr_netlist,
circuit_copy.stem,
command_runner=command_runner,
temp_dir=temp_dir,
second_run_args=second_run_args,
rr_graph_ext=rr_graph_ext,
)

The second run is performed here:

temp_dir = Path(temp_dir) if not isinstance(temp_dir, Path) else temp_dir
temp_dir.mkdir(parents=True, exist_ok=True)
rr_graph_out_file = ""
if "write_rr_graph" in second_run_args:
rr_graph_out_file = second_run_args["write_rr_graph"]
rr_graph_ext = Path(rr_graph_out_file).suffix
rr_graph_out_file2 = "rr_graph2" + rr_graph_ext
if "write_rr_graph" in second_run_args:
second_run_args["read_rr_graph"] = rr_graph_out_file
second_run_args["write_rr_graph"] = rr_graph_out_file2
inter_cluster_router_lookahead = ""
if "write_router_lookahead" in second_run_args:
inter_cluster_router_lookahead = second_run_args["write_router_lookahead"]
second_run_args["read_router_lookahead"] = inter_cluster_router_lookahead
second_run_args["write_router_lookahead"] = "inter_cluster_router_lookahead2.capnp"
intra_cluster_router_lookahead = ""
if "write_intra_cluster_router_lookahead" in second_run_args:
intra_cluster_router_lookahead = second_run_args["write_intra_cluster_router_lookahead"]
second_run_args["read_intra_cluster_router_lookahead"] = intra_cluster_router_lookahead
second_run_args[
"write_intra_cluster_router_lookahead"
] = "intra_cluster_router_lookahead2.capnp"
# run VPR
run(
architecture,
circuit,
circuit_name,
command_runner,
temp_dir,
log_filename="vpr_second_run.out",
vpr_exec=vpr_exec,
vpr_args=second_run_args,
)
if "write_rr_graph" in second_run_args:
cmd = ["diff", rr_graph_out_file, rr_graph_out_file2]
_, diff_result = command_runner.run_system_command(
cmd, temp_dir, log_filename="diff.rr_graph.out", indent_depth=1
)
if diff_result:
raise InspectError("failed: vpr (RR Graph XML output not consistent when reloaded)")
if "write_inter_cluster_router_lookahead" in second_run_args:
cmd = ["diff", inter_cluster_router_lookahead, "inter_cluster_router_lookahead2.capnp"]
_, diff_result = command_runner.run_system_command(
cmd, temp_dir, log_filename="diff.inter_cluster_router_lookahead.out", indent_depth=1
)
if diff_result:
raise InspectError(
"failed: vpr (Inter Cluster Router Lookahead output not consistent when reloaded)"
)
if "write_intra_cluster_router_lookahead" in second_run_args:
cmd = ["diff", intra_cluster_router_lookahead, "intra_cluster_router_lookahead2.capnp"]
_, diff_result = command_runner.run_system_command(
cmd, temp_dir, log_filename="diff.intra_cluster_router_lookahead.out", indent_depth=1
)
if diff_result:
raise InspectError(
"failed: vpr (Intra Cluster Router Lookahead not consistent when reloaded)"
)

Notice that the second run's args only change based on the router lookahead and rr graph.

Currently, when running the VPR stage of the vtr_flow script, if you are
routing at a fixed channel width and you have "--route" or "--analysis"
in the command, it will run the VPR stage twice with the exact same
arguments. This is unnecessary and can make some of the runs 2x longer
than they need to be.

The purpose of running the VPR flow twice is that the second time would
load in the temporary files produced by the first run to ensure they are
the same values. It appears as though route and analysis used to be part
of this check; however it is no longer being used. I checked the second
run code and having the --route or --analysis flag set has no affect on
the second run's arguments; so the exact same run is dispatched.

I looked through all the regression tests and only found one testcase
that used either of these options; which may be the reason this was
never caught.

This is useful for the AP flow since, to use the AP flow, we need to
specify the --analytical_place flow which inherently does not perfrom
routing. So we have to add --route to our arguments. I noticed that
these runs took 2x longer than they should and found this issue.
@github-actions github-actions bot added the lang-python Python code label Mar 4, 2025
@vaughnbetz vaughnbetz merged commit 4157a48 into verilog-to-routing:master Apr 8, 2025
36 checks passed
@AlexandreSinger AlexandreSinger deleted the feature-vtr-flow-second-run branch April 10, 2025 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-python Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants