Skip to content

Commit 68e293e

Browse files
committed
Clear the packing of the previous circuit when the data of vpr is freed
vpr_free_all() leaves the packing of the circuit in the clustering context. Running vpr a second time with another circuit then failed the check of the clusters against the atoms of the new circuit. Clear it when the data of a run is freed, and test running vpr with different circuits in one process.
1 parent 884e893 commit 68e293e

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎openfpga/python_tests/test_vpr_rerun.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,18 @@ def test_commands_after_rerun(shell, vpr_cmd, and2_files):
8383
"--sort_gsb_chan_node_in_edges"
8484
)
8585
shell.run("build_fabric --compress_routing")
86+
87+
88+
def test_vpr_with_another_circuit(shell, and2_files, flow_dir):
89+
# The packing of the first circuit must not be checked against the second
90+
other = (
91+
flow_dir / "benchmarks" / "ubm" / "simple_gates" / "and2_or2" / "and2_or2.blif"
92+
)
93+
if not other.exists():
94+
pytest.skip(f"missing {other}")
95+
for blif in (and2_files["blif"], other, and2_files["blif"]):
96+
command = (
97+
f"vpr {and2_files['vpr_arch']} {blif} --clock_modeling route "
98+
"--device 2x2 --route_chan_width 20 --pack --place --route"
99+
)
100+
assert "VPR succeeded" in shell.run(command).log

‎openfpga/src/vpr_wrapper/vpr_main.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ std::unique_ptr<VprRun> last_vpr_run;
4444
void free_vpr_run(VprRun& run) {
4545
try {
4646
vpr_free_all(run.arch, run.setup);
47+
/* vpr_free_all() leaves the packing of the circuit in the clustering
48+
* context: the next circuit would be checked against it */
49+
ClusteringContext& cluster_ctx = g_vpr_ctx.mutable_clustering();
50+
cluster_ctx.atoms_lookup.clear();
51+
cluster_ctx.post_routing_clb_pin_nets.clear();
52+
cluster_ctx.pre_routing_net_pin_mapping.clear();
4753
} catch (const std::exception& exc) {
4854
VTR_LOG_ERROR("Fail to free VPR data: %s\n", exc.what());
4955
}

0 commit comments

Comments
 (0)