Skip to content

Commit a72f6e3

Browse files
authored
Merge pull request #1884 from RapidSilicon/api_set_node_cost_index
Add a new API set_node_cost_index() to RRGraphBuilder
2 parents 20b90ee + 2594ccf commit a72f6e3

7 files changed

+34
-33
lines changed

vpr/src/device/rr_graph_builder.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,16 @@ class RRGraphBuilder {
6969
node_storage_.set_node_coordinates(id, x1, y1, x2, y2);
7070
}
7171

72-
/** @brief Set the node_ptc_num; The ptc (pin, track, or class) number is an integer
73-
* that allows you to differentiate between wires, pins or sources/sinks with overlapping x,y coordinates or extent.
74-
* This is useful for drawing rr-graphs nicely.
75-
*
76-
* The ptc_num carries different meanings for different node types
72+
/** @brief The ptc_num carries different meanings for different node types
7773
* (true in VPR RRG that is currently supported, may not be true in customized RRG)
7874
* CHANX or CHANY: the track id in routing channels
7975
* OPIN or IPIN: the index of pins in the logic block data structure
80-
* SOURCE and SINK: the class id of a pin (indicating logic equivalence of pins) in the logic block data structure */
76+
* SOURCE and SINK: the class id of a pin (indicating logic equivalence of pins) in the logic block data structure
77+
* @note
78+
* This API is very powerful and developers should not use it unless it is necessary,
79+
* e.g the node type is unknown. If the node type is known, the more specific routines, `set_node_pin_num()`,
80+
* `set_node_track_num()`and `set_node_class_num()`, for different types of nodes should be used.*/
81+
8182
inline void set_node_ptc_num(RRNodeId id, short new_ptc_num) {
8283
node_storage_.set_node_ptc_num(id, new_ptc_num);
8384
}
@@ -102,6 +103,14 @@ class RRGraphBuilder {
102103
node_storage_.set_node_direction(id, new_direction);
103104
}
104105

106+
/** @brief set_node_cost_index gets the index of cost data in the list of cost_indexed_data data structure
107+
* It contains the routing cost for different nodes in the RRGraph
108+
* when used in evaluate different routing paths
109+
*/
110+
inline void set_node_cost_index(RRNodeId id, RRIndexedDataId new_cost_index) {
111+
node_storage_.set_node_cost_index(id, new_cost_index);
112+
}
113+
105114
/** @brief Set the rc_index of routing resource node. */
106115
inline void set_node_rc_index(RRNodeId id, NodeRCIndex new_rc_index) {
107116
node_storage_.set_node_rc_index(id, new_rc_index);

vpr/src/route/clock_connection_builders.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ RRNodeId RoutingToClockConnection::create_virtual_clock_network_sink_node(int x,
110110
rr_graph_builder.set_node_class_num(node_index, ptc);
111111
rr_graph_builder.set_node_coordinates(node_index, x, y, x, y);
112112
rr_graph_builder.set_node_capacity(node_index, 1);
113-
rr_graph.set_node_cost_index(node_index, RRIndexedDataId(SINK_COST_INDEX));
113+
rr_graph_builder.set_node_cost_index(node_index, RRIndexedDataId(SINK_COST_INDEX));
114114

115115
float R = 0.;
116116
float C = 0.;

vpr/src/route/clock_network_builders.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ int ClockRib::create_chanx_wire(int x_start,
316316
RRGraphBuilder& rr_graph_builder) {
317317
rr_nodes->emplace_back();
318318
auto node_index = rr_nodes->size() - 1;
319-
auto node = rr_nodes->back();
320319
RRNodeId chanx_node = RRNodeId(node_index);
321320

322321
rr_graph_builder.set_node_type(chanx_node, CHANX);
@@ -342,7 +341,7 @@ int ClockRib::create_chanx_wire(int x_start,
342341
VTR_ASSERT_MSG(false, "Unidentified direction type for clock rib");
343342
break;
344343
}
345-
node.set_cost_index(RRIndexedDataId(CHANX_COST_INDEX_START + seg_index)); // Actual value set later
344+
rr_graph_builder.set_node_cost_index(chanx_node, RRIndexedDataId(CHANX_COST_INDEX_START + seg_index)); // Actual value set later
346345

347346
/* Add the node to spatial lookup */
348347
auto& rr_graph = (*rr_nodes);
@@ -622,7 +621,6 @@ int ClockSpine::create_chany_wire(int y_start,
622621
int num_segments) {
623622
rr_nodes->emplace_back();
624623
auto node_index = rr_nodes->size() - 1;
625-
auto node = rr_nodes->back();
626624
RRNodeId chany_node = RRNodeId(node_index);
627625

628626
rr_graph_builder.set_node_type(chany_node, CHANY);
@@ -648,7 +646,7 @@ int ClockSpine::create_chany_wire(int y_start,
648646
VTR_ASSERT_MSG(false, "Unidentified direction type for clock rib");
649647
break;
650648
}
651-
node.set_cost_index(RRIndexedDataId(CHANX_COST_INDEX_START + num_segments + seg_index));
649+
rr_graph_builder.set_node_cost_index(chany_node, RRIndexedDataId(CHANX_COST_INDEX_START + num_segments + seg_index));
652650

653651
/* Add the node to spatial lookup */
654652
auto& rr_graph = (*rr_nodes);

vpr/src/route/rr_graph.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
231231
const t_chan_details& chan_details_x,
232232
const t_chan_details& chan_details_y,
233233
t_rr_edge_info_set& created_rr_edges,
234-
t_rr_graph_storage& L_rr_node,
235234
const int wire_to_ipin_switch,
236235
const enum e_directionality directionality);
237236

@@ -1223,7 +1222,7 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
12231222
CHANX_COST_INDEX_START,
12241223
max_chan_width, grid, tracks_per_chan,
12251224
sblock_pattern, Fs / 3, chan_details_x, chan_details_y,
1226-
rr_edges_to_create, L_rr_node,
1225+
rr_edges_to_create,
12271226
wire_to_ipin_switch,
12281227
directionality);
12291228

@@ -1238,7 +1237,7 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
12381237
CHANX_COST_INDEX_START + num_seg_types,
12391238
max_chan_width, grid, tracks_per_chan,
12401239
sblock_pattern, Fs / 3, chan_details_x, chan_details_y,
1241-
rr_edges_to_create, L_rr_node,
1240+
rr_edges_to_create,
12421241
wire_to_ipin_switch,
12431242
directionality);
12441243

@@ -1410,7 +1409,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder,
14101409
rr_edges_to_create.emplace_back(inode, opin_nodes[iedge], delayless_switch);
14111410
}
14121411

1413-
L_rr_node.set_node_cost_index(inode, RRIndexedDataId(SOURCE_COST_INDEX));
1412+
rr_graph_builder.set_node_cost_index(inode, RRIndexedDataId(SOURCE_COST_INDEX));
14141413
rr_graph_builder.set_node_type(inode, SOURCE);
14151414
} else { /* SINK */
14161415
VTR_ASSERT(class_inf[iclass].type == RECEIVER);
@@ -1428,7 +1427,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder,
14281427
* - set_node_cost_index(RRNodeId, int);
14291428
* - set_node_type(RRNodeId, t_rr_type);
14301429
*/
1431-
L_rr_node.set_node_cost_index(inode, RRIndexedDataId(SINK_COST_INDEX));
1430+
rr_graph_builder.set_node_cost_index(inode, RRIndexedDataId(SINK_COST_INDEX));
14321431
rr_graph_builder.set_node_type(inode, SINK);
14331432
}
14341433

@@ -1463,7 +1462,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder,
14631462
//Add info about the edge to be created
14641463
rr_edges_to_create.emplace_back(inode, to_node, delayless_switch);
14651464

1466-
L_rr_node.set_node_cost_index(inode, RRIndexedDataId(IPIN_COST_INDEX));
1465+
rr_graph_builder.set_node_cost_index(inode, RRIndexedDataId(IPIN_COST_INDEX));
14671466
rr_graph_builder.set_node_type(inode, IPIN);
14681467
}
14691468
} else {
@@ -1475,7 +1474,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder,
14751474
/* Output pins may not exist on some sides, we may not always find one */
14761475
if (inode) {
14771476
//Initially left unconnected
1478-
L_rr_node.set_node_cost_index(inode, RRIndexedDataId(OPIN_COST_INDEX));
1477+
rr_graph_builder.set_node_cost_index(inode, RRIndexedDataId(OPIN_COST_INDEX));
14791478
rr_graph_builder.set_node_type(inode, OPIN);
14801479
}
14811480
}
@@ -1527,7 +1526,6 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
15271526
const t_chan_details& chan_details_x,
15281527
const t_chan_details& chan_details_y,
15291528
t_rr_edge_info_set& rr_edges_to_create,
1530-
t_rr_graph_storage& L_rr_node,
15311529
const int wire_to_ipin_switch,
15321530
const enum e_directionality directionality) {
15331531
/* this function builds both x and y-directed channel segments, so set up our
@@ -1661,7 +1659,7 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
16611659
}
16621660

16631661
/* Edge arrays have now been built up. Do everything else. */
1664-
L_rr_node.set_node_cost_index(node, RRIndexedDataId(cost_index_offset + seg_details[track].index()));
1662+
rr_graph_builder.set_node_cost_index(node, RRIndexedDataId(cost_index_offset + seg_details[track].index()));
16651663
rr_graph_builder.set_node_capacity(node, 1); /* GLOBAL routing handled elsewhere */
16661664

16671665
if (chan_type == CHANX) {

vpr/src/route/rr_graph_uxsdcxx_serializer.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -705,13 +705,15 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
705705
}
706706

707707
auto node = (*rr_nodes_)[inode];
708+
RRNodeId node_id = node.id();
709+
708710
if (GRAPH_GLOBAL == graph_type_) {
709-
node.set_cost_index(RRIndexedDataId(0));
711+
rr_graph_builder_->set_node_cost_index(node_id, RRIndexedDataId(0));
710712
} else if (rr_graph.node_type(node.id()) == CHANX) {
711-
node.set_cost_index(RRIndexedDataId(CHANX_COST_INDEX_START + segment_id));
713+
rr_graph_builder_->set_node_cost_index(node_id, RRIndexedDataId(CHANX_COST_INDEX_START + segment_id));
712714
seg_index_[rr_graph.node_cost_index(node.id())] = segment_id;
713715
} else if (rr_graph.node_type(node.id()) == CHANY) {
714-
node.set_cost_index(RRIndexedDataId(CHANX_COST_INDEX_START + segment_inf_.size() + segment_id));
716+
rr_graph_builder_->set_node_cost_index(node_id, RRIndexedDataId(CHANX_COST_INDEX_START + segment_inf_.size() + segment_id));
715717
seg_index_[rr_graph.node_cost_index(node.id())] = segment_id;
716718
}
717719
return inode;
@@ -774,16 +776,16 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
774776
case CHANY:
775777
break;
776778
case SOURCE:
777-
node.set_cost_index(RRIndexedDataId(SOURCE_COST_INDEX));
779+
rr_graph_builder_->set_node_cost_index(node_id, RRIndexedDataId(SOURCE_COST_INDEX));
778780
break;
779781
case SINK:
780-
node.set_cost_index(RRIndexedDataId(SINK_COST_INDEX));
782+
rr_graph_builder_->set_node_cost_index(node_id, RRIndexedDataId(SINK_COST_INDEX));
781783
break;
782784
case OPIN:
783-
node.set_cost_index(RRIndexedDataId(OPIN_COST_INDEX));
785+
rr_graph_builder_->set_node_cost_index(node_id, RRIndexedDataId(OPIN_COST_INDEX));
784786
break;
785787
case IPIN:
786-
node.set_cost_index(RRIndexedDataId(IPIN_COST_INDEX));
788+
rr_graph_builder_->set_node_cost_index(node_id, RRIndexedDataId(IPIN_COST_INDEX));
787789
break;
788790
default:
789791
report_error(

vpr/src/route/rr_node.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,3 @@ bool t_rr_node::validate() const {
4040

4141
return true;
4242
}
43-
44-
void t_rr_node::set_cost_index(RRIndexedDataId new_cost_index) {
45-
storage_->set_node_cost_index(id_, new_cost_index);
46-
}

vpr/src/route/rr_node.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ class t_rr_node {
103103
bool validate() const;
104104

105105
public: //Mutators
106-
void set_cost_index(RRIndexedDataId);
107-
108106
void set_side(e_side);
109107

110108
void next_node() {

0 commit comments

Comments
 (0)