-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2669 from verilog-to-routing/temp_place_ref
Remove accesses to global placement state during placement stage
- Loading branch information
Showing
111 changed files
with
3,100 additions
and
2,344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
|
||
#include "blk_loc_registry.h" | ||
#include "globals.h" | ||
|
||
const vtr::vector_map<ClusterBlockId, t_block_loc>& BlkLocRegistry::block_locs() const { | ||
return block_locs_; | ||
} | ||
|
||
vtr::vector_map<ClusterBlockId, t_block_loc>& BlkLocRegistry::mutable_block_locs() { | ||
return block_locs_; | ||
} | ||
|
||
const GridBlock& BlkLocRegistry::grid_blocks() const { | ||
return grid_blocks_; | ||
} | ||
|
||
GridBlock& BlkLocRegistry::mutable_grid_blocks() { | ||
return grid_blocks_; | ||
} | ||
|
||
const vtr::vector_map<ClusterPinId, int>& BlkLocRegistry::physical_pins() const { | ||
return physical_pins_; | ||
} | ||
|
||
vtr::vector_map<ClusterPinId, int>& BlkLocRegistry::mutable_physical_pins() { | ||
return physical_pins_; | ||
} | ||
|
||
int BlkLocRegistry::tile_pin_index(const ClusterPinId pin) const { | ||
return physical_pins_[pin]; | ||
} | ||
|
||
int BlkLocRegistry::net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const { | ||
auto& cluster_ctx = g_vpr_ctx.clustering(); | ||
|
||
// Get the logical pin index of pin within its logical block type | ||
ClusterPinId pin_id = cluster_ctx.clb_nlist.net_pin(net_id, net_pin_index); | ||
|
||
return this->tile_pin_index(pin_id); | ||
} | ||
|
||
void BlkLocRegistry::set_block_location(ClusterBlockId blk_id, const t_pl_loc& location) { | ||
auto& device_ctx = g_vpr_ctx.device(); | ||
auto& cluster_ctx = g_vpr_ctx.clustering(); | ||
|
||
const std::string& block_name = cluster_ctx.clb_nlist.block_name(blk_id); | ||
|
||
//Check if block location is out of range of grid dimensions | ||
if (location.x < 0 || location.x > int(device_ctx.grid.width() - 1) | ||
|| location.y < 0 || location.y > int(device_ctx.grid.height() - 1)) { | ||
VPR_THROW(VPR_ERROR_PLACE, "Block %s with ID %d is out of range at location (%d, %d). \n", | ||
block_name.c_str(), blk_id, location.x, location.y); | ||
} | ||
|
||
//Set the location of the block | ||
block_locs_[blk_id].loc = location; | ||
|
||
//Check if block is at an illegal location | ||
auto physical_tile = device_ctx.grid.get_physical_type({location.x, location.y, location.layer}); | ||
auto logical_block = cluster_ctx.clb_nlist.block_type(blk_id); | ||
|
||
if (location.sub_tile >= physical_tile->capacity || location.sub_tile < 0) { | ||
VPR_THROW(VPR_ERROR_PLACE, "Block %s subtile number (%d) is out of range. \n", block_name.c_str(), location.sub_tile); | ||
} | ||
|
||
if (!is_sub_tile_compatible(physical_tile, logical_block, block_locs_[blk_id].loc.sub_tile)) { | ||
VPR_THROW(VPR_ERROR_PLACE, "Attempt to place block %s with ID %d at illegal location (%d,%d,%d). \n", | ||
block_name.c_str(), | ||
blk_id, | ||
location.x, | ||
location.y, | ||
location.layer); | ||
} | ||
|
||
//Mark the grid location and usage of the block | ||
grid_blocks_.set_block_at_location(location, blk_id); | ||
grid_blocks_.increment_usage({location.x, location.y, location.layer}); | ||
|
||
place_sync_external_block_connections(blk_id); | ||
} | ||
|
||
void BlkLocRegistry::place_sync_external_block_connections(ClusterBlockId iblk) { | ||
const auto& cluster_ctx = g_vpr_ctx.clustering(); | ||
const auto& clb_nlist = cluster_ctx.clb_nlist; | ||
|
||
t_pl_loc block_loc = block_locs_[iblk].loc; | ||
|
||
auto physical_tile = physical_tile_type(block_loc); | ||
auto logical_block = clb_nlist.block_type(iblk); | ||
|
||
int sub_tile_index = get_sub_tile_index(iblk, block_locs_); | ||
auto sub_tile = physical_tile->sub_tiles[sub_tile_index]; | ||
|
||
VTR_ASSERT(sub_tile.num_phy_pins % sub_tile.capacity.total() == 0); | ||
|
||
int max_num_block_pins = sub_tile.num_phy_pins / sub_tile.capacity.total(); | ||
/* Logical location and physical location is offset by z * max_num_block_pins */ | ||
|
||
int rel_capacity = block_loc.sub_tile - sub_tile.capacity.low; | ||
|
||
for (ClusterPinId pin : clb_nlist.block_pins(iblk)) { | ||
int logical_pin_index = clb_nlist.pin_logical_index(pin); | ||
int sub_tile_pin_index = get_sub_tile_physical_pin(sub_tile_index, physical_tile, logical_block, logical_pin_index); | ||
|
||
int new_physical_pin_index = sub_tile.sub_tile_to_tile_pin_indices[sub_tile_pin_index + rel_capacity * max_num_block_pins]; | ||
|
||
auto result = physical_pins_.find(pin); | ||
if (result != physical_pins_.end()) { | ||
physical_pins_[pin] = new_physical_pin_index; | ||
} else { | ||
physical_pins_.insert(pin, new_physical_pin_index); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#ifndef VTR_BLK_LOC_REGISTRY_H | ||
#define VTR_BLK_LOC_REGISTRY_H | ||
|
||
#include "clustered_netlist_fwd.h" | ||
#include "vtr_vector_map.h" | ||
#include "vpr_types.h" | ||
#include "grid_block.h" | ||
|
||
struct t_block_loc; | ||
|
||
/** | ||
* @class BlkLocRegistry contains information about the placement of clustered blocks. | ||
* More specifically: | ||
* 1) block_locs stores the location where each clustered blocks is placed at. | ||
* 2) grid_blocks stores which blocks (if any) are placed at a given location. | ||
* 3) physical_pins stores the mapping between the pins of a clustered block and | ||
* the pins of the physical tile where the clustered blocks is placed. | ||
* | ||
*/ | ||
class BlkLocRegistry { | ||
public: | ||
BlkLocRegistry() = default; | ||
~BlkLocRegistry() = default; | ||
BlkLocRegistry(const BlkLocRegistry&) = delete; | ||
BlkLocRegistry& operator=(const BlkLocRegistry&) = default; | ||
BlkLocRegistry(BlkLocRegistry&&) = delete; | ||
BlkLocRegistry& operator=(BlkLocRegistry&&) = delete; | ||
|
||
private: | ||
///@brief Clustered block placement locations | ||
vtr::vector_map<ClusterBlockId, t_block_loc> block_locs_; | ||
|
||
///@brief Clustered block associated with each grid location (i.e. inverse of block_locs) | ||
GridBlock grid_blocks_; | ||
|
||
///@brief Clustered pin placement mapping with physical pin | ||
vtr::vector_map<ClusterPinId, int> physical_pins_; | ||
|
||
public: | ||
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs() const; | ||
vtr::vector_map<ClusterBlockId, t_block_loc>& mutable_block_locs(); | ||
|
||
const GridBlock& grid_blocks() const; | ||
GridBlock& mutable_grid_blocks(); | ||
|
||
const vtr::vector_map<ClusterPinId, int>& physical_pins() const; | ||
vtr::vector_map<ClusterPinId, int>& mutable_physical_pins(); | ||
|
||
///@brief Returns the physical pin of the tile, related to the given ClusterPinId | ||
int tile_pin_index(const ClusterPinId pin) const; | ||
|
||
///@brief Returns the physical pin of the tile, related to the given ClusterNedId, and the net pin index. | ||
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const; | ||
|
||
/** | ||
* @brief Performs error checking to see if location is legal for block type, | ||
* and sets the location and grid usage of the block if it is legal. | ||
* @param blk_id The unique ID of the clustered block whose location is to set. | ||
* @param location The location where the clustered block should placed at. | ||
*/ | ||
void set_block_location(ClusterBlockId blk_id, const t_pl_loc& location); | ||
|
||
/** | ||
* @brief Syncs the logical block pins corresponding to the input iblk with the corresponding chosen physical tile | ||
* @param iblk cluster block ID to sync within the assigned physical tile | ||
* | ||
* This routine updates the physical pins vector of the place context after the placement step | ||
* to synchronize the pins related to the logical block with the actual connection interface of | ||
* the belonging physical tile with the RR graph. | ||
* | ||
* This step is required as the logical block can be placed at any compatible sub tile locations | ||
* within a physical tile. | ||
* Given that it is possible to have equivalent logical blocks within a specific sub tile, with | ||
* a different subset of IO pins, the various pins offsets must be correctly computed and assigned | ||
* to the physical pins vector, so that, when the net RR terminals are computed, the correct physical | ||
* tile IO pins are selected. | ||
* | ||
* This routine uses the x,y and sub_tile coordinates of the clb netlist, and expects those to place each netlist block | ||
* at a legal location that can accommodate it. | ||
* It does not check for overuse of locations, therefore it can be used with placements that have resource overuse. | ||
*/ | ||
void place_sync_external_block_connections(ClusterBlockId iblk); | ||
}; | ||
|
||
#endif //VTR_BLK_LOC_REGISTRY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
#include "grid_block.h" | ||
|
||
#include "globals.h" | ||
|
||
void GridBlock::zero_initialize() { | ||
auto& device_ctx = g_vpr_ctx.device(); | ||
|
||
/* Initialize all occupancy to zero. */ | ||
for (int layer_num = 0; layer_num < (int)device_ctx.grid.get_num_layers(); layer_num++) { | ||
for (int i = 0; i < (int)device_ctx.grid.width(); i++) { | ||
for (int j = 0; j < (int)device_ctx.grid.height(); j++) { | ||
set_usage({i, j, layer_num}, 0); | ||
auto tile = device_ctx.grid.get_physical_type({i, j, layer_num}); | ||
|
||
for (const auto& sub_tile : tile->sub_tiles) { | ||
auto capacity = sub_tile.capacity; | ||
|
||
for (int k = 0; k < capacity.total(); k++) { | ||
set_block_at_location({i, j, k + capacity.low, layer_num}, ClusterBlockId::INVALID()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
void GridBlock::load_from_block_locs(const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs) { | ||
auto& cluster_ctx = g_vpr_ctx.clustering(); | ||
auto& device_ctx = g_vpr_ctx.device(); | ||
|
||
zero_initialize(); | ||
|
||
for (ClusterBlockId blk_id : cluster_ctx.clb_nlist.blocks()) { | ||
t_pl_loc location = block_locs[blk_id].loc; | ||
|
||
VTR_ASSERT(location.x < (int)device_ctx.grid.width()); | ||
VTR_ASSERT(location.y < (int)device_ctx.grid.height()); | ||
|
||
set_block_at_location(location, blk_id); | ||
increment_usage({location.x, location.y, location.layer}); | ||
} | ||
} | ||
|
||
int GridBlock::increment_usage(const t_physical_tile_loc& loc) { | ||
int curr_usage = get_usage(loc); | ||
int updated_usage = set_usage(loc, curr_usage + 1); | ||
|
||
return updated_usage; | ||
} | ||
|
||
int GridBlock::decrement_usage(const t_physical_tile_loc& loc) { | ||
int curr_usage = get_usage(loc); | ||
int updated_usage = set_usage(loc, curr_usage - 1); | ||
|
||
return updated_usage; | ||
} | ||
|
||
|
Oops, something went wrong.