Skip to content

Commit 46741da

Browse files
committed
heterogeneous: address review comments
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 7a7333c commit 46741da

File tree

9 files changed

+39
-59
lines changed

9 files changed

+39
-59
lines changed

vpr/src/base/read_place.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void read_user_pad_loc(const char* pad_loc_file) {
250250

251251
auto physical_tile = device_ctx.grid[i][j].type;
252252
auto logical_block = cluster_ctx.clb_nlist.block_type(bnum);
253-
if (!is_tile_compatible(physical_tile, logical_block, place_ctx.block_locs[bnum].loc)) {
253+
if (!is_tile_compatible(physical_tile, logical_block, place_ctx.block_locs[bnum].loc.sub_tile)) {
254254
VPR_THROW(VPR_ERROR_PLACE_F, pad_loc_file, 0,
255255
"Attempt to place block %s at illegal location (%d, %d).\n", bname, i, j);
256256
}

vpr/src/place/compressed_grid.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,22 @@ std::vector<t_compressed_block_grid> create_compressed_block_grids() {
2323
}
2424

2525
std::vector<t_compressed_block_grid> compressed_type_grids(device_ctx.logical_block_types.size());
26-
for (const auto& type : device_ctx.logical_block_types) {
27-
compressed_type_grids[type.index] = create_compressed_block_grid(block_locations[type.index]);
26+
for (const auto& logical_block : device_ctx.logical_block_types) {
27+
auto compressed_block_grid = create_compressed_block_grid(block_locations[logical_block.index]);
28+
29+
for (const auto& physical_tile : logical_block.equivalent_tiles) {
30+
std::vector<int> compatible_sub_tiles;
31+
32+
for (int capacity = 0; capacity < physical_tile->capacity; capacity++) {
33+
if (is_tile_compatible(physical_tile, &logical_block, capacity)) {
34+
compatible_sub_tiles.push_back(capacity);
35+
}
36+
}
37+
38+
compressed_block_grid.compatible_sub_tiles_map.insert({physical_tile->index, compatible_sub_tiles});
39+
}
40+
41+
compressed_type_grids[logical_block.index] = compressed_block_grid;
2842
}
2943

3044
return compressed_type_grids;

vpr/src/place/compressed_grid.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ struct t_compressed_block_grid {
3232
//stored sparsely, since we may not have full columns of blocks.
3333
//This makes it easy to check whether there exist
3434
std::vector<vtr::flat_map2<int, t_type_loc>> grid;
35+
36+
std::unordered_map<int, std::vector<int>> compatible_sub_tiles_map;
3537
};
3638

3739
//Compressed grid space for each block type

vpr/src/place/move_utils.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ bool is_legal_swap_to_location(ClusterBlockId blk, t_pl_loc to) {
445445
auto logical_block = cluster_ctx.clb_nlist.block_type(blk);
446446

447447
if (to.sub_tile < 0 || to.sub_tile >= physical_tile->capacity
448-
|| !is_tile_compatible(physical_tile, logical_block, to)) {
448+
|| !is_tile_compatible(physical_tile, logical_block, to.sub_tile)) {
449449
return false;
450450
}
451451
// If the destination block is user constrained, abort this swap
@@ -639,14 +639,7 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
639639

640640
//Each x/y location possibly contains multiple sub tiles, so we need to pick
641641
//a z location within a compatible sub tile.
642-
std::vector<int> compatible_sub_tiles;
643-
for (int capacity = 0; capacity < to_type->capacity; capacity++) {
644-
t_pl_loc loc(to.x, to.y, capacity);
645-
646-
if (is_tile_compatible(to_type, type, loc)) {
647-
compatible_sub_tiles.push_back(capacity);
648-
}
649-
}
642+
auto& compatible_sub_tiles = compressed_block_grid.compatible_sub_tiles_map.at(to_type->index);
650643
to.sub_tile = compatible_sub_tiles[vtr::irand((int)compatible_sub_tiles.size() - 1)];
651644

652645
VTR_ASSERT_MSG(is_tile_compatible(to_type, type), "Type must be compatible");

vpr/src/route/route_common.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,7 @@ static t_clb_opins_used alloc_and_load_clb_opins_used_locally() {
848848
auto type = physical_tile_type(blk_id);
849849
auto sub_tile = type->sub_tiles[get_sub_tile_index(blk_id)];
850850

851-
int class_low, class_high;
852-
get_class_range_for_block(blk_id, &class_low, &class_high);
851+
auto class_range = get_class_range_for_block(blk_id);
853852

854853
clb_opins_used_locally[blk_id].resize((int)type->class_inf.size());
855854

@@ -873,7 +872,7 @@ static t_clb_opins_used alloc_and_load_clb_opins_used_locally() {
873872
VTR_ASSERT(type->class_inf[iclass].type == DRIVER);
874873

875874
/* Check to make sure class is in same range as that assigned to block */
876-
VTR_ASSERT(iclass >= class_low && iclass <= class_high);
875+
VTR_ASSERT(iclass >= class_range.low && iclass <= class_range.high);
877876

878877
//We push back OPEN to reserve space to store the exact pin which
879878
//will be reserved (determined later)
@@ -1030,12 +1029,11 @@ static vtr::vector<ClusterBlockId, std::vector<int>> load_rr_clb_sources(const t
10301029
auto type = physical_tile_type(blk_id);
10311030
auto sub_tile = type->sub_tiles[get_sub_tile_index(blk_id)];
10321031

1033-
int class_low, class_high;
1034-
get_class_range_for_block(blk_id, &class_low, &class_high);
1032+
auto class_range = get_class_range_for_block(blk_id);
10351033

10361034
rr_blk_source[blk_id].resize((int)type->class_inf.size());
10371035
for (iclass = 0; iclass < (int)type->class_inf.size(); iclass++) {
1038-
if (iclass >= class_low && iclass <= class_high) {
1036+
if (iclass >= class_range.low && iclass <= class_range.high) {
10391037
i = place_ctx.block_locs[blk_id].loc.x;
10401038
j = place_ctx.block_locs[blk_id].loc.y;
10411039

vpr/src/route/rr_graph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,9 +1397,9 @@ static void build_rr_sinks_sources(const int i,
13971397

13981398
auto type = grid[i][j].type;
13991399
int num_class = (int)type->class_inf.size();
1400-
std::vector<t_class> class_inf = type->class_inf;
1400+
const std::vector<t_class>& class_inf = type->class_inf;
14011401
int num_pins = type->num_pins;
1402-
std::vector<int> pin_class = type->pin_class;
1402+
const std::vector<int>& pin_class = type->pin_class;
14031403

14041404
/* SINK and SOURCE-to-OPIN edges */
14051405
for (int iclass = 0; iclass < num_class; ++iclass) {

vpr/src/route/rr_graph2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ int get_rr_node_index(const t_rr_node_indices& L_rr_node_indices,
14541454
* and ptc gives the number of this resource. ptc is the class number,
14551455
* pin number or track number, depending on what type of resource this
14561456
* is. All ptcs start at 0 and go up to pins_per_clb-1 or the equivalent.
1457-
* There are (int)type->class_inf.size() SOURCEs + SINKs, type->num_pins IPINs + OPINs,
1457+
* There are class_inf size SOURCEs + SINKs, type->num_pins IPINs + OPINs,
14581458
* and max_chan_width CHANX and CHANY (each).
14591459
*
14601460
* Note that for segments (CHANX and CHANY) of length > 1, the segment is

vpr/src/util/vpr_utils.cpp

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,7 @@ int get_unique_pb_graph_node_id(const t_pb_graph_node* pb_graph_node) {
726726
}
727727
}
728728

729-
void get_class_range_for_block(const ClusterBlockId blk_id,
730-
int* class_low,
731-
int* class_high) {
729+
t_class_range get_class_range_for_block(const ClusterBlockId blk_id) {
732730
/* Assumes that the placement has been done so each block has a set of pins allocated to it */
733731
auto& place_ctx = g_vpr_ctx.placement();
734732

@@ -741,8 +739,11 @@ void get_class_range_for_block(const ClusterBlockId blk_id,
741739
VTR_ASSERT((class_range_total) % sub_tile_capacity == 0);
742740
int rel_capacity = place_ctx.block_locs[blk_id].loc.sub_tile - sub_tile.capacity.low;
743741

744-
*class_low = rel_capacity * (class_range_total / sub_tile_capacity) + class_range.low;
745-
*class_high = (rel_capacity + 1) * (class_range_total / sub_tile_capacity) - 1 + class_range.low;
742+
t_class_range abs_class_range;
743+
abs_class_range.low = rel_capacity * (class_range_total / sub_tile_capacity) + class_range.low;
744+
abs_class_range.high = (rel_capacity + 1) * (class_range_total / sub_tile_capacity) - 1 + class_range.low;
745+
746+
return abs_class_range;
746747
}
747748

748749
void get_pin_range_for_block(const ClusterBlockId blk_id,
@@ -2161,10 +2162,10 @@ bool is_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_block_
21612162
return std::find(equivalent_tiles.begin(), equivalent_tiles.end(), physical_tile) != equivalent_tiles.end();
21622163
}
21632164

2164-
bool is_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_block_type_ptr logical_block, t_pl_loc loc) {
2165+
bool is_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_block_type_ptr logical_block, int sub_tile_loc) {
21652166
bool capacity_compatible = false;
21662167
for (auto& sub_tile : physical_tile->sub_tiles) {
2167-
if (sub_tile.capacity.is_in_range(loc.sub_tile)) {
2168+
if (sub_tile.capacity.is_in_range(sub_tile_loc)) {
21682169
capacity_compatible = true;
21692170
break;
21702171
}
@@ -2251,31 +2252,7 @@ int get_physical_pin(t_physical_tile_type_ptr physical_tile,
22512252

22522253
VTR_ASSERT(sub_tile_index != OPEN);
22532254

2254-
t_logical_pin logical_pin(sub_tile_index, pin);
2255-
2256-
const auto& direct_map = physical_tile->tile_block_pin_directs_map.at(logical_block->index);
2257-
auto result = direct_map.find(logical_pin);
2258-
2259-
if (result == direct_map.end()) {
2260-
VTR_LOG_WARN(
2261-
"Couldn't find the corresponding physical pin of the logical pin %d."
2262-
"Physical Tile: %s, Logical Block: %s.\n",
2263-
pin, physical_tile->name, logical_block->name);
2264-
return OPEN;
2265-
}
2266-
2267-
return result->second.pin;
2268-
}
2269-
2270-
int get_physical_pin_offset(t_sub_tile* sub_tile,
2271-
t_physical_tile_type_ptr physical_tile) {
2272-
int offset = 0;
2273-
2274-
for (int isub_tile = 0; isub_tile < sub_tile->index; isub_tile++) {
2275-
offset += physical_tile->sub_tiles[isub_tile].num_phy_pins;
2276-
}
2277-
2278-
return offset;
2255+
return get_physical_pin(sub_tile_index, physical_tile, logical_block, pin);
22792256
}
22802257

22812258
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) {

vpr/src/util/vpr_utils.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ int get_sub_tile_index(ClusterBlockId blk);
3535

3636
int get_unique_pb_graph_node_id(const t_pb_graph_node* pb_graph_node);
3737

38-
void get_class_range_for_block(const ClusterBlockId blk_id,
39-
int* class_low,
40-
int* class_high);
38+
t_class_range get_class_range_for_block(const ClusterBlockId blk_id);
4139

4240
void get_pin_range_for_block(const ClusterBlockId blk_id,
4341
int* pin_low,
@@ -148,7 +146,7 @@ int get_max_num_pins(t_logical_block_type_ptr logical_block);
148146

149147
bool is_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_block_type_ptr logical_block);
150148

151-
bool is_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_block_type_ptr logical_block, t_pl_loc loc);
149+
bool is_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_block_type_ptr logical_block, int sub_tile_loc);
152150

153151
//Returns the physical tile type which 'best' matches logical_block
154152
t_physical_tile_type_ptr pick_best_physical_type(t_logical_block_type_ptr logical_block);
@@ -170,8 +168,6 @@ int get_physical_pin(int sub_tile_index,
170168
t_physical_tile_type_ptr physical_tile,
171169
t_logical_block_type_ptr logical_block,
172170
int pin);
173-
int get_physical_pin_offset(t_sub_tile* sub_tile,
174-
t_physical_tile_type_ptr physical_tile);
175171

176172
//Returns the physical pin of the tile, related to the given ClusterNedId, and the net pin index
177173
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index);

0 commit comments

Comments
 (0)