Skip to content

Commit f715a53

Browse files
cherry-picked some packing updates from noc congestion branch
1 parent 634d852 commit f715a53

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

vpr/src/base/vpr_api.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,8 @@ bool vpr_pack(t_vpr_setup& vpr_setup, const t_arch& arch) {
652652
return try_pack(&vpr_setup.PackerOpts, &vpr_setup.AnalysisOpts,
653653
&arch, vpr_setup.user_models,
654654
vpr_setup.library_models, inter_cluster_delay,
655-
vpr_setup.PackerRRGraph);
655+
vpr_setup.PackerRRGraph,
656+
vpr_setup.NocOpts.noc);
656657
}
657658

658659
void vpr_load_packing(t_vpr_setup& vpr_setup, const t_arch& arch) {

vpr/src/pack/pack.cpp

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ bool try_pack(t_packer_opts* packer_opts,
5757
const t_model* user_models,
5858
const t_model* library_models,
5959
float interc_delay,
60-
std::vector<t_lb_type_rr_node>* lb_type_rr_graphs) {
60+
std::vector<t_lb_type_rr_node>* lb_type_rr_graphs,
61+
bool noc_enabled) {
6162
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
6263
auto& atom_ctx = g_vpr_ctx.atom();
6364
auto& atom_mutable_ctx = g_vpr_ctx.mutable_atom();
@@ -142,7 +143,22 @@ bool try_pack(t_packer_opts* packer_opts,
142143

143144
int pack_iteration = 1;
144145
bool floorplan_regions_overfull = false;
145-
bool allow_high_fanout_connectivity_clustering = false;
146+
bool allow_high_fanout_connectivity_clustering;
147+
148+
/* If the design contains NoC routers, don't use high fanout connectivity
149+
* to find candidate atoms for growing the current cluster. In NoC-based designs,
150+
* modules connected to different routers may not have any shared net except for
151+
* clock and other global signals. By not using high fanout connectivity,
152+
* atoms belonging to different modules become less likely to be clustered together.
153+
* This allows the placement engine to place clustered blocks closer to their
154+
* corresponding NoC router, reducing WL as a result. Otherwise, blocks containing
155+
* atoms from two different modules would be stretched between two routers.
156+
*/
157+
if (noc_enabled) {
158+
allow_high_fanout_connectivity_clustering = false;
159+
} else {
160+
allow_high_fanout_connectivity_clustering = true;
161+
}
146162

147163
while (true) {
148164
free_clustering_data(*packer_opts, clustering_data);
@@ -174,15 +190,20 @@ bool try_pack(t_packer_opts* packer_opts,
174190

175191
if (fits_on_device && !floorplan_regions_overfull) {
176192
break; //Done
177-
} else if (pack_iteration == 1 && !floorplan_not_fitting) {
193+
/*
194+
* If NoC is enabled and the first packing attempt has failed, we don't care whether a floorplan constraint couldn't be satisfied
195+
* or the clustered netlist does not fit into the target FPGA device. Enabling high fanout connectivity clustering
196+
* can help with both, so we enable it.
197+
*/
198+
} else if (noc_enabled && pack_iteration == 1) {
178199
VTR_ASSERT(allow_high_fanout_connectivity_clustering == false);
179200
allow_high_fanout_connectivity_clustering = true;
180201
VTR_LOG("Packing failed to fit on device. Re-packing with: unrelated_logic_clustering=%s balance_block_type_util=%s allow_high_fanout_connectivity_clustering=%s\n",
181202
(allow_unrelated_clustering ? "true" : "false"),
182203
(balance_block_type_util ? "true" : "false"),
183204
(allow_high_fanout_connectivity_clustering ? "true" : "false"));
184-
} else if (pack_iteration == 2 && !floorplan_not_fitting) {
185-
//1st pack attempt was unsucessful (i.e. not dense enough) and we have control of unrelated clustering
205+
} else if (!floorplan_not_fitting && ((noc_enabled && pack_iteration == 2) || (!noc_enabled && pack_iteration == 1))) {
206+
//1st pack attempt was unsuccessful (i.e. not dense enough) and we have control of unrelated clustering
186207
//
187208
//Turn it on to increase packing density
188209
if (packer_opts->allow_unrelated_clustering == e_unrelated_clustering::AUTO) {
@@ -207,21 +228,21 @@ bool try_pack(t_packer_opts* packer_opts,
207228
* we create attraction groups for partitions with overfull regions (pack those atoms more densely). We continue this way
208229
* until the last iteration, when we create attraction groups for every partition, if needed.
209230
*/
210-
} else if (pack_iteration == 1 && floorplan_not_fitting) {
231+
} else if (floorplan_not_fitting && ((!noc_enabled && pack_iteration == 1) || (noc_enabled && pack_iteration == 2))) {
211232
VTR_LOG("Floorplan regions are overfull: trying to pack again using cluster attraction groups. \n");
212233
attraction_groups.create_att_groups_for_overfull_regions();
213234
attraction_groups.set_att_group_pulls(1);
214235

215-
} else if (pack_iteration >= 2 && pack_iteration < 5 && floorplan_not_fitting) {
216-
if (pack_iteration == 2) {
236+
} else if (floorplan_not_fitting && ((!noc_enabled && pack_iteration >= 2 && pack_iteration < 5) || (noc_enabled && pack_iteration >= 3 && pack_iteration < 6))) {
237+
if ((!noc_enabled && pack_iteration == 2) || (noc_enabled && pack_iteration == 3)) {
217238
VTR_LOG("Floorplan regions are overfull: trying to pack again with more attraction groups exploration. \n");
218239
attraction_groups.create_att_groups_for_overfull_regions();
219240
VTR_LOG("Pack iteration is %d\n", pack_iteration);
220-
} else if (pack_iteration == 3) {
241+
} else if ((!noc_enabled && pack_iteration == 3) || (noc_enabled && pack_iteration == 4)) {
221242
attraction_groups.create_att_groups_for_all_regions();
222243
VTR_LOG("Floorplan regions are overfull: trying to pack again with more attraction groups exploration. \n");
223244
VTR_LOG("Pack iteration is %d\n", pack_iteration);
224-
} else if (pack_iteration == 4) {
245+
} else if ((!noc_enabled && pack_iteration == 4) || (noc_enabled && pack_iteration == 5)) {
225246
attraction_groups.create_att_groups_for_all_regions();
226247
VTR_LOG("Floorplan regions are overfull: trying to pack again with more attraction groups exploration and higher target pin utilization. \n");
227248
VTR_LOG("Pack iteration is %d\n", pack_iteration);
@@ -230,9 +251,7 @@ bool try_pack(t_packer_opts* packer_opts,
230251
helper_ctx.target_external_pin_util.set_block_pin_util("clb", pin_util);
231252
}
232253

233-
} else {
234-
//Unable to pack densely enough: Give Up
235-
254+
} else { //Unable to pack densely enough: Give Up
236255
if (floorplan_regions_overfull) {
237256
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
238257
"Failed to find pack clusters densely enough to fit in the designated floorplan regions.\n"
@@ -258,7 +277,7 @@ bool try_pack(t_packer_opts* packer_opts,
258277
resource_avail += std::string(iter->first->name) + ": " + std::to_string(num_instances);
259278
}
260279

261-
VPR_FATAL_ERROR(VPR_ERROR_OTHER, "Failed to find device which satisifies resource requirements required: %s (available %s)", resource_reqs.c_str(), resource_avail.c_str());
280+
VPR_FATAL_ERROR(VPR_ERROR_OTHER, "Failed to find device which satisfies resource requirements required: %s (available %s)", resource_reqs.c_str(), resource_avail.c_str());
262281
}
263282

264283
//Reset clustering for re-packing

vpr/src/pack/pack.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ bool try_pack(t_packer_opts* packer_opts,
1111
const t_model* user_models,
1212
const t_model* library_models,
1313
float interc_delay,
14-
std::vector<t_lb_type_rr_node>* lb_type_rr_graphs);
14+
std::vector<t_lb_type_rr_node>* lb_type_rr_graphs,
15+
bool noc_enabled);
1516

1617
float get_arch_switch_info(short switch_index, int switch_fanin, float& Tdel_switch, float& R_switch, float& Cout_switch);
1718

0 commit comments

Comments
 (0)