Skip to content

Commit f217f82

Browse files
committed
Merge branch 'master' into routing_constraints
2 parents 9364e9f + ed4a43a commit f217f82

26 files changed

+884
-6990
lines changed

libs/librrgraph/src/base/rr_graph_view.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,13 @@ class RRGraphView {
255255
std::string start_y; //start y-coordinate
256256
std::string end_x; //end x-coordinate
257257
std::string end_y; //end y-coordinate
258-
std::string layer_num_str; //layer number
258+
std::string start_layer_str; //layer number
259+
std::string end_layer_str; //layer number
259260
std::string arrow; //direction arrow
260261
std::string coordinate_string = node_type_string(node); //write the component's type as a routing resource node
261262
coordinate_string += ":" + std::to_string(size_t(node)) + " "; //add the index of the routing resource node
263+
264+
int node_layer_num = node_layer(node);
262265
if (node_type(node) == OPIN || node_type(node) == IPIN) {
263266
coordinate_string += "side: ("; //add the side of the routing resource node
264267
for (const e_side& node_side : SIDES) {
@@ -272,12 +275,12 @@ class RRGraphView {
272275
// and the end to the lower coordinate
273276
start_x = " (" + std::to_string(node_xhigh(node)) + ","; //start and end coordinates are the same for OPINs and IPINs
274277
start_y = std::to_string(node_yhigh(node)) + ",";
275-
layer_num_str = std::to_string(node_layer(node)) + ")";
278+
start_layer_str = std::to_string(node_layer_num) + ")";
276279
} else if (node_type(node) == SOURCE || node_type(node) == SINK) {
277280
// For SOURCE and SINK the starting and ending coordinate are identical, so just use start
278281
start_x = " (" + std::to_string(node_xhigh(node)) + ",";
279282
start_y = std::to_string(node_yhigh(node)) + ",";
280-
layer_num_str = std::to_string(node_layer(node)) + ")";
283+
start_layer_str = std::to_string(node_layer_num) + ")";
281284
} else if (node_type(node) == CHANX || node_type(node) == CHANY) { //for channels, we would like to describe the component with segment specific information
282285
RRIndexedDataId cost_index = node_cost_index(node);
283286
int seg_index = rr_indexed_data_[cost_index].seg_index;
@@ -291,26 +294,28 @@ class RRGraphView {
291294

292295
start_x = " (" + std::to_string(node_xhigh(node)) + ","; //start coordinates have large value
293296
start_y = std::to_string(node_yhigh(node)) + ",";
297+
start_layer_str = std::to_string(node_layer_num);
294298
end_x = " (" + std::to_string(node_xlow(node)) + ","; //end coordinates have smaller value
295299
end_y = std::to_string(node_ylow(node)) + ",";
296-
layer_num_str = std::to_string(node_layer(node)) + ")";
300+
end_layer_str = std::to_string(node_layer_num) + ")";
297301
}
298302

299303
else { // signal travels in increasing direction, stays at same point, or can travel both directions
300304
start_x = " (" + std::to_string(node_xlow(node)) + ","; //start coordinates have smaller value
301305
start_y = std::to_string(node_ylow(node)) + ",";
306+
start_layer_str = std::to_string(node_layer_num);
302307
end_x = " (" + std::to_string(node_xhigh(node)) + ","; //end coordinates have larger value
303308
end_y = std::to_string(node_yhigh(node)) + ",";
304-
layer_num_str = std::to_string(node_layer(node)) + ")"; //layer number
309+
end_layer_str = std::to_string(node_layer_num) + ")"; //layer number
305310
if (node_direction(node) == Direction::BIDIR) {
306311
arrow = "<->"; //indicate that signal can travel both direction
307312
}
308313
}
309314
}
310315

311-
coordinate_string += start_x + start_y + layer_num_str; //Write the starting coordinates
316+
coordinate_string += start_x + start_y + start_layer_str; //Write the starting coordinates
312317
coordinate_string += arrow; //Indicate the direction
313-
coordinate_string += end_x + end_y + layer_num_str; //Write the end coordinates
318+
coordinate_string += end_x + end_y + end_layer_str; //Write the end coordinates
314319
return coordinate_string;
315320
}
316321

libs/librrgraph/src/utils/alloc_and_load_rr_indexed_data.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,18 @@ static void load_rr_indexed_data_base_costs(const RRGraphView& rr_graph,
351351
rr_indexed_data[RRIndexedDataId(SOURCE_COST_INDEX)].base_cost = delay_normalization_fac;
352352
rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)].base_cost = 0.;
353353
rr_indexed_data[RRIndexedDataId(OPIN_COST_INDEX)].base_cost = delay_normalization_fac;
354+
// If the SPEC_CPU flag is set, we need to make sure that all floating point numbers are perfectly representable in
355+
// binary format. Thus, we changed the IPIN_COST_INDEX base cost from 0.95 to 0.875.
356+
// This number is perfectly representable in a binary mantissa (without round-off) so we can get the same routing result on different platforms.
357+
// Since the router cost calculations and heap use floating point numbers, normally we get slightly different round off with different compiler settings,
358+
// leading to different heap sorts and hence different routings.
359+
// To make result validation for SPEC easier, we choose all router parameters to result in calculations that fit perfectly in a 24-bit binary mantissa.
360+
// .875 = 1/2 + 1/4 + 1/8 can be perfectly represented in a binary mantissa with only the first 3 bits set.
361+
#ifdef SPEC_CPU
362+
rr_indexed_data[RRIndexedDataId(IPIN_COST_INDEX)].base_cost = 0.875 * delay_normalization_fac;
363+
#else
354364
rr_indexed_data[RRIndexedDataId(IPIN_COST_INDEX)].base_cost = 0.95 * delay_normalization_fac;
365+
#endif
355366

356367
auto rr_segment_counts = count_rr_segment_types(rr_graph, rr_indexed_data);
357368
size_t total_segments = std::accumulate(rr_segment_counts.begin(), rr_segment_counts.end(), 0u);

vpr/src/route/connection_router.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ t_heap* ConnectionRouter<Heap>::timing_driven_route_connection_from_heap(RRNodeI
203203
const t_conn_cost_params cost_params,
204204
t_bb bounding_box) {
205205
VTR_ASSERT_SAFE(heap_.is_valid());
206-
//std::cout << "using this: " << (void *)this << "\n";
207-
//std::cout << "using heap: " << heap_.get_ptr() << "\n";
208206

209207
if (heap_.is_empty_heap()) { //No source
210208
VTR_LOGV_DEBUG(router_debug_, " Initial heap empty (no source)\n");

vpr/src/route/router_lookahead_extended_map.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static std::pair<float, int> run_dijkstra(RRNodeId start_node,
6565
std::vector<util::Search_Path>* paths,
6666
util::RoutingCosts* routing_costs);
6767

68-
std::pair<float, float> ExtendedMapLookahead::get_src_opin_cost(RRNodeId from_node, int delta_x, int delta_y, const t_conn_cost_params& params) const {
68+
std::pair<float, float> ExtendedMapLookahead::get_src_opin_cost(RRNodeId from_node, int delta_x, int delta_y, int to_layer_num, const t_conn_cost_params& params) const {
6969
auto& device_ctx = g_vpr_ctx.device();
7070
auto& rr_graph = device_ctx.rr_graph;
7171

@@ -109,7 +109,7 @@ std::pair<float, float> ExtendedMapLookahead::get_src_opin_cost(RRNodeId from_no
109109
float expected_delay_cost = std::numeric_limits<float>::infinity();
110110
float expected_cong_cost = std::numeric_limits<float>::infinity();
111111

112-
for (const auto& kv : this->src_opin_delays[from_layer_num][tile_index][from_ptc]) {
112+
for (const auto& kv : this->src_opin_delays[from_layer_num][tile_index][from_ptc][to_layer_num]) {
113113
const util::t_reachable_wire_inf& reachable_wire_inf = kv.second;
114114

115115
util::Cost_Entry cost_entry;
@@ -195,13 +195,15 @@ std::pair<float, float> ExtendedMapLookahead::get_expected_delay_and_cong(RRNode
195195
int to_x = rr_graph.node_xlow(to_node);
196196
int to_y = rr_graph.node_ylow(to_node);
197197

198+
int to_layer_num = rr_graph.node_layer(to_node);
199+
198200
int dx, dy;
199201
dx = to_x - from_x;
200202
dy = to_y - from_y;
201203

202204
e_rr_type from_type = rr_graph.node_type(from_node);
203205
if (from_type == SOURCE || from_type == OPIN) {
204-
return this->get_src_opin_cost(from_node, dx, dy, params);
206+
return this->get_src_opin_cost(from_node, dx, dy, to_layer_num, params);
205207
} else if (from_type == IPIN) {
206208
return std::make_pair(0., 0.);
207209
}
@@ -420,7 +422,7 @@ std::pair<float, int> ExtendedMapLookahead::run_dijkstra(RRNodeId start_node,
420422

421423
// compute the cost maps for lookahead
422424
void ExtendedMapLookahead::compute(const std::vector<t_segment_inf>& segment_inf) {
423-
std::tie(this->src_opin_delays, this->src_opin_inter_layer_delays) = util::compute_router_src_opin_lookahead(is_flat_);
425+
this->src_opin_delays = util::compute_router_src_opin_lookahead(is_flat_);
424426

425427
this->chan_ipins_delays = util::compute_router_chan_ipin_lookahead();
426428

@@ -616,7 +618,7 @@ void ExtendedMapLookahead::write(const std::string& file) const {
616618
void ExtendedMapLookahead::read(const std::string& file) {
617619
cost_map_.read(file);
618620

619-
std::tie(this->src_opin_delays, this->src_opin_inter_layer_delays) = util::compute_router_src_opin_lookahead(is_flat_);
621+
this->src_opin_delays = util::compute_router_src_opin_lookahead(is_flat_);
620622

621623
this->chan_ipins_delays = util::compute_router_chan_ipin_lookahead();
622624
}

vpr/src/route/router_lookahead_extended_map.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ class ExtendedMapLookahead : public RouterLookahead {
1919
///<Look-up table from SOURCE/OPIN to CHANX/CHANY of various types
2020
util::t_src_opin_delays src_opin_delays;
2121

22-
///< Lookup table from SOURCE/OPIN to CHANX/CHANY of the another layer
23-
util::t_src_opin_inter_layer_delays src_opin_inter_layer_delays;
24-
2522
///<Look-up table from CHANX/CHANY to SINK/IPIN of various types
2623
util::t_chan_ipins_delays chan_ipins_delays;
2724

@@ -33,7 +30,7 @@ class ExtendedMapLookahead : public RouterLookahead {
3330
* @param criticality_fac criticality of the current connection between 0 (all congestion) and 1 (all timing)
3431
* @return expected cost to get to the destination
3532
*/
36-
std::pair<float, float> get_src_opin_cost(RRNodeId from_node, int delta_x, int delta_y, const t_conn_cost_params& params) const;
33+
std::pair<float, float> get_src_opin_cost(RRNodeId from_node, int delta_x, int delta_y, int to_layer_num, const t_conn_cost_params& params) const;
3734

3835
/**
3936
* @brief Returns the CHAN -> IPIN delay that gets added to the final expected delay

0 commit comments

Comments
 (0)