Skip to content

Commit ef319d7

Browse files
Improve RR Graph Interposer comments
1 parent 0c0f149 commit ef319d7

File tree

5 files changed

+109
-20
lines changed

5 files changed

+109
-20
lines changed

libs/librrgraph/src/base/rr_graph_builder.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,11 @@ class RRGraphBuilder {
352352
node_storage_.alloc_and_load_edges(rr_edges_to_create);
353353
}
354354

355-
/** @brief Removes a given list of RREdgeIds for the RR Graph.
355+
/** @brief Removes a given list of RREdgeIds from the RR Graph.
356356
* This method does not preserve the order of edges. If you're
357-
* calling it after partition_edges has been called, you need
358-
* to call it again.
357+
* calling it after partition_edges has been called, you will
358+
* need to call partition_edges again.
359+
* This operation is O(#RR Graph edges) and should not be called frequently.
359360
*
360361
* @param rr_edges_to_remove list of RREdgeIds to be removed
361362
*/

libs/librrgraph/src/base/rr_graph_storage.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class t_rr_graph_storage {
401401
}
402402

403403
/** @brief Returns a range of all edges in the RR Graph.
404-
* This method does not depend on the edges begin correctly
404+
* This method does not depend on the edges being correctly
405405
* sorted and can be used before partition_edges is called.
406406
*/
407407
inline vtr::StrongIdRange<RREdgeId> all_edges() const {
@@ -784,10 +784,11 @@ class t_rr_graph_storage {
784784
/** @brief Adds a batch of edges.*/
785785
void alloc_and_load_edges(const t_rr_edge_info_set* rr_edges_to_create);
786786

787-
/** @brief Removes a given list of RREdgeIds for the RR Graph.
787+
/** @brief Removes a given list of RREdgeIds from the RR Graph.
788788
* This method does not preserve the order of edges. If you're
789-
* calling it after partition_edges has been called, you need
790-
* to call it again.
789+
* calling it after partition_edges has been called, you will
790+
* need to call partition_edges again.
791+
* This operation is O(#RR Graph edges) and should not be called frequently.
791792
*
792793
* @param rr_edges_to_remove list of RREdgeIds to be removed
793794
*/

vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
16711671

16721672
// If there are any interposer cuts, remove the edges and shorten the wires that cross interposer cut lines.
16731673
if (grid.has_interposer_cuts()) {
1674-
std::vector<RREdgeId> interposer_edges = mark_interposer_cut_edges_for_removal(rr_graph, grid);
1674+
std::vector<RREdgeId> interposer_edges = get_interposer_cut_edges_for_removal(rr_graph, grid);
16751675
rr_graph_builder.remove_edges(interposer_edges);
16761676

16771677
update_interposer_crossing_nodes_in_spatial_lookup_and_rr_graph_storage(rr_graph, grid, rr_graph_builder, sg_node_indices);

vpr/src/route/rr_graph_generation/rr_graph_interposer.cpp

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @file interposer_cut.h
3+
* @brief This file implements functions can be used to generate RR Graphs for 2.5D architectures. See rr_graph_interposer.h for more details.
4+
*/
5+
16
#include <cstddef>
27
#include <utility>
38
#include <vector>
@@ -19,7 +24,7 @@
1924
// Static function declarations
2025

2126
/**
22-
* @brief Takes location of a source and a sink and determines wether it crosses cut_loc or not.
27+
* @brief Takes location of a source and a sink and determines whether it crosses cut_loc or not.
2328
* For example, the interval (1, 4) is cut by 3, while it is not cut by 5 or 0.
2429
*/
2530
static bool should_cut(int src_loc, int sink_loc, int cut_loc);
@@ -35,11 +40,23 @@ static short node_xstart(const RRGraphView& rr_graph, RRNodeId node);
3540
static short node_ystart(const RRGraphView& rr_graph, RRNodeId node);
3641

3742
/**
38-
* @brief Update a CHANY node's bounding box in RRGraph and SpatialLookup entries.
43+
* @brief Update a CHANY node's bounding box in RR Graph and Spatial Lookup entries.
3944
* This function assumes that the channel node actually crosses the cut location and
4045
* might not function correctly otherwise.
4146
*
4247
* This is a low level function, you should use cut_channel_node that wraps this up in a nicer API.
48+
*
49+
* @param node Node's ID
50+
* @param x_low Node's lower x position
51+
* @param y_low Node's lower y position
52+
* @param x_high Node's higher x position
53+
* @param y_high Node's higher y position
54+
* @param layer Node's layer
55+
* @param ptc_num Node's ptc_num
56+
* @param cut_loc_y y location of horizontal interposer cut line
57+
* @param node_direction Node's direction
58+
* @param rr_graph_builder RR Graph builder for mutating the RR Graph
59+
* @param spatial_lookup RR Graph spatial lookup
4360
*/
4461
static void cut_chan_y_node(RRNodeId node,
4562
int x_low,
@@ -59,6 +76,18 @@ static void cut_chan_y_node(RRNodeId node,
5976
* might not function correctly otherwise.
6077
*
6178
* This is a low level function, you should use cut_channel_node that wraps this up in a nicer API.
79+
*
80+
* @param node Node's ID
81+
* @param x_low Node's lower x position
82+
* @param y_low Node's lower y position
83+
* @param x_high Node's higher x position
84+
* @param y_high Node's higher y position
85+
* @param layer Node's layer
86+
* @param ptc_num Node's ptc_num
87+
* @param cut_loc_x x location of vertical interposer cut line
88+
* @param node_direction Node's direction
89+
* @param rr_graph_builder RR Graph builder for mutating the RR Graph
90+
* @param spatial_lookup RR Graph spatial lookup
6291
*/
6392
static void cut_chan_x_node(RRNodeId node,
6493
int x_low,
@@ -167,11 +196,10 @@ static short node_ystart(const RRGraphView& rr_graph, RRNodeId node) {
167196
}
168197
}
169198

170-
std::vector<RREdgeId> mark_interposer_cut_edges_for_removal(const RRGraphView& rr_graph, const DeviceGrid& grid) {
199+
std::vector<RREdgeId> get_interposer_cut_edges_for_removal(const RRGraphView& rr_graph, const DeviceGrid& grid) {
171200
std::vector<RREdgeId> edges_to_be_removed;
172201

173-
// Loop over all RREdgeIds and mark ones that cross a cutline to be removed
174-
202+
// Loop over all RREdgeIds and add ones that cross a cutline to a list for removal
175203
for (RREdgeId edge_id : rr_graph.all_edges()) {
176204
RRNodeId src_node = rr_graph.edge_src_node(edge_id);
177205
RRNodeId sink_node = rr_graph.edge_sink_node(edge_id);
@@ -190,6 +218,8 @@ std::vector<RREdgeId> mark_interposer_cut_edges_for_removal(const RRGraphView& r
190218

191219
int layer = rr_graph.node_layer_low(src_node);
192220

221+
// If the start of the source node and the start of the sink node of this edge are on different sides of an interposer cut line
222+
// the edge starts on a piece of wire that would be cut by the interposed and should be added to the removal list.
193223
for (int cut_loc_y : grid.get_horizontal_interposer_cuts()[layer]) {
194224
int src_start_loc_y = node_ystart(rr_graph, src_node);
195225
int sink_start_loc_y = node_ystart(rr_graph, sink_node);
@@ -223,16 +253,19 @@ static void cut_chan_y_node(RRNodeId node,
223253
Direction node_direction,
224254
RRGraphBuilder& rr_graph_builder,
225255
RRSpatialLookup& spatial_lookup) {
256+
257+
VTR_ASSERT_SAFE(should_cut(y_low, y_high, cut_loc_y));
258+
226259
if (node_direction == Direction::INC) {
227-
// Anything above cut_loc_y shouldn't exist
260+
// This node should not exist at locations above cut_loc_y
228261
rr_graph_builder.set_node_coordinates(node, x_low, y_low, x_high, cut_loc_y);
229262

230263
// Do a loop from cut_loc_y to y_high and remove node from spatial lookup
231264
for (int y_loc = cut_loc_y + 1; y_loc <= y_high; y_loc++) {
232265
spatial_lookup.remove_node(node, layer, x_low, y_loc, e_rr_type::CHANY, ptc_num);
233266
}
234267
} else if (node_direction == Direction::DEC) {
235-
// Anything below cut_loc_y (inclusive) shouldn't exist
268+
// This node should not exist at locations below cut_loc_y (inclusive)
236269
rr_graph_builder.set_node_coordinates(node, x_low, cut_loc_y + 1, x_high, y_high);
237270

238271
// Do a loop from y_low to cut_loc_y and remove node from spatial lookup
@@ -255,16 +288,18 @@ static void cut_chan_x_node(RRNodeId node,
255288
Direction node_direction,
256289
RRGraphBuilder& rr_graph_builder,
257290
RRSpatialLookup& spatial_lookup) {
291+
VTR_ASSERT_SAFE(should_cut(x_low, x_high, cut_loc_x));
292+
258293
if (node_direction == Direction::INC) {
259-
// Anything to the right of cut_loc_x shouldn't exist
294+
// This node should not exist at locations to the right of cut_loc_x
260295
rr_graph_builder.set_node_coordinates(node, x_low, y_low, cut_loc_x, y_high);
261296

262297
// Do a loop from cut_loc_x to x_high and remove node from spatial lookup
263298
for (int x_loc = cut_loc_x + 1; x_loc <= x_high; x_loc++) {
264299
spatial_lookup.remove_node(node, layer, x_loc, y_low, e_rr_type::CHANX, ptc_num);
265300
}
266301
} else if (node_direction == Direction::DEC) {
267-
// Anything to the left of cut_loc_x (inclusive) shouldn't exist
302+
// This node should not exist at locations to the left of cut_loc_x (inclusive)
268303
rr_graph_builder.set_node_coordinates(node, cut_loc_x + 1, y_low, x_high, y_high);
269304

270305
// Do a loop from x_low to cut_loc_x - 1 and remove node from spatial lookup

vpr/src/route/rr_graph_generation/rr_graph_interposer.h

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,53 @@
33
/**
44
* @file interposer_cut.h
55
* @brief This file implements functions that:
6-
* (1) Marks all edges that cross an interposer cut for removal
6+
*
7+
* (1) Get a list of all edges that cross an interposer cut for removal. Edges whose source and sink nodes start on opposite
8+
* sides of an interposer cut line are considered to cross the cut line and will be removed.
9+
*
710
* (2) Makes the channel nodes that cross an interposer cut shorter to have them not cross the interposer anymore
11+
*
812
* Using these two functions and combined with 2D scatter-gather patterns, you can model and implement 2.5D FPGA RR Graphs.
13+
*
14+
* Below you can see a diagram of a device with a vertical interposer cut at x = 2 (Shown with X) and a horizontal interposer cut at y = 2 (shown with =)
15+
* X(x,y) denotes the ChanX at location (x,y) and Y(x,y) denotes the ChanX at location (x,y). Consistent with VPR's coordinate system, each tile "owns"
16+
* the channels above and to the right of it, therefore interposer cut lines will leave the channels on the side of the tile it belongs to.
17+
*
18+
*
19+
* X(0,3) X(1,3) X X(2,3) X(3,3) X(4,3)
20+
* _________ _________ X _________ _________ _________
21+
* | | | | X | | | | | |
22+
* | | Y(0,3) | |Y(1,3)X | | Y(2,3) | | Y(3,3) | | Y(4,3)
23+
* | | | | X | | | | | |
24+
* --------- --------- X --------- --------- ---------
25+
* X
26+
* X(0,2) X(1,2) X X(2,2) X(3,2) X(4,2)
27+
* X
28+
* _________ _________ X _________ _________ _________
29+
* | | | | X | | | | | |
30+
* | | Y(0,2) | |Y(1,2)X | | Y(2,2) | | Y(3,2) | | Y(4,2)
31+
* | | | | X | | | | | |
32+
* --------- --------- X --------- --------- ---------
33+
* ===================================X=================================================
34+
* X(0,1) X(1,1) X X(2,1) X(3,1) X(4,1)
35+
* X
36+
* _________ _________ X _________ _________ _________
37+
* | | | | X | | | | | |
38+
* | | Y(0,1) | |Y(1,1)X | | Y(2,1) | | Y(3,1) | | Y(4,1)
39+
* | | | | X | | | | | |
40+
* --------- --------- X --------- --------- ---------
41+
* X
42+
* X(0,0) X(1,0) X X(2,0) X(3,0) X(4,0)
43+
* X
44+
* _________ _________ X _________ _________ _________
45+
* | | | | X | | | | | |
46+
* | | Y(0,0) | |Y(1,0)X | | Y(2,0) | | Y(3,0) | | Y(4,0)
47+
* | | | | X | | | | | |
48+
* --------- --------- X --------- --------- ---------
49+
* X
50+
* X
51+
*
52+
*
953
*/
1054

1155
#include <vector>
@@ -15,14 +59,22 @@
1559

1660
/**
1761
* @brief Goes through all edges in the RR Graph and returns a list of the edges that cross an interposer cut line.
62+
* Edges whose source and sink nodes start on opposite sides of an interposer cut line are considered to cross the
63+
* cut line and will be removed.
1864
*
1965
* @return std::vector<RREdgeId> List of all edges that cross an interposer cut line.
2066
*/
21-
std::vector<RREdgeId> mark_interposer_cut_edges_for_removal(const RRGraphView& rr_graph, const DeviceGrid& grid);
67+
std::vector<RREdgeId> get_interposer_cut_edges_for_removal(const RRGraphView& rr_graph, const DeviceGrid& grid);
2268

2369
/**
24-
* @brief Shortens the channel nodes that cross an interposer cut line
70+
* @brief Shortens the channel nodes that cross an interposer cut line.
2571
*
72+
* @details When a wire crosses an interposer cut line, it is shortened to instead end at the interposed cut line
73+
* unless it is in the list of sg_node_indices. The wire's drive point and the wire up to the interposer cut is
74+
* retained and will not be modified. "Shortening a wire" in this context means modifying the information in the
75+
* RR Graph itself (Changing the bounding box of the corresponding RR Graph node) and the spatial lookup
76+
* (Making sure there is no reference to the shortened wire in locations it doesn't exist at anymore.)
77+
*
2678
* @param rr_graph RRGraphView, used to read the RR Graph.
2779
* @param grid Device grid, used to access interposer cut locations.
2880
* @param rr_graph_builder RRGraphBuilder, to modify the RRGraph.

0 commit comments

Comments
 (0)