Skip to content

Commit 8cc499e

Browse files
committed
hoisted the subtile selection to find_centroid_loc
1 parent e0522b0 commit 8cc499e

File tree

1 file changed

+40
-25
lines changed

1 file changed

+40
-25
lines changed

vpr/src/place/initial_placement.cpp

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ static bool is_loc_legal(const t_pl_loc& loc,
159159
*/
160160
static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
161161
t_pl_loc& centroid,
162-
const BlkLocRegistry& blk_loc_registry);
162+
const BlkLocRegistry& blk_loc_registry,
163+
t_logical_block_type_ptr block_type,
164+
const PartitionRegion& pr,
165+
vtr::RngContainer& rng);
163166

164167
/**
165168
* @brief Tries to find a nearest location to the centroid location if calculated centroid location is not legal or is occupied.
@@ -392,7 +395,10 @@ static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
392395

393396
static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
394397
t_pl_loc& centroid,
395-
const BlkLocRegistry& blk_loc_registry) {
398+
const BlkLocRegistry& blk_loc_registry,
399+
t_logical_block_type_ptr block_type,
400+
const PartitionRegion& pr,
401+
vtr::RngContainer& rng) {
396402
const auto& cluster_ctx = g_vpr_ctx.clustering();
397403
const auto& block_locs = blk_loc_registry.block_locs();
398404

@@ -485,6 +491,14 @@ static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
485491
} else {
486492
centroid.layer = head_layer_num;
487493
}
494+
if (is_loc_on_chip({centroid.x, centroid.y, centroid.layer}) && is_loc_legal(centroid, pr, block_type)) {
495+
//finding the subtile location
496+
auto& device_ctx = g_vpr_ctx.device();
497+
const auto& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
498+
const auto& type = device_ctx.grid.get_physical_type({centroid.x, centroid.y, centroid.layer});
499+
const auto& compatible_sub_tiles = compressed_block_grid.compatible_sub_tile_num(type->index);
500+
centroid.sub_tile = compatible_sub_tiles[rng.irand((int)compatible_sub_tiles.size() - 1)]; // for testing previous functionality.
501+
}
488502
}
489503

490504
return connected_blocks_to_update;
@@ -553,7 +567,7 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
553567
if (!flat_placement_info.valid) {
554568
// If a flat placement is not provided, use the centroid of connected
555569
// blocks which have already been placed.
556-
unplaced_blocks_to_update_their_score = find_centroid_loc(pl_macro, centroid_loc, blk_loc_registry);
570+
unplaced_blocks_to_update_their_score = find_centroid_loc(pl_macro, centroid_loc, blk_loc_registry, block_type, pr, rng);
557571
} else {
558572
// If a flat placement is provided, use the flat placement to get the
559573
// centroid.
@@ -565,7 +579,7 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
565579
// location near the flat placement centroid.
566580
if (!is_loc_on_chip({centroid_loc.x, centroid_loc.y, centroid_loc.layer}) ||
567581
!is_loc_legal(centroid_loc, pr, block_type)) {
568-
unplaced_blocks_to_update_their_score = find_centroid_loc(pl_macro, centroid_loc, blk_loc_registry);
582+
unplaced_blocks_to_update_their_score = find_centroid_loc(pl_macro, centroid_loc, blk_loc_registry, block_type, pr, rng);
569583
}
570584
}
571585

@@ -593,28 +607,29 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
593607
//choose the location's subtile if the centroid location is legal.
594608
//if the location is found within the "find_centroid_neighbor", it already has a subtile
595609
//we don't need to find one again
596-
if (!neighbor_legal_loc) {
597-
const auto& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
598-
const auto& type = device_ctx.grid.get_physical_type({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
599-
const auto& compatible_sub_tiles = compressed_block_grid.compatible_sub_tile_num(type->index);
610+
// if (!neighbor_legal_loc) {
611+
// const auto& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
612+
// const auto& type = device_ctx.grid.get_physical_type({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
613+
// const auto& compatible_sub_tiles = compressed_block_grid.compatible_sub_tile_num(type->index);
600614

601-
//filter out occupied subtiles to prevent falling to try_place_macro_randomly while we have available subtiles already.
602-
const GridBlock& grid_blocks = blk_loc_registry.grid_blocks();
603-
std::vector<int> available_sub_tiles;
604-
for (int sub_tile : compatible_sub_tiles) {
605-
t_pl_loc pos = {centroid_loc.x, centroid_loc.y, sub_tile, centroid_loc.layer};
606-
if (!grid_blocks.block_at_location(pos)) {
607-
available_sub_tiles.push_back(sub_tile);
608-
}
609-
}
610-
611-
//if no available subtile is found, we don't need to try_place_macro.
612-
if (available_sub_tiles.empty()) {
613-
return false;
614-
}
615-
616-
centroid_loc.sub_tile = available_sub_tiles[rng.irand((int)available_sub_tiles.size() - 1)];
617-
}
615+
// // //filter out occupied subtiles to prevent falling to try_place_macro_randomly while we have available subtiles already.
616+
// // const GridBlock& grid_blocks = blk_loc_registry.grid_blocks();
617+
// // std::vector<int> available_sub_tiles;
618+
// // for (int sub_tile : compatible_sub_tiles) {
619+
// // t_pl_loc pos = {centroid_loc.x, centroid_loc.y, sub_tile, centroid_loc.layer};
620+
// // if (!grid_blocks.block_at_location(pos)) {
621+
// // available_sub_tiles.push_back(sub_tile);
622+
// // }
623+
// // }
624+
625+
// // //if no available subtile is found, we don't need to try_place_macro.
626+
// // if (available_sub_tiles.empty()) {
627+
// // return false;
628+
// // }
629+
630+
// // centroid_loc.sub_tile = available_sub_tiles[rng.irand((int)available_sub_tiles.size() - 1)];
631+
// centroid_loc.sub_tile = compatible_sub_tiles[rng.irand((int)compatible_sub_tiles.size() - 1)]; // for testing previous functionality.
632+
// }
618633
int width_offset = device_ctx.grid.get_width_offset({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
619634
int height_offset = device_ctx.grid.get_height_offset({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
620635
VTR_ASSERT(width_offset == 0);

0 commit comments

Comments
 (0)