Skip to content

Commit 57c333b

Browse files
committed
Added strong id RRIndexedDataId
Signed-off-by: Ethan Rogers <[email protected]>
1 parent 46a1f6a commit 57c333b

23 files changed

+140
-135
lines changed

vpr/src/base/vpr_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ struct DeviceContext : public Context {
149149
*/
150150
t_rr_graph_storage rr_nodes; // autogenerated in build_rr_graph
151151

152-
std::vector<t_rr_indexed_data> rr_indexed_data; // [0 .. num_rr_indexed_data-1]
152+
vtr::vector<RRIndexedDataId, t_rr_indexed_data> rr_indexed_data; // [0 .. num_rr_indexed_data-1]
153153

154154
///@brief Fly-weighted Resistance/Capacitance data for RR Nodes
155155
std::vector<t_rr_rc_data> rr_rc_data;

vpr/src/device/rr_graph_fwd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ class RRGraph;
1515

1616
struct rr_node_id_tag;
1717
struct rr_edge_id_tag;
18+
struct rr_indexed_data_id_tag;
1819
struct rr_switch_id_tag;
1920
struct rr_segment_id_tag;
2021

2122
typedef vtr::StrongId<rr_node_id_tag, unsigned int> RRNodeId;
2223
typedef vtr::StrongId<rr_edge_id_tag, unsigned int> RREdgeId;
24+
typedef vtr::StrongId<rr_indexed_data_id_tag, unsigned int> RRIndexedDataId;
2325
typedef vtr::StrongId<rr_switch_id_tag, short> RRSwitchId;
2426
typedef vtr::StrongId<rr_segment_id_tag, short> RRSegmentId;
2527

vpr/src/device/rr_graph_obj.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ short RRGraph::node_class_num(const RRNodeId& node) const {
151151
return node_ptc_num(node);
152152
}
153153

154-
short RRGraph::node_cost_index(const RRNodeId& node) const {
154+
RRIndexedDataId RRGraph::node_cost_index(const RRNodeId& node) const {
155155
VTR_ASSERT_SAFE(valid_node_id(node));
156-
return node_cost_indices_[node];
156+
return RRIndexedDataId(node_cost_indices_[node]);
157157
}
158158

159159
Direction RRGraph::node_direction(const RRNodeId& node) const {
@@ -990,9 +990,9 @@ void RRGraph::set_node_class_num(const RRNodeId& node, const short& class_id) {
990990
set_node_ptc_num(node, class_id);
991991
}
992992

993-
void RRGraph::set_node_cost_index(const RRNodeId& node, const short& cost_index) {
993+
void RRGraph::set_node_cost_index(const RRNodeId& node, const RRIndexedDataId& cost_index) {
994994
VTR_ASSERT(valid_node_id(node));
995-
node_cost_indices_[node] = cost_index;
995+
node_cost_indices_[node] = (size_t) cost_index;
996996
}
997997

998998
void RRGraph::set_node_direction(const RRNodeId& node, const Direction& direction) {

vpr/src/device/rr_graph_obj.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class RRGraph {
410410
* when used in evaluate different routing paths
411411
* See cross-reference section in this header file for more details
412412
*/
413-
short node_cost_index(const RRNodeId& node) const;
413+
RRIndexedDataId node_cost_index(const RRNodeId& node) const;
414414

415415
/* Get the directionality of a node
416416
* see node coordinate for details
@@ -669,7 +669,7 @@ class RRGraph {
669669

670670
/* Set the routing cost index for node, see node_cost_index() for details */
671671
/* TODO: the cost index should be changed to a StrongId!!! */
672-
void set_node_cost_index(const RRNodeId& node, const short& cost_index);
672+
void set_node_cost_index(const RRNodeId& node, const RRIndexedDataId& cost_index);
673673

674674
/* Set the directionality for a node, only applicable to CHANX and CHANY */
675675
void set_node_direction(const RRNodeId& node, const Direction& direction);

vpr/src/device/rr_graph_view.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "rr_node.h"
33
#include "physical_types.h"
44

5-
RRGraphView::RRGraphView(const t_rr_graph_storage& node_storage, const RRSpatialLookup& node_lookup, const std::vector<t_rr_indexed_data>& rr_indexed_data, const std::vector<t_segment_inf>& rr_segments)
5+
RRGraphView::RRGraphView(const t_rr_graph_storage& node_storage, const RRSpatialLookup& node_lookup, const vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data, const std::vector<t_segment_inf>& rr_segments)
66
: node_storage_(node_storage)
77
, node_lookup_(node_lookup)
88
, rr_indexed_data_(rr_indexed_data)

vpr/src/device/rr_graph_view.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class RRGraphView {
3737
/* See detailed comments about the data structures in the internal data storage section of this file */
3838
RRGraphView(const t_rr_graph_storage& node_storage,
3939
const RRSpatialLookup& node_lookup,
40-
const std::vector<t_rr_indexed_data>& rr_indexed_data,
40+
const vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data,
4141
const std::vector<t_segment_inf>& rr_segments);
4242

4343
/* Disable copy constructors and copy assignment operator
@@ -207,7 +207,7 @@ class RRGraphView {
207207
arrow = "";
208208
}
209209
if (node_type(node) == CHANX || node_type(node) == CHANY) { //for channels, we would like to describe the component with segment specific information
210-
int cost_index = node_cost_index(node);
210+
RRIndexedDataId cost_index = node_cost_index(node);
211211
int seg_index = rr_indexed_data_[cost_index].seg_index;
212212
coordinate_string += rr_segments_[seg_index].name; //Write the segment name
213213
coordinate_string += " length:" + std::to_string(node_length(node)); //add the length of the segment
@@ -245,7 +245,7 @@ class RRGraphView {
245245
}
246246

247247
/** @brief Get the cost index of a routing resource node. This function is inlined for runtime optimization. */
248-
inline short node_cost_index(RRNodeId node) const {
248+
RRIndexedDataId node_cost_index(RRNodeId node) const {
249249
return node_storage_.node_cost_index(node);
250250
}
251251

@@ -263,7 +263,7 @@ class RRGraphView {
263263
const RRSpatialLookup& node_lookup_;
264264

265265
/* rr_indexed_data_ and rr_segments_ are needed to lookup the segment information in node_coordinate_to_string() */
266-
const std::vector<t_rr_indexed_data>& rr_indexed_data_;
266+
const vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data_;
267267

268268
/* Segment info for rr nodes */
269269
const std::vector<t_segment_inf>& rr_segments_;

vpr/src/route/check_rr_graph.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ void check_rr_node(int inode, enum e_route_type route_type, const DeviceContext&
295295
int xlow, ylow, xhigh, yhigh, ptc_num, capacity;
296296
t_rr_type rr_type;
297297
t_physical_tile_type_ptr type;
298-
int nodes_per_chan, tracks_per_node, num_edges, cost_index;
298+
int nodes_per_chan, tracks_per_node, num_edges;
299+
RRIndexedDataId cost_index;
299300
float C, R;
300301
const auto& rr_graph = device_ctx.rr_graph;
301302
RRNodeId rr_node = RRNodeId(inode);
@@ -326,7 +327,7 @@ void check_rr_node(int inode, enum e_route_type route_type, const DeviceContext&
326327
"in check_rr_node: inode %d (type %d) had a ptc_num of %d.\n", inode, rr_type, ptc_num);
327328
}
328329

329-
if (cost_index < 0 || cost_index >= (int)device_ctx.rr_indexed_data.size()) {
330+
if ((size_t) cost_index < 0 || (size_t) cost_index >= (int)device_ctx.rr_indexed_data.size()) {
330331
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
331332
"in check_rr_node: node %d cost index (%d) is out of range.\n", inode, cost_index);
332333
}

vpr/src/route/clock_connection_builders.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ RRNodeId RoutingToClockConnection::create_virtual_clock_network_sink_node(int x,
108108
rr_graph.set_node_ptc_num(node_index, ptc);
109109
rr_graph.set_node_coordinates(node_index, x, y, x, y);
110110
rr_graph.set_node_capacity(node_index, 1);
111-
rr_graph.set_node_cost_index(node_index, SINK_COST_INDEX);
111+
rr_graph.set_node_cost_index(node_index, RRIndexedDataId(SINK_COST_INDEX));
112112
rr_graph.set_node_type(node_index, SINK);
113113
float R = 0.;
114114
float C = 0.;

vpr/src/route/clock_network_builders.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ int ClockRib::create_chanx_wire(int x_start,
341341
VTR_ASSERT_MSG(false, "Unidentified direction type for clock rib");
342342
break;
343343
}
344-
node.set_cost_index(CHANX_COST_INDEX_START + seg_index); // Actual value set later
344+
node.set_cost_index(RRIndexedDataId(CHANX_COST_INDEX_START + seg_index)); // Actual value set later
345345

346346
/* Add the node to spatial lookup */
347347
auto& rr_graph = (*rr_nodes);
@@ -647,7 +647,7 @@ int ClockSpine::create_chany_wire(int y_start,
647647
VTR_ASSERT_MSG(false, "Unidentified direction type for clock rib");
648648
break;
649649
}
650-
node.set_cost_index(CHANX_COST_INDEX_START + num_segments + seg_index);
650+
node.set_cost_index(RRIndexedDataId(CHANX_COST_INDEX_START + num_segments + seg_index));
651651

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

vpr/src/route/route_timing.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,10 +1550,10 @@ void update_rr_base_costs(int fanout) {
15501550
factor = sqrt(fanout);
15511551

15521552
for (index = CHANX_COST_INDEX_START; index < device_ctx.rr_indexed_data.size(); index++) {
1553-
if (device_ctx.rr_indexed_data[index].T_quadratic > 0.) { /* pass transistor */
1554-
device_ctx.rr_indexed_data[index].base_cost = device_ctx.rr_indexed_data[index].saved_base_cost * factor;
1553+
if (device_ctx.rr_indexed_data[RRIndexedDataId(index)].T_quadratic > 0.) { /* pass transistor */
1554+
device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = device_ctx.rr_indexed_data[RRIndexedDataId(index)].saved_base_cost * factor;
15551555
} else {
1556-
device_ctx.rr_indexed_data[index].base_cost = device_ctx.rr_indexed_data[index].saved_base_cost;
1556+
device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = device_ctx.rr_indexed_data[RRIndexedDataId(index)].saved_base_cost;
15571557
}
15581558
}
15591559
}

vpr/src/route/router_lookahead.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ std::pair<float, float> ClassicLookahead::get_expected_delay_and_cong(RRNodeId n
6161
int num_segs_ortho_dir = 0;
6262
int num_segs_same_dir = get_expected_segs_to_target(node, target_node, &num_segs_ortho_dir);
6363

64-
int cost_index = rr_graph.node_cost_index(node);
64+
auto cost_index = rr_graph.node_cost_index(node);
6565
int ortho_cost_index = device_ctx.rr_indexed_data[cost_index].ortho_cost_index;
6666

6767
const auto& same_data = device_ctx.rr_indexed_data[cost_index];
68-
const auto& ortho_data = device_ctx.rr_indexed_data[ortho_cost_index];
69-
const auto& ipin_data = device_ctx.rr_indexed_data[IPIN_COST_INDEX];
70-
const auto& sink_data = device_ctx.rr_indexed_data[SINK_COST_INDEX];
68+
const auto& ortho_data = device_ctx.rr_indexed_data[RRIndexedDataId(ortho_cost_index)];
69+
const auto& ipin_data = device_ctx.rr_indexed_data[RRIndexedDataId(IPIN_COST_INDEX)];
70+
const auto& sink_data = device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)];
7171

7272
float cong_cost = num_segs_same_dir * same_data.base_cost
7373
+ num_segs_ortho_dir * ortho_data.base_cost
@@ -83,7 +83,7 @@ std::pair<float, float> ClassicLookahead::get_expected_delay_and_cong(RRNodeId n
8383

8484
return std::make_pair(params.criticality * Tdel, (1 - params.criticality) * cong_cost);
8585
} else if (rr_type == IPIN) { /* Change if you're allowing route-throughs */
86-
return std::make_pair(0., device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost);
86+
return std::make_pair(0., device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)].base_cost);
8787

8888
} else { /* Change this if you want to investigate route-throughs */
8989
return std::make_pair(0., 0.);
@@ -113,7 +113,8 @@ static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int
113113
const auto& rr_graph = device_ctx.rr_graph;
114114

115115
t_rr_type rr_type;
116-
int target_x, target_y, num_segs_same_dir, cost_index, ortho_cost_index;
116+
int target_x, target_y, num_segs_same_dir, ortho_cost_index;
117+
RRIndexedDataId cost_index;
117118
int no_need_to_pass_by_clb;
118119
float inv_length, ortho_inv_length, ylow, yhigh, xlow, xhigh;
119120

@@ -123,7 +124,7 @@ static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int
123124
cost_index = rr_graph.node_cost_index(inode);
124125
inv_length = device_ctx.rr_indexed_data[cost_index].inv_length;
125126
ortho_cost_index = device_ctx.rr_indexed_data[cost_index].ortho_cost_index;
126-
ortho_inv_length = device_ctx.rr_indexed_data[ortho_cost_index].inv_length;
127+
ortho_inv_length = device_ctx.rr_indexed_data[RRIndexedDataId(ortho_cost_index)].inv_length;
127128
rr_type = rr_graph.node_type(inode);
128129

129130
if (rr_type == CHANX) {

vpr/src/route/router_lookahead_cost_map.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void CostMap::set_counts(size_t seg_count) {
5959
*/
6060
int CostMap::node_to_segment(int from_node_ind) const {
6161
const auto& device_ctx = g_vpr_ctx.device();
62-
int from_cost_index = device_ctx.rr_graph.node_cost_index(RRNodeId(from_node_ind));
62+
auto from_cost_index = device_ctx.rr_graph.node_cost_index(RRNodeId(from_node_ind));
6363
return device_ctx.rr_indexed_data[from_cost_index].seg_index;
6464
}
6565

vpr/src/route/router_lookahead_extended_map.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ float ExtendedMapLookahead::get_expected_cost(
586586
} else if (rr_type == IPIN) { /* Change if you're allowing route-throughs */
587587
// This is to return only the cost between the IPIN and SINK. No need to
588588
// query the cost map, as the routing of this connection is almost done.
589-
return device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost;
589+
return device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)].base_cost;
590590
} else { /* Change this if you want to investigate route-throughs */
591591
return 0.;
592592
}

vpr/src/route/router_lookahead_map.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class PQ_Entry {
151151
this->congestion_upstream = parent_congestion_upstream;
152152
this->R_upstream = parent_R_upstream;
153153
if (!starting_node) {
154-
int cost_index = rr_graph.node_cost_index(RRNodeId(set_rr_node));
154+
auto cost_index = rr_graph.node_cost_index(RRNodeId(set_rr_node));
155155
//this->delay += rr_graph.node_C(RRNodeId(set_rr_node)) * (g_rr_switch_inf[switch_ind].R + 0.5*rr_graph.node_R(RRNodeId(set_rr_node))) +
156156
// g_rr_switch_inf[switch_ind].Tdel;
157157

@@ -244,7 +244,7 @@ float MapLookahead::get_expected_cost(RRNodeId current_node, RRNodeId target_nod
244244
std::tie(delay_cost, cong_cost) = get_expected_delay_and_cong(current_node, target_node, params, R_upstream);
245245
return delay_cost + cong_cost;
246246
} else if (rr_type == IPIN) { /* Change if you're allowing route-throughs */
247-
return (device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost);
247+
return (device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)].base_cost);
248248
} else { /* Change this if you want to investigate route-throughs */
249249
return (0.);
250250
}
@@ -336,7 +336,7 @@ std::pair<float, float> MapLookahead::get_expected_delay_and_cong(RRNodeId from_
336336
VTR_ASSERT_SAFE(from_type == CHANX || from_type == CHANY);
337337
//When estimating costs from a wire, we directly look-up the result in the wire lookahead (f_wire_cost_map)
338338

339-
int from_cost_index = temp_rr_graph.node_cost_index(from_node);
339+
auto from_cost_index = temp_rr_graph.node_cost_index(from_node);
340340
int from_seg_index = device_ctx.rr_indexed_data[from_cost_index].seg_index;
341341

342342
VTR_ASSERT(from_seg_index >= 0);
@@ -356,7 +356,7 @@ std::pair<float, float> MapLookahead::get_expected_delay_and_cong(RRNodeId from_
356356
describe_rr_node(size_t(from_node)).c_str())
357357
.c_str());
358358
} else if (from_type == IPIN) { /* Change if you're allowing route-throughs */
359-
return std::make_pair(0., device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost);
359+
return std::make_pair(0., device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)].base_cost);
360360
} else { /* Change this if you want to investigate route-throughs */
361361
return std::make_pair(0., 0.);
362362
}
@@ -479,8 +479,8 @@ static void compute_router_wire_lookahead(const std::vector<t_segment_inf>& segm
479479
auto rr_type = temp_rr_graph.node_type(rr_node);
480480
if (rr_type != chan_type) continue;
481481

482-
int cost_index = temp_rr_graph.node_cost_index(rr_node);
483-
VTR_ASSERT(cost_index != OPEN);
482+
auto cost_index = temp_rr_graph.node_cost_index(rr_node);
483+
VTR_ASSERT(cost_index != RRIndexedDataId(OPEN));
484484

485485
int seg_index = device_ctx.rr_indexed_data[cost_index].seg_index;
486486

@@ -568,7 +568,7 @@ static RRNodeId get_start_node(int start_x, int start_y, int target_x, int targe
568568
VTR_ASSERT(rr_graph.node_type(node_id) == rr_type);
569569

570570
Direction node_direction = rr_graph.node_direction(node_id);
571-
int node_cost_ind = rr_graph.node_cost_index(node_id);
571+
auto node_cost_ind = rr_graph.node_cost_index(node_id);
572572
int node_seg_ind = device_ctx.rr_indexed_data[node_cost_ind].seg_index;
573573

574574
if ((node_direction == direction || node_direction == Direction::BIDIR) && node_seg_ind == seg_index) {

vpr/src/route/router_lookahead_map_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ static void dijkstra_flood_to_wires(int itile, RRNodeId node, util::t_src_opin_d
469469
int seg_index;
470470
if (curr_rr_type != SINK) {
471471
//It's a wire, figure out its type
472-
int cost_index = temp_rr_graph.node_cost_index(curr.node);
472+
auto cost_index = temp_rr_graph.node_cost_index(curr.node);
473473
seg_index = device_ctx.rr_indexed_data[cost_index].seg_index;
474474
} else {
475475
//This is a direct-connect path between an IPIN and OPIN,
@@ -493,7 +493,7 @@ static void dijkstra_flood_to_wires(int itile, RRNodeId node, util::t_src_opin_d
493493

494494
} else if (curr_rr_type == SOURCE || curr_rr_type == OPIN || curr_rr_type == IPIN) {
495495
//We allow expansion through SOURCE/OPIN/IPIN types
496-
int cost_index = temp_rr_graph.node_cost_index(curr.node);
496+
auto cost_index = temp_rr_graph.node_cost_index(curr.node);
497497
float incr_cong = device_ctx.rr_indexed_data[cost_index].base_cost; //Current nodes congestion cost
498498

499499
for (RREdgeId edge : rr_graph.edge_range(curr.node)) {
@@ -588,7 +588,7 @@ static void dijkstra_flood_to_ipins(RRNodeId node, util::t_chan_ipins_delays& ch
588588
}
589589

590590
//We allow expansion through SOURCE/OPIN/IPIN types
591-
int cost_index = temp_rr_graph.node_cost_index(curr.node);
591+
auto cost_index = temp_rr_graph.node_cost_index(curr.node);
592592
float new_cong = device_ctx.rr_indexed_data[cost_index].base_cost; //Current nodes congestion cost
593593

594594
for (RREdgeId edge : rr_graph.edge_range(curr.node)) {

0 commit comments

Comments
 (0)