diff --git a/vpr/src/base/vpr_context.h b/vpr/src/base/vpr_context.h index 63639f7fb69..1ae4c11b04c 100644 --- a/vpr/src/base/vpr_context.h +++ b/vpr/src/base/vpr_context.h @@ -540,7 +540,7 @@ struct FloorplanningContext : public Context { */ std::vector> compressed_cluster_constraints; - std::vector overfull_regions; + std::vector overfull_partition_regions; }; /** diff --git a/vpr/src/pack/attraction_groups.cpp b/vpr/src/pack/attraction_groups.cpp index b8f0351d6a7..9d8e29fcfef 100644 --- a/vpr/src/pack/attraction_groups.cpp +++ b/vpr/src/pack/attraction_groups.cpp @@ -47,35 +47,24 @@ void AttractionInfo::create_att_groups_for_overfull_regions() { atom_attraction_group.resize(num_atoms); fill(atom_attraction_group.begin(), atom_attraction_group.end(), AttractGroupId::INVALID()); - const auto& overfull_regions = floorplanning_ctx.overfull_regions; - PartitionRegion overfull_regions_pr; - for (const auto& overfull_region : overfull_regions) { - overfull_regions_pr.add_to_part_region(overfull_region); - } - /* - * Create a PartitionRegion that contains all the overfull regions so that you can - * make an attraction group for any partition that intersects with any of these regions - */ + const std::vector& overfull_prs = floorplanning_ctx.overfull_partition_regions; /* - * Create an attraction group for each parition with an overfull region. + * Create an attraction group for each partition that overlaps with at least one overfull partition */ - for (int ipart = 0; ipart < num_parts; ipart++) { PartitionId partid(ipart); const Partition& part = floorplanning_ctx.constraints.get_partition(partid); - const auto& pr_regions = part.get_part_region(); - PartitionRegion intersect_pr; - - intersect_pr = intersection(overfull_regions_pr, pr_regions); - - if (!intersect_pr.empty()) { - AttractionGroup group_info; - group_info.group_atoms = floorplanning_ctx.constraints.get_part_atoms(partid); - - attraction_groups.push_back(group_info); + for (const PartitionRegion& overfull_pr : overfull_prs) { + PartitionRegion intersect_pr = intersection(part.get_part_region(), overfull_pr); + if (!intersect_pr.empty()) { + AttractionGroup group_info; + group_info.group_atoms = floorplanning_ctx.constraints.get_part_atoms(partid); + attraction_groups.push_back(group_info); + break; + } } } diff --git a/vpr/src/pack/constraints_report.cpp b/vpr/src/pack/constraints_report.cpp index 9051c58019c..a6e7711ba69 100644 --- a/vpr/src/pack/constraints_report.cpp +++ b/vpr/src/pack/constraints_report.cpp @@ -8,52 +8,55 @@ bool floorplan_constraints_regions_overfull() { auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning(); auto& device_ctx = g_vpr_ctx.device(); - auto& block_types = device_ctx.logical_block_types; + const std::vector& block_types = device_ctx.logical_block_types; - std::unordered_map> regions_count_info; + // keep record of how many blocks of each type are assigned to each PartitionRegion + std::unordered_map> pr_count_info; - for (auto blk_id : cluster_ctx.clb_nlist.blocks()) { + for (const ClusterBlockId blk_id : cluster_ctx.clb_nlist.blocks()) { if (!is_cluster_constrained(blk_id)) { continue; } t_logical_block_type_ptr bt = cluster_ctx.clb_nlist.block_type(blk_id); const PartitionRegion& pr = floorplanning_ctx.cluster_constraints[blk_id]; - const std::vector& regions = pr.get_regions(); - - for (const auto& current_reg : regions) { - auto got = regions_count_info.find(current_reg); - - if (got == regions_count_info.end()) { - std::vector block_type_counts(block_types.size(), 0); - - block_type_counts[bt->index]++; - - regions_count_info.insert({current_reg, block_type_counts}); + auto got = pr_count_info.find(pr); - } else { - got->second[bt->index]++; - } + if (got == pr_count_info.end()) { + std::vector block_type_counts(block_types.size(), 0); + block_type_counts[bt->index]++; + pr_count_info.insert({pr, block_type_counts}); + } else { + got->second[bt->index]++; } } bool floorplan_regions_overfull = false; - for (const auto& [region, block_type_counts] : regions_count_info) { - const vtr::Rect& rect = region.get_rect(); - const auto [layer_low, layer_high] = region.get_layer_range(); - for (const auto & block_type : block_types) { + for (const auto& [pr, block_type_counts] : pr_count_info) { + const std::vector& regions = pr.get_regions(); + + for (const t_logical_block_type& block_type : block_types) { int num_assigned_blocks = block_type_counts[block_type.index]; - int num_tiles = grid_tiles.region_tile_count(region, &block_type); + int num_tiles = std::accumulate(regions.begin(), regions.end(), 0, [&grid_tiles, &block_type](int acc, const Region& reg) -> int { + return acc + grid_tiles.region_tile_count(reg, &block_type); + }); + if (num_assigned_blocks > num_tiles) { floorplan_regions_overfull = true; - floorplanning_ctx.overfull_regions.push_back(region); - VTR_LOG("\n \nRegion (%d, %d, %d) to (%d, %d, %d) st %d \n", - rect.xmin(), rect.ymin(), layer_low, - rect.xmax(), rect.ymax(), layer_high, - region.get_sub_tile()); - VTR_LOG("Assigned %d blocks of type %s, but only has %d tiles of that type\n", + floorplanning_ctx.overfull_partition_regions.push_back(pr); + VTR_LOG("\n\nA partition including the following regions has been assigned %d blocks of type $s, " + "but only has %d tiles of that type\n", num_assigned_blocks, block_type.name, num_tiles); + for (const Region& reg : regions) { + const vtr::Rect& rect = reg.get_rect(); + const auto [layer_low, layer_high] = reg.get_layer_range(); + VTR_LOG("\tRegion (%d, %d, %d) to (%d, %d, %d) st %d \n", + rect.xmin(), rect.ymin(), layer_low, + rect.xmax(), rect.ymax(), layer_high, + reg.get_sub_tile()); + } + } } }