Skip to content

Commit ee1448e

Browse files
pass grid_blocks to alloc_and_load_legal_placement_locations()
1 parent dc9c2e2 commit ee1448e

10 files changed

+26
-16
lines changed

vpr/src/base/read_route.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static void process_nodes(const Netlist<>& net_list, std::ifstream& fp, ClusterN
222222
auto& device_ctx = g_vpr_ctx.mutable_device();
223223
const auto& rr_graph = device_ctx.rr_graph;
224224
auto& route_ctx = g_vpr_ctx.mutable_routing();
225-
const auto& grid_blocks = g_vpr_ctx.placement().get_grid_blocks();
225+
const auto& grid_blocks = g_vpr_ctx.placement().grid_blocks();
226226

227227
t_trace* head_ptr = nullptr;
228228
t_trace* tptr = nullptr;
@@ -569,7 +569,7 @@ static bool check_rr_graph_connectivity(RRNodeId prev_node, RRNodeId node) {
569569
void print_route(const Netlist<>& net_list,
570570
FILE* fp,
571571
bool is_flat) {
572-
const auto& grid_blocks = g_vpr_ctx.placement().get_grid_blocks();
572+
const auto& grid_blocks = g_vpr_ctx.placement().grid_blocks();
573573
auto& device_ctx = g_vpr_ctx.device();
574574
const auto& rr_graph = device_ctx.rr_graph;
575575
auto& route_ctx = g_vpr_ctx.mutable_routing();

vpr/src/base/vpr_api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ void vpr_load_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
833833

834834
//Initialize placement data structures, which will be filled when loading placement
835835
auto& block_locs = place_ctx.mutable_block_locs();
836-
GridBlock& grid_blocks = place_ctx.get_mutable_grid_blocks();
836+
GridBlock& grid_blocks = place_ctx.mutable_grid_blocks();
837837
init_placement_context(block_locs, grid_blocks);
838838

839839
//Load an existing placement from a file
@@ -1283,7 +1283,7 @@ static void free_atoms() {
12831283
static void free_placement() {
12841284
auto& place_ctx = g_vpr_ctx.mutable_placement();
12851285
place_ctx.mutable_block_locs().clear();
1286-
place_ctx.get_mutable_grid_blocks().clear();
1286+
place_ctx.mutable_grid_blocks().clear();
12871287
}
12881288

12891289
static void free_routing() {

vpr/src/base/vpr_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ struct PlacementContext : public Context {
402402

403403
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs() const { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.block_locs(); }
404404
vtr::vector_map<ClusterBlockId, t_block_loc>& mutable_block_locs() { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.mutable_block_locs(); }
405-
const GridBlock& get_grid_blocks() const { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.grid_blocks(); }
406-
GridBlock& get_mutable_grid_blocks() { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.mutable_grid_blocks(); }
405+
const GridBlock& grid_blocks() const { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.grid_blocks(); }
406+
GridBlock& mutable_grid_blocks() { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.mutable_grid_blocks(); }
407407
vtr::vector_map<ClusterPinId, int>& mutable_physical_pins() { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.mutable_physical_pins(); }
408408
const vtr::vector_map<ClusterPinId, int>& physical_pins() const { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.physical_pins(); }
409409
BlkLocRegistry& mutable_blk_loc_registry() { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_; }

vpr/src/base/vpr_types.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,14 @@ class GridBlock {
908908
};
909909

910910
class BlkLocRegistry {
911+
public:
912+
BlkLocRegistry() = default;
913+
~BlkLocRegistry() = default;
914+
BlkLocRegistry(const BlkLocRegistry&) = delete;
915+
BlkLocRegistry& operator=(const BlkLocRegistry&) = default;
916+
BlkLocRegistry(BlkLocRegistry&&) = delete;
917+
BlkLocRegistry& operator=(BlkLocRegistry&&) = delete;
918+
911919
private:
912920
///@brief Clustered block placement locations
913921
vtr::vector_map<ClusterBlockId, t_block_loc> block_locs_;

vpr/src/place/analytic_placer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,9 @@ void AnalyticPlacer::build_solve_type(t_logical_block_type_ptr run, int iter) {
295295
// (stored in legal_pos). For a type of sub_tile_t found in tile_t, legal_pos[tile_t][sub_tile_t]
296296
// gives a vector containing all positions (t_pl_loc type) for this sub_tile_t.
297297
void AnalyticPlacer::build_legal_locations() {
298+
const auto& grid_blocks = placer_loc_vars_ref_.grid_blocks();
298299
// invoking same function used in initial_placement.cpp (can ignore function name)
299-
alloc_and_load_legal_placement_locations(legal_pos);
300+
alloc_and_load_legal_placement_locations(legal_pos, grid_blocks);
300301
}
301302

302303
// transfer initial placement from g_vpr_ctx to AnalyticPlacer data members, such as: blk_locs, place_blks

vpr/src/place/place_util.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ void zero_initialize_grid_blocks(GridBlock& grid_blocks) {
316316
}
317317
}
318318

319-
void alloc_and_load_legal_placement_locations(std::vector<std::vector<std::vector<t_pl_loc>>>& legal_pos) {
319+
void alloc_and_load_legal_placement_locations(std::vector<std::vector<std::vector<t_pl_loc>>>& legal_pos,
320+
const GridBlock& grid_blocks) {
320321
auto& device_ctx = g_vpr_ctx.device();
321-
auto& place_ctx = g_vpr_ctx.placement();
322322

323323
//alloc the legal placement positions
324324
int num_tile_types = device_ctx.physical_tile_types.size();
@@ -338,7 +338,7 @@ void alloc_and_load_legal_placement_locations(std::vector<std::vector<std::vecto
338338
auto capacity = sub_tile.capacity;
339339

340340
for (int k = 0; k < capacity.total(); k++) {
341-
if (place_ctx.get_grid_blocks().block_at_location({i, j, k + capacity.low, layer_num}) == INVALID_BLOCK_ID) {
341+
if (grid_blocks.block_at_location({i, j, k + capacity.low, layer_num}) == INVALID_BLOCK_ID) {
342342
continue;
343343
}
344344
// If this is the anchor position of a block, add it to the legal_pos.

vpr/src/place/place_util.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ void load_grid_blocks_from_block_locs(GridBlock& grid_blocks,
352352
* of the proper tile type and sub_tile type
353353
*
354354
*/
355-
void alloc_and_load_legal_placement_locations(std::vector<std::vector<std::vector<t_pl_loc>>>& legal_pos);
355+
void alloc_and_load_legal_placement_locations(std::vector<std::vector<std::vector<t_pl_loc>>>& legal_pos,
356+
const GridBlock& grid_blocks);
356357

357358
///@brief Performs error checking to see if location is legal for block type,
358359
/// and sets the location and grid usage of the block if it is legal.

vpr/src/power/power.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ static void power_usage_blocks(t_power_usage* power_usage) {
626626
t_pb* pb = nullptr;
627627
t_power_usage pb_power;
628628

629-
ClusterBlockId iblk = place_ctx.get_grid_blocks().block_at_location({x, y, z, layer_num});
629+
ClusterBlockId iblk = place_ctx.grid_blocks().block_at_location({x, y, z, layer_num});
630630

631631
if (iblk != EMPTY_BLOCK_ID && iblk != INVALID_BLOCK_ID) {
632632
pb = cluster_ctx.clb_nlist.block_pb(iblk);

vpr/src/route/overuse_report.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static void report_overused_ipin_opin(std::ostream& os,
242242

243243
//Add block type for IPINs/OPINs in overused rr-node report
244244
const auto& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
245-
const auto& grid_info = place_ctx.get_grid_blocks();
245+
const auto& grid_info = place_ctx.grid_blocks();
246246

247247
os << "Grid location: X = " << grid_x << ", Y = " << grid_y << '\n';
248248
os << "Number of blocks currently occupying this grid location = " << grid_info.get_usage({grid_x, grid_y, grid_layer}) << '\n';

vpr/src/util/vpr_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void sync_grid_to_blocks() {
127127

128128
const int num_layers = device_ctx.grid.get_num_layers();
129129

130-
auto& grid_blocks = place_ctx.get_mutable_grid_blocks();
130+
auto& grid_blocks = place_ctx.mutable_grid_blocks();
131131
auto& block_locs = place_ctx.block_locs();
132132

133133
/* Reset usage and allocate blocks list if needed */
@@ -2363,7 +2363,7 @@ std::vector<int> get_cluster_netlist_intra_tile_classes_at_loc(int layer,
23632363

23642364
const auto& place_ctx = g_vpr_ctx.placement();
23652365
const auto& atom_lookup = g_vpr_ctx.atom().lookup;
2366-
const auto& grid_block = place_ctx.get_grid_blocks();
2366+
const auto& grid_block = place_ctx.grid_blocks();
23672367

23682368
class_num_vec.reserve(physical_type->primitive_class_inf.size());
23692369

@@ -2394,7 +2394,7 @@ std::vector<int> get_cluster_netlist_intra_tile_pins_at_loc(const int layer,
23942394
const vtr::vector<ClusterBlockId, std::unordered_set<int>>& pin_chains_num,
23952395
t_physical_tile_type_ptr physical_type) {
23962396
const auto& place_ctx = g_vpr_ctx.placement();
2397-
const auto& grid_block = place_ctx.get_grid_blocks();
2397+
const auto& grid_block = place_ctx.grid_blocks();
23982398

23992399
std::vector<int> pin_num_vec;
24002400
pin_num_vec.reserve(get_tile_num_internal_pin(physical_type));

0 commit comments

Comments
 (0)