Skip to content

Commit cb01961

Browse files
committed
enable option to force molecule placement on a specified primitive site
1 parent 2bf5d27 commit cb01961

File tree

7 files changed

+56
-13
lines changed

7 files changed

+56
-13
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ class t_pb_graph_node {
12871287
int num_output_pin_class; /* number of output pin classes that this pb_graph_node has */
12881288

12891289
int total_primitive_count; /* total number of this primitive type in the cluster */
1290-
int flat_site_index; /* index of this primitive within sites of its type in this cluster */
1290+
int flat_site_index; /* index of this primitive within sites of its type in this cluster */
12911291

12921292

12931293
/* Interconnect instances for this pb

vpr/src/pack/cluster_placement.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,14 @@ t_cluster_placement_stats* alloc_and_load_cluster_placement_stats() {
8686
* primitives_list - a list of primitives indexed to match atom_block_ids of molecule.
8787
* Expects an allocated array of primitives ptrs as inputs.
8888
* This function loads the array with the lowest cost primitives that implement molecule
89+
* force_site - optional user-specified primitive site on which to place the molecule; if a force_site
90+
* argument is provided, the function either selects the specified site or reports failure.
91+
* If the force_site argument is set to its default value (-1), vpr selects an available site.
8992
*/
9093
bool get_next_primitive_list(t_cluster_placement_stats* cluster_placement_stats,
9194
const t_pack_molecule* molecule,
92-
t_pb_graph_node** primitives_list) {
95+
t_pb_graph_node** primitives_list,
96+
int force_site) {
9397
std::unordered_multimap<int, t_cluster_placement_primitive*>::iterator best;
9498

9599
int i;
@@ -136,6 +140,23 @@ bool get_next_primitive_list(t_cluster_placement_stats* cluster_placement_stats,
136140
continue;
137141
}
138142

143+
144+
/* check for force site match, if applicable */
145+
if (force_site > -1) {
146+
if (force_site == it->second->pb_graph_node->flat_site_index) {
147+
cost = try_place_molecule(molecule, it->second->pb_graph_node, primitives_list);
148+
if (cost < HUGE_POSITIVE_FLOAT) {
149+
cluster_placement_stats->move_primitive_to_inflight(i, it);
150+
return true;
151+
} else {
152+
break;
153+
}
154+
} else {
155+
++it;
156+
continue;
157+
}
158+
}
159+
139160
/* try place molecule at root location cur */
140161
cost = try_place_molecule(molecule, it->second->pb_graph_node, primitives_list);
141162

@@ -153,6 +174,11 @@ bool get_next_primitive_list(t_cluster_placement_stats* cluster_placement_stats,
153174
}
154175
}
155176

177+
/* if force_site was specified but not found, fail */
178+
if (force_site > -1) {
179+
found_best = false;
180+
}
181+
156182
if (!found_best) {
157183
/* failed to find a placement */
158184
for (i = 0; i < molecule->num_blocks; i++) {

vpr/src/pack/cluster_placement.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ t_cluster_placement_stats* alloc_and_load_cluster_placement_stats();
1111
bool get_next_primitive_list(
1212
t_cluster_placement_stats* cluster_placement_stats,
1313
const t_pack_molecule* molecule,
14-
t_pb_graph_node** primitives_list);
14+
t_pb_graph_node** primitives_list,
15+
int force_site = -1);
1516
void commit_primitive(t_cluster_placement_stats* cluster_placement_stats,
1617
const t_pb_graph_node* primitive);
1718
void set_mode_cluster_placement_stats(const t_pb_graph_node* complex_block,

vpr/src/pack/cluster_util.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,8 @@ e_block_pack_status try_pack_molecule(t_cluster_placement_stats* cluster_placeme
932932
int feasible_block_array_size,
933933
t_ext_pin_util max_external_pin_util,
934934
PartitionRegion& temp_cluster_pr,
935-
NocGroupId& temp_noc_grp_id) {
935+
NocGroupId& temp_noc_grp_id,
936+
int force_site) {
936937
t_pb* parent;
937938
t_pb* cur_pb;
938939

@@ -1009,7 +1010,7 @@ e_block_pack_status try_pack_molecule(t_cluster_placement_stats* cluster_placeme
10091010

10101011
while (block_pack_status != e_block_pack_status::BLK_PASSED) {
10111012
if (get_next_primitive_list(cluster_placement_stats_ptr, molecule,
1012-
primitives_list)) {
1013+
primitives_list, force_site)) {
10131014
block_pack_status = e_block_pack_status::BLK_PASSED;
10141015

10151016
int failed_location = 0;

vpr/src/pack/cluster_util.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ e_block_pack_status try_pack_molecule(t_cluster_placement_stats* cluster_placeme
214214
int feasible_block_array_size,
215215
t_ext_pin_util max_external_pin_util,
216216
PartitionRegion& temp_cluster_pr,
217-
NocGroupId& temp_noc_grp_id);
217+
NocGroupId& temp_noc_grp_id,
218+
int force_site = -1);
218219

219220
void try_fill_cluster(const t_packer_opts& packer_opts,
220221
t_cluster_placement_stats* cur_cluster_placement_stats_ptr,
@@ -493,4 +494,4 @@ bool cleanup_pb(t_pb* pb);
493494
void alloc_and_load_pb_stats(t_pb* pb, const int feasible_block_array_size);
494495

495496
void init_clb_atoms_lookup(vtr::vector<ClusterBlockId, std::unordered_set<AtomBlockId>>& atoms_lookup);
496-
#endif
497+
#endif

vpr/src/pack/re_cluster_util.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
130130
t_lb_router_data** router_data,
131131
PartitionRegion& temp_cluster_pr,
132132
NocGroupId& temp_cluster_noc_grp_id,
133-
enum e_detailed_routing_stages detailed_routing_stage) {
133+
enum e_detailed_routing_stages detailed_routing_stage,
134+
int force_site) {
134135
auto& atom_ctx = g_vpr_ctx.atom();
135136
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
136137
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
@@ -172,7 +173,8 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
172173
0,
173174
FULL_EXTERNAL_PIN_UTIL,
174175
temp_cluster_pr,
175-
temp_cluster_noc_grp_id);
176+
temp_cluster_noc_grp_id,
177+
force_site);
176178

177179
// If clustering succeeds, add it to the clb netlist
178180
if (pack_result == e_block_pack_status::BLK_PASSED) {
@@ -215,7 +217,8 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
215217
t_clustering_data& clustering_data,
216218
t_lb_router_data*& router_data,
217219
enum e_detailed_routing_stages detailed_routing_stage,
218-
bool enable_pin_feasibility_filter) {
220+
bool enable_pin_feasibility_filter,
221+
int force_site) {
219222

220223
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
221224
auto& cluster_ctx = g_vpr_ctx.mutable_clustering();
@@ -250,7 +253,8 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
250253
helper_ctx.feasible_block_array_size,
251254
target_ext_pin_util,
252255
temp_cluster_pr,
253-
temp_cluster_noc_grp_id);
256+
temp_cluster_noc_grp_id,
257+
force_site);
254258

255259
// If clustering succeeds, add it to the clb netlist
256260
if (pack_result == e_block_pack_status::BLK_PASSED) {

vpr/src/pack/re_cluster_util.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ void remove_mol_from_cluster(const t_pack_molecule* molecule,
8484
* the function does not run a detailed intra-cluster routing-based legality check.
8585
* If many molecules will be added to a cluster, this option enables use of a single
8686
* routing check on the completed cluster (vs many incremental checks).
87+
* @param force_site: optional user-specified primitive site on which to place the molecule; this is passed to
88+
* try_pack_molecule and then to get_next_primitive_site. If a force_site argument is provided,
89+
* the molecule is either placed on the specified site or fails to add to the cluster.
90+
* If the force_site argument is set to its default value (-1), vpr selects an available site.
8791
*/
8892
bool start_new_cluster_for_mol(t_pack_molecule* molecule,
8993
const t_logical_block_type_ptr& type,
@@ -97,7 +101,8 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
97101
t_lb_router_data** router_data,
98102
PartitionRegion& temp_cluster_pr,
99103
NocGroupId& temp_cluster_noc_grp_id,
100-
enum e_detailed_routing_stages detailed_routing_stage = E_DETAILED_ROUTE_FOR_EACH_ATOM);
104+
enum e_detailed_routing_stages detailed_routing_stage = E_DETAILED_ROUTE_FOR_EACH_ATOM,
105+
int force_site = -1);
101106

102107
/**
103108
* @brief A function that packs a molecule into an existing cluster
@@ -118,6 +123,10 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
118123
* If many molecules will be added to a cluster, this option enables use of a single
119124
* routing check on the completed cluster (vs many incremental checks).
120125
* @param enable_pin_feasibility_filter: do a pin couting based legality check (before or in place of intra-cluster routing check).
126+
* @param force_site: optional user-specified primitive site on which to place the molecule; this is passed to
127+
* try_pack_molecule and then to get_next_primitive_site. If a force_site argument is provided,
128+
* the molecule is either placed on the specified site or fails to add to the cluster.
129+
* If the force_site argument is set to its default value (-1), vpr selects an available site.
121130
*/
122131
bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
123132
int molecule_size,
@@ -127,7 +136,8 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
127136
t_clustering_data& clustering_data,
128137
t_lb_router_data*& router_data,
129138
enum e_detailed_routing_stages detailed_routing_stage = E_DETAILED_ROUTE_FOR_EACH_ATOM,
130-
bool enable_pin_feasibility_filter = true);
139+
bool enable_pin_feasibility_filter = true,
140+
int force_site = -1);
131141

132142
/**
133143
* @brief A function that fix the clustered netlist if the move is performed

0 commit comments

Comments
 (0)