Skip to content

Commit 4b45eda

Browse files
[Task] Added Ability to Constrain Circuits in Config
The VTR task interface uses configuration files to specify what circuits to run for a given task. The current implementation of these config files only allowed the user to run all of their circuits on the same device and using the same flat constraint file (for example fixing the IOs). This was only able to be done through specifying them in the script_params option, but this was limited. This causes problems for the AP flow since each circuit has different IO constraints and may be constrained to different devices or architectures. The only way to use the VTR tasks is to create one configuration file per circuit, which is very wasteful and challenging to work with. It also makes parsing the QoR more difficult. Added a new configuration option that can be added to the configuration file which can constrain a circuit to a given option. The syntax is as follows: circuit_constraint_list_add=(<circuit>, <constr_key, constr_val>) This line will tell VTR run task to constrain the circuit on the constr_key option. The currently supported constraint keys are: - arch: Constrain the circuit to only run on the given arch - device: Constrain the circuit to only use the given device - constraints: Constrain the circuit's atom placement If a constraint is not specified, the bahaviour is unchanged. So, for example, if an arch constraint is not specified, the circuit will run on all the architectures in the arch_list (as usual). Future work is to support constraining the route_chan_width so different circuits can be run with different channel widths in the same config file. This can easily be added using this interface.
1 parent dc3e5dc commit 4b45eda

File tree

16 files changed

+155
-126
lines changed

16 files changed

+155
-126
lines changed

vtr_flow/parse/parse_config/vpr_fixed_chan_width.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
%include "common/vpr.common.txt"
1313
%include "timing/vpr.pack.txt"
1414
%include "timing/vpr.place.txt"
15+
%include "timing/vpr.ap.txt"
1516
%include "timing/vpr.route_fixed_chan_width.txt"

vtr_flow/scripts/python_libs/vtr/task.py

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(
5555
pad_file=None,
5656
additional_files=None,
5757
additional_files_list_add=None,
58+
circuit_constraint_list_add=None
5859
):
5960
self.task_name = task_name
6061
self.config_dir = config_dir
@@ -81,6 +82,9 @@ def __init__(
8182
self.pad_file = pad_file
8283
self.additional_files = additional_files
8384
self.additional_files_list_add = additional_files_list_add
85+
self.circuit_constraints = parse_circuit_constraint_list(circuit_constraint_list_add,
86+
self.circuits,
87+
self.archs)
8488

8589

8690
# pylint: enable=too-few-public-methods
@@ -225,7 +229,9 @@ def load_task_config(config_file) -> TaskConfig:
225229
# Interpret the file
226230
key_values = {}
227231
for line in values:
228-
key, value = line.split("=")
232+
# Split the key and value using only the first equal sign. This allows
233+
# the value to have an equal sign.
234+
key, value = line.split("=", 1)
229235

230236
# Trim whitespace
231237
key = key.strip()
@@ -300,6 +306,73 @@ def check_include_fields(config_file, key_values):
300306
)
301307
)
302308

309+
def parse_circuit_constraint_list(
310+
circuit_constraint_list, circuits_list, arch_list
311+
) -> dict:
312+
"""
313+
Parse the circuit constraints passed in via the config file.
314+
Circuit constraints are expected to have the following syntax:
315+
(<circuit>, <constr_key>=<constr_val>)
316+
This function generates a dictionary which can be accessed:
317+
circuit_constraints[circuit][constr_key]
318+
If this dictionary returns "None", then the circuit is unconstrained for
319+
that key.
320+
"""
321+
322+
# Constraint keys that can be specified.
323+
circuit_constraint_keys = set(
324+
[
325+
"arch",
326+
"device",
327+
"constraints",
328+
]
329+
)
330+
331+
# Initialize the dictionary to be unconstrained for all circuits and keys.
332+
res_circuit_constraints = {
333+
circuit: {constraint_key: None for constraint_key in circuit_constraint_keys}
334+
for circuit in circuits_list
335+
}
336+
337+
# If there were no circuit constraints passed by the user, return dictionary
338+
# of Nones.
339+
if circuit_constraint_list is None:
340+
return res_circuit_constraints
341+
342+
# Parse the circuit constraint list
343+
for circuit_constraint in circuit_constraint_list:
344+
# Remove the round brackets.
345+
if circuit_constraint[0] != '(' or circuit_constraint[-1] != ')':
346+
raise VtrError(f"Circuit constraint syntax error: \"{circuit_constraint}\"")
347+
circuit_constraint = circuit_constraint[1:-1]
348+
# Split the circuit and the constraint
349+
split_constraint_line = circuit_constraint.split(',')
350+
if len(split_constraint_line) != 2:
351+
raise VtrError(f"Circuit constraint has too many arguments: \"{circuit_constraint}\"")
352+
circuit = split_constraint_line[0].strip()
353+
constraint = split_constraint_line[1].strip()
354+
# Check that the circuit actually exists.
355+
if circuit not in circuits_list:
356+
raise VtrError(f"Cannot constrain circuit \"{circuit}\", circuit has not been added")
357+
# Parse the constraint
358+
split_constraint = constraint.split("=")
359+
if len(split_constraint) != 2:
360+
raise VtrError(f"Circuit constraint syntax error: \"{circuit_constraint}\"")
361+
constr_key = split_constraint[0].strip()
362+
constr_val = split_constraint[1].strip()
363+
# Check that the constr_key is valid.
364+
if constr_key not in circuit_constraint_keys:
365+
raise VtrError(f"Invalid constraint \"{constr_key}\" used on circuit \"{circuit}\"")
366+
# In the case of arch constraints, make sure this arch exists.
367+
if constr_key == "arch" and constr_val not in arch_list:
368+
raise VtrError(f"Cannot constrain arch \"{constr_key}\", arch has not been added")
369+
# Make sure this circuit is not already constrained with this constr_arg
370+
if res_circuit_constraints[circuit][constr_key] is not None:
371+
raise VtrError(f"Circuit \"{circuit}\" cannot be constrained more than once")
372+
# Add the constraint for this circuit
373+
res_circuit_constraints[circuit][constr_key] = constr_val
374+
375+
return res_circuit_constraints
303376

304377
def shorten_task_names(configs, common_task_prefix):
305378
"""
@@ -496,6 +569,11 @@ def create_jobs(args, configs, after_run=False) -> List[Job]:
496569
]
497570

498571
for arch, circuit, noc_traffic in combinations:
572+
# If the circuit is constrained to only run on a specific arch, and
573+
# this arch is not that arch, skip this combination.
574+
circuit_arch_constraint = config.circuit_constraints[circuit]["arch"]
575+
if circuit_arch_constraint is not None and circuit_arch_constraint != arch:
576+
continue
499577
golden_results = load_parse_results(
500578
str(PurePath(config.config_dir).joinpath("golden_results.txt"))
501579
)
@@ -613,6 +691,10 @@ def create_job(
613691
cmd += ["-expect_fail", expected_vpr_status]
614692
current_parse_cmd = parse_cmd.copy()
615693

694+
# Apply the command-line circuit constraints provided by the circuit
695+
# constraint list in the config file.
696+
apply_cmd_line_circuit_constraints(cmd, circuit, config)
697+
616698
if config.parse_file:
617699
current_parse_cmd += [
618700
"arch={}".format(arch),
@@ -697,6 +779,19 @@ def ret_expected_vpr_status(arch, circuit, golden_results, script_params=None):
697779

698780
return golden_metrics["vpr_status"]
699781

782+
def apply_cmd_line_circuit_constraints(cmd, circuit, config):
783+
"""
784+
Apply the circuit constraints to the command line. If the circuit is not
785+
constrained for any key, this method will not do anything.
786+
"""
787+
# Check if this circuit is constrained to a specific device.
788+
constrained_device = config.circuit_constraints[circuit]["device"]
789+
if constrained_device is not None:
790+
cmd += ["--device", constrained_device]
791+
# Check if the circuit has constrained atom locations.
792+
circuit_vpr_constraints = config.circuit_constraints[circuit]["constraints"]
793+
if circuit_vpr_constraints is not None:
794+
cmd += ["--read_vpr_constraints", circuit_vpr_constraints]
700795

701796
def resolve_vtr_source_file(config, filename, base_dir=""):
702797
"""

vtr_flow/tasks/regression_tests/vtr_reg_strong/basic_ap/ch_intrinsics/config/config.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
##############################################
2+
# Configuration file for running experiments
3+
##############################################
4+
5+
# Path to directory of circuits to use
6+
circuits_dir=benchmarks/verilog
7+
8+
# Path to directory of architectures to use
9+
archs_dir=arch/timing/fixed_size
10+
11+
# TODO: Add a path to the atom constraints (different from the place constraints)
12+
# "atom_const_dir"
13+
# TODO: Add a directory next to the config to hold the constraints.
14+
15+
# Add circuits to list to sweep
16+
circuit_list_add=single_wire.v
17+
circuit_list_add=single_ff.v
18+
circuit_list_add=ch_intrinsics.v
19+
circuit_list_add=diffeq1.v
20+
21+
# Add architectures to list to sweep
22+
arch_list_add=fixed_k6_frac_N8_22nm.xml
23+
24+
# Constrain the circuits to a fixed device with fixed IO constraints.
25+
circuit_constraint_list_add=(single_wire.v, arch=fixed_k6_frac_N8_22nm.xml)
26+
circuit_constraint_list_add=(single_wire.v, device=unnamed_device)
27+
circuit_constraint_list_add=(single_wire.v, constraints=../../../../constraints/single_wire_fixed_io.xml)
28+
29+
circuit_constraint_list_add=(single_ff.v, arch=fixed_k6_frac_N8_22nm.xml)
30+
circuit_constraint_list_add=(single_ff.v, device=unnamed_device)
31+
circuit_constraint_list_add=(single_ff.v, constraints=../../../../constraints/single_ff_fixed_io.xml)
32+
33+
circuit_constraint_list_add=(ch_intrinsics.v, arch=fixed_k6_frac_N8_22nm.xml)
34+
circuit_constraint_list_add=(ch_intrinsics.v, device=unnamed_device)
35+
circuit_constraint_list_add=(ch_intrinsics.v, constraints=../../../../constraints/ch_intrinsics_fixed_io.xml)
36+
37+
circuit_constraint_list_add=(diffeq1.v, arch=fixed_k6_frac_N8_22nm.xml)
38+
circuit_constraint_list_add=(diffeq1.v, device=unnamed_device)
39+
circuit_constraint_list_add=(diffeq1.v, constraints=../../../../constraints/diffeq1_fixed_io.xml)
40+
41+
# Parse info and how to parse
42+
parse_file=vpr_standard.txt
43+
44+
# How to parse QoR info
45+
qor_parse_file=qor_standard.txt
46+
47+
# Pass requirements
48+
pass_requirements_file=pass_requirements_ap.txt
49+
50+
# Script parameters
51+
script_params_common=-track_memory_usage --analytical_place --route
52+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
arch circuit script_params vtr_flow_elapsed_time vtr_max_mem_stage vtr_max_mem error odin_synth_time max_odin_mem parmys_synth_time max_parmys_mem abc_depth abc_synth_time abc_cec_time abc_sec_time max_abc_mem ace_time max_ace_mem num_clb num_io num_memories num_mult vpr_status vpr_revision vpr_build_info vpr_compiler vpr_compiled hostname rundir max_vpr_mem num_primary_inputs num_primary_outputs num_pre_packed_nets num_pre_packed_blocks num_netlist_clocks num_post_packed_nets num_post_packed_blocks device_width device_height device_grid_tiles device_limiting_resources device_name pack_mem pack_time placed_wirelength_est total_swap accepted_swap rejected_swap aborted_swap place_mem place_time place_quench_time placed_CPD_est placed_setup_TNS_est placed_setup_WNS_est placed_geomean_nonvirtual_intradomain_critical_path_delay_est place_delay_matrix_lookup_time place_quench_timing_analysis_time place_quench_sta_time place_total_timing_analysis_time place_total_sta_time ap_mem ap_time ap_full_legalizer_mem ap_full_legalizer_time min_chan_width routed_wirelength min_chan_width_route_success_iteration logic_block_area_total logic_block_area_used min_chan_width_routing_area_total min_chan_width_routing_area_per_tile min_chan_width_route_time min_chan_width_total_timing_analysis_time min_chan_width_total_sta_time crit_path_num_rr_graph_nodes crit_path_num_rr_graph_edges crit_path_collapsed_nodes crit_path_routed_wirelength crit_path_route_success_iteration crit_path_total_nets_routed crit_path_total_connections_routed crit_path_total_heap_pushes crit_path_total_heap_pops critical_path_delay geomean_nonvirtual_intradomain_critical_path_delay setup_TNS setup_WNS hold_TNS hold_WNS crit_path_routing_area_total crit_path_routing_area_per_tile router_lookahead_computation_time crit_path_route_time crit_path_create_rr_graph_time crit_path_create_intra_cluster_rr_graph_time crit_path_tile_lookahead_computation_time crit_path_router_lookahead_computation_time crit_path_total_timing_analysis_time crit_path_total_sta_time
2+
fixed_k6_frac_N8_22nm.xml single_wire.v common 1.86 vpr 70.71 MiB -1 -1 0.14 16260 1 0.02 -1 -1 29996 -1 -1 0 1 0 0 success v8.0.0-11569-g4abbff8da release VTR_ASSERT_LEVEL=3 GNU 9.4.0 on Linux-4.15.0-213-generic x86_64 2024-10-17T15:58:41 betzgrp-wintermute.eecg.utoronto.ca /home/singera8/vtr-verilog-to-routing/vtr_flow/tasks 72404 1 1 0 2 0 1 2 17 17 289 -1 unnamed_device -1 -1 -1 -1 -1 -1 -1 70.7 MiB 0.09 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 70.7 MiB 0.09 70.7 MiB 0.09 8 14 1 6.79088e+06 0 166176. 575.005 0.37 0.00145994 0.0013718 20206 45088 -1 19 1 1 1 194 45 0.7726 nan -0.7726 -0.7726 0 0 202963. 702.294 0.11 0.00 0.08 -1 -1 0.11 0.00115987 0.00113118
3+
fixed_k6_frac_N8_22nm.xml single_ff.v common 2.32 vpr 70.91 MiB -1 -1 0.12 16324 1 0.02 -1 -1 29972 -1 -1 1 2 0 0 success v8.0.0-11569-g4abbff8da release VTR_ASSERT_LEVEL=3 GNU 9.4.0 on Linux-4.15.0-213-generic x86_64 2024-10-17T15:58:41 betzgrp-wintermute.eecg.utoronto.ca /home/singera8/vtr-verilog-to-routing/vtr_flow/tasks 72608 2 1 3 3 1 3 4 17 17 289 -1 unnamed_device -1 -1 -1 -1 -1 -1 -1 70.9 MiB 0.09 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 70.9 MiB 0.09 70.9 MiB 0.09 20 32 1 6.79088e+06 13472 414966. 1435.87 0.65 0.0013976 0.00133449 22510 95286 -1 40 1 2 2 394 99 1.06752 1.06752 -2.06486 -1.06752 0 0 503264. 1741.40 0.20 0.00 0.16 -1 -1 0.20 0.0013263 0.00128456
4+
fixed_k6_frac_N8_22nm.xml ch_intrinsics.v common 6.78 vpr 71.84 MiB -1 -1 0.48 18336 3 0.11 -1 -1 33188 -1 -1 34 99 1 0 success v8.0.0-11569-g4abbff8da release VTR_ASSERT_LEVEL=3 GNU 9.4.0 on Linux-4.15.0-213-generic x86_64 2024-10-17T15:58:41 betzgrp-wintermute.eecg.utoronto.ca /home/singera8/vtr-verilog-to-routing/vtr_flow/tasks 73568 99 130 240 229 1 238 264 17 17 289 -1 unnamed_device -1 -1 -1 -1 -1 -1 -1 71.8 MiB 0.27 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 71.8 MiB 0.27 71.8 MiB 0.27 34 2792 13 6.79088e+06 1.00605e+06 618332. 2139.56 3.94 0.383735 0.349796 25102 150614 -1 2694 15 616 987 97889 23015 2.47058 2.47058 -150.612 -2.47058 0 0 787024. 2723.27 0.27 0.11 0.23 -1 -1 0.27 0.0610859 0.0560772
5+
fixed_k6_frac_N8_22nm.xml diffeq1.v common 24.21 vpr 74.00 MiB -1 -1 0.75 22884 15 0.37 -1 -1 34280 -1 -1 55 162 0 5 success v8.0.0-11569-g4abbff8da release VTR_ASSERT_LEVEL=3 GNU 9.4.0 on Linux-4.15.0-213-generic x86_64 2024-10-17T15:58:41 betzgrp-wintermute.eecg.utoronto.ca /home/singera8/vtr-verilog-to-routing/vtr_flow/tasks 75780 162 96 817 258 1 775 318 17 17 289 -1 unnamed_device -1 -1 -1 -1 -1 -1 -1 74.0 MiB 0.68 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 74.0 MiB 0.68 74.0 MiB 0.66 72 17155 27 6.79088e+06 2.72096e+06 1.19926e+06 4149.71 18.39 3.30386 3.12634 32302 307853 -1 15386 19 3657 8928 1435723 311083 21.8615 21.8615 -1810.62 -21.8615 0 0 1.50317e+06 5201.28 0.50 0.73 0.55 -1 -1 0.50 0.298787 0.283438

vtr_flow/tasks/regression_tests/vtr_reg_strong/basic_ap/diffeq1/config/config.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.

vtr_flow/tasks/regression_tests/vtr_reg_strong/basic_ap/single_ff/config/config.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.

vtr_flow/tasks/regression_tests/vtr_reg_strong/basic_ap/single_ff/config/golden_results.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

vtr_flow/tasks/regression_tests/vtr_reg_strong/basic_ap/single_wire/config/config.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)