Skip to content

Commit 46434be

Browse files
add increment_usage() and decrement_usage() to GridBlock
1 parent 155efc6 commit 46434be

File tree

7 files changed

+25
-14
lines changed

7 files changed

+25
-14
lines changed

vpr/src/base/blk_loc_registry.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ void BlkLocRegistry::set_block_location(ClusterBlockId blk_id, const t_pl_loc& l
7474

7575
//Mark the grid location and usage of the block
7676
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);
77+
grid_blocks_.increment_usage({location.x, location.y, location.layer});
7978

8079
place_sync_external_block_connections(blk_id);
8180
}

vpr/src/base/grid_block.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ class GridBlock {
7575
*/
7676
void zero_initialize();
7777

78+
int increment_usage(const t_physical_tile_loc& loc);
79+
80+
int decrement_usage(const t_physical_tile_loc& loc);
81+
7882
private:
7983
vtr::NdMatrix<t_grid_blocks, 3> grid_blocks_;
8084
};

vpr/src/grid_block.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,17 @@ void GridBlock::zero_initialize() {
2424
}
2525
}
2626
}
27+
28+
int GridBlock::increment_usage(const t_physical_tile_loc& loc) {
29+
int curr_usage = get_usage(loc);
30+
int updated_usage = set_usage(loc, curr_usage + 1);
31+
32+
return updated_usage;
33+
}
34+
35+
int GridBlock::decrement_usage(const t_physical_tile_loc& loc) {
36+
int curr_usage = get_usage(loc);
37+
int updated_usage = set_usage(loc, curr_usage - 1);
38+
39+
return updated_usage;
40+
}

vpr/src/place/cut_spreader.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,7 @@ void CutSpreader::bind_tile(t_pl_loc sub_tile, ClusterBlockId blk) {
969969
VTR_ASSERT(block_locs[blk].is_fixed == false);
970970
grid_blocks.set_block_at_location(sub_tile, blk);
971971
block_locs[blk].loc = sub_tile;
972-
grid_blocks.set_usage({sub_tile.x, sub_tile.y, sub_tile.layer},
973-
grid_blocks.get_usage({sub_tile.x, sub_tile.y, sub_tile.layer}) + 1);
972+
grid_blocks.increment_usage({sub_tile.x, sub_tile.y, sub_tile.layer});
974973
ap->blk_locs[blk].loc = sub_tile;
975974
}
976975

@@ -987,8 +986,7 @@ void CutSpreader::unbind_tile(t_pl_loc sub_tile) {
987986
VTR_ASSERT(block_locs[blk].is_fixed == false);
988987
block_locs[blk].loc = t_pl_loc{};
989988
grid_blocks.set_block_at_location(sub_tile, ClusterBlockId::INVALID());
990-
grid_blocks.set_usage({sub_tile.x, sub_tile.y, sub_tile.layer},
991-
grid_blocks.get_usage({sub_tile.x, sub_tile.y, sub_tile.layer}) - 1);
989+
grid_blocks.decrement_usage({sub_tile.x, sub_tile.y, sub_tile.layer});
992990
}
993991

994992
/*

vpr/src/place/move_transactions.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,13 @@ void commit_move_blocks(const t_pl_blocks_to_be_moved& blocks_affected,
110110
//Remove from old location only if it hasn't already been updated by a previous block update
111111
if (grid_blocks.block_at_location(from) == blk) {
112112
grid_blocks.set_block_at_location(from, ClusterBlockId::INVALID());
113-
grid_blocks.set_usage({from.x, from.y, from.layer},
114-
grid_blocks.get_usage({from.x, from.y, from.layer}) - 1);
113+
grid_blocks.decrement_usage({from.x, from.y, from.layer});
115114
}
116115

117116
//Add to new location
118117
if (grid_blocks.block_at_location(to) == ClusterBlockId::INVALID()) {
119118
//Only need to increase usage if previously unused
120-
grid_blocks.set_usage({to.x, to.y, to.layer},
121-
grid_blocks.get_usage({to.x, to.y, to.layer}) + 1);
119+
grid_blocks.increment_usage({to.x, to.y, to.layer});
122120
}
123121
grid_blocks.set_block_at_location(to, blk);
124122

vpr/src/place/place_util.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ void load_grid_blocks_from_block_locs(GridBlock& grid_blocks,
287287
VTR_ASSERT(location.y < (int)device_ctx.grid.height());
288288

289289
grid_blocks.set_block_at_location(location, blk_id);
290-
grid_blocks.set_usage({location.x, location.y, location.layer},
291-
grid_blocks.get_usage({location.x, location.y, location.layer}) + 1);
290+
grid_blocks.increment_usage({location.x, location.y, location.layer});
292291
}
293292
}
294293

vpr/src/util/vpr_utils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ void sync_grid_to_blocks() {
186186
for (int width = 0; width < type->width; ++width) {
187187
for (int height = 0; height < type->height; ++height) {
188188
grid_blocks.set_block_at_location({blk_x + width, blk_y + height, blk_z, blk_layer}, blk_id);
189-
grid_blocks.set_usage({blk_x + width, blk_y + height, blk_layer},
190-
grid_blocks.get_usage({blk_x + width, blk_y + height, blk_layer}) + 1);
189+
grid_blocks.increment_usage({blk_x + width, blk_y + height, blk_layer});
191190

192191
VTR_ASSERT(device_ctx.grid.get_width_offset({blk_x + width, blk_y + height, blk_layer}) == width);
193192
VTR_ASSERT(device_ctx.grid.get_height_offset({blk_x + width, blk_y + height, blk_layer}) == height);

0 commit comments

Comments
 (0)