Skip to content

Commit d4a76f6

Browse files
committed
[VPR] Remove the hard requirement on side option when adding a node; Add comments about TODO action items;
1 parent 1f3c410 commit d4a76f6

File tree

6 files changed

+23
-16
lines changed

6 files changed

+23
-16
lines changed

vpr/src/device/rr_spatial_lookup.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,13 @@ std::vector<RRNodeId> RRSpatialLookup::find_sink_nodes(int x,
162162
return sink_nodes;
163163
}
164164

165-
/* By default, we always added the channel nodes to the TOP side (to save memory) */
165+
/* By default, we always added the sink nodes to the TOP side (to save memory) */
166166
e_side node_side = TOP;
167167
if (node_side >= rr_node_indices_[SINK].dim_size(2)) {
168168
return sink_nodes;
169169
}
170170

171+
/* Only insert valid ids in the returned vector */
171172
for (const auto& node : rr_node_indices_[SINK][x][y][node_side]) {
172173
if (RRNodeId(node)) {
173174
sink_nodes.push_back(RRNodeId(node));
@@ -212,6 +213,11 @@ void RRSpatialLookup::add_node(RRNodeId node,
212213
VTR_ASSERT(node); /* Must have a valid node id to be added */
213214
VTR_ASSERT_SAFE(3 == rr_node_indices_[type].ndims());
214215

216+
/* For non-IPIN/OPIN nodes, the side should always be the TOP side which follows the convention in find_node() API! */
217+
if (type != IPIN && type != OPIN) {
218+
VTR_ASSERT(side == SIDES[0]);
219+
}
220+
215221
resize_nodes(x, y, type, side);
216222

217223
if (size_t(ptc) >= rr_node_indices_[type][x][y][side].size()) {

vpr/src/device/rr_spatial_lookup.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class RRSpatialLookup {
8888
*
8989
* Note:
9090
* - Return an empty list if there are no sinks at the given (x, y) location
91-
* - The node list returned only contain valid ids
91+
* - The node list returned only contains valid ids
9292
*/
9393
std::vector<RRNodeId> find_sink_nodes(int x,
9494
int y) const;
@@ -130,7 +130,7 @@ class RRSpatialLookup {
130130
int y,
131131
t_rr_type type,
132132
int ptc,
133-
e_side side);
133+
e_side side = SIDES[0]);
134134

135135
/**
136136
* Mirror the last dimension of a look-up, i.e., a list of nodes, from a source coordinate to
@@ -191,7 +191,7 @@ class RRSpatialLookup {
191191
* or inside the data structures to be changed later.
192192
* That explains why the reference is used here temporarily
193193
*/
194-
/* Fast look-up */
194+
/* Fast look-up: TODO: Should rework the data type. Currently it is based on a 3-dimensional arrqay mater where some dimensions must always be accessed with a specific index. Such limitation should be overcome */
195195
t_rr_node_indices& rr_node_indices_;
196196
};
197197

vpr/src/route/clock_connection_builders.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ void RoutingToClockConnection::create_switches(const ClockRRGraphBuilder& clock_
5454
auto& device_ctx = g_vpr_ctx.device();
5555
const auto& node_lookup = device_ctx.rr_graph.node_lookup();
5656

57-
int virtual_clock_network_root_idx = create_virtual_clock_network_sink_node(switch_location.x, switch_location.y);
57+
RRNodeId virtual_clock_network_root_idx = create_virtual_clock_network_sink_node(switch_location.x, switch_location.y);
5858
{
5959
auto& mut_device_ctx = g_vpr_ctx.mutable_device();
60-
mut_device_ctx.virtual_clock_network_root_idx = virtual_clock_network_root_idx;
60+
mut_device_ctx.virtual_clock_network_root_idx = size_t(virtual_clock_network_root_idx);
6161
}
6262

6363
// rr_node indices for x and y channel routing wires and clock wires to connect to
@@ -85,13 +85,11 @@ void RoutingToClockConnection::create_switches(const ClockRRGraphBuilder& clock_
8585

8686
// Connect to virtual clock sink node
8787
// used by the two stage router
88-
clock_graph.add_edge(rr_edges_to_create, clock_index, virtual_clock_network_root_idx, arch_switch_idx);
88+
clock_graph.add_edge(rr_edges_to_create, clock_index, size_t(virtual_clock_network_root_idx), arch_switch_idx);
8989
}
9090
}
9191

92-
int RoutingToClockConnection::create_virtual_clock_network_sink_node(
93-
int x,
94-
int y) {
92+
RRNodeId RoutingToClockConnection::create_virtual_clock_network_sink_node(int x, int y) {
9593
auto& device_ctx = g_vpr_ctx.mutable_device();
9694
auto& rr_graph = device_ctx.rr_nodes;
9795
auto& node_lookup = device_ctx.rr_graph_builder.node_lookup();
@@ -120,11 +118,11 @@ int RoutingToClockConnection::create_virtual_clock_network_sink_node(
120118
// However, since the SINK node has the same xhigh/xlow as well as yhigh/ylow, we can probably use a shortcut
121119
for (int ix = rr_graph.node_xlow(node_index); ix <= rr_graph.node_xhigh(node_index); ++ix) {
122120
for (int iy = rr_graph.node_ylow(node_index); iy <= rr_graph.node_yhigh(node_index); ++iy) {
123-
node_lookup.add_node(node_index, ix, iy, rr_graph.node_type(node_index), rr_graph.node_ptc_num(node_index), SIDES[0]);
121+
node_lookup.add_node(node_index, ix, iy, rr_graph.node_type(node_index), rr_graph.node_ptc_num(node_index));
124122
}
125123
}
126124

127-
return size_t(node_index);
125+
return node_index;
128126
}
129127

130128
/*

vpr/src/route/clock_connection_builders.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class RoutingToClockConnection : public ClockConnection {
5757
/* Connects the inter-block routing to the clock source at the specified coordinates */
5858
void create_switches(const ClockRRGraphBuilder& clock_graph, t_rr_edge_info_set* rr_edges_to_create) override;
5959
size_t estimate_additional_nodes() override;
60-
int create_virtual_clock_network_sink_node(int x, int y);
60+
RRNodeId create_virtual_clock_network_sink_node(int x, int y);
6161
};
6262

6363
class ClockToClockConneciton : public ClockConnection {

vpr/src/route/clock_network_builders.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,11 @@ int ClockRib::create_chanx_wire(int x_start,
346346
/* Add the node to spatial lookup */
347347
auto& rr_graph = (*rr_nodes);
348348
RRNodeId chanx_node = RRNodeId(node_index);
349+
/* TODO: Will replace these codes with an API add_node_to_all_locs() of RRGraphBuilder */
349350
for (int ix = rr_graph.node_xlow(chanx_node); ix <= rr_graph.node_xhigh(chanx_node); ++ix) {
350351
for (int iy = rr_graph.node_ylow(chanx_node); iy <= rr_graph.node_yhigh(chanx_node); ++iy) {
351352
//TODO: CHANX uses odd swapped x/y indices here. Will rework once rr_node_indices is shadowed
352-
rr_graph_builder.node_lookup().add_node(chanx_node, iy, ix, rr_graph.node_type(chanx_node), rr_graph.node_ptc_num(chanx_node), SIDES[0]);
353+
rr_graph_builder.node_lookup().add_node(chanx_node, iy, ix, rr_graph.node_type(chanx_node), rr_graph.node_ptc_num(chanx_node));
353354
}
354355
}
355356

@@ -651,9 +652,10 @@ int ClockSpine::create_chany_wire(int y_start,
651652
/* Add the node to spatial lookup */
652653
auto& rr_graph = (*rr_nodes);
653654
RRNodeId chany_node = RRNodeId(node_index);
655+
/* TODO: Will replace these codes with an API add_node_to_all_locs() of RRGraphBuilder */
654656
for (int ix = rr_graph.node_xlow(chany_node); ix <= rr_graph.node_xhigh(chany_node); ++ix) {
655657
for (int iy = rr_graph.node_ylow(chany_node); iy <= rr_graph.node_yhigh(chany_node); ++iy) {
656-
rr_graph_builder.node_lookup().add_node(chany_node, ix, iy, rr_graph.node_type(chany_node), rr_graph.node_ptc_num(chany_node), SIDES[0]);
658+
rr_graph_builder.node_lookup().add_node(chany_node, ix, iy, rr_graph.node_type(chany_node), rr_graph.node_ptc_num(chany_node));
657659
}
658660
}
659661

vpr/src/route/rr_edge.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef RR_EDGE_H
22
#define RR_EDGE_H
33

4+
/* TODO: MUST change the node id to RRNodeId before refactoring is finished! */
45
struct t_rr_edge_info {
56
t_rr_edge_info(int from, int to, short type) noexcept
67
: from_node(from)
@@ -22,4 +23,4 @@ struct t_rr_edge_info {
2223

2324
typedef std::vector<t_rr_edge_info> t_rr_edge_info_set;
2425

25-
#endif /* RR_EDGE */
26+
#endif /* RR_EDGE */

0 commit comments

Comments
 (0)