Skip to content
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

Added the option to load external clustering attraction data #2376

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions vpr/src/base/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ void SetupPackerOpts(const t_options& Options,
PackerOpts->alpha = Options.alpha_clustering;
PackerOpts->beta = Options.beta_clustering;
PackerOpts->pack_verbosity = Options.pack_verbosity;
PackerOpts->external_attraction_file = Options.external_attraction_file;
PackerOpts->external_attraction_default_weight = 0.5; /* DEFAULT: Experiment now */
PackerOpts->external_attraction_default_value = -1;
PackerOpts->enable_pin_feasibility_filter = Options.enable_clustering_pin_feasibility_filter;
PackerOpts->balance_block_type_utilization = Options.balance_block_type_utilization;
PackerOpts->target_external_pin_util = Options.target_external_pin_util;
Expand Down
6 changes: 6 additions & 0 deletions vpr/src/base/ShowSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,12 @@ static void ShowAnalysisOpts(const t_analysis_opts& AnalysisOpts) {
}

static void ShowPackerOpts(const t_packer_opts& PackerOpts) {
if (PackerOpts.external_attraction_file.empty()) {
VTR_LOG("external_attraction_file: None used\n");
} else {
VTR_LOG("external_attraction_file: %s\n", PackerOpts.external_attraction_file.c_str());
}

VTR_LOG("PackerOpts.allow_unrelated_clustering: ");
if (PackerOpts.allow_unrelated_clustering == e_unrelated_clustering::ON) {
VTR_LOG("true\n");
Expand Down
5 changes: 5 additions & 0 deletions vpr/src/base/read_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,11 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
.default_value("2")
.show_in(argparse::ShowIn::HELP_ONLY);

pack_grp.add_argument<std::string>(args.external_attraction_file, "--external_attraction_file")
.help("Whether to use external attraction data from a file")
.default_value("")
.show_in(argparse::ShowIn::HELP_ONLY);

pack_grp.add_argument<bool, ParseOnOff>(args.use_attraction_groups, "--use_attraction_groups")
.help("Whether attraction groups are used to make it easier to pack primitives in the same floorplan region together.")
.default_value("on")
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/read_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ struct t_options {
argparse::ArgValue<int> pack_feasible_block_array_size;
argparse::ArgValue<std::vector<std::string>> pack_high_fanout_threshold;
argparse::ArgValue<int> pack_verbosity;
argparse::ArgValue<std::string> external_attraction_file;
argparse::ArgValue<bool> use_attraction_groups;
argparse::ArgValue<int> pack_num_moves;
argparse::ArgValue<std::string> pack_move_type;
Expand Down
12 changes: 12 additions & 0 deletions vpr/src/base/vpr_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,18 @@ struct ClusteringHelperContext : public Context {
// A vector of unordered_sets of AtomBlockIds that are inside each clustered block [0 .. num_clustered_blocks-1]
// unordered_set for faster insertion/deletion during the iterative improvement process of packing
vtr::vector<ClusterBlockId, std::unordered_set<AtomBlockId>> atoms_lookup;

// 2D vector to store the external attraction data from one atom to another, default set to slight repulsion in SetupPackerOpts()
// external_atom_attraction_data[src][dst]:
// The attraction of putting dst atom to src atom
std::unordered_map<AtomBlockId, std::map<AtomBlockId, double>> external_atom_attraction_data;

// A vector of ordered_sets of AtomBlockIds that are inside each clustered block during the time of clustering
// This is used when we are clustering, hence the lookup map is not complete during the clustering algorithm.
// Each cluster contains all the atoms that are determined to be packed into the same cluster (there might be other atoms to be packed later)
// The data structure will be cleaned after the clustering stage to keep memory impact minimal
vtr::vector<const ClusterBlockId, std::set<AtomBlockId>> incomplete_cluster_to_atoms_lookup;

~ClusteringHelperContext() {
delete[] primitives_list;
}
Expand Down
3 changes: 3 additions & 0 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,9 @@ struct t_packer_opts {
e_unrelated_clustering allow_unrelated_clustering;
bool connection_driven;
int pack_verbosity;
std::string external_attraction_file;
float external_attraction_default_weight;
float external_attraction_default_value;
bool enable_pin_feasibility_filter;
e_balance_block_type_util balance_block_type_utilization;
std::vector<std::string> target_external_pin_util;
Expand Down
21 changes: 19 additions & 2 deletions vpr/src/pack/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
auto& device_ctx = g_vpr_ctx.mutable_device();
auto& cluster_ctx = g_vpr_ctx.mutable_clustering();
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
const auto& cl_helper_ctx = g_vpr_ctx.cl_helper();

helper_ctx.enable_pin_feasibility_filter = packer_opts.enable_pin_feasibility_filter;
helper_ctx.feasible_block_array_size = packer_opts.feasible_block_array_size;
Expand All @@ -174,6 +175,12 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa

istart = nullptr;

// load external attraction data
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();

/* determine bound on cluster size and primitive input size */
helper_ctx.max_cluster_size = 0;
max_pb_depth = 0;
Expand Down Expand Up @@ -292,7 +299,8 @@ std::map<t_logical_block_type_ptr, size_t> 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) {
Expand All @@ -304,6 +312,9 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
cluster_stats.num_unrelated_clustering_attempts = 0;
next_molecule = get_molecule_for_cluster(cluster_ctx.clb_nlist.block_pb(clb_index),
attraction_groups,
cl_helper_ctx.external_atom_attraction_data,
packer_opts.external_attraction_default_weight,
packer_opts.external_attraction_default_value,
allow_unrelated_clustering,
packer_opts.prioritize_transitive_connectivity,
packer_opts.transitive_fanout_threshold,
Expand Down Expand Up @@ -350,6 +361,9 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
clb_index,
detailed_routing_stage,
attraction_groups,
cl_helper_ctx.external_atom_attraction_data,
packer_opts.external_attraction_default_weight,
packer_opts.external_attraction_default_value,
clb_inter_blk_nets,
allow_unrelated_clustering,
high_fanout_threshold,
Expand All @@ -369,7 +383,7 @@ std::map<t_logical_block_type_ptr, size_t> 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);
}
Expand All @@ -386,6 +400,9 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
//check_floorplan_regions(floorplan_regions_overfull);
floorplan_regions_overfull = floorplan_constraints_regions_overfull();

// clear up to data clustering decision (No one should use incomplete_cluster_to_atoms_lookup after this point)
helper_ctx.incomplete_cluster_to_atoms_lookup.clear();

return num_used_type_instances;
}

Expand Down
Loading