@@ -221,7 +221,7 @@ e_block_move_result record_macro_swaps(t_pl_blocks_to_be_moved& blocks_affected,
221
221
// to a new position offset from its current position by swap_offset. The new location must be where
222
222
// blk_to is located and blk_to must be part of imacro_to.
223
223
e_block_move_result record_macro_macro_swaps (t_pl_blocks_to_be_moved& blocks_affected, const int imacro_from, int & imember_from, const int imacro_to, ClusterBlockId blk_to, t_pl_offset swap_offset) {
224
- // Adds the macro imacro_to to the set of affected block caused by swapping 'blk_to' to it's
224
+ // Adds the macro imacro_to to the set of affected block caused by swapping 'blk_to' to its
225
225
// new position.
226
226
//
227
227
// This function is only called when both the main swap's from/to blocks are placement macros.
@@ -484,7 +484,7 @@ std::set<t_pl_loc> determine_locations_emptied_by_move(t_pl_blocks_to_be_moved&
484
484
std::set<t_pl_loc> moved_to;
485
485
486
486
for (int iblk = 0 ; iblk < blocks_affected.num_moved_blocks ; ++iblk) {
487
- // When a block is moved it's old location becomes free
487
+ // When a block is moved its old location becomes free
488
488
moved_from.emplace (blocks_affected.moved_blocks [iblk].old_loc );
489
489
490
490
// But any block later moved to a position fills it
@@ -591,19 +591,12 @@ ClusterBlockId propose_block_to_move(const t_placer_opts& /* placer_opts */,
591
591
}
592
592
593
593
const std::vector<ClusterBlockId>& movable_blocks_per_type (const t_logical_block_type& blk_type) {
594
- // empty vector is declared static to avoid re-allocation every time the function is called
595
- static std::vector<ClusterBlockId> empty_vector;
596
-
597
594
const auto & place_ctx = g_vpr_ctx.placement ();
598
595
599
- if (place_ctx.movable_blocks_per_type .count (blk_type.index ) == 0 ) {
600
- return empty_vector;
601
- }
602
-
603
596
// the vector is returned as const reference to avoid unnecessary copies,
604
597
// especially that returned vectors may be very large as they contain
605
598
// all clustered blocks with a specific block type
606
- return place_ctx.movable_blocks_per_type . at ( blk_type.index ) ;
599
+ return place_ctx.movable_blocks_per_type [ blk_type.index ] ;
607
600
}
608
601
609
602
// Pick a random movable block to be swapped with another random block.
@@ -629,22 +622,15 @@ ClusterBlockId pick_from_block() {
629
622
ClusterBlockId pick_from_block (const int logical_blk_type_index) {
630
623
auto & place_ctx = g_vpr_ctx.mutable_placement ();
631
624
632
- auto found_blocks = place_ctx.movable_blocks_per_type .find (logical_blk_type_index);
633
- if (found_blocks != place_ctx.movable_blocks_per_type .end ()) {
634
- const auto & blocks_per_type = found_blocks->second ;
635
- // no blocks with this type is movable
636
- if (blocks_per_type.empty ()) {
637
- return ClusterBlockId::INVALID ();
638
- }
639
-
640
- // Pick a block at random
641
- auto b_from = ClusterBlockId (blocks_per_type[vtr::irand ((int )blocks_per_type.size () - 1 )]);
625
+ const auto & movable_blocks_of_type = place_ctx.movable_blocks_per_type [logical_blk_type_index];
642
626
643
- // return the movable block of the given type
644
- return b_from ;
627
+ if (movable_blocks_of_type. empty ()) {
628
+ return ClusterBlockId::INVALID () ;
645
629
}
646
630
647
- return ClusterBlockId::INVALID ();
631
+ auto b_from = ClusterBlockId (movable_blocks_of_type[vtr::irand ((int )movable_blocks_of_type.size () - 1 )]);
632
+
633
+ return b_from;
648
634
}
649
635
650
636
// Pick a random highly critical block to be swapped with another random block.
0 commit comments