Skip to content

Commit d4771a1

Browse files
committed
vpr: Add --balance_block_type_utilization option
This option controls whether the clusterer attempts to balance resource utilization across different block types which can implement the same primitive. Default is 'on' which matches previous behaviour.
1 parent 93fc414 commit d4771a1

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

vpr/src/base/SetupVPR.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ void SetupPackerOpts(const t_options& Options,
425425
PackerOpts->beta = Options.beta_clustering;
426426
PackerOpts->pack_verbosity = Options.pack_verbosity;
427427
PackerOpts->enable_pin_feasibility_filter = Options.enable_clustering_pin_feasibility_filter;
428+
PackerOpts->balance_block_type_utilization = Options.balance_block_type_utilization;
428429
PackerOpts->target_external_pin_util = Options.target_external_pin_util;
429430
PackerOpts->target_device_utilization = Options.target_device_utilization;
430431

vpr/src/base/read_options.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,12 @@ static argparse::ArgumentParser create_arg_parser(std::string prog_name, t_optio
943943
.default_value("on")
944944
.show_in(argparse::ShowIn::HELP_ONLY);
945945

946+
pack_grp.add_argument<bool,ParseOnOff>(args.balance_block_type_utilization, "--balance_block_type_utilization")
947+
.help("If enabled, when a primitive can potentially be mapped to multiple block types the packer will "
948+
"pick the block type which (currently) has lower utilization.")
949+
.default_value("on")
950+
.show_in(argparse::ShowIn::HELP_ONLY);
951+
946952
pack_grp.add_argument(args.target_external_pin_util, "--target_ext_pin_util")
947953
.help("Sets the external pin utilization target during clustering.\n"
948954
"Value Ranges: [1.0, 0.0]\n"

vpr/src/base/read_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct t_options {
6969
argparse::ArgValue<bool> timing_driven_clustering;
7070
argparse::ArgValue<e_cluster_seed> cluster_seed_type;
7171
argparse::ArgValue<bool> enable_clustering_pin_feasibility_filter;
72+
argparse::ArgValue<bool> balance_block_type_utilization;
7273
argparse::ArgValue<std::vector<std::string>> target_external_pin_util;
7374
argparse::ArgValue<int> pack_verbosity;
7475

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ struct t_packer_opts {
667667
bool connection_driven;
668668
int pack_verbosity;
669669
bool enable_pin_feasibility_filter;
670+
bool balance_block_type_utilization;
670671
std::vector<std::string> target_external_pin_util;
671672
e_stage_action doPacking;
672673
enum e_packer_algorithm packer_algorithm;

vpr/src/pack/cluster.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ static void start_new_cluster(
241241
ClusteredNetlist *clb_nlist,
242242
const std::map<const t_model*,std::vector<t_type_ptr>>& primitive_candidate_block_types,
243243
int verbosity,
244-
bool enable_pin_feasibility_filter);
244+
bool enable_pin_feasibility_filter,
245+
bool balance_block_type_utilization);
245246

246247
static t_pack_molecule* get_highest_gain_molecule(
247248
t_pb *cur_pb,
@@ -505,7 +506,8 @@ std::map<t_type_ptr,size_t> do_clustering(const t_packer_opts& packer_opts, cons
505506
detailed_routing_stage, &cluster_ctx.clb_nlist,
506507
primitive_candidate_block_types,
507508
packer_opts.pack_verbosity,
508-
packer_opts.enable_pin_feasibility_filter);
509+
packer_opts.enable_pin_feasibility_filter,
510+
packer_opts.balance_block_type_utilization);
509511

510512
if (packer_opts.pack_verbosity > 1 && packer_opts.pack_verbosity < 3) {
511513
VTR_LOG("Complex block %d: %s, type: %s ",
@@ -1855,7 +1857,8 @@ static void start_new_cluster(
18551857
ClusteredNetlist *clb_nlist,
18561858
const std::map<const t_model*,std::vector<t_type_ptr>>& primitive_candidate_block_types,
18571859
int verbosity,
1858-
bool enable_pin_feasibility_filter) {
1860+
bool enable_pin_feasibility_filter,
1861+
bool balance_block_type_utilization) {
18591862
/* Given a starting seed block, start_new_cluster determines the next cluster type to use
18601863
It expands the FPGA if it cannot find a legal cluster for the atom block
18611864
*/
@@ -1872,19 +1875,21 @@ static void start_new_cluster(
18721875
VTR_ASSERT(itr != primitive_candidate_block_types.end());
18731876
std::vector<t_type_ptr> candidate_types = itr->second;
18741877

1875-
//We sort the candidate types in ascending order by their current utilization.
1876-
//This means that the packer will prefer to use types with lower utilization.
1877-
//This is a naive approach to try balancing utilization when multiple types can
1878-
//support the same primitive(s).
1879-
std::sort(candidate_types.begin(), candidate_types.end(),
1880-
[&](t_type_ptr lhs, t_type_ptr rhs) {
1881-
float lhs_util = float(num_used_type_instances[lhs]) / device_ctx.grid.num_instances(lhs);
1882-
float rhs_util = float(num_used_type_instances[rhs]) / device_ctx.grid.num_instances(rhs);
1883-
1884-
//Lower util first
1885-
return lhs_util < rhs_util;
1886-
}
1887-
);
1878+
if (balance_block_type_utilization) {
1879+
//We sort the candidate types in ascending order by their current utilization.
1880+
//This means that the packer will prefer to use types with lower utilization.
1881+
//This is a naive approach to try balancing utilization when multiple types can
1882+
//support the same primitive(s).
1883+
std::sort(candidate_types.begin(), candidate_types.end(),
1884+
[&](t_type_ptr lhs, t_type_ptr rhs) {
1885+
float lhs_util = float(num_used_type_instances[lhs]) / device_ctx.grid.num_instances(lhs);
1886+
float rhs_util = float(num_used_type_instances[rhs]) / device_ctx.grid.num_instances(rhs);
1887+
1888+
//Lower util first
1889+
return lhs_util < rhs_util;
1890+
}
1891+
);
1892+
}
18881893

18891894

18901895
if (verbosity > 2) {

0 commit comments

Comments
 (0)