Skip to content

Commit d2af592

Browse files
move add_and_connect_non_3d_sg_links() to rr_graph_sg
1 parent 0097c56 commit d2af592

File tree

3 files changed

+110
-110
lines changed

3 files changed

+110
-110
lines changed

vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -360,30 +360,6 @@ static void build_rr_graph(e_graph_type graph_type,
360360
static int get_delayless_switch_id(const t_det_routing_arch& det_routing_arch,
361361
bool load_rr_graph);
362362

363-
/**
364-
* @brief Adds and connects non-3D scatter–gather (SG) links to the RR graph.
365-
*
366-
* For each bottleneck link, this function creates a corresponding RR node
367-
* representing the non-3D SG link, and records edges between the node and
368-
* gather and scatter wires. The edges are stored in `non_3d_sg_rr_edges_to_create`
369-
* for deferred creation.
370-
*
371-
* @param rr_graph_builder Reference to the RR graph builder.
372-
* @param sg_links List of scatter–gather bottleneck links.
373-
* @param sg_node_indices RR node IDs and track numbers for SG links.
374-
* @param chan_details_x Channel details for CHANX segments.
375-
* @param chan_details_y Channel details for CHANY segments.
376-
* @param num_seg_types_x Number of segment types in the X direction.
377-
* @param non_3d_sg_rr_edges_to_create Set collecting RR edges to create later.
378-
*/
379-
static void add_and_connect_non_3d_sg_links(RRGraphBuilder& rr_graph_builder,
380-
const std::vector<t_bottleneck_link>& sg_links,
381-
const std::vector<std::pair<RRNodeId, int>>& sg_node_indices,
382-
const t_chan_details& chan_details_x,
383-
const t_chan_details& chan_details_y,
384-
size_t num_seg_types_x,
385-
t_rr_edge_info_set& non_3d_sg_rr_edges_to_create);
386-
387363
/**
388364
* @brief Calculates the routing channel width at each grid location.
389365
*
@@ -2001,92 +1977,6 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
20011977
}
20021978
}
20031979

2004-
static void add_and_connect_non_3d_sg_links(RRGraphBuilder& rr_graph_builder,
2005-
const std::vector<t_bottleneck_link>& sg_links,
2006-
const std::vector<std::pair<RRNodeId, int>>& sg_node_indices,
2007-
const t_chan_details& chan_details_x,
2008-
const t_chan_details& chan_details_y,
2009-
size_t num_seg_types_x,
2010-
t_rr_edge_info_set& non_3d_sg_rr_edges_to_create) {
2011-
// Each SG link should have a corresponding RR node index
2012-
VTR_ASSERT(sg_links.size() == sg_node_indices.size());
2013-
const size_t num_links = sg_links.size();
2014-
2015-
for (size_t i = 0; i < num_links; i++) {
2016-
2017-
const t_bottleneck_link& link = sg_links[i];
2018-
2019-
int xlow, xhigh, ylow, yhigh;
2020-
Direction direction;
2021-
e_rr_type chan_type;
2022-
const t_physical_tile_loc& src_loc = link.gather_loc;
2023-
const t_physical_tile_loc& dst_loc = link.scatter_loc;
2024-
2025-
// Step 1: Determine the link’s direction and its spatial span.
2026-
// SG links are confined to one layer (non-3D), but can run in X or Y.
2027-
VTR_ASSERT_SAFE(src_loc.layer_num == dst_loc.layer_num);
2028-
const int layer = src_loc.layer_num;
2029-
compute_non_3d_sg_link_geometry(src_loc, dst_loc, chan_type, xlow, xhigh, ylow, yhigh,direction);
2030-
2031-
// Retrieve the node ID and track number allocated earlier
2032-
const RRNodeId node_id = sg_node_indices[i].first;
2033-
const int track_num = sg_node_indices[i].second;
2034-
2035-
// Step 2: Assign coordinates
2036-
rr_graph_builder.set_node_layer(node_id, layer, layer);
2037-
rr_graph_builder.set_node_coordinates(node_id, xlow, ylow, xhigh, yhigh);
2038-
rr_graph_builder.set_node_capacity(node_id, 1);
2039-
2040-
// Step 3: Set cost index based on segment type and orientation
2041-
const size_t cons_index = link.chan_type == e_rr_type::CHANX ? CHANX_COST_INDEX_START + link.parallel_segment_index
2042-
: CHANX_COST_INDEX_START + num_seg_types_x + link.parallel_segment_index;
2043-
rr_graph_builder.set_node_cost_index(node_id, RRIndexedDataId(cons_index));
2044-
2045-
// Step 4: Assign electrical characteristics
2046-
const NodeRCIndex rc_index = find_create_rr_rc_data(link.R_metal, link.C_metal, g_vpr_ctx.mutable_device().rr_rc_data);
2047-
rr_graph_builder.set_node_rc_index(node_id, rc_index);
2048-
// Step 5: Set node type, track number, and direction
2049-
rr_graph_builder.set_node_type(node_id, link.chan_type);
2050-
rr_graph_builder.set_node_track_num(node_id, track_num);
2051-
rr_graph_builder.set_node_direction(node_id, direction);
2052-
2053-
// Step 6: Add incoming edges from gather (fanin) channel wires
2054-
// Each gather wire connects to this SG link node using the SG wire switch.
2055-
for (const t_sg_candidate& gather_wire : link.gather_fanin_connections) {
2056-
const t_physical_tile_loc& chan_loc = gather_wire.chan_loc.location;
2057-
e_rr_type gather_chan_type = gather_wire.chan_loc.chan_type;
2058-
2059-
// Locate the source RR node for this gather wire
2060-
RRNodeId gather_node = rr_graph_builder.node_lookup().find_node(chan_loc.layer_num,
2061-
chan_loc.x,
2062-
chan_loc.y,
2063-
gather_chan_type,
2064-
gather_wire.wire_switchpoint.wire);
2065-
// Record deferred edge creation (gather_node --> sg_node)
2066-
non_3d_sg_rr_edges_to_create.emplace_back(gather_node, node_id, link.arch_wire_switch, false);
2067-
}
2068-
2069-
// Step 7: Add outgoing edges to scatter (fanout) channel wires
2070-
// Each scatter wire connects from this SG link node outward.
2071-
for (const t_sg_candidate& scatter_wire : link.scatter_fanout_connections) {
2072-
const t_physical_tile_loc& chan_loc = scatter_wire.chan_loc.location;
2073-
e_rr_type scatter_chan_type = scatter_wire.chan_loc.chan_type;
2074-
const t_chan_details& chan_details = (scatter_chan_type == e_rr_type::CHANX) ? chan_details_x : chan_details_y;
2075-
2076-
// Locate the destination RR node for this scatter wire
2077-
RRNodeId scatter_node = rr_graph_builder.node_lookup().find_node(chan_loc.layer_num,
2078-
chan_loc.x,
2079-
chan_loc.y,
2080-
scatter_chan_type,
2081-
scatter_wire.wire_switchpoint.wire);
2082-
// Determine which architecture switch this edge should use
2083-
int switch_index = chan_details[chan_loc.x][chan_loc.y][scatter_wire.wire_switchpoint.wire].arch_wire_switch();
2084-
// Record deferred edge creation (sg_node --> scatter_node)
2085-
non_3d_sg_rr_edges_to_create.emplace_back(node_id, scatter_node, switch_index, false);
2086-
}
2087-
}
2088-
}
2089-
20901980
void alloc_and_load_edges(RRGraphBuilder& rr_graph_builder, const t_rr_edge_info_set& rr_edges_to_create) {
20911981
rr_graph_builder.alloc_and_load_edges(&rr_edges_to_create);
20921982
}

vpr/src/route/rr_graph_generation/rr_graph_sg.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,90 @@ void add_edges_opin_chanz(const RRGraphView& rr_graph,
148148
}
149149
}
150150
}
151+
}
152+
153+
void add_and_connect_non_3d_sg_links(RRGraphBuilder& rr_graph_builder,
154+
const std::vector<t_bottleneck_link>& sg_links,
155+
const std::vector<std::pair<RRNodeId, int>>& sg_node_indices,
156+
const t_chan_details& chan_details_x,
157+
const t_chan_details& chan_details_y,
158+
size_t num_seg_types_x,
159+
t_rr_edge_info_set& non_3d_sg_rr_edges_to_create) {
160+
// Each SG link should have a corresponding RR node index
161+
VTR_ASSERT(sg_links.size() == sg_node_indices.size());
162+
const size_t num_links = sg_links.size();
163+
164+
for (size_t i = 0; i < num_links; i++) {
165+
166+
const t_bottleneck_link& link = sg_links[i];
167+
168+
int xlow, xhigh, ylow, yhigh;
169+
Direction direction;
170+
e_rr_type chan_type;
171+
const t_physical_tile_loc& src_loc = link.gather_loc;
172+
const t_physical_tile_loc& dst_loc = link.scatter_loc;
173+
174+
// Step 1: Determine the link’s direction and its spatial span.
175+
// SG links are confined to one layer (non-3D), but can run in X or Y.
176+
VTR_ASSERT_SAFE(src_loc.layer_num == dst_loc.layer_num);
177+
const int layer = src_loc.layer_num;
178+
compute_non_3d_sg_link_geometry(src_loc, dst_loc, chan_type, xlow, xhigh, ylow, yhigh,direction);
179+
180+
// Retrieve the node ID and track number allocated earlier
181+
const RRNodeId node_id = sg_node_indices[i].first;
182+
const int track_num = sg_node_indices[i].second;
183+
184+
// Step 2: Assign coordinates
185+
rr_graph_builder.set_node_layer(node_id, layer, layer);
186+
rr_graph_builder.set_node_coordinates(node_id, xlow, ylow, xhigh, yhigh);
187+
rr_graph_builder.set_node_capacity(node_id, 1);
188+
189+
// Step 3: Set cost index based on segment type and orientation
190+
const size_t cons_index = link.chan_type == e_rr_type::CHANX ? CHANX_COST_INDEX_START + link.parallel_segment_index
191+
: CHANX_COST_INDEX_START + num_seg_types_x + link.parallel_segment_index;
192+
rr_graph_builder.set_node_cost_index(node_id, RRIndexedDataId(cons_index));
193+
194+
// Step 4: Assign electrical characteristics
195+
const NodeRCIndex rc_index = find_create_rr_rc_data(link.R_metal, link.C_metal, g_vpr_ctx.mutable_device().rr_rc_data);
196+
rr_graph_builder.set_node_rc_index(node_id, rc_index);
197+
// Step 5: Set node type, track number, and direction
198+
rr_graph_builder.set_node_type(node_id, link.chan_type);
199+
rr_graph_builder.set_node_track_num(node_id, track_num);
200+
rr_graph_builder.set_node_direction(node_id, direction);
201+
202+
// Step 6: Add incoming edges from gather (fanin) channel wires
203+
// Each gather wire connects to this SG link node using the SG wire switch.
204+
for (const t_sg_candidate& gather_wire : link.gather_fanin_connections) {
205+
const t_physical_tile_loc& chan_loc = gather_wire.chan_loc.location;
206+
e_rr_type gather_chan_type = gather_wire.chan_loc.chan_type;
207+
208+
// Locate the source RR node for this gather wire
209+
RRNodeId gather_node = rr_graph_builder.node_lookup().find_node(chan_loc.layer_num,
210+
chan_loc.x,
211+
chan_loc.y,
212+
gather_chan_type,
213+
gather_wire.wire_switchpoint.wire);
214+
// Record deferred edge creation (gather_node --> sg_node)
215+
non_3d_sg_rr_edges_to_create.emplace_back(gather_node, node_id, link.arch_wire_switch, false);
216+
}
217+
218+
// Step 7: Add outgoing edges to scatter (fanout) channel wires
219+
// Each scatter wire connects from this SG link node outward.
220+
for (const t_sg_candidate& scatter_wire : link.scatter_fanout_connections) {
221+
const t_physical_tile_loc& chan_loc = scatter_wire.chan_loc.location;
222+
e_rr_type scatter_chan_type = scatter_wire.chan_loc.chan_type;
223+
const t_chan_details& chan_details = (scatter_chan_type == e_rr_type::CHANX) ? chan_details_x : chan_details_y;
224+
225+
// Locate the destination RR node for this scatter wire
226+
RRNodeId scatter_node = rr_graph_builder.node_lookup().find_node(chan_loc.layer_num,
227+
chan_loc.x,
228+
chan_loc.y,
229+
scatter_chan_type,
230+
scatter_wire.wire_switchpoint.wire);
231+
// Determine which architecture switch this edge should use
232+
int switch_index = chan_details[chan_loc.x][chan_loc.y][scatter_wire.wire_switchpoint.wire].arch_wire_switch();
233+
// Record deferred edge creation (sg_node --> scatter_node)
234+
non_3d_sg_rr_edges_to_create.emplace_back(node_id, scatter_node, switch_index, false);
235+
}
236+
}
151237
}

vpr/src/route/rr_graph_generation/rr_graph_sg.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,27 @@ void add_edges_opin_chanz(const RRGraphView& rr_graph,
3939
int num_seg_types,
4040
t_rr_edge_info_set& rr_edges_to_create,
4141
const std::vector<t_bottleneck_link>& interdie_3d_links);
42+
43+
/**
44+
* @brief Adds and connects non-3D scatter–gather (SG) links to the RR graph.
45+
*
46+
* For each bottleneck link, this function creates a corresponding RR node
47+
* representing the non-3D SG link, and records edges between the node and
48+
* gather and scatter wires. The edges are stored in `non_3d_sg_rr_edges_to_create`
49+
* for deferred creation.
50+
*
51+
* @param rr_graph_builder Reference to the RR graph builder.
52+
* @param sg_links List of scatter–gather bottleneck links.
53+
* @param sg_node_indices RR node IDs and track numbers for SG links.
54+
* @param chan_details_x Channel details for CHANX segments.
55+
* @param chan_details_y Channel details for CHANY segments.
56+
* @param num_seg_types_x Number of segment types in the X direction.
57+
* @param non_3d_sg_rr_edges_to_create Set collecting RR edges to create later.
58+
*/
59+
void add_and_connect_non_3d_sg_links(RRGraphBuilder& rr_graph_builder,
60+
const std::vector<t_bottleneck_link>& sg_links,
61+
const std::vector<std::pair<RRNodeId, int>>& sg_node_indices,
62+
const t_chan_details& chan_details_x,
63+
const t_chan_details& chan_details_y,
64+
size_t num_seg_types_x,
65+
t_rr_edge_info_set& non_3d_sg_rr_edges_to_create);

0 commit comments

Comments
 (0)