Skip to content

Commit 0fc6d07

Browse files
Rename interposer_cut to rr_graph_interposer
1 parent 6b39edc commit 0fc6d07

File tree

3 files changed

+41
-25
lines changed

3 files changed

+41
-25
lines changed

vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "rr_graph_intra_cluster.h"
3434
#include "rr_graph_tile_nodes.h"
3535
#include "rr_graph_3d.h"
36+
#include "rr_graph_interposer.h"
3637
#include "rr_graph_timing_params.h"
3738
#include "check_rr_graph.h"
3839
#include "echo_files.h"
@@ -47,8 +48,6 @@
4748
#include "rr_types.h"
4849
#include "rr_node_indices.h"
4950

50-
#include "interposer_cut.h"
51-
5251

5352
//#define VERBOSE
5453
//used for getting the exact count of each edge type and printing it to std out.

vpr/src/route/rr_graph_generation/interposer_cut.cpp renamed to vpr/src/route/rr_graph_generation/rr_graph_interposer.cpp

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
#include "vpr_error.h"
1414
#include "vtr_assert.h"
1515

16-
#include "interposer_cut.h"
16+
#include "rr_graph_interposer.h"
1717

1818
/**
19-
* @brief Takes location of a source and a sink and determines wether it crosses cut_loc or not. For example, the interval (1, 4) is cut by 3, while it is not cut by 5 or 0.
19+
* @brief Takes location of a source and a sink and determines wether it crosses cut_loc or not.
20+
* For example, the interval (1, 4) is cut by 3, while it is not cut by 5 or 0.
2021
*/
2122
static bool should_cut(int src_loc, int sink_loc, int cut_loc) {
2223
int src_delta = src_loc - cut_loc;
@@ -34,22 +35,27 @@ static bool should_cut(int src_loc, int sink_loc, int cut_loc) {
3435
* @brief Calculates the starting x point of node based on it's directionality.
3536
*/
3637
static short node_xstart(const RRGraphView& rr_graph, RRNodeId node) {
38+
e_rr_type node_type = rr_graph.node_type(node);
39+
Direction node_direction = rr_graph.node_direction(node);
40+
short node_xlow = rr_graph.node_xlow(node);
41+
short node_xhigh = rr_graph.node_xhigh(node);
42+
3743
// Return early for OPIN and IPIN types (Some BIDIR pins would trigger the assertion below)
38-
if (rr_graph.node_type(node) == e_rr_type::OPIN || rr_graph.node_type(node) == e_rr_type::IPIN) {
39-
VTR_ASSERT(rr_graph.node_xlow(node) == rr_graph.node_xhigh(node));
40-
return rr_graph.node_xlow(node);
44+
if (is_pin(node_type)) {
45+
VTR_ASSERT(node_xlow == node_xhigh);
46+
return node_xlow;
4147
}
4248

43-
switch (rr_graph.node_direction(node)) {
49+
switch (node_direction) {
4450
case Direction::DEC:
45-
return rr_graph.node_xhigh(node);
51+
return node_xhigh;
4652

4753
case Direction::INC:
48-
return rr_graph.node_xlow(node);
54+
return node_xlow;
4955

5056
case Direction::NONE:
51-
VTR_ASSERT(rr_graph.node_xlow(node) == rr_graph.node_xhigh(node));
52-
return (rr_graph.node_xlow(node));
57+
VTR_ASSERT(node_xlow == node_xhigh);
58+
return (node_xlow);
5359

5460
case Direction::BIDIR:
5561
VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "Bidir node has no starting point.");
@@ -65,21 +71,26 @@ static short node_xstart(const RRGraphView& rr_graph, RRNodeId node) {
6571
* @brief Calculates the starting y point of node based on it's directionality.
6672
*/
6773
static short node_ystart(const RRGraphView& rr_graph, RRNodeId node) {
74+
e_rr_type node_type = rr_graph.node_type(node);
75+
Direction node_direction = rr_graph.node_direction(node);
76+
short node_ylow = rr_graph.node_ylow(node);
77+
short node_yhigh = rr_graph.node_yhigh(node);
78+
6879
// Return early for OPIN and IPIN types (Some BIDIR pins would trigger the assertion below)
69-
if (rr_graph.node_type(node) == e_rr_type::OPIN || rr_graph.node_type(node) == e_rr_type::IPIN) {
70-
return rr_graph.node_ylow(node);
80+
if (is_pin(node_type)) {
81+
return node_ylow;
7182
}
7283

73-
switch (rr_graph.node_direction(node)) {
84+
switch (node_direction) {
7485
case Direction::DEC:
75-
return rr_graph.node_yhigh(node);
86+
return node_yhigh;
7687

7788
case Direction::INC:
78-
return rr_graph.node_ylow(node);
89+
return node_ylow;
7990

8091
case Direction::NONE:
81-
VTR_ASSERT(rr_graph.node_ylow(node) == rr_graph.node_yhigh(node));
82-
return (rr_graph.node_ylow(node));
92+
VTR_ASSERT(node_ylow == node_yhigh);
93+
return (node_ylow);
8394

8495
case Direction::BIDIR:
8596
VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "Bidir node has no starting point.");
@@ -143,7 +154,8 @@ std::vector<RREdgeId> mark_interposer_cut_edges_for_removal(const RRGraphView& r
143154
*
144155
* This is a low level function, you should use cut_channel_node that wraps this up in a nicer API.
145156
*/
146-
static void cut_chan_y_node(RRNodeId node, int x_low, int y_low, int x_high, int y_high, int layer, int ptc_num, int cut_loc_y, Direction node_direction, RRGraphBuilder& rr_graph_builder, RRSpatialLookup& spatial_lookup) {
157+
static void cut_chan_y_node(RRNodeId node, int x_low, int y_low, int x_high, int y_high, int layer, int ptc_num, int cut_loc_y,
158+
Direction node_direction, RRGraphBuilder& rr_graph_builder, RRSpatialLookup& spatial_lookup) {
147159
if (node_direction == Direction::INC) {
148160
// Anything above cut_loc_y shouldn't exist
149161
rr_graph_builder.set_node_coordinates(node, x_low, y_low, x_high, cut_loc_y);
@@ -172,7 +184,8 @@ static void cut_chan_y_node(RRNodeId node, int x_low, int y_low, int x_high, int
172184
*
173185
* This is a low level function, you should use cut_channel_node that wraps this up in a nicer API.
174186
*/
175-
static void cut_chan_x_node(RRNodeId node, int x_low, int y_low, int x_high, int y_high, int layer, int ptc_num, int cut_loc_x, Direction node_direction, RRGraphBuilder& rr_graph_builder, RRSpatialLookup& spatial_lookup) {
187+
static void cut_chan_x_node(RRNodeId node, int x_low, int y_low, int x_high, int y_high, int layer, int ptc_num, int cut_loc_x,
188+
Direction node_direction, RRGraphBuilder& rr_graph_builder, RRSpatialLookup& spatial_lookup) {
176189
if (node_direction == Direction::INC) {
177190
// Anything to the right of cut_loc_x shouldn't exist
178191
rr_graph_builder.set_node_coordinates(node, x_low, y_low, cut_loc_x, y_high);
@@ -202,7 +215,8 @@ static void cut_chan_x_node(RRNodeId node, int x_low, int y_low, int x_high, int
202215
* @param interposer_cut_type Type of the interposer cut line (Horizontal or vertical)
203216
* @param sg_node_indices Sorted list of scatter-gather node IDs. We do not want to cut these nodes as they're allowed to cross an interposer cut line.
204217
*/
205-
static void cut_channel_node(RRNodeId node, int cut_loc, e_interposer_cut_type interposer_cut_type, const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder, RRSpatialLookup& spatial_lookup, const std::vector<std::pair<RRNodeId, int>>& sg_node_indices) {
218+
static void cut_channel_node(RRNodeId node, int cut_loc, e_interposer_cut_type interposer_cut_type, const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder,
219+
RRSpatialLookup& spatial_lookup, const std::vector<std::pair<RRNodeId, int>>& sg_node_indices) {
206220
constexpr auto node_indice_compare = [](RRNodeId l, RRNodeId r) noexcept { return size_t(l) < size_t(r); };
207221
bool is_sg_node = std::ranges::binary_search(std::views::keys(sg_node_indices), node, node_indice_compare);
208222
if (is_sg_node) {
@@ -239,7 +253,8 @@ static void cut_channel_node(RRNodeId node, int cut_loc, e_interposer_cut_type i
239253
}
240254
}
241255

242-
void update_interposer_crossing_nodes_in_spatial_lookup_and_rr_graph_storage(const RRGraphView& rr_graph, const DeviceGrid& grid, RRGraphBuilder& rr_graph_builder, const std::vector<std::pair<RRNodeId, int>>& sg_node_indices) {
256+
void update_interposer_crossing_nodes_in_spatial_lookup_and_rr_graph_storage(const RRGraphView& rr_graph, const DeviceGrid& grid, RRGraphBuilder& rr_graph_builder,
257+
const std::vector<std::pair<RRNodeId, int>>& sg_node_indices) {
243258

244259
VTR_ASSERT(std::is_sorted(sg_node_indices.begin(), sg_node_indices.end()));
245260

@@ -249,7 +264,8 @@ void update_interposer_crossing_nodes_in_spatial_lookup_and_rr_graph_storage(con
249264
for (size_t x_loc = 0; x_loc < grid.width(); x_loc++) {
250265
std::vector<RRNodeId> channel_nodes = spatial_lookup.find_channel_nodes(layer, x_loc, cut_loc_y, e_rr_type::CHANY);
251266
for (RRNodeId node : channel_nodes) {
252-
cut_channel_node(node, cut_loc_y, e_interposer_cut_type::HORZ, rr_graph, rr_graph_builder, spatial_lookup, sg_node_indices);
267+
cut_channel_node(node, cut_loc_y, e_interposer_cut_type::HORZ,
268+
rr_graph, rr_graph_builder, spatial_lookup, sg_node_indices);
253269
}
254270
}
255271
}
@@ -258,7 +274,8 @@ void update_interposer_crossing_nodes_in_spatial_lookup_and_rr_graph_storage(con
258274
for (size_t y_loc = 0; y_loc < grid.height(); y_loc++) {
259275
std::vector<RRNodeId> channel_nodes = spatial_lookup.find_channel_nodes(layer, cut_loc_x, y_loc, e_rr_type::CHANX);
260276
for (RRNodeId node : channel_nodes) {
261-
cut_channel_node(node, cut_loc_x, e_interposer_cut_type::VERT, rr_graph, rr_graph_builder, spatial_lookup, sg_node_indices);
277+
cut_channel_node(node, cut_loc_x, e_interposer_cut_type::VERT,
278+
rr_graph, rr_graph_builder, spatial_lookup, sg_node_indices);
262279
}
263280
}
264281
}

0 commit comments

Comments
 (0)