Skip to content

Commit be886d6

Browse files
committed
partially restored packer_fix
1 parent 3af194c commit be886d6

File tree

5 files changed

+291
-192
lines changed

5 files changed

+291
-192
lines changed

CMakeLists.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,25 +127,25 @@ FILE(COPY ${EBLIF_TRANSFORM_SRC_H}
127127
DESTINATION
128128
${EBLIF_TRANSFORM_DEST})
129129

130-
## patch VPR
131-
#FILE(COPY ${PACKER_SRC_DIR}/cluster.cpp
132-
# ${PACKER_SRC_DIR}/cluster_util.cpp
133-
# ${PACKER_SRC_DIR}/cluster_util.h
134-
# ${PACKER_SRC_DIR}/output_clustering.cpp
135-
# ${PACKER_SRC_DIR}/output_clustering.h
130+
# patch VPR
131+
FILE(COPY ${PACKER_SRC_DIR}/cluster.cpp
132+
${PACKER_SRC_DIR}/cluster_util.cpp
133+
${PACKER_SRC_DIR}/cluster_util.h
134+
${PACKER_SRC_DIR}/output_clustering.cpp
135+
${PACKER_SRC_DIR}/output_clustering.h
136136
# ${PACKER_SRC_DIR}/cluster_router.cpp
137-
# ${PACKER_SRC_DIR}/post_routing_pb_pin_fixup.cpp
138-
# DESTINATION
139-
# ${VPR_DEST_DIR}/src/pack)
140-
#
141-
## add to VPR/pack
142-
#FILE(COPY ${PACKER_SRC_DIR}/nl_Par.h
143-
# ${PACKER_SRC_DIR}/nl_Par.cpp
144-
# ${PACKER_SRC_DIR}/pinc_log.h
145-
# ${PACKER_SRC_DIR}/pinc_log.cpp
146-
# DESTINATION
147-
# ${VPR_DEST_DIR}/src/pack)
148-
#message(STATUS "NOTE: ADDED to VPR src/pack: nl_Par.cpp,h pinc_log.cpp,h")
137+
${PACKER_SRC_DIR}/post_routing_pb_pin_fixup.cpp
138+
DESTINATION
139+
${VPR_DEST_DIR}/src/pack)
140+
141+
# add to VPR/pack
142+
FILE(COPY ${PACKER_SRC_DIR}/nl_Par.h
143+
${PACKER_SRC_DIR}/nl_Par.cpp
144+
${PACKER_SRC_DIR}/pinc_log.h
145+
${PACKER_SRC_DIR}/pinc_log.cpp
146+
DESTINATION
147+
${VPR_DEST_DIR}/src/pack)
148+
message(STATUS "NOTE: ADDED to VPR src/pack: nl_Par.cpp,h pinc_log.cpp,h")
149149

150150
# add to VPR/base
151151
file(COPY

include/packer_fix/cluster.cpp

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* t_pb:
2020
* Represents a clustered instance of a t_pb_graph_node containing netlist primitives
2121
*
22-
* t_pb_type and t_pb_graph_node (and related types) describe the targetted FPGA architecture, while t_pb represents
22+
* t_pb_type and t_pb_graph_node (and related types) describe the targeted FPGA architecture, while t_pb represents
2323
* the actual clustering of the user netlist.
2424
*
2525
* For example:
@@ -87,7 +87,7 @@
8787
* cluster until a nullptr is returned. So, the number of repeated molecules is changed from 1 to 500,
8888
* effectively making the clusterer pack a cluster until a nullptr is returned.
8989
*/
90-
#define ATTRACTION_GROUPS_MAX_REPEATED_MOLECULES 500
90+
static constexpr int ATTRACTION_GROUPS_MAX_REPEATED_MOLECULES = 500;
9191

9292
static bool s_partitioning_status_NOP = false;
9393
bool partitioning_status_NOP() { return s_partitioning_status_NOP; }
@@ -132,9 +132,8 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
132132
t_cluster_progress_stats cluster_stats;
133133

134134
//int num_molecules, num_molecules_processed, mols_since_last_print, blocks_since_last_analysis,
135-
int num_blocks_hill_added, max_pb_depth,
136-
seedindex, savedseedindex /* index of next most timing critical block */,
137-
detailed_routing_stage;
135+
int num_blocks_hill_added = 0, max_pb_depth = 0, detailed_routing_stage = 0;
136+
int seedindex = 0, savedseedindex = 0; // index of next most timing critical block
138137

139138
const int verbosity = packer_opts.pack_verbosity;
140139

@@ -146,7 +145,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
146145

147146
std::map<t_logical_block_type_ptr, size_t> num_used_type_instances;
148147

149-
bool is_cluster_legal = 0;
148+
bool isClusterLegal = false;
150149
enum e_block_pack_status block_pack_status;
151150

152151
t_cluster_placement_stats* cur_cluster_placement_stats_ptr = nullptr;
@@ -187,8 +186,6 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
187186
helper_ctx.max_cluster_size = 0;
188187
max_pb_depth = 0;
189188

190-
seedindex = 0;
191-
192189
const t_molecule_stats max_molecule_stats = calc_max_molecules_stats(molecule_head);
193190

194191
mark_all_molecules_valid(molecule_head);
@@ -233,9 +230,12 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
233230
clustering_delay_calc, timing_info, atom_criticality);
234231
}
235232

233+
// Assign gain scores to atoms and sort them based on the scores.
236234
auto seed_atoms = initialize_seed_atoms(packer_opts.cluster_seed_type, max_molecule_stats, atom_criticality);
237235

238-
istart = get_highest_gain_seed_molecule(seedindex, seed_atoms);
236+
/* index of next most timing critical block */
237+
int seed_index = 0;
238+
istart = get_highest_gain_seed_molecule(seed_index, seed_atoms);
239239

240240
print_pack_status_header();
241241

@@ -353,7 +353,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
353353

354354
while (istart != nullptr) {
355355

356-
is_cluster_legal = false;
356+
isClusterLegal = false;
357357
savedseedindex = seedindex;
358358

359359
// If in the previous "for (detailed_routing_stage ..." call we failed all the
@@ -387,7 +387,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
387387
failed_for_loop = true;
388388

389389
for (detailed_routing_stage = (int)E_DETAILED_ROUTE_AT_END_ONLY;
390-
!is_cluster_legal && detailed_routing_stage != (int)E_DETAILED_ROUTE_INVALID;
390+
!isClusterLegal && detailed_routing_stage != (int)E_DETAILED_ROUTE_INVALID;
391391
detailed_routing_stage++) {
392392

393393
ClusterBlockId clb_index(helper_ctx.total_clb_num);
@@ -399,6 +399,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
399399
* stores PartitionRegion information while the cluster is packed*/
400400
PartitionRegion temp_cluster_pr;
401401

402+
#if 0
402403
start_new_cluster(helper_ctx.cluster_placement_stats, helper_ctx.primitives_list,
403404
clb_index, istart,
404405
num_used_type_instances,
@@ -413,6 +414,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
413414
balance_block_type_utilization,
414415
packer_opts.feasible_block_array_size,
415416
temp_cluster_pr);
417+
#endif ////00000000000000000000000000000000000000000000000000
416418

417419
//initial molecule in cluster has been processed
418420
cluster_stats.num_molecules_processed++;
@@ -495,6 +497,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
495497
break;
496498
}
497499

500+
#if 0
498501
try_fill_cluster(packer_opts,
499502
cur_cluster_placement_stats_ptr,
500503
prev_molecule,
@@ -522,16 +525,17 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
522525
unclustered_list_head_size,
523526
net_output_feeds_driving_block_input,
524527
primitive_candidate_block_types);
528+
#endif ////////000000000000000
525529

526530
i++;
527531

528532
}
529533

530534
max_nb_molecule = i;
531535

532-
is_cluster_legal = check_cluster_legality(verbosity, detailed_routing_stage, router_data);
536+
isClusterLegal = check_cluster_legality(verbosity, detailed_routing_stage, router_data);
533537

534-
if (is_cluster_legal) {
538+
if (isClusterLegal) {
535539

536540
// Calls the extra check for "clb" only (may need to revisit this check) (T.Besson)
537541
//
@@ -547,25 +551,25 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
547551

548552
// Call the check as if we would output the final packing ... and see if there is any
549553
// mode conflict. (T.Besson)
550-
// 'is_cluster_legal' turns to false if there is a mode conflict.
554+
// 'isClusterLegal' turns to false if there is a mode conflict.
551555
//
552-
is_cluster_legal = rsbe::check_if_xml_mode_conflict(packer_opts, arch,
556+
isClusterLegal = rsbe::check_if_xml_mode_conflict(packer_opts, arch,
553557
clustering_data.intra_lb_routing);
554558

555559
// Remove the previous pushed "intra_lb_routing_solution" to clean up
556560
// the place. (T.Besson)
557561
//
558562
(clustering_data.intra_lb_routing).pop_back();
559563

560-
if (!is_cluster_legal &&
564+
if (!isClusterLegal &&
561565
(detailed_routing_stage == (int)E_DETAILED_ROUTE_FOR_EACH_ATOM)) {
562566

563567
VTR_LOGV(verbosity > 0, "Info: rejected cluster packing solution with modes conflict [%d]\n",
564568
max_nb_molecule);
565569
}
566570
}
567571

568-
if (is_cluster_legal) {
572+
if (isClusterLegal) {
569573

570574
istart = save_cluster_routing_and_pick_new_seed(packer_opts, helper_ctx.total_clb_num,
571575
seed_atoms, num_blocks_hill_added, clustering_data.intra_lb_routing,
@@ -610,9 +614,10 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
610614
} else {
611615

612616
while (istart != nullptr) {
613-
is_cluster_legal = false;
614-
savedseedindex = seedindex;
615-
for (detailed_routing_stage = (int)E_DETAILED_ROUTE_AT_END_ONLY; !is_cluster_legal && detailed_routing_stage != (int)E_DETAILED_ROUTE_INVALID; detailed_routing_stage++) {
617+
isClusterLegal = false;
618+
int saved_seed_index = seed_index;
619+
for (detailed_routing_stage = (int)E_DETAILED_ROUTE_AT_END_ONLY; !isClusterLegal && detailed_routing_stage != (int)E_DETAILED_ROUTE_INVALID; detailed_routing_stage++) {
620+
// Use the total number created clusters so far as the ID for the new cluster
616621
ClusterBlockId clb_index(helper_ctx.total_clb_num);
617622

618623
VTR_LOGV(verbosity > 2, "Complex block %d:\n", helper_ctx.total_clb_num);
@@ -621,6 +626,12 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
621626
* Since some of the primitives might fail legality, this structure temporarily
622627
* stores PartitionRegion information while the cluster is packed*/
623628
PartitionRegion temp_cluster_pr;
629+
/*
630+
* Stores the cluster's NoC group ID as more primitives are added to it.
631+
* This is used to check if a candidate primitive is in the same NoC group
632+
* as the atom blocks that have already been added to the primitive.
633+
*/
634+
NocGroupId temp_cluster_noc_grp_id = NocGroupId::INVALID();
624635

625636
start_new_cluster(helper_ctx.cluster_placement_stats, helper_ctx.primitives_list,
626637
clb_index, istart,
@@ -635,7 +646,8 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
635646
packer_opts.enable_pin_feasibility_filter,
636647
balance_block_type_utilization,
637648
packer_opts.feasible_block_array_size,
638-
temp_cluster_pr);
649+
temp_cluster_pr,
650+
temp_cluster_noc_grp_id);
639651

640652
//initial molecule in cluster has been processed
641653
cluster_stats.num_molecules_processed++;
@@ -659,7 +671,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
659671
t_ext_pin_util target_ext_pin_util = helper_ctx.target_external_pin_util.get_pin_util(cluster_ctx.clb_nlist.block_type(clb_index)->name);
660672
int high_fanout_threshold = helper_ctx.high_fanout_thresholds.get_threshold(cluster_ctx.clb_nlist.block_type(clb_index)->name);
661673
update_cluster_stats(istart, clb_index,
662-
is_clock, //Set of clock nets
674+
is_clock, //Set of clock nets
663675
is_global, //Set of global nets (currently all clocks)
664676
packer_opts.global_clocks,
665677
packer_opts.alpha, packer_opts.beta,
@@ -734,20 +746,21 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
734746
router_data,
735747
target_ext_pin_util,
736748
temp_cluster_pr,
749+
temp_cluster_noc_grp_id,
737750
block_pack_status,
738751
clustering_data.unclustered_list_head,
739752
unclustered_list_head_size,
740753
net_output_feeds_driving_block_input,
741754
primitive_candidate_block_types);
742755
}
743756

744-
is_cluster_legal = check_cluster_legality(verbosity, detailed_routing_stage, router_data);
757+
isClusterLegal = check_cluster_legality(verbosity, detailed_routing_stage, router_data);
745758

746-
if (is_cluster_legal) {
747-
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);
759+
if (isClusterLegal) {
760+
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, seed_index, cluster_stats, router_data);
748761
store_cluster_info_and_free(packer_opts, clb_index, logic_block_type, le_pb_type, le_count, clb_inter_blk_nets);
749762
} else {
750-
free_data_and_requeue_used_mols_if_illegal(clb_index, savedseedindex, num_used_type_instances, helper_ctx.total_clb_num, seedindex);
763+
free_data_and_requeue_used_mols_if_illegal(clb_index, saved_seed_index, num_used_type_instances, helper_ctx.total_clb_num, seed_index);
751764
}
752765
free_router_data(router_data);
753766
router_data = nullptr;

0 commit comments

Comments
 (0)