From 864bd282676157a692bbdc1cd86c6629d04264f8 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Thu, 5 Dec 2024 16:58:20 -0500 Subject: [PATCH] remove one of the signatures of pick_from_block and pick_from_highly_critical_block --- libs/libarchfpga/src/physical_types_util.h | 2 +- vpr/src/place/move_utils.cpp | 93 ++++------------------ vpr/src/place/move_utils.h | 17 ---- 3 files changed, 18 insertions(+), 94 deletions(-) diff --git a/libs/libarchfpga/src/physical_types_util.h b/libs/libarchfpga/src/physical_types_util.h index d4d5dc5592..a081683fae 100644 --- a/libs/libarchfpga/src/physical_types_util.h +++ b/libs/libarchfpga/src/physical_types_util.h @@ -212,7 +212,7 @@ int get_logical_block_physical_sub_tile_index(t_physical_tile_type_ptr physical_ t_logical_block_type_ptr logical_block); /** * @brief Returns the physical pin index (within 'physical_tile') corresponding to the - * logical index ('pin' of the first instance of 'logical_block' within the physcial tile. + * logical index ('pin' of the first instance of 'logical_block' within the physical tile. * * This function is called before/during placement, when a sub tile index was not yet assigned. * diff --git a/vpr/src/place/move_utils.cpp b/vpr/src/place/move_utils.cpp index bab61cd0f6..601d2dea85 100644 --- a/vpr/src/place/move_utils.cpp +++ b/vpr/src/place/move_utils.cpp @@ -552,26 +552,19 @@ ClusterBlockId propose_block_to_move(const t_placer_opts& placer_opts, int* pin_from, const PlacerState& placer_state, vtr::RngContainer& rng) { - ClusterBlockId b_from = ClusterBlockId::INVALID(); const auto& cluster_ctx = g_vpr_ctx.clustering(); - if (logical_blk_type_index == -1) { //If the block type is unspecified, choose any random block to be swapped with another random block - if (highly_crit_block) { - b_from = pick_from_highly_critical_block(*net_from, *pin_from, placer_state, *placer_criticalities, rng); - } else { - b_from = pick_from_block(rng); - } + ClusterBlockId b_from = ClusterBlockId::INVALID(); - //if a movable block found, set the block type - if (b_from) { - logical_blk_type_index = cluster_ctx.clb_nlist.block_type(b_from)->index; - } - } else { //If the block type is specified, choose a random block with blk_type to be swapped with another random block - if (highly_crit_block) { - b_from = pick_from_highly_critical_block(*net_from, *pin_from, logical_blk_type_index, placer_state, *placer_criticalities, rng); - } else { - b_from = pick_from_block(logical_blk_type_index, rng); - } + if (highly_crit_block) { + b_from = pick_from_highly_critical_block(*net_from, *pin_from, logical_blk_type_index, placer_state, *placer_criticalities, rng); + } else { + b_from = pick_from_block(logical_blk_type_index, rng); + } + + //if a movable block found, set the block type + if (b_from) { + logical_blk_type_index = cluster_ctx.clb_nlist.block_type(b_from)->index; } if constexpr (VTR_ENABLE_DEBUG_LOGGING_CONST_EXPR) { @@ -590,71 +583,20 @@ const std::vector& movable_blocks_per_type(const t_logical_block return place_ctx.movable_blocks_per_type[blk_type.index]; } -ClusterBlockId pick_from_block(vtr::RngContainer& rng) { - auto& place_ctx = g_vpr_ctx.placement(); - - // get the number of movable clustered blocks - const size_t n_movable_blocks = place_ctx.movable_blocks.size(); - - if (n_movable_blocks > 0) { - //Pick a movable block at random and return it - auto b_from = ClusterBlockId(rng.irand((int)n_movable_blocks - 1)); - return b_from; - } else { - //No movable blocks found - return ClusterBlockId::INVALID(); - } -} - ClusterBlockId pick_from_block(const int logical_blk_type_index, vtr::RngContainer& rng) { - auto& place_ctx = g_vpr_ctx.placement(); - - const auto& movable_blocks_of_type = place_ctx.movable_blocks_per_type[logical_blk_type_index]; - - if (movable_blocks_of_type.empty()) { - return ClusterBlockId::INVALID(); - } - - auto b_from = ClusterBlockId(movable_blocks_of_type[rng.irand((int)movable_blocks_of_type.size() - 1)]); - - return b_from; -} - -//Pick a random highly critical block to be swapped with another random block. -//If none is found return ClusterBlockId::INVALID() -ClusterBlockId pick_from_highly_critical_block(ClusterNetId& net_from, - int& pin_from, - const PlacerState& placer_state, - const PlacerCriticalities& placer_criticalities, - vtr::RngContainer& rng) { - const auto& cluster_ctx = g_vpr_ctx.clustering(); - const auto& block_locs = placer_state.block_locs(); - - //Initialize critical net and pin to be invalid - net_from = ClusterNetId::INVALID(); - pin_from = -1; + const auto& place_ctx = g_vpr_ctx.placement(); - const auto& highly_crit_pins = placer_criticalities.get_highly_critical_pins(); + // if logical block type is specified, pick the 'from' block from block of that type; otherwise, + // pick it from all blocks + const auto& movable_blocks = (logical_blk_type_index < 0 )? place_ctx.movable_blocks : place_ctx.movable_blocks_per_type[logical_blk_type_index]; - //check if any critical block is available - if (highly_crit_pins.empty()) { + if (movable_blocks.empty()) { return ClusterBlockId::INVALID(); } - //pick a random highly critical pin and find the nets driver block - std::pair crit_pin = highly_crit_pins[rng.irand(highly_crit_pins.size() - 1)]; - ClusterBlockId b_from = cluster_ctx.clb_nlist.net_driver_block(crit_pin.first); - - if (block_locs[b_from].is_fixed) { - return ClusterBlockId::INVALID(); //Block is fixed, cannot move - } + ClusterBlockId b_from = movable_blocks[rng.irand((int)movable_blocks.size() - 1)]; - net_from = crit_pin.first; - pin_from = crit_pin.second; return b_from; - - //Unreachable statement - return ClusterBlockId::INVALID(); } //Pick a random highly critical block with a specified block type to be swapped with another random block. @@ -686,7 +628,7 @@ ClusterBlockId pick_from_highly_critical_block(ClusterNetId& net_from, //Check if picked block type matches with the blk_type specified, and it is not fixed //blk_type from propose move doesn't account for the EMPTY type auto b_from_type = cluster_ctx.clb_nlist.block_type(b_from); - if (b_from_type->index == logical_blk_type_index) { + if (b_from_type->index == logical_blk_type_index || logical_blk_type_index < 0) { if (block_locs[b_from].is_fixed) { return ClusterBlockId::INVALID(); //Block is fixed, cannot move } @@ -697,7 +639,6 @@ ClusterBlockId pick_from_highly_critical_block(ClusterNetId& net_from, } //No critical block with 'blk_type' found - //Unreachable statement return ClusterBlockId::INVALID(); } diff --git a/vpr/src/place/move_utils.h b/vpr/src/place/move_utils.h index 1aa5591f5c..2b3f8de0ce 100644 --- a/vpr/src/place/move_utils.h +++ b/vpr/src/place/move_utils.h @@ -185,12 +185,6 @@ ClusterBlockId propose_block_to_move(const t_placer_opts& placer_opts, */ const std::vector& movable_blocks_per_type(const t_logical_block_type& blk_type); -/** - * @brief Select a random block to be swapped with another block - * - * @return BlockId of the selected block, ClusterBlockId::INVALID() if no block with specified block type found - */ -ClusterBlockId pick_from_block(vtr::RngContainer& rng); /** * @brief Find a block with a specific block type to be swapped with another block @@ -201,17 +195,6 @@ ClusterBlockId pick_from_block(vtr::RngContainer& rng); */ ClusterBlockId pick_from_block(int logical_blk_type_index, vtr::RngContainer& rng); -/** - * @brief Select a random highly critical block to be swapped with another block - * - * @return BlockId of the selected block, ClusterBlockId::INVALID() if no block with specified block type found - */ -ClusterBlockId pick_from_highly_critical_block(ClusterNetId& net_from, - int& pin_from, - const PlacerState& placer_state, - const PlacerCriticalities& placer_criticalities, - vtr::RngContainer& rng); - /** * @brief Find a block with a specific block type to be swapped with another block *