Skip to content

Commit fe1ee45

Browse files
add load_from_block_locs() to GridBlock
1 parent 46434be commit fe1ee45

10 files changed

+40
-33
lines changed

vpr/src/grid_block.cpp renamed to vpr/src/base/grid_block.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ void GridBlock::zero_initialize() {
2525
}
2626
}
2727

28+
void GridBlock::load_from_block_locs(const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs) {
29+
auto& cluster_ctx = g_vpr_ctx.clustering();
30+
auto& device_ctx = g_vpr_ctx.device();
31+
32+
zero_initialize();
33+
34+
for (ClusterBlockId blk_id : cluster_ctx.clb_nlist.blocks()) {
35+
t_pl_loc location = block_locs[blk_id].loc;
36+
37+
VTR_ASSERT(location.x < (int)device_ctx.grid.width());
38+
VTR_ASSERT(location.y < (int)device_ctx.grid.height());
39+
40+
set_block_at_location(location, blk_id);
41+
increment_usage({location.x, location.y, location.layer});
42+
}
43+
}
44+
2845
int GridBlock::increment_usage(const t_physical_tile_loc& loc) {
2946
int curr_usage = get_usage(loc);
3047
int updated_usage = set_usage(loc, curr_usage + 1);
@@ -38,3 +55,5 @@ int GridBlock::decrement_usage(const t_physical_tile_loc& loc) {
3855

3956
return updated_usage;
4057
}
58+
59+

vpr/src/base/grid_block.h

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

78+
/**
79+
* @brief Initializes the GridBlock object with the given block_locs.
80+
* @param block_locs Stores the location of each clustered block.
81+
*/
82+
void load_from_block_locs(const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs);
83+
7884
int increment_usage(const t_physical_tile_loc& loc);
7985

8086
int decrement_usage(const t_physical_tile_loc& loc);

vpr/src/place/cut_spreader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# include "globals.h"
1313
# include "vtr_log.h"
1414
# include "place_util.h"
15+
# include "grid_block.h"
1516

1617
// sentinel for base case in CutSpreader (i.e. only 1 block left in region)
1718
constexpr std::pair<int, int> BASE_CASE = {-2, -2};

vpr/src/place/move_transactions.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "move_utils.h"
33

44
#include "globals.h"
5-
#include "place_util.h"
65
#include "grid_block.h"
76
#include "vtr_assert.h"
87

vpr/src/place/move_utils.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,12 @@ void set_placer_breakpoint_reached(bool);
256256
* if it was able to find a compatible location and false otherwise.
257257
* It is similar to find_to_loc_uniform but searching in a defined range instead of searching in a range around the current block location.
258258
*
259-
* @param blk_type: the type of the moving block
260-
* @param from_loc: the original location of the moving block
261-
* @param limit_coords: the region where I can move the block to
262-
* @param to_loc: the new location that the function picked for the block
259+
* @param blk_type the type of the moving block
260+
* @param from_loc the original location of the moving block
261+
* @param limit_coords the region where I can move the block to
262+
* @param to_loc the new location that the function picked for the block
263+
* @param b_from The unique ID of the clustered block whose median location is to be computed.
264+
* @param blk_loc_registry Information about clustered block locations.
263265
*/
264266
bool find_to_loc_median(t_logical_block_type_ptr blk_type,
265267
const t_pl_loc& from_loc,
@@ -313,6 +315,7 @@ void compressed_grid_to_loc(t_logical_block_type_ptr blk_type,
313315
*
314316
* @param type logical block type
315317
* @param to_loc The location to be checked
318+
* @param grid_blocks A mapping from grid locations to clustered blocks placed there.
316319
*
317320
* @return int The subtile number if there is an empty compatible subtile, otherwise -1
318321
* is returned to indicate that there are no empty subtiles compatible with the given type..
@@ -428,10 +431,6 @@ std::string e_move_result_to_string(e_move_result move_outcome);
428431
* @brif Iterate over all layers that have a physical tile at the x-y location specified by "loc" that can accommodate "logical_block".
429432
* If the location in the layer specified by "layer_num" is empty, return that layer. Otherwise,
430433
* return a layer that is not occupied at that location. If there isn't any, again, return the layer of loc.
431-
*
432-
* @param logical_block
433-
* @param loc
434-
* @return
435434
*/
436435
int find_free_layer(t_logical_block_type_ptr logical_block,
437436
const t_pl_loc& loc,

vpr/src/place/noc_place_checkpoint.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ class NoCPlacementCheckpoint {
3636
/**
3737
* @brief Saves the current NoC router placement as a checkpoint
3838
*
39-
* @param cost: The placement cost associated with the current placement
39+
* @param cost The placement cost associated with the current placement
40+
* @param block_locs Stores where each clustered block (including NoC routers) is placed at.
4041
*/
4142
void save_checkpoint(double cost, const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs);
4243

4344
/**
4445
* @brief Loads the save checkpoint into global placement data structues.
4546
*
46-
* @param costs: Used to load NoC related costs for the checkpoint
47+
* @param costs Used to load NoC related costs for the checkpoint
48+
* @param blk_loc_registry To be updated with the save checkpoint for NoC router locations.
4749
*/
4850
void restore_checkpoint(t_placer_costs& costs,
4951
BlkLocRegistry& blk_loc_registry);

vpr/src/place/place_checkpoint.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "place_checkpoint.h"
22
#include "noc_place_utils.h"
33
#include "placer_state.h"
4+
#include "grid_block.h"
45

56
float t_placement_checkpoint::get_cp_cpd() const { return cpd_; }
67

@@ -20,7 +21,7 @@ void t_placement_checkpoint::save_placement(const vtr::vector_map<ClusterBlockId
2021
t_placer_costs t_placement_checkpoint::restore_placement(vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs,
2122
GridBlock& grid_blocks) {
2223
block_locs = block_locs_;
23-
load_grid_blocks_from_block_locs(grid_blocks, block_locs);
24+
grid_blocks.load_from_block_locs(block_locs);
2425
return costs_;
2526
}
2627

vpr/src/place/place_util.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,23 +273,6 @@ double get_std_dev(int n, double sum_x_squared, double av_x) {
273273
return (std_dev > 0.) ? sqrt(std_dev) : 0.;
274274
}
275275

276-
void load_grid_blocks_from_block_locs(GridBlock& grid_blocks,
277-
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs) {
278-
auto& cluster_ctx = g_vpr_ctx.clustering();
279-
auto& device_ctx = g_vpr_ctx.device();
280-
281-
grid_blocks.zero_initialize();
282-
283-
for (ClusterBlockId blk_id : cluster_ctx.clb_nlist.blocks()) {
284-
t_pl_loc location = block_locs[blk_id].loc;
285-
286-
VTR_ASSERT(location.x < (int)device_ctx.grid.width());
287-
VTR_ASSERT(location.y < (int)device_ctx.grid.height());
288-
289-
grid_blocks.set_block_at_location(location, blk_id);
290-
grid_blocks.increment_usage({location.x, location.y, location.layer});
291-
}
292-
}
293276

294277
void alloc_and_load_legal_placement_locations(std::vector<std::vector<std::vector<t_pl_loc>>>& legal_pos) {
295278
auto& device_ctx = g_vpr_ctx.device();

vpr/src/place/place_util.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,6 @@ int get_initial_move_lim(const t_placer_opts& placer_opts, const t_annealing_sch
336336
*/
337337
double get_std_dev(int n, double sum_x_squared, double av_x);
338338

339-
///@brief a utility to calculate grid_blocks given the updated block_locs (used in restore_checkpoint)
340-
void load_grid_blocks_from_block_locs(GridBlock& grid_blocks,
341-
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs);
342-
343339
/**
344340
* @brief Builds (alloc and load) legal_pos that holds all the legal locations for placement
345341
*

vpr/src/util/vpr_utils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "user_route_constraints.h"
2020
#include "re_cluster_util.h"
2121
#include "placer_state.h"
22+
#include "grid_block.h"
2223

2324
/* This module contains subroutines that are used in several unrelated parts *
2425
* of VPR. They are VPR-specific utility routines. */

0 commit comments

Comments
 (0)