Skip to content

Commit a1fe8e1

Browse files
Merge branch 'master' into temp_chan_w_factors_prefix_sum
2 parents 9307ef3 + 1876d05 commit a1fe8e1

File tree

9 files changed

+930
-177
lines changed

9 files changed

+930
-177
lines changed

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "full_legalizer.h"
99

10-
#include <cmath>
1110
#include <list>
1211
#include <unordered_set>
1312
#include <vector>
@@ -27,6 +26,8 @@
2726
#include "physical_types.h"
2827
#include "place_constraints.h"
2928
#include "place_macro.h"
29+
#include "verify_clustering.h"
30+
#include "verify_placement.h"
3031
#include "vpr_api.h"
3132
#include "vpr_context.h"
3233
#include "vpr_error.h"
@@ -392,9 +393,32 @@ 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.
398411
place_clusters(clb_nlist, p_placement);
412+
413+
// Verify that the placement created by the full legalizer is valid.
414+
unsigned num_placement_errors = verify_placement(g_vpr_ctx);
415+
if (num_placement_errors == 0) {
416+
VTR_LOG("Completed placement consistency check successfully.\n");
417+
} else {
418+
VPR_ERROR(VPR_ERROR_AP,
419+
"Completed placement consistency check, %u errors found.\n"
420+
"Aborting program.\n",
421+
num_placement_errors);
422+
}
399423
}
400424

vpr/src/base/vpr_api.cpp

Lines changed: 29 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) {
@@ -793,6 +801,9 @@ bool vpr_place_flow(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_a
793801
vpr_load_placement(vpr_setup, arch);
794802
}
795803

804+
// FIXME: This synchronization is not consistent with the rest of
805+
// placement. This requires it to happen after the placement is
806+
// verified. See issue #2801
796807
sync_grid_to_blocks();
797808
post_place_sync();
798809
}

0 commit comments

Comments
 (0)