Skip to content

Commit 693becf

Browse files
[Clustering] Independent Clustering Verification
Created a method that would independently verify the clustering in the VPR flow. If a clustering passes this verification, it is assumed that it can be used in placement and routing without issue. By design, this method does not use any global variables (everything needs to be passed in) and it recomputes everything that it does not assume. This allows it to be independent of the packing flow, so this method can also be used in the AP flow.
1 parent b3b3084 commit 693becf

File tree

4 files changed

+558
-0
lines changed

4 files changed

+558
-0
lines changed

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "pack.h"
2525
#include "physical_types.h"
2626
#include "place_constraints.h"
27+
#include "verify_clustering.h"
2728
#include "vpr_api.h"
2829
#include "vpr_context.h"
2930
#include "vpr_error.h"
@@ -389,6 +390,18 @@ void FullLegalizer::legalize(const PartialPlacement& p_placement) {
389390

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

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

vpr/src/base/vpr_api.cpp

Lines changed: 17 additions & 0 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

@@ -644,6 +645,22 @@ bool vpr_pack_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {
644645
/* Sanity check the resulting netlist */
645646
check_netlist(packer_opts.pack_verbosity);
646647

648+
// Independently verify the clusterings to ensure the clustering can be
649+
// used for the rest of the VPR flow.
650+
// NOTE: This is done here since it must be done after vpr_load_packing
651+
// and load_cluster_constraints.
652+
// TODO: If load_cluster_constraints was in vpr_load_packing, this could
653+
// also be in vpr_load_packing which would make more sense.
654+
unsigned num_errors = verify_clustering(g_vpr_ctx);
655+
if (num_errors == 0) {
656+
VTR_LOG("Completed clustering consistency check successfully.\n");
657+
} else {
658+
VPR_ERROR(VPR_ERROR_PACK,
659+
"%u errors found while performing clustering consistency "
660+
"check. Aborting program.\n",
661+
num_errors);
662+
}
663+
647664
/* Output the netlist stats to console and optionally to file. */
648665
writeClusteredNetlistStats(vpr_setup.FileNameOpts.write_block_usage);
649666

0 commit comments

Comments
 (0)