Skip to content

Commit ed54bcc

Browse files
committed
runtime failures in vtr_reg_nightly_test1 solved
1 parent 8737d00 commit ed54bcc

File tree

2 files changed

+21
-28
lines changed

2 files changed

+21
-28
lines changed

vpr/src/place/initial_placement.cpp

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static std::vector<t_grid_empty_locs_block_type> init_blk_types_empty_locations(
136136
static inline void fix_IO_block_types(t_pl_macro pl_macro, t_pl_loc loc, enum e_pad_loc_type pad_loc_type);
137137

138138
/**
139-
* @brief Determine whether a specific macro can be placed in a specific location.
139+
* @brief Determine whether a specific macro can be placed in a specific location and choose the location's subtile if the location is legal.
140140
*
141141
* @param loc The location at which the macro head member is placed.
142142
* @param pr The PartitionRegion of the macro head member - represents its floorplanning constraints, is the size of the whole chip if the macro is not
@@ -145,7 +145,7 @@ static inline void fix_IO_block_types(t_pl_macro pl_macro, t_pl_loc loc, enum e_
145145
*
146146
* @return True if the location is legal for the macro head member, false otherwise.
147147
*/
148-
static bool is_loc_legal(t_pl_loc loc, PartitionRegion& pr, t_logical_block_type_ptr block_type);
148+
static bool is_loc_legal(t_pl_loc& loc, PartitionRegion& pr, t_logical_block_type_ptr block_type);
149149

150150
/**
151151
* @brief Calculates a centroid location for a block based on its placed connections.
@@ -264,24 +264,31 @@ static bool is_block_placed(ClusterBlockId blk_id) {
264264
return (!(place_ctx.block_locs[blk_id].loc.x == INVALID_X));
265265
}
266266

267-
static bool is_loc_legal(t_pl_loc loc, PartitionRegion& pr, t_logical_block_type_ptr block_type) {
267+
static bool is_loc_legal(t_pl_loc& loc, PartitionRegion& pr, t_logical_block_type_ptr block_type) {
268268
const auto& grid = g_vpr_ctx.device().grid;
269-
auto& place_ctx = g_vpr_ctx.mutable_placement();
270269
bool legal = false;
271270

272271
//Check if the location is within its constraint region
273272
for (auto reg : pr.get_partition_region()) {
274273
if (reg.get_region_rect().contains(vtr::Point<int>(loc.x, loc.y))) {
275-
//Check if blk_id type and the location physical types match
276-
if (is_tile_compatible(grid[loc.x][loc.y].type, block_type)) {
277-
//Check if the location is an anchor position
278-
if (grid[loc.x][loc.y].height_offset == 0 && grid[loc.x][loc.y].width_offset == 0) {
279-
legal = true;
280-
break;
281-
}
274+
//Check if the location is an anchor position
275+
if (grid[loc.x][loc.y].height_offset == 0 && grid[loc.x][loc.y].width_offset == 0) {
276+
legal = true;
277+
break;
282278
}
283279
}
284280
}
281+
282+
if (legal) { // location (x,y) is legal for the block type, a compatible subtile should be choosen to place the block
283+
legal = false;
284+
for (auto subtile = 0; subtile < grid[loc.x][loc.y].type->capacity; subtile++) {
285+
if (is_sub_tile_compatible(grid[loc.x][loc.y].type, block_type, loc.sub_tile)) {
286+
loc.sub_tile = subtile;
287+
legal = true;
288+
}
289+
}
290+
}
291+
285292
return legal;
286293
}
287294

@@ -426,26 +433,12 @@ static bool try_centroid_placement(t_pl_macro pl_macro, PartitionRegion& pr, t_l
426433
return false;
427434
}
428435

429-
auto& grid = g_vpr_ctx.device().grid;
430-
auto to_type = grid[centroid_loc.x][centroid_loc.y].type;
431-
432436
auto& device_ctx = g_vpr_ctx.device();
433-
auto& place_ctx = g_vpr_ctx.mutable_placement();
434-
435-
centroid_loc.sub_tile = 0;
436-
437-
for (int subtile = 0; subtile < to_type->capacity; subtile++) {
438-
if (place_ctx.grid_blocks[centroid_loc.x][centroid_loc.y].blocks[subtile] == EMPTY_BLOCK_ID) {
439-
if (is_sub_tile_compatible(to_type, block_type, subtile)) {
440-
centroid_loc.sub_tile = subtile;
441-
}
442-
}
443-
}
444437

445438
VTR_ASSERT(device_ctx.grid[centroid_loc.x][centroid_loc.y].width_offset == 0);
446439
VTR_ASSERT(device_ctx.grid[centroid_loc.x][centroid_loc.y].height_offset == 0);
447440

448-
bool legal = false;
441+
bool legal;
449442

450443
legal = try_place_macro(pl_macro, centroid_loc);
451444

@@ -892,7 +885,7 @@ static void place_all_blocks(vtr::vector<ClusterBlockId, t_block_score>& block_s
892885

893886
auto blk_id_type = cluster_ctx.clb_nlist.block_type(blk_id);
894887
blocks_placed_since_heap_update++;
895-
888+
896889
bool block_placed = place_one_block(blk_id, pad_loc_type, &blk_types_empty_locs_in_grid[blk_id_type->index], &block_scores);
897890

898891
//update heap based on update_heap_freq calculated above

vpr/src/place/place_constraints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,5 +441,5 @@ double get_floorplan_score(ClusterBlockId blk_id, PartitionRegion& pr, t_logical
441441

442442
int total_type_tiles = grid_tiles.total_type_tiles(block_type);
443443

444-
return (double)(total_type_tiles - num_pr_tiles)/total_type_tiles;
444+
return (double)(total_type_tiles - num_pr_tiles) / total_type_tiles;
445445
}

0 commit comments

Comments
 (0)