7
7
#include " vpr_error.h"
8
8
#include " globals.h"
9
9
10
- static int get_expected_segs_to_target (RRNodeId inode, RRNodeId target_node, int * num_segs_ortho_dir_ptr);
10
+ /* *
11
+ * Assuming inode is CHANX or CHANY, this function calculates the number of required wires of the same type as inode
12
+ * to arrive at target_noe.
13
+ * @param inode The source node from which the cost to the target node is obtained.
14
+ * @param target_node The target node to which the cost is obtained.
15
+ * @return std::pait<int, int> The first element is the number of required wires in the same direction as inode,
16
+ * while the second element determines the number of wires in the direction orthogonal to inode.
17
+ */
18
+ static std::pair<int , int > get_expected_segs_to_target (RRNodeId inode, RRNodeId target_node);
19
+
11
20
static int round_up (float x);
12
21
13
22
static std::unique_ptr<RouterLookahead> make_router_lookahead_object (const t_det_routing_arch& det_routing_arch,
@@ -31,8 +40,8 @@ static std::unique_ptr<RouterLookahead> make_router_lookahead_object(const t_det
31
40
32
41
std::unique_ptr<RouterLookahead> make_router_lookahead (const t_det_routing_arch& det_routing_arch,
33
42
e_router_lookahead router_lookahead_type,
34
- std::string write_lookahead,
35
- std::string read_lookahead,
43
+ const std::string& write_lookahead,
44
+ const std::string& read_lookahead,
36
45
const std::vector<t_segment_inf>& segment_inf,
37
46
bool is_flat) {
38
47
std::unique_ptr<RouterLookahead> router_lookahead = make_router_lookahead_object (det_routing_arch,
@@ -53,8 +62,7 @@ std::unique_ptr<RouterLookahead> make_router_lookahead(const t_det_routing_arch&
53
62
}
54
63
55
64
float ClassicLookahead::get_expected_cost (RRNodeId current_node, RRNodeId target_node, const t_conn_cost_params& params, float R_upstream) const {
56
- float delay_cost, cong_cost;
57
- std::tie (delay_cost, cong_cost) = get_expected_delay_and_cong (current_node, target_node, params, R_upstream);
65
+ auto [delay_cost, cong_cost] = get_expected_delay_and_cong (current_node, target_node, params, R_upstream);
58
66
59
67
return delay_cost + cong_cost;
60
68
}
@@ -66,8 +74,7 @@ std::pair<float, float> ClassicLookahead::get_expected_delay_and_cong(RRNodeId n
66
74
t_rr_type rr_type = rr_graph.node_type (node);
67
75
68
76
if (rr_type == CHANX || rr_type == CHANY) {
69
- int num_segs_ortho_dir = 0 ;
70
- int num_segs_same_dir = get_expected_segs_to_target (node, target_node, &num_segs_ortho_dir);
77
+ auto [num_segs_same_dir, num_segs_ortho_dir] = get_expected_segs_to_target (node, target_node);
71
78
72
79
auto cost_index = rr_graph.node_cost_index (node);
73
80
int ortho_cost_index = device_ctx.rr_indexed_data [cost_index].ortho_cost_index ;
@@ -112,28 +119,27 @@ static int round_up(float x) {
112
119
return std::ceil (x - 0.001 );
113
120
}
114
121
115
- static int get_expected_segs_to_target (RRNodeId inode, RRNodeId target_node, int * num_segs_ortho_dir_ptr ) {
122
+ static std::pair< int , int > get_expected_segs_to_target (RRNodeId inode, RRNodeId target_node) {
116
123
/* Returns the number of segments the same type as inode that will be needed *
117
124
* to reach target_node (not including inode) in each direction (the same *
118
125
* direction (horizontal or vertical) as inode and the orthogonal direction).*/
119
-
120
126
auto & device_ctx = g_vpr_ctx.device ();
121
127
const auto & rr_graph = device_ctx.rr_graph ;
122
128
123
- t_rr_type rr_type ;
124
- int target_x, target_y, num_segs_same_dir, ortho_cost_index ;
125
- RRIndexedDataId cost_index;
129
+ int num_segs_ortho_dir ;
130
+ int num_segs_same_dir;
131
+
126
132
int no_need_to_pass_by_clb;
127
- float inv_length, ortho_inv_length, ylow, yhigh, xlow, xhigh;
133
+ float ylow, yhigh, xlow, xhigh;
128
134
129
- target_x = rr_graph.node_xlow (target_node);
130
- target_y = rr_graph.node_ylow (target_node);
135
+ int target_x = rr_graph.node_xlow (target_node);
136
+ int target_y = rr_graph.node_ylow (target_node);
131
137
132
- cost_index = rr_graph.node_cost_index (inode);
133
- inv_length = device_ctx.rr_indexed_data [cost_index].inv_length ;
134
- ortho_cost_index = device_ctx.rr_indexed_data [cost_index].ortho_cost_index ;
135
- ortho_inv_length = device_ctx.rr_indexed_data [RRIndexedDataId (ortho_cost_index)].inv_length ;
136
- rr_type = rr_graph.node_type (inode);
138
+ RRIndexedDataId cost_index = rr_graph.node_cost_index (inode);
139
+ float inv_length = device_ctx.rr_indexed_data [cost_index].inv_length ;
140
+ int ortho_cost_index = device_ctx.rr_indexed_data [cost_index].ortho_cost_index ;
141
+ float ortho_inv_length = device_ctx.rr_indexed_data [RRIndexedDataId (ortho_cost_index)].inv_length ;
142
+ t_rr_type rr_type = rr_graph.node_type (inode);
137
143
138
144
if (rr_type == CHANX) {
139
145
ylow = rr_graph.node_ylow (inode);
@@ -143,13 +149,13 @@ static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int
143
149
/* Count vertical (orthogonal to inode) segs first. */
144
150
145
151
if (ylow > target_y) { /* Coming from a row above target? */
146
- *num_segs_ortho_dir_ptr = round_up ((ylow - target_y + 1 .) * ortho_inv_length);
152
+ num_segs_ortho_dir = round_up ((ylow - target_y + 1 .) * ortho_inv_length);
147
153
no_need_to_pass_by_clb = 1 ;
148
154
} else if (ylow < target_y - 1 ) { /* Below the CLB bottom? */
149
- *num_segs_ortho_dir_ptr = round_up ((target_y - ylow) * ortho_inv_length);
155
+ num_segs_ortho_dir = round_up ((target_y - ylow) * ortho_inv_length);
150
156
no_need_to_pass_by_clb = 1 ;
151
157
} else { /* In a row that passes by target CLB */
152
- *num_segs_ortho_dir_ptr = 0 ;
158
+ num_segs_ortho_dir = 0 ;
153
159
no_need_to_pass_by_clb = 0 ;
154
160
}
155
161
@@ -170,13 +176,13 @@ static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int
170
176
/* Count horizontal (orthogonal to inode) segs first. */
171
177
172
178
if (xlow > target_x) { /* Coming from a column right of target? */
173
- *num_segs_ortho_dir_ptr = round_up ((xlow - target_x + 1 .) * ortho_inv_length);
179
+ num_segs_ortho_dir = round_up ((xlow - target_x + 1 .) * ortho_inv_length);
174
180
no_need_to_pass_by_clb = 1 ;
175
181
} else if (xlow < target_x - 1 ) { /* Left of and not adjacent to the CLB? */
176
- *num_segs_ortho_dir_ptr = round_up ((target_x - xlow) * ortho_inv_length);
182
+ num_segs_ortho_dir = round_up ((target_x - xlow) * ortho_inv_length);
177
183
no_need_to_pass_by_clb = 1 ;
178
184
} else { /* In a column that passes by target CLB */
179
- *num_segs_ortho_dir_ptr = 0 ;
185
+ num_segs_ortho_dir = 0 ;
180
186
no_need_to_pass_by_clb = 0 ;
181
187
}
182
188
@@ -191,7 +197,7 @@ static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int
191
197
}
192
198
}
193
199
194
- return ( num_segs_same_dir) ;
200
+ return { num_segs_same_dir, num_segs_ortho_dir} ;
195
201
}
196
202
197
203
void invalidate_router_lookahead_cache () {
@@ -201,8 +207,8 @@ void invalidate_router_lookahead_cache() {
201
207
202
208
const RouterLookahead* get_cached_router_lookahead (const t_det_routing_arch& det_routing_arch,
203
209
e_router_lookahead router_lookahead_type,
204
- std::string write_lookahead,
205
- std::string read_lookahead,
210
+ const std::string& write_lookahead,
211
+ const std::string& read_lookahead,
206
212
const std::vector<t_segment_inf>& segment_inf,
207
213
bool is_flat) {
208
214
auto & router_ctx = g_vpr_ctx.routing ();
0 commit comments