Skip to content

Commit ec8a7d1

Browse files
add compute_non_3d_sg_link_geometry() function
1 parent deac4fa commit ec8a7d1

File tree

4 files changed

+53
-50
lines changed

4 files changed

+53
-50
lines changed

vpr/src/route/rr_graph_generation/build_scatter_gathers.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,40 @@ void convert_interposer_cuts_to_sg_patterns(const std::vector<t_layer_def>& inte
393393
}
394394
}
395395
}
396+
397+
void compute_non_3d_sg_link_geometry(const t_physical_tile_loc& src_loc,
398+
const t_physical_tile_loc& dst_loc,
399+
e_rr_type& chan_type,
400+
int& xlow, int& xhigh,
401+
int& ylow, int& yhigh,
402+
Direction& direction) {
403+
VTR_ASSERT_SAFE(src_loc.layer_num == dst_loc.layer_num);
404+
405+
if (dst_loc.x > src_loc.x) {
406+
chan_type = e_rr_type::CHANX;
407+
ylow = yhigh = dst_loc.y;
408+
xlow = src_loc.x + 1;
409+
xhigh = dst_loc.x;
410+
direction = Direction::INC;
411+
} else if (dst_loc.x < src_loc.x) {
412+
chan_type = e_rr_type::CHANX;
413+
ylow = yhigh = dst_loc.y;
414+
xlow = dst_loc.x + 1;
415+
xhigh = src_loc.x;
416+
direction = Direction::DEC;
417+
} else if (dst_loc.y > src_loc.y) {
418+
chan_type = e_rr_type::CHANY;
419+
xlow = xhigh = dst_loc.x;
420+
ylow = src_loc.y + 1;
421+
yhigh = dst_loc.y;
422+
direction = Direction::INC;
423+
} else if (dst_loc.y < src_loc.y) {
424+
chan_type = e_rr_type::CHANY;
425+
xlow = xhigh = dst_loc.x;
426+
ylow = dst_loc.y + 1;
427+
yhigh = src_loc.y;
428+
direction = Direction::DEC;
429+
} else {
430+
VTR_ASSERT_MSG(false, "Source and destination locations cannot be identical");
431+
}
432+
}

vpr/src/route/rr_graph_generation/build_scatter_gathers.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,14 @@ std::vector<t_bottleneck_link> alloc_and_load_scatter_gather_connections(const s
7474
*/
7575
void convert_interposer_cuts_to_sg_patterns(const std::vector<t_layer_def>& interposer_inf,
7676
std::vector<t_scatter_gather_pattern>& sg_patterns);
77+
78+
/**
79+
* @brief Computes the channel type, direction, and coordinate span between two locations
80+
* on the same layer. Used by SG link construction routines to determine geometry.
81+
*/
82+
void compute_non_3d_sg_link_geometry(const t_physical_tile_loc& src_loc,
83+
const t_physical_tile_loc& dst_loc,
84+
e_rr_type& chan_type,
85+
int& xlow, int& xhigh,
86+
int& ylow, int& yhigh,
87+
Direction& direction);

vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,37 +2074,15 @@ static void add_and_connect_non_3d_sg_links(RRGraphBuilder& rr_graph_builder,
20742074

20752075
int xlow, xhigh, ylow, yhigh;
20762076
Direction direction;
2077+
e_rr_type chan_type;
20772078
const t_physical_tile_loc& src_loc = link.gather_loc;
20782079
const t_physical_tile_loc& dst_loc = link.scatter_loc;
20792080

20802081
// Step 1: Determine the link’s direction and its spatial span.
20812082
// SG links are confined to one layer (non-3D), but can run in X or Y.
20822083
VTR_ASSERT_SAFE(src_loc.layer_num == dst_loc.layer_num);
20832084
const int layer = src_loc.layer_num;
2084-
2085-
if (dst_loc.x > src_loc.x) {
2086-
direction = Direction::INC;
2087-
ylow = yhigh = dst_loc.y;
2088-
xlow = src_loc.x + 1;
2089-
xhigh = dst_loc.x;
2090-
} else if (dst_loc.x < src_loc.x) {
2091-
direction = Direction::DEC;
2092-
ylow = yhigh = dst_loc.y;
2093-
xlow = dst_loc.x + 1;
2094-
xhigh = src_loc.x;
2095-
} else if (dst_loc.y > src_loc.y) {
2096-
direction = Direction::INC;
2097-
xlow = xhigh = dst_loc.x;
2098-
ylow = src_loc.y + 1;
2099-
yhigh = dst_loc.y;
2100-
} else if (dst_loc.y < src_loc.y) {
2101-
direction = Direction::DEC;
2102-
xlow = xhigh = dst_loc.x;
2103-
ylow = dst_loc.y + 1;
2104-
yhigh = src_loc.y;
2105-
} else {
2106-
VTR_ASSERT(false);
2107-
}
2085+
compute_non_3d_sg_link_geometry(src_loc, dst_loc, chan_type, xlow, xhigh, ylow, yhigh,direction);
21082086

21092087
// Retrieve the node ID and track number allocated earlier
21102088
const RRNodeId node_id = sg_node_indices[i].first;

vpr/src/route/rr_graph_generation/rr_node_indices.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -380,36 +380,13 @@ std::vector<std::pair<RRNodeId, int>> alloc_and_load_non_3d_sg_pattern_rr_node_i
380380
for (const t_bottleneck_link& link : bottleneck_links) {
381381
int xlow, xhigh, ylow, yhigh;
382382
e_rr_type chan_type;
383+
Direction direction;
383384
const t_physical_tile_loc& src_loc = link.gather_loc;
384385
const t_physical_tile_loc& dst_loc = link.scatter_loc;
385386

386-
VTR_ASSERT_SAFE(src_loc.layer_num == dst_loc.layer_num);
387-
const int layer = src_loc.layer_num;
388-
389387
// Step 1: Determine the channel type (CHANX/CHANY) and span coordinates
390-
if (dst_loc.x > src_loc.x) {
391-
chan_type = e_rr_type::CHANX;
392-
ylow = yhigh = dst_loc.y;
393-
xlow = src_loc.x + 1;
394-
xhigh = dst_loc.x;
395-
} else if (dst_loc.x < src_loc.x) {
396-
chan_type = e_rr_type::CHANX;
397-
ylow = yhigh = dst_loc.y;
398-
xlow = dst_loc.x + 1;
399-
xhigh = src_loc.x;
400-
} else if (dst_loc.y > src_loc.y) {
401-
chan_type = e_rr_type::CHANY;
402-
xlow = xhigh = dst_loc.x;
403-
ylow = src_loc.y + 1;
404-
yhigh = dst_loc.y;
405-
} else if (dst_loc.y < src_loc.y) {
406-
chan_type = e_rr_type::CHANY;
407-
xlow = xhigh = dst_loc.x;
408-
ylow = dst_loc.y + 1;
409-
yhigh = src_loc.y;
410-
} else {
411-
VTR_ASSERT(false);
412-
}
388+
const int layer = src_loc.layer_num;
389+
compute_non_3d_sg_link_geometry(src_loc, dst_loc, chan_type, xlow, xhigh, ylow, yhigh,direction);
413390

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

0 commit comments

Comments
 (0)