Skip to content

Commit fbd992d

Browse files
make place_sync_external_block_connections() and set_block_location() methods of BlkLocRegistry
1 parent ac30b4b commit fbd992d

11 files changed

+113
-120
lines changed

vpr/src/base/blk_loc_registry.cpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,78 @@ int BlkLocRegistry::net_pin_to_tile_pin_index(const ClusterNetId net_id, int net
3838

3939
return this->tile_pin_index(pin_id);
4040
}
41+
42+
void BlkLocRegistry::set_block_location(ClusterBlockId blk_id, const t_pl_loc& location) {
43+
auto& device_ctx = g_vpr_ctx.device();
44+
auto& cluster_ctx = g_vpr_ctx.clustering();
45+
46+
const std::string& block_name = cluster_ctx.clb_nlist.block_name(blk_id);
47+
48+
//Check if block location is out of range of grid dimensions
49+
if (location.x < 0 || location.x > int(device_ctx.grid.width() - 1)
50+
|| location.y < 0 || location.y > int(device_ctx.grid.height() - 1)) {
51+
VPR_THROW(VPR_ERROR_PLACE, "Block %s with ID %d is out of range at location (%d, %d). \n",
52+
block_name.c_str(), blk_id, location.x, location.y);
53+
}
54+
55+
//Set the location of the block
56+
block_locs_[blk_id].loc = location;
57+
58+
//Check if block is at an illegal location
59+
auto physical_tile = device_ctx.grid.get_physical_type({location.x, location.y, location.layer});
60+
auto logical_block = cluster_ctx.clb_nlist.block_type(blk_id);
61+
62+
if (location.sub_tile >= physical_tile->capacity || location.sub_tile < 0) {
63+
VPR_THROW(VPR_ERROR_PLACE, "Block %s subtile number (%d) is out of range. \n", block_name.c_str(), location.sub_tile);
64+
}
65+
66+
if (!is_sub_tile_compatible(physical_tile, logical_block, block_locs_[blk_id].loc.sub_tile)) {
67+
VPR_THROW(VPR_ERROR_PLACE, "Attempt to place block %s with ID %d at illegal location (%d,%d,%d). \n",
68+
block_name.c_str(),
69+
blk_id,
70+
location.x,
71+
location.y,
72+
location.layer);
73+
}
74+
75+
//Mark the grid location and usage of the block
76+
grid_blocks_.set_block_at_location(location, blk_id);
77+
grid_blocks_.set_usage({location.x, location.y, location.layer},
78+
grid_blocks_.get_usage({location.x, location.y, location.layer}) + 1);
79+
80+
place_sync_external_block_connections(blk_id);
81+
}
82+
83+
void BlkLocRegistry::place_sync_external_block_connections(ClusterBlockId iblk) {
84+
const auto& cluster_ctx = g_vpr_ctx.clustering();
85+
const auto& clb_nlist = cluster_ctx.clb_nlist;
86+
87+
t_pl_loc block_loc = block_locs_[iblk].loc;
88+
89+
auto physical_tile = physical_tile_type(block_loc);
90+
auto logical_block = clb_nlist.block_type(iblk);
91+
92+
int sub_tile_index = get_sub_tile_index(iblk, block_locs_);
93+
auto sub_tile = physical_tile->sub_tiles[sub_tile_index];
94+
95+
VTR_ASSERT(sub_tile.num_phy_pins % sub_tile.capacity.total() == 0);
96+
97+
int max_num_block_pins = sub_tile.num_phy_pins / sub_tile.capacity.total();
98+
/* Logical location and physical location is offset by z * max_num_block_pins */
99+
100+
int rel_capacity = block_loc.sub_tile - sub_tile.capacity.low;
101+
102+
for (ClusterPinId pin : clb_nlist.block_pins(iblk)) {
103+
int logical_pin_index = clb_nlist.pin_logical_index(pin);
104+
int sub_tile_pin_index = get_sub_tile_physical_pin(sub_tile_index, physical_tile, logical_block, logical_pin_index);
105+
106+
int new_physical_pin_index = sub_tile.sub_tile_to_tile_pin_indices[sub_tile_pin_index + rel_capacity * max_num_block_pins];
107+
108+
auto result = physical_pins_.find(pin);
109+
if (result != physical_pins_.end()) {
110+
physical_pins_[pin] = new_physical_pin_index;
111+
} else {
112+
physical_pins_.insert(pin, new_physical_pin_index);
113+
}
114+
}
115+
}

vpr/src/base/blk_loc_registry.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,35 @@ class BlkLocRegistry {
5151

5252
///@brief Returns the physical pin of the tile, related to the given ClusterNedId, and the net pin index.
5353
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const;
54+
55+
/**
56+
* @brief Performs error checking to see if location is legal for block type,
57+
* and sets the location and grid usage of the block if it is legal.
58+
* @param blk_id The unique ID of the clustered block whose location is to set.
59+
* @param location The location where the clustered block should placed at.
60+
*/
61+
void set_block_location(ClusterBlockId blk_id, const t_pl_loc& location);
62+
63+
/**
64+
* @brief Syncs the logical block pins corresponding to the input iblk with the corresponding chosen physical tile
65+
* @param iblk cluster block ID to sync within the assigned physical tile
66+
*
67+
* This routine updates the physical pins vector of the place context after the placement step
68+
* to synchronize the pins related to the logical block with the actual connection interface of
69+
* the belonging physical tile with the RR graph.
70+
*
71+
* This step is required as the logical block can be placed at any compatible sub tile locations
72+
* within a physical tile.
73+
* Given that it is possible to have equivalent logical blocks within a specific sub tile, with
74+
* a different subset of IO pins, the various pins offsets must be correctly computed and assigned
75+
* to the physical pins vector, so that, when the net RR terminals are computed, the correct physical
76+
* tile IO pins are selected.
77+
*
78+
* This routine uses the x,y and sub_tile coordinates of the clb netlist, and expects those to place each netlist block
79+
* at a legal location that can accommodate it.
80+
* It does not check for overuse of locations, therefore it can be used with placements that have resource overuse.
81+
*/
82+
void place_sync_external_block_connections(ClusterBlockId iblk);
5483
};
5584

5685
#endif //VTR_BLK_LOC_REGISTRY_H

vpr/src/base/place_and_route.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,6 @@ void post_place_sync() {
580580

581581
// Cluster-based netlist is used for placement
582582
for (const ClusterBlockId block_id : cluster_ctx.clb_nlist.blocks()) {
583-
place_sync_external_block_connections(block_id, blk_loc_registry);
583+
blk_loc_registry.place_sync_external_block_connections(block_id);
584584
}
585585
}

vpr/src/base/read_place.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static std::string read_place_body(std::ifstream& placement_file,
314314
blk_id, loc.x, loc.y, loc.layer, loc.sub_tile, constraint_loc.x, constraint_loc.y, constraint_loc.layer, constraint_loc.sub_tile);
315315
}
316316
}
317-
set_block_location(blk_id, loc, blk_loc_registry);
317+
blk_loc_registry.set_block_location(blk_id, loc);
318318
}
319319

320320
//need to lock down blocks if it is a constraints file

vpr/src/place/initial_placement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ bool try_place_macro(const t_pl_macro& pl_macro,
890890
for (const t_pl_macro_member& pl_macro_member : pl_macro.members) {
891891
t_pl_loc member_pos = head_pos + pl_macro_member.offset;
892892
ClusterBlockId iblk = pl_macro_member.blk_index;
893-
set_block_location(iblk, member_pos, blk_loc_registry);
893+
blk_loc_registry.set_block_location(iblk, member_pos);
894894
} // Finish placing all the members in the macro
895895
}
896896

vpr/src/place/move_transactions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void apply_move_blocks(const t_pl_blocks_to_be_moved& blocks_affected,
9090

9191
//if physical tile type of old location does not equal physical tile type of new location, sync the new physical pins
9292
if (old_type != new_type) {
93-
place_sync_external_block_connections(blk, blk_loc_registry);
93+
blk_loc_registry.place_sync_external_block_connections(blk);
9494
}
9595
}
9696
}
@@ -147,7 +147,7 @@ void revert_move_blocks(const t_pl_blocks_to_be_moved& blocks_affected,
147147

148148
//if physical tile type of old location does not equal physical tile type of new location, sync the new physical pins
149149
if (old_type != new_type) {
150-
place_sync_external_block_connections(blk, blk_loc_registry);
150+
blk_loc_registry.place_sync_external_block_connections(blk);
151151
}
152152

153153
VTR_ASSERT_SAFE_MSG(blk_loc_registry.grid_blocks().block_at_location(old_loc) == blk,

vpr/src/place/noc_place_checkpoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void NoCPlacementCheckpoint::restore_checkpoint(t_placer_costs& costs,
6060

6161
// Place routers based on router_locations_
6262
for (const auto& [router_blk_id, location] : router_locations_) {
63-
set_block_location(router_blk_id, location, blk_loc_registry);
63+
blk_loc_registry.set_block_location(router_blk_id, location);
6464
}
6565

6666
// Re-initialize routes and static variables that keep track of NoC-related costs

vpr/src/place/place.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ void try_place(const Netlist<>& net_list,
475475

476476
// Update physical pin values
477477
for (const ClusterBlockId block_id : cluster_ctx.clb_nlist.blocks()) {
478-
place_sync_external_block_connections(block_id, blk_loc_registry);
478+
blk_loc_registry.place_sync_external_block_connections(block_id);
479479
}
480480

481481
const int width_fac = placer_opts.place_chan_width;
@@ -903,7 +903,7 @@ void try_place(const Netlist<>& net_list,
903903

904904
// Update physical pin values
905905
for (const ClusterBlockId block_id : cluster_ctx.clb_nlist.blocks()) {
906-
place_sync_external_block_connections(block_id, blk_loc_registry);
906+
blk_loc_registry.place_sync_external_block_connections(block_id);
907907
}
908908

909909
check_place(costs,

vpr/src/place/place_constraints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ void mark_fixed_blocks(BlkLocRegistry& blk_loc_registry) {
270270
* and mark it as fixed.
271271
*/
272272
if (is_pr_size_one(pr, block_type, loc)) {
273-
set_block_location(blk_id, loc, blk_loc_registry);
273+
blk_loc_registry.set_block_location(blk_id, loc);
274274
blk_loc_registry.mutable_block_locs()[blk_id].is_fixed = true;
275275
}
276276
}

vpr/src/place/place_util.cpp

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -356,51 +356,6 @@ void alloc_and_load_legal_placement_locations(std::vector<std::vector<std::vecto
356356
legal_pos.shrink_to_fit();
357357
}
358358

359-
void set_block_location(ClusterBlockId blk_id,
360-
const t_pl_loc& location,
361-
BlkLocRegistry& blk_loc_registry) {
362-
auto& device_ctx = g_vpr_ctx.device();
363-
auto& cluster_ctx = g_vpr_ctx.clustering();
364-
auto& block_locs = blk_loc_registry.mutable_block_locs();
365-
auto& grid_blocks = blk_loc_registry.mutable_grid_blocks();
366-
367-
const std::string& block_name = cluster_ctx.clb_nlist.block_name(blk_id);
368-
369-
//Check if block location is out of range of grid dimensions
370-
if (location.x < 0 || location.x > int(device_ctx.grid.width() - 1)
371-
|| location.y < 0 || location.y > int(device_ctx.grid.height() - 1)) {
372-
VPR_THROW(VPR_ERROR_PLACE, "Block %s with ID %d is out of range at location (%d, %d). \n",
373-
block_name.c_str(), blk_id, location.x, location.y);
374-
}
375-
376-
//Set the location of the block
377-
block_locs[blk_id].loc = location;
378-
379-
//Check if block is at an illegal location
380-
auto physical_tile = device_ctx.grid.get_physical_type({location.x, location.y, location.layer});
381-
auto logical_block = cluster_ctx.clb_nlist.block_type(blk_id);
382-
383-
if (location.sub_tile >= physical_tile->capacity || location.sub_tile < 0) {
384-
VPR_THROW(VPR_ERROR_PLACE, "Block %s subtile number (%d) is out of range. \n", block_name.c_str(), location.sub_tile);
385-
}
386-
387-
if (!is_sub_tile_compatible(physical_tile, logical_block, block_locs[blk_id].loc.sub_tile)) {
388-
VPR_THROW(VPR_ERROR_PLACE, "Attempt to place block %s with ID %d at illegal location (%d,%d,%d). \n",
389-
block_name.c_str(),
390-
blk_id,
391-
location.x,
392-
location.y,
393-
location.layer);
394-
}
395-
396-
//Mark the grid location and usage of the block
397-
grid_blocks.set_block_at_location(location, blk_id);
398-
grid_blocks.set_usage({location.x, location.y, location.layer},
399-
grid_blocks.get_usage({location.x, location.y, location.layer}) + 1);
400-
401-
place_sync_external_block_connections(blk_id, blk_loc_registry);
402-
}
403-
404359
bool macro_can_be_placed(const t_pl_macro& pl_macro,
405360
const t_pl_loc& head_pos,
406361
bool check_all_legality,
@@ -492,40 +447,3 @@ NocCostTerms& NocCostTerms::operator+=(const NocCostTerms& noc_delta_cost) {
492447

493448
return *this;
494449
}
495-
496-
void place_sync_external_block_connections(ClusterBlockId iblk,
497-
BlkLocRegistry& blk_loc_registry) {
498-
const auto& cluster_ctx = g_vpr_ctx.clustering();
499-
const auto& clb_nlist = cluster_ctx.clb_nlist;
500-
const auto& block_locs = blk_loc_registry.block_locs();
501-
auto& physical_pins = blk_loc_registry.mutable_physical_pins();
502-
503-
t_pl_loc block_loc = block_locs[iblk].loc;
504-
505-
auto physical_tile = physical_tile_type(block_loc);
506-
auto logical_block = clb_nlist.block_type(iblk);
507-
508-
int sub_tile_index = get_sub_tile_index(iblk, block_locs);
509-
auto sub_tile = physical_tile->sub_tiles[sub_tile_index];
510-
511-
VTR_ASSERT(sub_tile.num_phy_pins % sub_tile.capacity.total() == 0);
512-
513-
int max_num_block_pins = sub_tile.num_phy_pins / sub_tile.capacity.total();
514-
/* Logical location and physical location is offset by z * max_num_block_pins */
515-
516-
int rel_capacity = block_loc.sub_tile - sub_tile.capacity.low;
517-
518-
for (ClusterPinId pin : clb_nlist.block_pins(iblk)) {
519-
int logical_pin_index = clb_nlist.pin_logical_index(pin);
520-
int sub_tile_pin_index = get_sub_tile_physical_pin(sub_tile_index, physical_tile, logical_block, logical_pin_index);
521-
522-
int new_physical_pin_index = sub_tile.sub_tile_to_tile_pin_indices[sub_tile_pin_index + rel_capacity * max_num_block_pins];
523-
524-
auto result = physical_pins.find(pin);
525-
if (result != physical_pins.end()) {
526-
physical_pins[pin] = new_physical_pin_index;
527-
} else {
528-
physical_pins.insert(pin, new_physical_pin_index);
529-
}
530-
}
531-
}

vpr/src/place/place_util.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,6 @@ void load_grid_blocks_from_block_locs(GridBlock& grid_blocks,
352352
*/
353353
void alloc_and_load_legal_placement_locations(std::vector<std::vector<std::vector<t_pl_loc>>>& legal_pos);
354354

355-
///@brief Performs error checking to see if location is legal for block type,
356-
/// and sets the location and grid usage of the block if it is legal.
357-
void set_block_location(ClusterBlockId blk_id,
358-
const t_pl_loc& location,
359-
BlkLocRegistry& blk_loc_registry);
360-
361355
/// @brief check if a specified location is within the device grid
362356
inline bool is_loc_on_chip(t_physical_tile_loc loc) {
363357
const auto& grid = g_vpr_ctx.device().grid;
@@ -396,27 +390,4 @@ bool macro_can_be_placed(const t_pl_macro& pl_macro,
396390
const t_pl_loc& head_pos,
397391
bool check_all_legality,
398392
const BlkLocRegistry& blk_loc_registry);
399-
400-
/**
401-
* @brief Syncs the logical block pins corresponding to the input iblk with the corresponding chosen physical tile
402-
* @param iblk cluster block ID to sync within the assigned physical tile
403-
* @param blk_loc_registry Placement block location information. To be updated with new pin mapping info.
404-
*
405-
* This routine updates the physical pins vector of the place context after the placement step
406-
* to synchronize the pins related to the logical block with the actual connection interface of
407-
* the belonging physical tile with the RR graph.
408-
*
409-
* This step is required as the logical block can be placed at any compatible sub tile locations
410-
* within a physical tile.
411-
* Given that it is possible to have equivalent logical blocks within a specific sub tile, with
412-
* a different subset of IO pins, the various pins offsets must be correctly computed and assigned
413-
* to the physical pins vector, so that, when the net RR terminals are computed, the correct physical
414-
* tile IO pins are selected.
415-
*
416-
* This routine uses the x,y and sub_tile coordinates of the clb netlist, and expects those to place each netlist block
417-
* at a legal location that can accommodate it.
418-
* It does not check for overuse of locations, therefore it can be used with placements that have resource overuse.
419-
*/
420-
void place_sync_external_block_connections(ClusterBlockId iblk,
421-
BlkLocRegistry& blk_loc_registry);
422393
#endif

0 commit comments

Comments
 (0)