@@ -159,7 +159,10 @@ static bool is_loc_legal(const t_pl_loc& loc,
159
159
*/
160
160
static std::vector<ClusterBlockId> find_centroid_loc (const t_pl_macro& pl_macro,
161
161
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);
163
166
164
167
/* *
165
168
* @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,
392
395
393
396
static std::vector<ClusterBlockId> find_centroid_loc (const t_pl_macro& pl_macro,
394
397
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) {
396
402
const auto & cluster_ctx = g_vpr_ctx.clustering ();
397
403
const auto & block_locs = blk_loc_registry.block_locs ();
398
404
@@ -485,6 +491,14 @@ static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
485
491
} else {
486
492
centroid.layer = head_layer_num;
487
493
}
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
+ }
488
502
}
489
503
490
504
return connected_blocks_to_update;
@@ -553,7 +567,7 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
553
567
if (!flat_placement_info.valid ) {
554
568
// If a flat placement is not provided, use the centroid of connected
555
569
// 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 );
557
571
} else {
558
572
// If a flat placement is provided, use the flat placement to get the
559
573
// centroid.
@@ -565,7 +579,7 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
565
579
// location near the flat placement centroid.
566
580
if (!is_loc_on_chip ({centroid_loc.x , centroid_loc.y , centroid_loc.layer }) ||
567
581
!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 );
569
583
}
570
584
}
571
585
@@ -593,28 +607,29 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
593
607
// choose the location's subtile if the centroid location is legal.
594
608
// if the location is found within the "find_centroid_neighbor", it already has a subtile
595
609
// 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);
600
614
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
+ // }
618
633
int width_offset = device_ctx.grid .get_width_offset ({centroid_loc.x , centroid_loc.y , centroid_loc.layer });
619
634
int height_offset = device_ctx.grid .get_height_offset ({centroid_loc.x , centroid_loc.y , centroid_loc.layer });
620
635
VTR_ASSERT (width_offset == 0 );
0 commit comments