Skip to content

Commit 0dba701

Browse files
committed
updated the helper find_subtile_in_location structure and comments.
1 parent d7d6fc9 commit 0dba701

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

vpr/src/place/initial_placement.cpp

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,23 @@ static bool is_loc_legal(const t_pl_loc& loc,
147147
const PartitionRegion& pr,
148148
t_logical_block_type_ptr block_type);
149149

150+
/**
151+
* @brief Helper function to choose a subtile in specified location if compatible and available one exits.
152+
*
153+
* @param centroid The centroid location at which the subtile will be selected using its x,y, and layer.
154+
* @param block_type Logical block type of the macro head member.
155+
* @param block_loc_registry Placement block location information. To be filled with the location
156+
* where pl_macro is placed.
157+
* @param pr The PartitionRegion of the macro head member - represents its floorplanning constraints, is the size of
158+
* the whole chip if the macro is not constrained.
159+
* @param rng A random number generator to select subtile from available and compatible ones.
160+
*/
161+
static void find_subtile_in_location(t_pl_loc& centroid,
162+
t_logical_block_type_ptr block_type,
163+
const BlkLocRegistry& blk_loc_registry,
164+
const PartitionRegion& pr,
165+
vtr::RngContainer& rng);
166+
150167
/**
151168
* @brief Calculates a centroid location for a block based on its placed connections.
152169
*
@@ -342,6 +359,37 @@ static bool is_loc_legal(const t_pl_loc& loc,
342359
return legal;
343360
}
344361

362+
void find_subtile_in_location(t_pl_loc& centroid,
363+
t_logical_block_type_ptr block_type,
364+
const BlkLocRegistry& blk_loc_registry,
365+
const PartitionRegion& pr,
366+
vtr::RngContainer& rng) {
367+
//check if the location is on chip and legal, if yes try to update subtile
368+
if (is_loc_on_chip({centroid.x, centroid.y, centroid.layer}) && is_loc_legal(centroid, pr, block_type)) {
369+
//finding the subtile location
370+
auto& device_ctx = g_vpr_ctx.device();
371+
const auto& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
372+
const auto& type = device_ctx.grid.get_physical_type({centroid.x, centroid.y, centroid.layer});
373+
const auto& compatible_sub_tiles = compressed_block_grid.compatible_sub_tile_num(type->index);
374+
375+
//filter out occupied subtiles
376+
const GridBlock& grid_blocks = blk_loc_registry.grid_blocks();
377+
std::vector<int> available_sub_tiles;
378+
for (int sub_tile : compatible_sub_tiles) {
379+
t_pl_loc pos = {centroid.x, centroid.y, sub_tile, centroid.layer};
380+
if (!grid_blocks.block_at_location(pos)) {
381+
available_sub_tiles.push_back(sub_tile);
382+
}
383+
}
384+
385+
//if there is at least one available subtile, update the centroid and do not change otherwise
386+
if (!available_sub_tiles.empty()) {
387+
centroid.sub_tile = available_sub_tiles[rng.irand((int)available_sub_tiles.size() - 1)];
388+
}
389+
}
390+
}
391+
392+
345393
static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
346394
t_logical_block_type_ptr block_type,
347395
bool search_for_empty,
@@ -491,30 +539,8 @@ static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
491539
} else {
492540
centroid.layer = head_layer_num;
493541
}
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-
//filter out occupied subtiles to prevent falling to try_place_macro_randomly while we have available subtiles already.
502-
const GridBlock& grid_blocks = blk_loc_registry.grid_blocks();
503-
std::vector<int> available_sub_tiles;
504-
for (int sub_tile : compatible_sub_tiles) {
505-
t_pl_loc pos = {centroid.x, centroid.y, sub_tile, centroid.layer};
506-
if (!grid_blocks.block_at_location(pos)) {
507-
available_sub_tiles.push_back(sub_tile);
508-
}
509-
}
510-
511-
//if no available subtile is found, we don't need to try_place_macro.
512-
if (available_sub_tiles.empty()) {
513-
centroid.sub_tile = -1; //set to default
514-
} else {
515-
centroid.sub_tile = available_sub_tiles[rng.irand((int)available_sub_tiles.size() - 1)];
516-
}
517-
}
542+
//try to find an available and compatible subtile in that location
543+
find_subtile_in_location(centroid, block_type, blk_loc_registry, pr, rng);
518544
}
519545

520546
return connected_blocks_to_update;
@@ -620,32 +646,6 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
620646
}
621647

622648
auto& device_ctx = g_vpr_ctx.device();
623-
//choose the location's subtile if the centroid location is legal.
624-
//if the location is found within the "find_centroid_neighbor", it already has a subtile
625-
//we don't need to find one again
626-
// if (!neighbor_legal_loc) {
627-
// const auto& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
628-
// const auto& type = device_ctx.grid.get_physical_type({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
629-
// const auto& compatible_sub_tiles = compressed_block_grid.compatible_sub_tile_num(type->index);
630-
631-
// // //filter out occupied subtiles to prevent falling to try_place_macro_randomly while we have available subtiles already.
632-
// // const GridBlock& grid_blocks = blk_loc_registry.grid_blocks();
633-
// // std::vector<int> available_sub_tiles;
634-
// // for (int sub_tile : compatible_sub_tiles) {
635-
// // t_pl_loc pos = {centroid_loc.x, centroid_loc.y, sub_tile, centroid_loc.layer};
636-
// // if (!grid_blocks.block_at_location(pos)) {
637-
// // available_sub_tiles.push_back(sub_tile);
638-
// // }
639-
// // }
640-
641-
// // //if no available subtile is found, we don't need to try_place_macro.
642-
// // if (available_sub_tiles.empty()) {
643-
// // return false;
644-
// // }
645-
646-
// // centroid_loc.sub_tile = available_sub_tiles[rng.irand((int)available_sub_tiles.size() - 1)];
647-
// centroid_loc.sub_tile = compatible_sub_tiles[rng.irand((int)compatible_sub_tiles.size() - 1)]; // for testing previous functionality.
648-
// }
649649
int width_offset = device_ctx.grid.get_width_offset({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
650650
int height_offset = device_ctx.grid.get_height_offset({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
651651
VTR_ASSERT(width_offset == 0);

0 commit comments

Comments
 (0)