-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove accesses to global placement state during placement stage #2669
Merged
Merged
Changes from all commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
ccad435
moved ERROR_TOL to net_cost_handler.h
soheilshahrouz fb01f19
Merge remote-tracking branch 'origin/master' into temp_place_ref
soheilshahrouz 476d5b6
add t_swap_stats
soheilshahrouz 4862a91
changed the signitaure of create_move_generators()
soheilshahrouz 6d54b14
don't access global place context in get_coordinate_of_pin()
soheilshahrouz 05f4eb9
remove place_ctx.block_locs from noc_place_utils
soheilshahrouz 8cf3b06
remove place_ctx.block_locs from initial placement
soheilshahrouz 8b1b568
remove place_ctx.block_locs from move generators
soheilshahrouz db52147
remove place_ctx.block_locs from directed_moves_utils
soheilshahrouz dd99e60
remove a few more place_ctx.block_locs
soheilshahrouz e4e7b8b
remove place_ctx.block_locs from move_transactions.cpp
soheilshahrouz 3febe66
remove place_ctx.block_locs from noc_routing_has_cycle()
soheilshahrouz e68dd7a
remove place_ctx.block_locs from placement_checkpoint
soheilshahrouz 0b9851c
remove place_ctx.block_locs from read_place.cpp
soheilshahrouz a839891
replace some accesses outside the placement stage to place_ctx.block_…
soheilshahrouz 5151eb4
remove some accesses to place_ctx.block_locs
soheilshahrouz bc22a20
remove place_ctx.block_locs from timing graph resolver
soheilshahrouz f73092f
remove more accesses to place_ctx.block_locs
soheilshahrouz d15526d
an attempt to remove calls to physical_tile_type(ClusterBlockId blk)
soheilshahrouz 9192990
remove remaining place_ctx.block_locs from vpr_utils.cpp
soheilshahrouz cfb147e
remove g_placer_ctx
soheilshahrouz ea8c972
remove placer_globals files
soheilshahrouz d3f4ca7
trying to remove remaining place_ctx.block_locs
soheilshahrouz 1a4f52a
add PlaceLocVars
soheilshahrouz 816d44e
remove all remaining place_ctx.block_locs accesses
soheilshahrouz 519546b
rename block_locs() getters in the placement context
soheilshahrouz a208dc7
remove place_ctx.grid_blocks access in initial_noc_placement
soheilshahrouz 017b08d
remove place_ctx.grid_blocks accesses from move_utils and move_transa…
soheilshahrouz 1f84809
remove place_ctx.grid_block from find_empty_compatible_subtile
soheilshahrouz ca5f796
remove place_ctx.grid_block from find_free_layer
soheilshahrouz 613b7b6
remove place_ctx.grid_blocks from place_util and a few other files
soheilshahrouz 68f6547
remove place_ctx.grid_blocks
soheilshahrouz b94e00c
remove place_ctx.physical_pins
soheilshahrouz 869db57
initialize block_locs and grid_blocks in placer_ctx
soheilshahrouz 578b335
copy local placement loc vars to global state at the end of placement…
soheilshahrouz 7018bc3
add place_loc_vars_ref to graphics
soheilshahrouz 72f830a
replace accesses to placement context in graphics with accesses to it…
soheilshahrouz 67fe9c3
update the graphic place loc vars reference after the placement stage
soheilshahrouz b39cfe8
unlock place_loc_vars before accessing it
soheilshahrouz 0fa2cfd
enum class e_reward_function
soheilshahrouz 34a680a
replace accesses to global block_locs and grid_blocks with a referenc…
soheilshahrouz 15fab24
rename getter methods of PlacerContext
soheilshahrouz abbd495
add comments and code cleaning
soheilshahrouz 43c3fd8
fix the compilation error when VTR_ASSERT_SAFE_ENABLED is defined
soheilshahrouz da61fdb
fix unused arg warning
soheilshahrouz 25e803c
add comments
soheilshahrouz a85ecc4
enum class e_pad_loc_type and more comments
soheilshahrouz f574059
fix compilation error in place_loc_vars()
soheilshahrouz 6b80de0
add forward decls and include needed header files in read_place.h
soheilshahrouz 9bfb2a0
Merge branch 'master' into temp_place_ref
soheilshahrouz 56f6d8b
enum class e_cost_methods
soheilshahrouz 946a235
fix compilation errors
soheilshahrouz 7bb781b
use VTR_ASSERT_SAFE instead of VTR_ASSERT in placement context getters
soheilshahrouz a7c203c
rename PlaceLocVars to BlkLocRegistry
soheilshahrouz ae9dc10
rename getter methods for BlkLocRegistry objects
soheilshahrouz dc9c2e2
Merge branch 'master' into temp_place_ref
soheilshahrouz ee1448e
pass grid_blocks to alloc_and_load_legal_placement_locations()
soheilshahrouz 1ed4704
rename place_loc_vars args to blk_loc_registry
soheilshahrouz 6db42e9
added const BlkLocRegistry& member variable to VprTimingGraphResolver
soheilshahrouz 0c576c5
rename remaining place_loc_vars to blk_loc_registry
soheilshahrouz ec507de
fix test_fasm failure
soheilshahrouz d2a1632
no need to manually destruct PlacerContext as it is a local object
soheilshahrouz 75d1ef9
applied Alex's comments
soheilshahrouz 0902eaf
move place_sync_external_block_connections() from vpr_utils to place_…
soheilshahrouz f19f451
added some doxygen comments
soheilshahrouz 0a8474c
rename placer_context.h to placer_state.h
soheilshahrouz 1b40e0c
fix missing header inclusion
soheilshahrouz df53193
rename PlacerContext to PlacerState
soheilshahrouz a6ffb7b
rename a few remaining placer_loc_vars to blk_loc_registry
soheilshahrouz 1ecf07c
add blk_loc_registry.cpp/.h
soheilshahrouz 3b67601
add grid_block.h
soheilshahrouz 8084079
remove INVALID_BLOCK_ID
soheilshahrouz f7b183a
remove EMPTY_BLOCK_ID
soheilshahrouz ac30b4b
added some comments
soheilshahrouz fbd992d
make place_sync_external_block_connections() and set_block_location()…
soheilshahrouz 155efc6
add GridBlock::zero_initialize() method
soheilshahrouz 46434be
add increment_usage() and decrement_usage() to GridBlock
soheilshahrouz fe1ee45
add load_from_block_locs() to GridBlock
soheilshahrouz ad7d6cb
add a few more doxygen comments. PR comments are all addressed
soheilshahrouz 2e64e8a
fix compilation warning with no graphics
soheilshahrouz 609bb78
Merge branch 'master' into temp_place_ref
vaughnbetz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files located in
libs/EXTERNAL
are subtrees and modifying them should be avoided unless needed. If modifying them is needed you need to remember to push your changes back to the libtatum repository. See my instructions here: https://docs.verilogtorouting.org/en/latest/README.developers/#pushing-vtr-changes-back-to-upstream-subtreeThis prevents our version of libtatum from diverging from the libtatum repo. This is a consequence of using subtrees.
In my opinion, these changes may not be worth the effort. Especially because I do not think making this a const reference actually improves performance (since its iterating over a statically initialized list).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushing back to tatum is OK; it's leading user is VTR. But I agree this should be pushed back if you change it.