Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 182b693

Browse files
authoredFeb 23, 2025··
Merge branch 'master' into exa_tile
2 parents bb754dc + 3ef570f commit 182b693

File tree

186 files changed

+562
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+562
-516
lines changed
 

‎doc/src/vpr/command_line_usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ For people not working on CAD, you can probably leave all the options to their d
657657

658658
.. note::
659659

660-
If a pin utilization target is unspecified it defaults to 1.0 (i.e. 100% utilization).
660+
If some pin utilizations are specified, ``auto`` mode is turned off and the utilization target for any unspecified pin types defaults to 1.0 (i.e. 100% utilization).
661661

662662
For example:
663663

‎vpr/src/place/initial_placement.cpp

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,25 @@ 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 the type is compatible and an available one exists.
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 we would like to place here.
155+
* @param block_loc_registry Information on where other blocks have been placed.
156+
* @param pr The PartitionRegion of the block we are trying to place - represents its floorplanning constraints;
157+
* it is the size of the whole chip if the block is not constrained.
158+
* @param rng A random number generator to select a subtile from the available and compatible ones.
159+
*
160+
* @return True if the location is on the chip, legal, and at least one available subtile is found at that location;
161+
* false otherwise.
162+
*/
163+
static bool find_subtile_in_location(t_pl_loc& centroid,
164+
t_logical_block_type_ptr block_type,
165+
const BlkLocRegistry& blk_loc_registry,
166+
const PartitionRegion& pr,
167+
vtr::RngContainer& rng);
168+
150169
/**
151170
* @brief Calculates a centroid location for a block based on its placed connections.
152171
*
@@ -340,6 +359,39 @@ static bool is_loc_legal(const t_pl_loc& loc,
340359
return legal;
341360
}
342361

362+
bool 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+
//find the compatible subtiles
370+
const 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 the occupied subtiles
376+
const GridBlock& grid_blocks = blk_loc_registry.grid_blocks();
377+
std::vector<int> available_sub_tiles;
378+
available_sub_tiles.reserve(compatible_sub_tiles.size());
379+
for (int sub_tile : compatible_sub_tiles) {
380+
t_pl_loc pos = {centroid.x, centroid.y, sub_tile, centroid.layer};
381+
if (!grid_blocks.block_at_location(pos)) {
382+
available_sub_tiles.push_back(sub_tile);
383+
}
384+
}
385+
386+
if (!available_sub_tiles.empty()) {
387+
centroid.sub_tile = available_sub_tiles[rng.irand((int)available_sub_tiles.size() - 1)];
388+
return true;
389+
}
390+
}
391+
392+
return false;
393+
}
394+
343395
static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
344396
t_logical_block_type_ptr block_type,
345397
bool search_for_empty,
@@ -551,10 +603,13 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
551603
t_pl_loc centroid_loc(OPEN, OPEN, OPEN, OPEN);
552604
std::vector<ClusterBlockId> unplaced_blocks_to_update_their_score;
553605

606+
bool found_legal_subtile = false;
607+
554608
if (!flat_placement_info.valid) {
555609
// If a flat placement is not provided, use the centroid of connected
556610
// blocks which have already been placed.
557611
unplaced_blocks_to_update_their_score = find_centroid_loc(pl_macro, centroid_loc, blk_loc_registry);
612+
found_legal_subtile = find_subtile_in_location(centroid_loc, block_type, blk_loc_registry, pr, rng);
558613
} else {
559614
// If a flat placement is provided, use the flat placement to get the
560615
// centroid.
@@ -567,6 +622,7 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
567622
if (!is_loc_on_chip({centroid_loc.x, centroid_loc.y, centroid_loc.layer}) ||
568623
!is_loc_legal(centroid_loc, pr, block_type)) {
569624
unplaced_blocks_to_update_their_score = find_centroid_loc(pl_macro, centroid_loc, blk_loc_registry);
625+
found_legal_subtile = find_subtile_in_location(centroid_loc, block_type, blk_loc_registry, pr, rng);
570626
}
571627
}
572628

@@ -577,9 +633,8 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
577633

578634
//centroid suggestion was either occupied or does not match block type
579635
//try to find a near location that meet these requirements
580-
bool neighbor_legal_loc = false;
581-
if (!is_loc_legal(centroid_loc, pr, block_type)) {
582-
neighbor_legal_loc = find_centroid_neighbor(centroid_loc, block_type, false, blk_loc_registry, rng);
636+
if (!found_legal_subtile) {
637+
bool neighbor_legal_loc = find_centroid_neighbor(centroid_loc, block_type, false, blk_loc_registry, rng);
583638
if (!neighbor_legal_loc) { //no neighbor candidate found
584639
return false;
585640
}
@@ -591,15 +646,6 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
591646
}
592647

593648
auto& device_ctx = g_vpr_ctx.device();
594-
//choose the location's subtile if the centroid location is legal.
595-
//if the location is found within the "find_centroid_neighbor", it already has a subtile
596-
//we don't need to find one again
597-
if (!neighbor_legal_loc) {
598-
const auto& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
599-
const auto& type = device_ctx.grid.get_physical_type({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
600-
const auto& compatible_sub_tiles = compressed_block_grid.compatible_sub_tile_num(type->index);
601-
centroid_loc.sub_tile = compatible_sub_tiles[rng.irand((int)compatible_sub_tiles.size() - 1)];
602-
}
603649
int width_offset = device_ctx.grid.get_width_offset({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
604650
int height_offset = device_ctx.grid.get_height_offset({centroid_loc.x, centroid_loc.y, centroid_loc.layer});
605651
VTR_ASSERT(width_offset == 0);

0 commit comments

Comments
 (0)
Please sign in to comment.