Skip to content

Commit e0c16b6

Browse files
authored
Merge pull request #1799 from ethanroj23/rr_graph_node_fan_in
RRGraphView::node_fan_in() Implementation
2 parents 966d0e1 + 66e4f83 commit e0c16b6

File tree

8 files changed

+36
-35
lines changed

8 files changed

+36
-35
lines changed

vpr/src/device/rr_graph_view.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ class RRGraphView {
7777
return node_storage_.node_direction_string(node);
7878
}
7979

80+
/* Get the fan in of a routing resource node. This function is inlined for runtime optimization. */
81+
inline t_edge_size node_fan_in(RRNodeId node) const {
82+
return node_storage_.fan_in(node);
83+
}
84+
8085
/* Return the fast look-up data structure for queries from client functions */
8186
const RRSpatialLookup& node_lookup() const {
8287
return node_lookup_;

vpr/src/draw/draw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ static void draw_rr_chan(int inode, const ezgl::color color, ezgl::renderer* g)
15031503
if (switchpoint_min == 0) {
15041504
if (dir != Direction::BIDIR) {
15051505
//Draw a mux at the start of each wire, labelled with it's size (#inputs)
1506-
draw_mux_with_size(start, mux_dir, WIRE_DRAWING_WIDTH, device_ctx.rr_nodes[inode].fan_in(), g);
1506+
draw_mux_with_size(start, mux_dir, WIRE_DRAWING_WIDTH, rr_graph.node_fan_in(RRNodeId(inode)), g);
15071507
}
15081508
} else {
15091509
//Draw arrows and label with switch point
@@ -1529,7 +1529,7 @@ static void draw_rr_chan(int inode, const ezgl::color color, ezgl::renderer* g)
15291529
if (switchpoint_max == 0) {
15301530
if (dir != Direction::BIDIR) {
15311531
//Draw a mux at the start of each wire, labelled with it's size (#inputs)
1532-
draw_mux_with_size(start, mux_dir, WIRE_DRAWING_WIDTH, device_ctx.rr_nodes[inode].fan_in(), g);
1532+
draw_mux_with_size(start, mux_dir, WIRE_DRAWING_WIDTH, rr_graph.node_fan_in(RRNodeId(inode)), g);
15331533
}
15341534
} else {
15351535
//Draw arrows and label with switch point

vpr/src/power/power.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -824,26 +824,26 @@ static void power_usage_routing(t_power_usage* power_usage,
824824
for (t_edge_size edge_idx = 0; edge_idx < node.num_edges(); edge_idx++) {
825825
const auto& next_node_id = node.edge_sink_node(edge_idx);
826826
if (next_node_id != OPEN) {
827-
auto next_node = device_ctx.rr_nodes[next_node_id];
828827
t_rr_node_power* next_node_power = &rr_node_power[next_node_id];
829828

830829
switch (rr_graph.node_type(RRNodeId(next_node_id))) {
831830
case CHANX:
832831
case CHANY:
833-
case IPIN:
832+
case IPIN: {
834833
if (next_node_power->net_num == node_power->net_num) {
835834
next_node_power->selected_input = next_node_power->num_inputs;
836835
}
837836
next_node_power->in_dens[next_node_power->num_inputs] = clb_net_density(node_power->net_num);
838837
next_node_power->in_prob[next_node_power->num_inputs] = clb_net_prob(node_power->net_num);
839838
next_node_power->num_inputs++;
840-
if (next_node_power->num_inputs > next_node.fan_in()) {
839+
const t_edge_size next_node_fan_in = rr_graph.node_fan_in(RRNodeId(next_node_id));
840+
if (next_node_power->num_inputs > next_node_fan_in) {
841841
VTR_LOG("%d %d\n", next_node_power->num_inputs,
842-
next_node.fan_in());
842+
next_node_fan_in);
843843
fflush(nullptr);
844844
VTR_ASSERT(0);
845845
}
846-
break;
846+
} break;
847847
default:
848848
/* Do nothing */
849849
break;
@@ -865,6 +865,7 @@ static void power_usage_routing(t_power_usage* power_usage,
865865
int switchbox_fanout;
866866
//float C_per_seg_split;
867867
int wire_length;
868+
const t_edge_size node_fan_in = rr_graph.node_fan_in(RRNodeId(rr_node_idx));
868869

869870
switch (rr_graph.node_type(RRNodeId(rr_node_idx))) {
870871
case SOURCE:
@@ -877,13 +878,13 @@ static void power_usage_routing(t_power_usage* power_usage,
877878
* - Driver (accounted for at end of CHANX/Y - see below)
878879
* - Multiplexor */
879880

880-
if (node.fan_in()) {
881+
if (node_fan_in) {
881882
VTR_ASSERT(node_power->in_dens);
882883
VTR_ASSERT(node_power->in_prob);
883884

884885
/* Multiplexor */
885886
power_usage_mux_multilevel(&sub_power_usage,
886-
power_get_mux_arch(node.fan_in(),
887+
power_get_mux_arch(node_fan_in,
887888
power_ctx.arch->mux_transistor_size),
888889
node_power->in_prob, node_power->in_dens,
889890
node_power->selected_input, true,
@@ -912,11 +913,11 @@ static void power_usage_routing(t_power_usage* power_usage,
912913
int seg_index = device_ctx.rr_indexed_data[node.cost_index()].seg_index;
913914
C_wire = wire_length * device_ctx.rr_segments[seg_index].Cmetal;
914915
//(double)power_ctx.commonly_used->tile_length);
915-
VTR_ASSERT(node_power->selected_input < node.fan_in());
916+
VTR_ASSERT(node_power->selected_input < node_fan_in);
916917

917918
/* Multiplexor */
918919
power_usage_mux_multilevel(&sub_power_usage,
919-
power_get_mux_arch(node.fan_in(),
920+
power_get_mux_arch(node_fan_in,
920921
power_ctx.arch->mux_transistor_size),
921922
node_power->in_prob, node_power->in_dens,
922923
node_power->selected_input, true, power_ctx.solution_inf.T_crit);
@@ -1173,10 +1174,10 @@ void power_pb_pins_uninit() {
11731174
}
11741175

11751176
void power_routing_init(const t_det_routing_arch* routing_arch) {
1176-
int max_fanin;
1177-
int max_IPIN_fanin;
1178-
int max_seg_to_IPIN_fanout;
1179-
int max_seg_to_seg_fanout;
1177+
t_edge_size max_fanin;
1178+
t_edge_size max_IPIN_fanin;
1179+
t_edge_size max_seg_to_IPIN_fanout;
1180+
t_edge_size max_seg_to_seg_fanout;
11801181
auto& power_ctx = g_vpr_ctx.mutable_power();
11811182
auto& device_ctx = g_vpr_ctx.device();
11821183
const auto& rr_graph = device_ctx.rr_graph;
@@ -1205,20 +1206,20 @@ void power_routing_init(const t_det_routing_arch* routing_arch) {
12051206
max_seg_to_seg_fanout = 0;
12061207
max_seg_to_IPIN_fanout = 0;
12071208
for (size_t rr_node_idx = 0; rr_node_idx < device_ctx.rr_nodes.size(); rr_node_idx++) {
1208-
int fanout_to_IPIN = 0;
1209-
int fanout_to_seg = 0;
1209+
t_edge_size fanout_to_IPIN = 0;
1210+
t_edge_size fanout_to_seg = 0;
12101211
auto node = device_ctx.rr_nodes[rr_node_idx];
12111212
t_rr_node_power* node_power = &rr_node_power[rr_node_idx];
1213+
const t_edge_size node_fan_in = rr_graph.node_fan_in(RRNodeId(rr_node_idx));
12121214

12131215
switch (rr_graph.node_type(RRNodeId(rr_node_idx))) {
12141216
case IPIN:
1215-
max_IPIN_fanin = std::max(max_IPIN_fanin,
1216-
static_cast<int>(node.fan_in()));
1217-
max_fanin = std::max(max_fanin, static_cast<int>(node.fan_in()));
1217+
max_IPIN_fanin = std::max(max_IPIN_fanin, node_fan_in);
1218+
max_fanin = std::max(max_fanin, node_fan_in);
12181219

1219-
node_power->in_dens = (float*)vtr::calloc(node.fan_in(),
1220+
node_power->in_dens = (float*)vtr::calloc(node_fan_in,
12201221
sizeof(float));
1221-
node_power->in_prob = (float*)vtr::calloc(node.fan_in(),
1222+
node_power->in_prob = (float*)vtr::calloc(node_fan_in,
12221223
sizeof(float));
12231224
break;
12241225
case CHANX:
@@ -1233,11 +1234,11 @@ void power_routing_init(const t_det_routing_arch* routing_arch) {
12331234
max_seg_to_IPIN_fanout = std::max(max_seg_to_IPIN_fanout,
12341235
fanout_to_IPIN);
12351236
max_seg_to_seg_fanout = std::max(max_seg_to_seg_fanout, fanout_to_seg);
1236-
max_fanin = std::max(max_fanin, static_cast<int>(node.fan_in()));
1237+
max_fanin = std::max(max_fanin, node_fan_in);
12371238

1238-
node_power->in_dens = (float*)vtr::calloc(node.fan_in(),
1239+
node_power->in_dens = (float*)vtr::calloc(node_fan_in,
12391240
sizeof(float));
1240-
node_power->in_prob = (float*)vtr::calloc(node.fan_in(),
1241+
node_power->in_prob = (float*)vtr::calloc(node_fan_in,
12411242
sizeof(float));
12421243
break;
12431244
default:
@@ -1361,14 +1362,13 @@ bool power_uninit() {
13611362
bool error = false;
13621363

13631364
for (size_t rr_node_idx = 0; rr_node_idx < device_ctx.rr_nodes.size(); rr_node_idx++) {
1364-
auto node = device_ctx.rr_nodes[rr_node_idx];
13651365
t_rr_node_power* node_power = &rr_node_power[rr_node_idx];
13661366

13671367
switch (rr_graph.node_type(RRNodeId(rr_node_idx))) {
13681368
case CHANX:
13691369
case CHANY:
13701370
case IPIN:
1371-
if (node.fan_in()) {
1371+
if (rr_graph.node_fan_in(RRNodeId(rr_node_idx))) {
13721372
free(node_power->in_dens);
13731373
free(node_power->in_prob);
13741374
}

vpr/src/route/check_rr_graph.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,12 +601,13 @@ static bool has_adjacent_channel(const t_rr_node& node, const DeviceGrid& grid)
601601

602602
static void check_rr_edge(int from_node, int iedge, int to_node) {
603603
auto& device_ctx = g_vpr_ctx.device();
604+
const auto& rr_graph = device_ctx.rr_graph;
604605

605606
//Check that to to_node's fan-in is correct, given the switch type
606607
int iswitch = device_ctx.rr_nodes[from_node].edge_switch(iedge);
607608
auto switch_type = device_ctx.rr_switch_inf[iswitch].type();
608609

609-
int to_fanin = device_ctx.rr_nodes[to_node].fan_in();
610+
int to_fanin = rr_graph.node_fan_in(RRNodeId(to_node));
610611
switch (switch_type) {
611612
case SwitchType::BUFFER:
612613
//Buffer switches are non-configurable, and uni-directional -- they must have only one driver

vpr/src/route/rr_graph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2496,7 +2496,7 @@ std::string describe_rr_node(int inode) {
24962496
}
24972497

24982498
msg += vtr::string_fmt(" capacity: %d", rr_graph.node_capacity(RRNodeId(inode)));
2499-
msg += vtr::string_fmt(" fan-in: %d", rr_node.fan_in());
2499+
msg += vtr::string_fmt(" fan-in: %d", rr_graph.node_fan_in(RRNodeId(inode)));
25002500
msg += vtr::string_fmt(" fan-out: %d", rr_node.num_edges());
25012501

25022502
return msg;

vpr/src/route/rr_graph_area.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ void count_unidir_routing_transistors(std::vector<t_segment_inf>& /*segment_inf*
382382
int switch_index = device_ctx.rr_nodes[from_node].edge_switch(iedge);
383383
auto switch_type = device_ctx.rr_switch_inf[switch_index].type();
384384

385-
int fan_in = device_ctx.rr_nodes[to_node].fan_in();
385+
int fan_in = rr_graph.node_fan_in(RRNodeId(to_node));
386386

387387
if (device_ctx.rr_switch_inf[switch_index].type() == SwitchType::MUX) {
388388
/* Each wire segment begins with a multipexer followed by a driver for unidirectional */

vpr/src/route/rr_node.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class t_rr_node {
9292
short edge_switch(t_edge_size iedge) const;
9393

9494
bool edge_is_configurable(t_edge_size iedge) const;
95-
t_edge_size fan_in() const;
9695

9796
short xlow() const;
9897
short ylow() const;

vpr/src/route/rr_node_impl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ inline short t_rr_node::edge_switch(t_edge_size iedge) const {
102102
return storage_->edge_switch(id_, iedge);
103103
}
104104

105-
inline t_edge_size t_rr_node::fan_in() const {
106-
return storage_->fan_in(id_);
107-
}
108-
109105
inline short t_rr_node::xlow() const {
110106
return storage_->node_xlow(id_);
111107
}

0 commit comments

Comments
 (0)