Skip to content

Commit 219dd03

Browse files
set correct R/C values for SG nodes
1 parent ec8a7d1 commit 219dd03

File tree

12 files changed

+39
-38
lines changed

12 files changed

+39
-38
lines changed

libs/librrgraph/src/base/rr_rc_data.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ t_rr_rc_data::t_rr_rc_data(float Rval, float Cval) noexcept
44
: R(Rval)
55
, C(Cval) {}
66

7-
short find_create_rr_rc_data(const float R, const float C, std::vector<t_rr_rc_data>& rr_rc_data) {
7+
NodeRCIndex find_create_rr_rc_data(const float R, const float C, std::vector<t_rr_rc_data>& rr_rc_data) {
88

99
auto match = [&](const t_rr_rc_data& val) {
1010
return val.R == R
1111
&& val.C == C;
1212
};
1313

14-
//Just a linear search for now
14+
// Just a linear search for now
1515
auto itr = std::find_if(rr_rc_data.begin(),
1616
rr_rc_data.end(),
1717
match);
1818

1919
if (itr == rr_rc_data.end()) {
20-
//Not found -> create it
20+
// Not found -> create it
2121
rr_rc_data.emplace_back(R, C);
2222

23-
itr = --rr_rc_data.end(); //Iterator to inserted value
23+
itr = --rr_rc_data.end(); // Iterator to inserted value
2424
}
2525

26-
return std::distance(rr_rc_data.begin(), itr);
26+
return NodeRCIndex(std::distance(rr_rc_data.begin(), itr));
2727
}

libs/librrgraph/src/base/rr_rc_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
*
1111
* The returned indicies index into DeviceContext.rr_rc_data.
1212
*/
13-
short find_create_rr_rc_data(const float R, const float C, std::vector<t_rr_rc_data>& rr_rc_data);
13+
NodeRCIndex find_create_rr_rc_data(const float R, const float C, std::vector<t_rr_rc_data>& rr_rc_data);

libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,8 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
806806
inline int init_node_timing(int& inode, float C, float R) final {
807807
auto node = (*rr_nodes_)[inode];
808808
RRNodeId node_id = node.id();
809-
rr_graph_builder_->set_node_rc_index(node_id, NodeRCIndex(find_create_rr_rc_data(R, C, *rr_rc_data_)));
809+
const NodeRCIndex rc_index = find_create_rr_rc_data(R, C, *rr_rc_data_);
810+
rr_graph_builder_->set_node_rc_index(node_id, rc_index);
810811
return inode;
811812
}
812813
inline void finish_node_timing(int& /*inode*/) final {}
@@ -934,7 +935,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
934935
type);
935936
}
936937

937-
rr_graph_builder_->set_node_rc_index(node_id, NodeRCIndex(find_create_rr_rc_data(0, 0, *rr_rc_data_)));
938+
rr_graph_builder_->set_node_rc_index(node_id, find_create_rr_rc_data(0, 0, *rr_rc_data_));
938939

939940
return id;
940941
}

vpr/src/route/rr_graph_generation/build_scatter_gathers.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ std::vector<t_bottleneck_link> alloc_and_load_scatter_gather_connections(const s
306306

307307
bottleneck_link.chan_type = chan_type;
308308
bottleneck_link.parallel_segment_index = std::distance(segment_inf.begin(), seg_it);
309+
bottleneck_link.R_metal = seg_it->Rmetal;
310+
bottleneck_link.C_metal = seg_it->Cmetal;
309311

310312
if (is_3d_link) {
311313
if (sg_link.z_offset < 0 && wire_segment.arch_wire_switch_dec != ARCH_FPGA_UNDEFINED_VAL) {

vpr/src/route/rr_graph_generation/build_scatter_gathers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ struct t_bottleneck_link {
3333
t_physical_tile_loc scatter_loc; ///< Destination switchblock location.
3434
int arch_wire_switch; ///< The switch (mux) used to drive the bottleneck wire.
3535
int parallel_segment_index;
36+
float R_metal;
37+
float C_metal;
3638
e_rr_type chan_type;
3739
std::vector<t_sg_candidate> gather_fanin_connections; ///< Wires driving the bottleneck link at `gather_loc`
3840
std::vector<t_sg_candidate> scatter_fanout_connections; ///< Wires driven by the bottleneck link at `scatter_loc`

vpr/src/route/rr_graph_generation/clock_connection_builders.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ RRNodeId RoutingToClockConnection::create_virtual_clock_network_sink_node(int la
114114
rr_graph_builder.set_node_capacity(node_index, 1);
115115
rr_graph_builder.set_node_cost_index(node_index, RRIndexedDataId(SINK_COST_INDEX));
116116

117-
float R = 0.;
118-
float C = 0.;
119-
rr_graph_builder.set_node_rc_index(node_index, NodeRCIndex(find_create_rr_rc_data(R, C, rr_rc_data)));
117+
const NodeRCIndex rc_index = find_create_rr_rc_data(0, 0, rr_rc_data);
118+
rr_graph_builder.set_node_rc_index(node_index, rc_index);
120119

121120
// Use a generic way when adding nodes to lookup.
122121
// However, since the SINK node has the same xhigh/xlow as well as yhigh/ylow, we can probably use a shortcut

vpr/src/route/rr_graph_generation/clock_network_builders.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,16 @@ int ClockRib::create_chanx_wire(int layer,
337337
t_rr_graph_storage* rr_nodes,
338338
RRGraphBuilder& rr_graph_builder) {
339339
rr_nodes->emplace_back();
340-
auto node_index = rr_nodes->size() - 1;
340+
size_t node_index = rr_nodes->size() - 1;
341341
RRNodeId chanx_node = RRNodeId(node_index);
342342

343343
rr_graph_builder.set_node_type(chanx_node, e_rr_type::CHANX);
344344
rr_graph_builder.set_node_coordinates(chanx_node, x_start, y, x_end, y);
345345
rr_graph_builder.set_node_layer(chanx_node, layer, layer);
346346
rr_graph_builder.set_node_capacity(chanx_node, 1);
347347
rr_graph_builder.set_node_track_num(chanx_node, ptc_num);
348-
rr_graph_builder.set_node_rc_index(chanx_node, NodeRCIndex(find_create_rr_rc_data(
349-
x_chan_wire.layer.r_metal, x_chan_wire.layer.c_metal, g_vpr_ctx.mutable_device().rr_rc_data)));
348+
const NodeRCIndex rc_index = find_create_rr_rc_data(x_chan_wire.layer.r_metal, x_chan_wire.layer.c_metal, g_vpr_ctx.mutable_device().rr_rc_data);
349+
rr_graph_builder.set_node_rc_index(chanx_node, rc_index);
350350
rr_graph_builder.set_node_direction(chanx_node, direction);
351351

352352
short seg_index = 0;
@@ -686,8 +686,8 @@ int ClockSpine::create_chany_wire(int layer,
686686
rr_graph_builder.set_node_layer(chany_node, layer, layer);
687687
rr_graph_builder.set_node_capacity(chany_node, 1);
688688
rr_graph_builder.set_node_track_num(chany_node, ptc_num);
689-
rr_graph_builder.set_node_rc_index(chany_node, NodeRCIndex(find_create_rr_rc_data(
690-
y_chan_wire.layer.r_metal, y_chan_wire.layer.c_metal, g_vpr_ctx.mutable_device().rr_rc_data)));
689+
const NodeRCIndex rc_index = find_create_rr_rc_data(y_chan_wire.layer.r_metal, y_chan_wire.layer.c_metal, g_vpr_ctx.mutable_device().rr_rc_data);
690+
rr_graph_builder.set_node_rc_index(chany_node, rc_index);
691691
rr_graph_builder.set_node_direction(chany_node, direction);
692692

693693
short seg_index = 0;

vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,7 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
20492049
int length = end - start + 1;
20502050
float R = length * seg_details[track].Rmetal();
20512051
float C = length * seg_details[track].Cmetal();
2052-
rr_graph_builder.set_node_rc_index(node, NodeRCIndex(find_create_rr_rc_data(R, C, mutable_device_ctx.rr_rc_data)));
2052+
rr_graph_builder.set_node_rc_index(node, find_create_rr_rc_data(R, C, mutable_device_ctx.rr_rc_data));
20532053

20542054
rr_graph_builder.set_node_type(node, chan_type);
20552055
rr_graph_builder.set_node_track_num(node, track);
@@ -2099,9 +2099,8 @@ static void add_and_connect_non_3d_sg_links(RRGraphBuilder& rr_graph_builder,
20992099
rr_graph_builder.set_node_cost_index(node_id, RRIndexedDataId(cons_index));
21002100

21012101
// Step 4: Assign electrical characteristics
2102-
float R = 0;
2103-
float C = 0;
2104-
rr_graph_builder.set_node_rc_index(node_id, NodeRCIndex(find_create_rr_rc_data(R, C, g_vpr_ctx.mutable_device().rr_rc_data)));
2102+
const NodeRCIndex rc_index = find_create_rr_rc_data(link.R_metal, link.C_metal, g_vpr_ctx.mutable_device().rr_rc_data);
2103+
rr_graph_builder.set_node_rc_index(node_id, rc_index);
21052104
// Step 5: Set node type, track number, and direction
21062105
rr_graph_builder.set_node_type(node_id, link.chan_type);
21072106
rr_graph_builder.set_node_track_num(node_id, track_num);

vpr/src/route/rr_graph_generation/rr_graph_3d.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ void build_inter_die_3d_rr_chan(RRGraphBuilder& rr_graph_builder,
8585
rr_graph_builder.set_node_coordinates(node, x_coord, y_coord, x_coord, y_coord);
8686
rr_graph_builder.set_node_cost_index(node, RRIndexedDataId(const_index_offset + link.parallel_segment_index));
8787
rr_graph_builder.set_node_capacity(node, 1); // GLOBAL routing handled elsewhere
88-
float R = 0;
89-
float C = 0;
90-
rr_graph_builder.set_node_rc_index(node, NodeRCIndex(find_create_rr_rc_data(R, C, mutable_device_ctx.rr_rc_data)));
88+
const NodeRCIndex rc_index = find_create_rr_rc_data(link.R_metal, link.C_metal, mutable_device_ctx.rr_rc_data);
89+
rr_graph_builder.set_node_rc_index(node, rc_index);
9190

9291
rr_graph_builder.set_node_type(node, e_rr_type::CHANZ);
9392
rr_graph_builder.set_node_track_num(node, track_num);

vpr/src/route/rr_graph_generation/rr_graph_tile_nodes.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ void add_classes_rr_graph(RRGraphBuilder& rr_graph_builder,
3434
rr_graph_builder.set_node_coordinates(class_inode, (short)root_loc.x, (short)root_loc.y, (short)(root_loc.x + physical_type->width - 1), (short)(root_loc.y + physical_type->height - 1));
3535
VTR_ASSERT(root_loc.layer_num <= std::numeric_limits<short>::max());
3636
rr_graph_builder.set_node_layer(class_inode, root_loc.layer_num, root_loc.layer_num);
37-
float R = 0.;
38-
float C = 0.;
39-
rr_graph_builder.set_node_rc_index(class_inode, NodeRCIndex(find_create_rr_rc_data(R, C, mutable_device_ctx.rr_rc_data)));
37+
const NodeRCIndex rc_index = find_create_rr_rc_data(0, 0, mutable_device_ctx.rr_rc_data);
38+
rr_graph_builder.set_node_rc_index(class_inode, rc_index);
4039
rr_graph_builder.set_node_class_num(class_inode, class_num);
4140
}
4241
}
@@ -78,7 +77,7 @@ void add_pins_rr_graph(RRGraphBuilder& rr_graph_builder,
7877
rr_graph_builder.set_node_capacity(node_id, 1);
7978
float R = 0.;
8079
float C = 0.;
81-
rr_graph_builder.set_node_rc_index(node_id, NodeRCIndex(find_create_rr_rc_data(R, C, mutable_device_ctx.rr_rc_data)));
80+
rr_graph_builder.set_node_rc_index(node_id, find_create_rr_rc_data(R, C, mutable_device_ctx.rr_rc_data));
8281
rr_graph_builder.set_node_pin_num(node_id, pin_num);
8382
// Note that we store the grid tile location and side where the pin is located,
8483
// which greatly simplifies the drawing code

0 commit comments

Comments
 (0)