Skip to content

Commit f073047

Browse files
doxygen and implementation comments for alloc_and_load_non_3d_sg_pattern_rr_node_indices()
1 parent 97bd7b1 commit f073047

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

vpr/src/route/rr_graph_generation/rr_node_indices.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ std::vector<std::pair<RRNodeId, int>> alloc_and_load_non_3d_sg_pattern_rr_node_i
370370
const DeviceContext& device_ctx = g_vpr_ctx.device();
371371
const DeviceGrid& grid = device_ctx.grid;
372372

373+
// Initialize matrices tracking the next free track number (ptc)
373374
vtr::NdMatrix<int, 3> chanx_ptc({grid.get_num_layers(), grid.width(), grid.height()}, chan_width_inf.x_max);
374375
vtr::NdMatrix<int, 3> chany_ptc({grid.get_num_layers(), grid.width(), grid.height()}, chan_width_inf.y_max);
375376

@@ -385,6 +386,7 @@ std::vector<std::pair<RRNodeId, int>> alloc_and_load_non_3d_sg_pattern_rr_node_i
385386
VTR_ASSERT_SAFE(src_loc.layer_num == dst_loc.layer_num);
386387
const int layer = src_loc.layer_num;
387388

389+
// Step 1: Determine the channel type (CHANX/CHANY) and span coordinates
388390
if (dst_loc.x > src_loc.x) {
389391
chan_type = e_rr_type::CHANX;
390392
ylow = yhigh = dst_loc.y;
@@ -409,21 +411,29 @@ std::vector<std::pair<RRNodeId, int>> alloc_and_load_non_3d_sg_pattern_rr_node_i
409411
VTR_ASSERT(false);
410412
}
411413

414+
// Select the appropriate ptc matrix for this channel type
412415
vtr::NdMatrix<int, 3>& ptc_matrix = (chan_type == e_rr_type::CHANX) ? chanx_ptc : chany_ptc;
413416

417+
// Step 2: Find the maximum next-free ptc value across all (x,y) cells
418+
// spanned by this SG link. We use the max to ensure that the chosen
419+
// ptc number is free along the entire length of the node
414420
int ptc = 0;
415421
for (int x = xlow; x <= xhigh; x++) {
416422
for (int y = ylow; y <= yhigh; y++) {
417423
ptc = std::max(ptc, ptc_matrix[layer][x][y]);
418424
}
419425
}
420426

427+
// Step 3: Sanity check: no existing node should occupy this (layer,x,y,ptc)
421428
VTR_ASSERT(rr_graph_builder.node_lookup().find_nodes_in_range(layer, xlow, ylow, xhigh, yhigh, chan_type, ptc).empty());
422429

430+
// Step 4: Allocate a new RR node ID and record its (inode, ptc)
423431
const RRNodeId inode = RRNodeId(index);
424432
node_indices.push_back({inode, ptc});
425433
index++;
426434

435+
// Step 5: Register this node in the spatial lookup for every (x,y)
436+
// location it spans, and update ptc_matrix to mark this track as used.
427437
for (int x = xlow; x <= xhigh; x++) {
428438
for (int y = ylow; y <= yhigh; y++) {
429439
rr_graph_builder.node_lookup().add_node(inode, layer, x, y, chan_type, ptc);
@@ -432,6 +442,7 @@ std::vector<std::pair<RRNodeId, int>> alloc_and_load_non_3d_sg_pattern_rr_node_i
432442
}
433443
}
434444

445+
// Later, another routine will use this info to add nodes and edges to RR graph
435446
return node_indices;
436447
}
437448

vpr/src/route/rr_graph_generation/rr_node_indices.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ void alloc_and_load_inter_die_rr_node_indices(RRGraphBuilder& rr_graph_builder,
4141
const vtr::NdMatrix<std::vector<t_bottleneck_link>, 2>& interdie_3d_links,
4242
int* index);
4343

44+
/**
45+
* @brief Allocates RR nodes for non-3D scatter–gather links.
46+
*
47+
* Creates RR node indices for each bottleneck link, assigns track numbers
48+
* within CHANX/CHANY channels, and updates the RR graph lookup tables.
49+
*
50+
* @return A list of created RR node IDs paired with their track numbers.
51+
*/
4452
std::vector<std::pair<RRNodeId, int>> alloc_and_load_non_3d_sg_pattern_rr_node_indices(RRGraphBuilder& rr_graph_builder,
4553
const std::vector<t_bottleneck_link>& bottleneck_links,
4654
const t_chan_width& chan_width_inf,

0 commit comments

Comments
 (0)