@@ -8,52 +8,55 @@ bool floorplan_constraints_regions_overfull() {
8
8
auto & floorplanning_ctx = g_vpr_ctx.mutable_floorplanning ();
9
9
auto & device_ctx = g_vpr_ctx.device ();
10
10
11
- auto & block_types = device_ctx.logical_block_types ;
11
+ const std::vector<t_logical_block_type> & block_types = device_ctx.logical_block_types ;
12
12
13
- std::unordered_map<Region, std::vector<int >> regions_count_info;
13
+ // keep record of how many blocks of each type are assigned to each PartitionRegion
14
+ std::unordered_map<PartitionRegion, std::vector<int >> pr_count_info;
14
15
15
- for (auto blk_id : cluster_ctx.clb_nlist .blocks ()) {
16
+ for (const ClusterBlockId blk_id : cluster_ctx.clb_nlist .blocks ()) {
16
17
if (!is_cluster_constrained (blk_id)) {
17
18
continue ;
18
19
}
19
20
t_logical_block_type_ptr bt = cluster_ctx.clb_nlist .block_type (blk_id);
20
21
21
22
const PartitionRegion& pr = floorplanning_ctx.cluster_constraints [blk_id];
22
- const std::vector<Region>& regions = pr.get_regions ();
23
-
24
- for (const auto & current_reg : regions) {
25
- auto got = regions_count_info.find (current_reg);
26
-
27
- if (got == regions_count_info.end ()) {
28
- std::vector<int > block_type_counts (block_types.size (), 0 );
29
-
30
- block_type_counts[bt->index ]++;
31
-
32
- regions_count_info.insert ({current_reg, block_type_counts});
23
+ auto got = pr_count_info.find (pr);
33
24
34
- } else {
35
- got->second [bt->index ]++;
36
- }
25
+ if (got == pr_count_info.end ()) {
26
+ std::vector<int > block_type_counts (block_types.size (), 0 );
27
+ block_type_counts[bt->index ]++;
28
+ pr_count_info.insert ({pr, block_type_counts});
29
+ } else {
30
+ got->second [bt->index ]++;
37
31
}
38
32
}
39
33
40
34
bool floorplan_regions_overfull = false ;
41
35
42
- for (const auto & [region , block_type_counts] : regions_count_info ) {
43
- const vtr::Rect< int >& rect = region. get_rect ();
44
- const auto [layer_low, layer_high] = region. get_layer_range ();
45
- for (const auto & block_type : block_types) {
36
+ for (const auto & [pr , block_type_counts] : pr_count_info ) {
37
+ const std::vector<Region >& regions = pr. get_regions ();
38
+
39
+ for (const t_logical_block_type & block_type : block_types) {
46
40
int num_assigned_blocks = block_type_counts[block_type.index ];
47
- int num_tiles = grid_tiles.region_tile_count (region, &block_type);
41
+ int num_tiles = std::accumulate (regions.begin (), regions.end (), 0 , [&grid_tiles, &block_type](int acc, const Region& reg) -> int {
42
+ return acc + grid_tiles.region_tile_count (reg, &block_type);
43
+ });
44
+
48
45
if (num_assigned_blocks > num_tiles) {
49
46
floorplan_regions_overfull = true ;
50
- floorplanning_ctx.overfull_regions .push_back (region);
51
- VTR_LOG (" \n \n Region (%d, %d, %d) to (%d, %d, %d) st %d \n " ,
52
- rect.xmin (), rect.ymin (), layer_low,
53
- rect.xmax (), rect.ymax (), layer_high,
54
- region.get_sub_tile ());
55
- VTR_LOG (" Assigned %d blocks of type %s, but only has %d tiles of that type\n " ,
47
+ floorplanning_ctx.overfull_partition_regions .push_back (pr);
48
+ VTR_LOG (" \n\n A partition including the following regions has been assigned %d blocks of type $s, "
49
+ " but only has %d tiles of that type\n " ,
56
50
num_assigned_blocks, block_type.name , num_tiles);
51
+ for (const Region& reg : regions) {
52
+ const vtr::Rect<int >& rect = reg.get_rect ();
53
+ const auto [layer_low, layer_high] = reg.get_layer_range ();
54
+ VTR_LOG (" \t Region (%d, %d, %d) to (%d, %d, %d) st %d \n " ,
55
+ rect.xmin (), rect.ymin (), layer_low,
56
+ rect.xmax (), rect.ymax (), layer_high,
57
+ reg.get_sub_tile ());
58
+ }
59
+
57
60
}
58
61
}
59
62
}
0 commit comments