Skip to content

Commit 1876d05

Browse files
Merge pull request #2771 from AlexandreSinger/feature-verify-clustering
[Clustering] Independent Clustering Verification
2 parents 045a9e8 + 58ea2c0 commit 1876d05

File tree

4 files changed

+568
-18
lines changed

4 files changed

+568
-18
lines changed

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "physical_types.h"
2727
#include "place_constraints.h"
2828
#include "place_macro.h"
29+
#include "verify_clustering.h"
2930
#include "verify_placement.h"
3031
#include "vpr_api.h"
3132
#include "vpr_context.h"
@@ -392,6 +393,18 @@ void FullLegalizer::legalize(const PartialPlacement& p_placement) {
392393

393394
// Pack the atoms into clusters based on the partial placement.
394395
create_clusters(p_placement);
396+
// Verify that the clustering created by the full legalizer is valid.
397+
unsigned num_clustering_errors = verify_clustering(g_vpr_ctx);
398+
if (num_clustering_errors == 0) {
399+
VTR_LOG("Completed clustering consistency check successfully.\n");
400+
} else {
401+
VPR_ERROR(VPR_ERROR_AP,
402+
"Completed placement consistency check, %u errors found.\n"
403+
"Aborting program.\n",
404+
num_clustering_errors);
405+
}
406+
// Get the clustering from the global context.
407+
// TODO: Eventually should be returned from the create_clusters method.
395408
const ClusteredNetlist& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
396409

397410
// Place the clusters based on where the atoms want to be placed.

vpr/src/base/vpr_api.cpp

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include "place_util.h"
7171
#include "timing_fail_error.h"
7272
#include "analytical_placement_flow.h"
73+
#include "verify_clustering.h"
7374

7475
#include "vpr_constraints_writer.h"
7576

@@ -622,34 +623,16 @@ bool vpr_pack_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {
622623

623624
// generate a .net file by legalizing an input flat placement file
624625
if (packer_opts.load_flat_placement) {
625-
626626
//Load and legalizer flat placement file
627627
vpr_load_flat_placement(vpr_setup, arch);
628628

629629
//Load the result from the .net file
630630
vpr_load_packing(vpr_setup, arch);
631-
632631
} else {
633-
634632
//Load a previous packing from the .net file
635633
vpr_load_packing(vpr_setup, arch);
636-
637634
}
638-
639635
}
640-
641-
// Load cluster_constraints data structure.
642-
load_cluster_constraints();
643-
644-
/* Sanity check the resulting netlist */
645-
check_netlist(packer_opts.pack_verbosity);
646-
647-
/* Output the netlist stats to console and optionally to file. */
648-
writeClusteredNetlistStats(vpr_setup.FileNameOpts.write_block_usage);
649-
650-
// print the total number of used physical blocks for each
651-
// physical block type after finishing the packing stage
652-
print_pb_type_count(g_vpr_ctx.clustering().clb_nlist);
653636
}
654637

655638
return status;
@@ -742,6 +725,31 @@ void vpr_load_packing(t_vpr_setup& vpr_setup, const t_arch& arch) {
742725
std::ofstream ofs("packing_pin_util.rpt");
743726
report_packing_pin_usage(ofs, g_vpr_ctx);
744727
}
728+
729+
// Load cluster_constraints data structure.
730+
load_cluster_constraints();
731+
732+
/* Sanity check the resulting netlist */
733+
check_netlist(vpr_setup.PackerOpts.pack_verbosity);
734+
735+
// Independently verify the clusterings to ensure the clustering can be
736+
// used for the rest of the VPR flow.
737+
unsigned num_errors = verify_clustering(g_vpr_ctx);
738+
if (num_errors == 0) {
739+
VTR_LOG("Completed clustering consistency check successfully.\n");
740+
} else {
741+
VPR_ERROR(VPR_ERROR_PACK,
742+
"%u errors found while performing clustering consistency "
743+
"check. Aborting program.\n",
744+
num_errors);
745+
}
746+
747+
/* Output the netlist stats to console and optionally to file. */
748+
writeClusteredNetlistStats(vpr_setup.FileNameOpts.write_block_usage);
749+
750+
// print the total number of used physical blocks for each
751+
// physical block type after finishing the packing stage
752+
print_pb_type_count(g_vpr_ctx.clustering().clb_nlist);
745753
}
746754

747755
bool vpr_load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {

0 commit comments

Comments
 (0)