Skip to content

Commit e0522b0

Browse files
committed
changed the subtile selection in the initial_placement to prevent
falling into random macro placement while we have available subtiles in the selected location.
1 parent 7f0f9fc commit e0522b0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

vpr/src/place/initial_placement.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,23 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
597597
const auto& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
598598
const auto& type = device_ctx.grid.get_physical_type({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
599599
const auto& compatible_sub_tiles = compressed_block_grid.compatible_sub_tile_num(type->index);
600-
centroid_loc.sub_tile = compatible_sub_tiles[rng.irand((int)compatible_sub_tiles.size() - 1)];
600+
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)];
601617
}
602618
int width_offset = device_ctx.grid.get_width_offset({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
603619
int height_offset = device_ctx.grid.get_height_offset({centroid_loc.x, centroid_loc.y, centroid_loc.layer});

0 commit comments

Comments
 (0)