Skip to content

Commit e297202

Browse files
add rr_chanx/y_list to device context
1 parent 416ce96 commit e297202

File tree

3 files changed

+32
-29
lines changed

3 files changed

+32
-29
lines changed

vpr/src/base/vpr_context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ struct DeviceContext : public Context {
268268
/// Stores the number of CHANY wire segments in each routing channel at [layer][x][y]
269269
vtr::NdMatrix<int, 3> rr_chany_width;
270270

271+
std::vector<int> rr_chanx_list;
272+
std::vector<int> rr_chany_list;
273+
271274
bool rr_graph_is_flat = false;
272275

273276
/*

vpr/src/draw/draw.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,25 +463,17 @@ void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry) {
463463
}
464464
}
465465

466-
std::vector<int> chanx_width_list(grid.height(), 0);
467-
std::vector<int> chany_width_list(grid.width(), 0);
468-
469-
for (t_physical_tile_loc loc : grid.all_locations()) {
470-
chanx_width_list[loc.y] = std::max(device_ctx.rr_chanx_width[loc.layer_num][loc.x][loc.y], chanx_width_list[loc.y]);
471-
chany_width_list[loc.x] = std::max(device_ctx.rr_chany_width[loc.layer_num][loc.x][loc.y], chany_width_list[loc.x]);
472-
}
473-
474466
size_t j = 0;
475467
for (size_t i = 0; i < grid.width() - 1; i++) {
476468
draw_coords->tile_x[i] = (i * draw_coords->get_tile_width()) + j;
477-
j += chany_width_list[i] + 1; // N wires need N+1 units of space
469+
j += device_ctx.rr_chany_list[i] + 1; // N wires need N+1 units of space
478470
}
479471
draw_coords->tile_x[grid.width() - 1] = (grid.width() - 1) * draw_coords->get_tile_width() + j;
480472

481473
j = 0;
482474
for (size_t i = 0; i < device_ctx.grid.height() - 1; ++i) {
483475
draw_coords->tile_y[i] = (i * draw_coords->get_tile_width()) + j;
484-
j += chanx_width_list[i] + 1;
476+
j += device_ctx.rr_chanx_list[i] + 1;
485477
}
486478
draw_coords->tile_y[grid.height() - 1] = (grid.height() - 1) * draw_coords->get_tile_width() + j;
487479

vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,10 @@ static int get_delayless_switch_id(const t_det_routing_arch& det_routing_arch,
379379
/**
380380
* @brief Calculates the routing channel width at each grid location.
381381
*
382-
* Iterates through all RR nodes and counts how many wires pass through each (x, y) location
382+
* Iterates through all RR nodes and counts how many wires pass through each (layer, x, y) location
383383
* for both horizontal (CHANX) and vertical (CHANY) channels.
384-
*
385-
* @return A pair of 3D matrices:
386-
* - First: CHANX width per [layer][x][y]
387-
* - Second: CHANY width per [layer][x][y]
388384
*/
389-
static std::pair<vtr::NdMatrix<int, 3>, vtr::NdMatrix<int, 3>> calculate_channel_width();
385+
static void alloc_and_init_channel_width();
390386

391387
/******************* Subroutine definitions *******************************/
392388

@@ -545,7 +541,7 @@ void create_rr_graph(e_graph_type graph_type,
545541
device_ctx.rr_graph.rr_nodes(),
546542
is_flat);
547543

548-
std::tie(mutable_device_ctx.rr_chanx_width, mutable_device_ctx.rr_chany_width) = calculate_channel_width();
544+
alloc_and_init_channel_width();
549545

550546
print_rr_graph_stats();
551547

@@ -1130,19 +1126,19 @@ static int get_delayless_switch_id(const t_det_routing_arch& det_routing_arch,
11301126
return delayless_switch;
11311127
}
11321128

1133-
static std::pair<vtr::NdMatrix<int, 3>, vtr::NdMatrix<int, 3>> calculate_channel_width() {
1134-
const auto& device_ctx = g_vpr_ctx.device();
1135-
const auto& rr_graph = device_ctx.rr_graph;
1129+
static void alloc_and_init_channel_width() {
1130+
DeviceContext& mutable_device_ctx = g_vpr_ctx.mutable_device();
1131+
const DeviceGrid& grid = mutable_device_ctx.grid;
1132+
const auto& rr_graph = mutable_device_ctx.rr_graph;
1133+
1134+
vtr::NdMatrix<int, 3>& chanx_width = mutable_device_ctx.rr_chanx_width;
1135+
vtr::NdMatrix<int, 3>& chany_width = mutable_device_ctx.rr_chany_width;
11361136

1137-
auto chanx_width = vtr::NdMatrix<int, 3>({{device_ctx.grid.get_num_layers(),
1138-
device_ctx.grid.width(),
1139-
device_ctx.grid.height()}},
1140-
0);
1137+
chanx_width.resize({grid.get_num_layers(), grid.width(), grid.height()});
1138+
chany_width.resize({grid.get_num_layers(), grid.width(), grid.height()});
11411139

1142-
auto chany_width = vtr::NdMatrix<int, 3>({{device_ctx.grid.get_num_layers(),
1143-
device_ctx.grid.width(),
1144-
device_ctx.grid.height()}},
1145-
0);
1140+
chanx_width.fill(0);
1141+
chany_width.fill(0);
11461142

11471143
for (RRNodeId node_id : rr_graph.nodes()) {
11481144
e_rr_type rr_type = rr_graph.node_type(node_id);
@@ -1162,7 +1158,19 @@ static std::pair<vtr::NdMatrix<int, 3>, vtr::NdMatrix<int, 3>> calculate_channel
11621158
}
11631159
}
11641160

1165-
return {chanx_width, chany_width};
1161+
std::vector<int>& chanx_width_list = mutable_device_ctx.rr_chanx_list;
1162+
std::vector<int>& chany_width_list = mutable_device_ctx.rr_chany_list;
1163+
1164+
chanx_width_list.resize(grid.height());
1165+
chany_width_list.resize(grid.width());
1166+
1167+
std::ranges::fill(chanx_width_list, 0);
1168+
std::ranges::fill(chany_width_list, 0);
1169+
1170+
for (t_physical_tile_loc loc : grid.all_locations()) {
1171+
chanx_width_list[loc.y] = std::max(chanx_width[loc.layer_num][loc.x][loc.y], chanx_width_list[loc.y]);
1172+
chany_width_list[loc.x] = std::max(chany_width[loc.layer_num][loc.x][loc.y], chany_width_list[loc.x]);
1173+
}
11661174
}
11671175

11681176
void build_tile_rr_graph(RRGraphBuilder& rr_graph_builder,

0 commit comments

Comments
 (0)