From df71e4679efe11c6c6e940adcf7a47ee964975cb Mon Sep 17 00:00:00 2001 From: Louis-He Date: Sun, 10 Sep 2023 17:02:50 -0400 Subject: [PATCH] Add regression test for external attraction data. Add assertion for external atrraction data load --- vpr/src/pack/cluster.cpp | 7 +-- vpr/src/pack/cluster_util.cpp | 51 ++++++++++++++----- vpr/src/pack/cluster_util.h | 8 +-- vtr_flow/benchmarks/verilog/single_chain.v | 18 +++++++ .../pass_requirements_worse_cluster.txt | 3 ++ .../config/config.txt | 34 +++++++++++++ .../config/golden_results.txt | 2 + .../sample_external_attraction_data_2.xml | 28 ++++++++++ 8 files changed, 132 insertions(+), 19 deletions(-) create mode 100644 vtr_flow/benchmarks/verilog/single_chain.v create mode 100644 vtr_flow/parse/pass_requirements/pass_requirements_worse_cluster.txt create mode 100644 vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/config.txt create mode 100644 vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/golden_results.txt create mode 100644 vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/sample_external_attraction_data_2.xml diff --git a/vpr/src/pack/cluster.cpp b/vpr/src/pack/cluster.cpp index 9c76c0374d8..7fd660c97a8 100644 --- a/vpr/src/pack/cluster.cpp +++ b/vpr/src/pack/cluster.cpp @@ -176,7 +176,7 @@ std::map do_clustering(const t_packer_opts& pa istart = nullptr; // load external attraction data - load_external_attraction_data(packer_opts.external_attraction_file); + load_external_attraction_data(packer_opts.external_attraction_file, verbosity); // clear up to data clustering decision (This should be a clean start for clustering) helper_ctx.incomplete_cluster_to_atoms_lookup.clear(); @@ -299,7 +299,8 @@ std::map do_clustering(const t_packer_opts& pa high_fanout_threshold, *timing_info, attraction_groups, - net_output_feeds_driving_block_input); + net_output_feeds_driving_block_input, + verbosity); helper_ctx.total_clb_num++; if (packer_opts.timing_driven) { @@ -382,7 +383,7 @@ std::map do_clustering(const t_packer_opts& pa if (is_cluster_legal) { istart = save_cluster_routing_and_pick_new_seed(packer_opts, helper_ctx.total_clb_num, seed_atoms, num_blocks_hill_added, clustering_data.intra_lb_routing, seedindex, cluster_stats, router_data); - store_cluster_info_and_free(packer_opts, clb_index, logic_block_type, le_pb_type, le_count, clb_inter_blk_nets); + store_cluster_info_and_free(packer_opts, clb_index, logic_block_type, le_pb_type, le_count, clb_inter_blk_nets, verbosity); } else { free_data_and_requeue_used_mols_if_illegal(clb_index, savedseedindex, num_used_type_instances, helper_ctx.total_clb_num, seedindex); } diff --git a/vpr/src/pack/cluster_util.cpp b/vpr/src/pack/cluster_util.cpp index 1d0008bf2fd..8892b1354a4 100644 --- a/vpr/src/pack/cluster_util.cpp +++ b/vpr/src/pack/cluster_util.cpp @@ -1618,7 +1618,8 @@ void try_fill_cluster(const t_packer_opts& packer_opts, high_fanout_threshold, *timing_info, attraction_groups, - net_output_feeds_driving_block_input); + net_output_feeds_driving_block_input, + packer_opts.pack_verbosity); cluster_stats.num_unrelated_clustering_attempts = 0; if (packer_opts.timing_driven) { @@ -1677,7 +1678,8 @@ void store_cluster_info_and_free(const t_packer_opts& packer_opts, const t_logical_block_type_ptr logic_block_type, const t_pb_type* le_pb_type, std::vector& le_count, - vtr::vector>& clb_inter_blk_nets) { + vtr::vector>& clb_inter_blk_nets, + const int verbosity) { auto& cluster_ctx = g_vpr_ctx.mutable_clustering(); auto& atom_ctx = g_vpr_ctx.atom(); @@ -1690,6 +1692,18 @@ void store_cluster_info_and_free(const t_packer_opts& packer_opts, clb_inter_blk_nets[clb_index].push_back(mnet_id); } } + + if (verbosity > 2) { + VTR_LOG("Final Cluster Result for clb #%ld: ", static_cast(clb_index)); + auto& blks_in_the_cluster = g_vpr_ctx.cl_helper().incomplete_cluster_to_atoms_lookup.at(clb_index); + for (const auto& blk_id : blks_in_the_cluster) { + VTR_LOG("%s ", atom_ctx.nlist.block_name(blk_id).c_str()); + } + VTR_LOG("\n"); + } + + + auto cur_pb = cluster_ctx.clb_nlist.block_pb(clb_index); // update the data structure holding the LE counts @@ -1707,6 +1721,9 @@ void free_data_and_requeue_used_mols_if_illegal(const ClusterBlockId& clb_index, int& num_clb, int& seedindex) { auto& cluster_ctx = g_vpr_ctx.mutable_clustering(); + auto& cl_helper_ctx = g_vpr_ctx.mutable_cl_helper(); + cl_helper_ctx.incomplete_cluster_to_atoms_lookup.erase( + cl_helper_ctx.incomplete_cluster_to_atoms_lookup.cbegin() + static_cast(clb_index)); num_used_type_instances[cluster_ctx.clb_nlist.block_type(clb_index)]--; revalid_molecules(cluster_ctx.clb_nlist.block_pb(clb_index)); @@ -1935,7 +1952,8 @@ void update_cluster_stats(const t_pack_molecule* molecule, const int high_fanout_net_threshold, const SetupTimingInfo& timing_info, AttractionInfo& attraction_groups, - std::unordered_map& net_output_feeds_driving_block_input) { + std::unordered_map& net_output_feeds_driving_block_input, + const int verbosity) { /* Routine that is called each time a new molecule is added to the cluster. * Makes calls to update cluster stats such as the gain map for atoms, used pins, and clock structures, * in order to reflect the new content of the cluster. @@ -1960,12 +1978,17 @@ void update_cluster_stats(const t_pack_molecule* molecule, atom_ctx.lookup.set_atom_clb(blk_id, clb_index); //Update clustring clb to atoms mapping - if (static_cast(blk_id) >= cl_helper_ctx.incomplete_cluster_to_atoms_lookup.size()) { + if (static_cast(clb_index) >= cl_helper_ctx.incomplete_cluster_to_atoms_lookup.size()) { cl_helper_ctx.incomplete_cluster_to_atoms_lookup.push_back(std::set()); } auto& blks_in_the_cluster = cl_helper_ctx.incomplete_cluster_to_atoms_lookup.at(clb_index); blks_in_the_cluster.insert(blk_id); + if (verbosity > 2) + { + VTR_LOG("Adding block %s to cluster %d\n", atom_ctx.nlist.block_name(blk_id).c_str(), clb_index); + } + const t_pb* atom_pb = atom_ctx.lookup.atom_pb(blk_id); VTR_ASSERT(atom_pb); @@ -3845,7 +3868,7 @@ void init_clb_atoms_lookup(vtr::vector 1, "\nLoadign external attracion data\n"); // go through the file try { // load the file @@ -3885,7 +3908,9 @@ void load_external_attraction_data(const std::string& attraction_file) { double attraction_score = pugiutil::get_attribute(dst_node_tag, "score", loc_data, pugiutil::REQUIRED).as_double(); - VTR_LOG("attraction: score: %f, %d:%s -> %d:%s\n", attraction_score, src_block_id, src_node_name.c_str(), dst_block_id, dst_node_name.c_str()); + VTR_ASSERT(src_block_id); + VTR_ASSERT(dst_block_id); + VTR_LOGV(verbosity > 2, "attraction: score: %f, src: %d:%s, dst: %d:%s\n", attraction_score, src_block_id, src_node_name.c_str(), dst_block_id, dst_node_name.c_str()); attraction_data[src_block_id][dst_block_id] = attraction_score; } } @@ -3894,18 +3919,18 @@ void load_external_attraction_data(const std::string& attraction_file) { vpr_throw(VPR_ERROR_OTHER, attraction_file_char, e.line(), e.what()); } - VTR_LOG("\n=============================\n\n"); + VTR_LOGV(verbosity > 2,"\n=============================\n\n"); for (auto srckv : attraction_data) { for (auto dstkv : srckv.second) { - VTR_LOG("attraction: score: %f, %d -> %d\n", dstkv.second, srckv.first, dstkv.first); + VTR_LOGV(verbosity > 2,"attraction: score: %f, src: %d, dst: %d\n", dstkv.second, srckv.first, dstkv.first); } } - for (auto& block_id : atom_ctx.nlist.blocks()) { - std::string atom_name = atom_ctx.nlist.block_name(block_id); - VTR_LOG("atom id: %d, name: %s\n", block_id, atom_name.c_str()); - } + // for (auto& block_id : atom_ctx.nlist.blocks()) { + // std::string atom_name = atom_ctx.nlist.block_name(block_id); + // VTR_LOG("atom id: %d, name: %s\n", block_id, atom_name.c_str()); + // } } \ No newline at end of file diff --git a/vpr/src/pack/cluster_util.h b/vpr/src/pack/cluster_util.h index 6b5a8e576d5..bdd7e18b7c9 100644 --- a/vpr/src/pack/cluster_util.h +++ b/vpr/src/pack/cluster_util.h @@ -262,7 +262,8 @@ void store_cluster_info_and_free(const t_packer_opts& packer_opts, const t_logical_block_type_ptr logic_block_type, const t_pb_type* le_pb_type, std::vector& le_count, - vtr::vector>& clb_inter_blk_nets); + vtr::vector>& clb_inter_blk_nets, + const int verbosity); void free_data_and_requeue_used_mols_if_illegal(const ClusterBlockId& clb_index, const int& savedseedindex, @@ -325,7 +326,8 @@ void update_cluster_stats(const t_pack_molecule* molecule, const int high_fanout_net_threshold, const SetupTimingInfo& timing_info, AttractionInfo& attraction_groups, - std::unordered_map& net_output_feeds_driving_block_input); + std::unordered_map& net_output_feeds_driving_block_input, + const int verbosity); void start_new_cluster(t_cluster_placement_stats* cluster_placement_stats, t_pb_graph_node** primitives_list, @@ -486,5 +488,5 @@ void alloc_and_load_pb_stats(t_pb* pb, const int feasible_block_array_size); void init_clb_atoms_lookup(vtr::vector>& atoms_lookup); // Helper functions for load external attraction data -void load_external_attraction_data(const std::string& attraction_file); +void load_external_attraction_data(const std::string& attraction_file, const int verbosity); #endif \ No newline at end of file diff --git a/vtr_flow/benchmarks/verilog/single_chain.v b/vtr_flow/benchmarks/verilog/single_chain.v new file mode 100644 index 00000000000..a6eadef0af4 --- /dev/null +++ b/vtr_flow/benchmarks/verilog/single_chain.v @@ -0,0 +1,18 @@ +module top(input clock, in, output reg out); + reg [9:0] register_chain; + + always @(posedge clock) begin + register_chain[0] <= in; + register_chain[1] <= register_chain[0]; + register_chain[2] <= register_chain[1] + register_chain[1]; + register_chain[3] <= register_chain[2] + register_chain[2]; + register_chain[4] <= register_chain[3] + register_chain[3]; + register_chain[5] <= register_chain[4]; + register_chain[6] <= register_chain[5]; + register_chain[7] <= register_chain[6]; + register_chain[8] <= register_chain[7]; + register_chain[9] <= register_chain[8]; + out <= register_chain[9]; + end + +endmodule diff --git a/vtr_flow/parse/pass_requirements/pass_requirements_worse_cluster.txt b/vtr_flow/parse/pass_requirements/pass_requirements_worse_cluster.txt new file mode 100644 index 00000000000..bf7c35e02a4 --- /dev/null +++ b/vtr_flow/parse/pass_requirements/pass_requirements_worse_cluster.txt @@ -0,0 +1,3 @@ +placed_wirelength_est;Range(1.05,2.0) +num_post_packed_nets;Range(1.05,2.0) +min_chan_width_routing_area_total;Range(1.05,2.0) \ No newline at end of file diff --git a/vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/config.txt b/vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/config.txt new file mode 100644 index 00000000000..d8a1ff38c7d --- /dev/null +++ b/vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/config.txt @@ -0,0 +1,34 @@ +# +############################################ +# Configuration file for running experiments +############################################## + +# Path to directory of circuits to use +circuits_dir=benchmarks/verilog + +# Path to directory of architectures to use +archs_dir=arch/timing + +# Add circuits to list to sweep +circuit_list_add=single_chain.v + +# Add architectures to list to sweep +arch_list_add=EArch.xml + +# Parse info and how to parse +parse_file=vpr_standard.txt + +# How to parse QoR info +qor_parse_file=qor_standard.txt + +# Pass requirements +pass_requirements_file=pass_requirements_worse_cluster.txt + +#Sweep option range +script_params_common = --cluster_seed_type timing --pack_verbosity 3 + +#additional_files_list_add =--external_attraction_file,sample_external_attraction_data.xml +# script_params_list_add =--seed 1 + +#additional_files_list_add =--external_attraction_file,sample_external_attraction_data_2.xml +script_params_list_add =--seed 1 --external_attraction_file ../../../../config/sample_external_attraction_data_2.xml diff --git a/vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/golden_results.txt b/vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/golden_results.txt new file mode 100644 index 00000000000..916e1e17a2e --- /dev/null +++ b/vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/golden_results.txt @@ -0,0 +1,2 @@ +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 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 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 crit_path_total_internal_heap_pushes crit_path_total_internal_heap_pops crit_path_total_external_heap_pushes crit_path_total_external_heap_pops crit_path_total_external_SOURCE_pushes crit_path_total_external_SOURCE_pops crit_path_total_internal_SOURCE_pushes crit_path_total_internal_SOURCE_pops crit_path_total_external_SINK_pushes crit_path_total_external_SINK_pops crit_path_total_internal_SINK_pushes crit_path_total_internal_SINK_pops crit_path_total_external_IPIN_pushes crit_path_total_external_IPIN_pops crit_path_total_internal_IPIN_pushes crit_path_total_internal_IPIN_pops crit_path_total_external_OPIN_pushes crit_path_total_external_OPIN_pops crit_path_total_internal_OPIN_pushes crit_path_total_internal_OPIN_pops crit_path_total_external_CHANX_pushes crit_path_total_external_CHANX_pops crit_path_total_internal_CHANX_pushes crit_path_total_internal_CHANX_pops crit_path_total_external_CHANY_pushes crit_path_total_external_CHANY_pops crit_path_total_internal_CHANY_pushes crit_path_total_internal_CHANY_pops crit_path_rt_node_SOURCE_pushes crit_path_rt_node_SINK_pushes crit_path_rt_node_IPIN_pushes crit_path_rt_node_OPIN_pushes crit_path_rt_node_CHANX_pushes crit_path_rt_node_CHANY_pushes crit_path_adding_all_rt crit_path_adding_high_fanout_rt crit_path_total_number_of_adding_all_rt_from_calling_high_fanout_rt 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 +EArch.xml single_chain.v common_--seed_1_--external_attraction_file_../../../../config/sample_external_attraction_data_2.xml 1.67 vpr 69.92 MiB -1 -1 0.08 23552 1 0.01 -1 -1 34404 -1 -1 3 2 0 0 success 4cb517a7f-dirty debug VTR_ASSERT_LEVEL=2 GNU 11.4.0 on Linux-6.2.0-32-generic x86_64 2023-09-10T16:03:13 siwei-X570 /home/siwei/Developer/vtr-verilog-to-routing/vtr_flow/tasks 71596 2 1 21 22 1 7 6 5 5 25 clb auto 31.6 MiB 0.03 12 69.9 MiB 0.00 0.00 0.97541 -7.57542 -0.97541 0.97541 0.23 0.000267334 0.000190603 0.00187422 0.00137103 12 25 5 323364 161682 13670.8 546.832 0.62 0.0139454 0.0111213 1380 2690 -1 23 1 4 4 180 104 0 0 180 104 4 4 0 0 20 18 0 0 28 28 0 0 4 4 0 0 73 24 0 0 51 26 0 0 4 0 0 0 0 0 4 0 0 1.19517 1.19517 -8.3775 -1.19517 0 0 17474.5 698.981 0.03 0.00 0.03 -1 -1 0.03 0.00432479 0.00331434 diff --git a/vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/sample_external_attraction_data_2.xml b/vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/sample_external_attraction_data_2.xml new file mode 100644 index 00000000000..9fb780e6ecd --- /dev/null +++ b/vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_cluster_external_attraction/config/sample_external_attraction_data_2.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +