Skip to content

Commit deddc8a

Browse files
author
Nathan Shreve
committed
Disabled RCV support for RouterLookahead, comments
1 parent 1c9bb58 commit deddc8a

19 files changed

+141
-67
lines changed

vpr/src/base/read_options.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,8 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
16771677
.help(
16781678
"For every routed sink, record the cost, delay, and congestion estimated by the router lookahead and the "
16791679
"actual cost, delay, and congestion, from every node along each route to the sink. These results, along with many "
1680-
"other attributes of the node, are recorded into the file name provided. File extension must be .csv.")
1680+
"other attributes of the node, are recorded into the file name provided. Used to assist in debugging or validating "
1681+
"the router lookahead. File extension must be .csv.")
16811682
.show_in(argparse::ShowIn::HELP_ONLY);
16821683

16831684
file_grp.add_argument(args.read_placement_delay_lookup, "--read_placement_delay_lookup")

vpr/src/base/vpr_types.h

+5
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,8 @@ struct t_router_opts {
14001400
std::string write_intra_cluster_router_lookahead;
14011401
std::string read_intra_cluster_router_lookahead;
14021402

1403+
///@brief The name of the output .csv file when PROFILE_LOOKAHEAD and --profile_router_lookahead are used.
1404+
///If the string is empty, there will be no output.
14031405
std::string lookahead_profiling_output;
14041406

14051407
e_heap_type router_heap;
@@ -1687,6 +1689,9 @@ struct t_rr_node_route_inf {
16871689
float path_cost;
16881690
float backward_path_cost;
16891691
#ifdef PROFILE_LOOKAHEAD
1692+
// This data is needed for the LookaheadProfiler, when enabled. It is only conditionally
1693+
// compiled since this struct is a hot and large data structure.
1694+
16901695
///@brief Total delay in the path up to and including this node.
16911696
float backward_path_delay;
16921697
///@brief Total congestion in the path up to and including this node.

vpr/src/place/timing_place_lookup.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ static void generic_compute_matrix_iterative_astar(
110110
const std::set<std::string>& allowed_types,
111111
bool /***/);
112112

113+
/**
114+
* @brief Compute delta delay matrix using Djikstra's algorithm to find shortest paths from a IPIN at the
115+
* source location to OPINs within (start_x, start_y) to (end_x, end_y).
116+
*
117+
* @param route_profiler Only used to call get_net_list(), which is passed into
118+
* calculate_all_path_delays_from_rr_node(), which is needed for the LookaheadProfiler.
119+
* @param matrix The matrix to be filled.
120+
* @param layer_num The layer of the source and sink nodes to be sampled.
121+
* @param (source_x, source_y) The coordinates of the tile to sample an IPIN at.
122+
* @param (start_x, start_y, end_x, end_y) The bounds within which OPINs should be sampled.
123+
* @param router_opts
124+
* @param measure_directconnect Whether to measure/include direct connects.
125+
* @param allowed_types The allowed tile type names for the source location. If this vector is empty, all
126+
* names are allowed. If the source tile type is not allowed, the matrix is filled with EMPTY_DELTA.
127+
* @param is_flat Whether flat routing is being used.
128+
*/
113129
static void generic_compute_matrix_dijkstra_expansion(
114130
RouterDelayProfiler& route_profiler,
115131
vtr::Matrix<std::vector<float>>& matrix,

vpr/src/route/connection_router.cpp

+5-16
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,10 @@ t_heap* ConnectionRouter<Heap>::timing_driven_route_connection_from_heap(RRNodeI
239239
// This is then placed into the traceback so that the correct path is returned
240240
// TODO: This can be eliminated by modifying the actual traceback function in route_timing
241241
if (rcv_path_manager.is_enabled()) {
242-
#ifdef PROFILE_LOOKAHEAD
243-
rcv_path_manager.insert_backwards_path_into_traceback(cheapest->path_data,
244-
cheapest->cost,
245-
cheapest->backward_path_cost,
246-
cheapest->backward_path_delay,
247-
cheapest->backward_path_congestion,
248-
route_ctx);
249-
#else
250242
rcv_path_manager.insert_backwards_path_into_traceback(cheapest->path_data,
251243
cheapest->cost,
252244
cheapest->backward_path_cost,
253-
/*backward_path_delay=*/0.f,
254-
/*backward_path_congestion=*/0.f,
255245
route_ctx);
256-
#endif
257246
}
258247
VTR_LOGV_DEBUG(router_debug_, " Found target %8d (%s)\n", inode, describe_rr_node(device_ctx.rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, inode, is_flat_).c_str());
259248
break;
@@ -947,15 +936,15 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
947936
tot_cost,
948937
describe_rr_node(device_ctx.rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, inode, is_flat_).c_str());
949938

950-
#ifdef PROFILE_LOOKAHEAD
939+
#ifndef PROFILE_LOOKAHEAD
951940
push_back_node(&heap_,
952941
rr_node_route_inf_,
953942
inode,
954943
tot_cost,
955944
/*prev_edge=*/RREdgeId::INVALID(),
956945
backward_path_cost,
957-
backward_path_delay,
958-
backward_path_congestion,
946+
/*backward_path_delay=*/0.f,
947+
/*backward_path_congestion=*/0.f,
959948
R_upstream);
960949
#else
961950
push_back_node(&heap_,
@@ -964,8 +953,8 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
964953
tot_cost,
965954
/*prev_edge=*/RREdgeId::INVALID(),
966955
backward_path_cost,
967-
/*backward_path_delay=*/0.f,
968-
/*backward_path_congestion=*/0.f,
956+
backward_path_delay,
957+
backward_path_congestion,
969958
R_upstream);
970959
#endif
971960
} else {

vpr/src/route/heap_type.h

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ struct t_heap {
1919
///.cost member contains not only the known backward cost but also an expected cost to the target.
2020
float backward_path_cost = 0.;
2121
#ifdef PROFILE_LOOKAHEAD
22+
// This data is needed for the LookaheadProfiler, when enabled. It is only conditionally
23+
// compiled since there may be many instances of this struct and it is in hot code.
24+
2225
///@brief The "known" delay in the path up to and including this node. Recorded for LookaheadProfiler during routing.
2326
float backward_path_delay = 0.;
2427
///@brief The "known" congestion in the path up to and including this node. Recorded for LookaheadProfiler during routing.

vpr/src/route/lookahead_profiler.cpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ void LookaheadProfiler::record(int iteration,
5555
const ParentNetId& net_id,
5656
const Netlist<>& net_list,
5757
const std::vector<RRNodeId>& branch_inodes) {
58+
/**
59+
* This function records data into the output file created in set_file_name(). If that file name was
60+
* an empty string, this function returns. If the output file is not open, VPR will throw an error.
61+
*
62+
* First, we get the RRNodeIds of the sink and source nodes (assumed to be the beginning and end of
63+
* branch_inodes, respectively.
64+
*
65+
* Next, using net_id, net_list, and target_net_pin_index, we obtain the name of the atom block,
66+
* the name of the type of atom block, the name of the type of cluster block, and the tile dimensions
67+
* where the sink node is located.
68+
*
69+
* We then iterate through all other nodes in branch_inodes and calculate the expected and actual cost,
70+
* congestion, and delay from the current node to the sink node, as well as the current node type and
71+
* length, and the xy-deltas to the sink node.
72+
*
73+
* Finally, all this information is written to the output .csv file.
74+
*/
75+
5876
if (!enabled_)
5977
return;
6078

@@ -162,7 +180,7 @@ void LookaheadProfiler::record(int iteration,
162180
lookahead_verifier_csv_ << "\n";
163181
}
164182
#else
165-
throw vtr::VtrError("Profiler enabled, but PROFILE_LOOKAHEAD not defined.", "lookahead_profiler.cpp", 165);
183+
throw vtr::VtrError("Profiler enabled, but PROFILE_LOOKAHEAD not defined.", "lookahead_profiler.cpp", 183);
166184
(void)iteration;
167185
(void)target_net_pin_index;
168186
(void)cost_params;

vpr/src/route/lookahead_profiler.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* well as the lookahead's estimation of this cost.
1414
*
1515
* @warning
16-
* To use the LookaheadProfiler, you must build VPR with #define PROFILE_LOOKAHEAD.
16+
* To use the LookaheadProfiler, you must build VPR with CMAKE_PARAMS="-DVPR_PROFILE_LOOKAHEAD=on".
1717
*/
1818
class LookaheadProfiler {
1919
public:
@@ -38,10 +38,13 @@ class LookaheadProfiler {
3838
*
3939
* @param iteration The router iteration.
4040
* @param target_net_pin_index Target pin of this sink in the net.
41-
* @param cost_params
42-
* @param router_lookahead
43-
* @param net_id
44-
* @param net_list
41+
* @param cost_params Passed into router_lookahead's methods to obtain expected cost,
42+
* delay, and congestion.
43+
* @param router_lookahead Its methods are called to obtain the expected cost, delay,
44+
* and congestion to the node represented by target_net_pin_index from all other nodes
45+
* in branch_inodes.
46+
* @param net_id Used to obtain atom and cluster block IDs.
47+
* @param net_list Used to obtain atom and cluster block IDs.
4548
* @param branch_inodes A backwards path of nodes, starting at a sink.
4649
*
4750
* @warning

vpr/src/route/route_common.h

+28-12
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,30 @@ float get_cost_from_lookahead(const RouterLookahead& router_lookahead,
145145
const t_conn_cost_params cost_params,
146146
bool is_flat);
147147

148-
/* Creates a new t_heap object to be placed on the heap, if the new cost *
149-
* given is lower than the current path_cost to this channel segment. The *
150-
* index of its predecessor is stored to make traceback easy. The index of *
151-
* the edge used to get from its predecessor to it is also stored to make *
152-
* timing analysis, etc. *
153-
* *
154-
* Returns t_heap suitable for adding to heap or nullptr if node is more *
155-
* expensive than previously explored path. */
148+
/**
149+
* @brief Creates a new t_heap object to be placed on the heap, if the new cost
150+
* given is lower than the current path_cost to this channel segment. The index
151+
* of its predecessor is stored to make traceback easy. The index of the edge
152+
* used to get from its predecessor to it is also stored to make timing analysis,
153+
* etc.
154+
*
155+
* @tparam T
156+
* @tparam RouteInf
157+
* @param heap
158+
* @param rr_node_route_inf
159+
* @param inode
160+
* @param total_cost
161+
* @param prev_edge
162+
* @param backward_path_cost
163+
* @param backward_path_delay The known backward path delay used to calculate
164+
* backward_path_cost. Only used for RouterLookahead, when enabled.
165+
* @param backward_path_congestion The known backward path congestion used to
166+
* calculate backward_path_cost. Only used for RouterLookahead, when enabled.
167+
* @param R_upstream
168+
*
169+
* @return t_heap suitable for adding to heap or nullptr if node is more expensive
170+
* than previously explored path.
171+
*/
156172
template<typename T, typename RouteInf>
157173
t_heap* prepare_to_add_node_to_heap(
158174
T* heap,
@@ -173,12 +189,12 @@ t_heap* prepare_to_add_node_to_heap(
173189
hptr->cost = total_cost;
174190
hptr->set_prev_edge(prev_edge);
175191
hptr->backward_path_cost = backward_path_cost;
176-
#ifdef PROFILE_LOOKAHEAD
177-
hptr->backward_path_delay = backward_path_delay;
178-
hptr->backward_path_congestion = backward_path_congestion;
179-
#else
192+
#ifndef PROFILE_LOOKAHEAD
180193
(void)backward_path_delay;
181194
(void)backward_path_congestion;
195+
#else
196+
hptr->backward_path_delay = backward_path_delay;
197+
hptr->backward_path_congestion = backward_path_congestion;
182198
#endif
183199
hptr->R_upstream = R_upstream;
184200
return hptr;

vpr/src/route/route_path_manager.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ void PathManager::mark_node_visited(RRNodeId node) {
4242
void PathManager::insert_backwards_path_into_traceback(t_heap_path* path_data,
4343
float cost,
4444
float backward_path_cost,
45-
float backward_path_delay,
46-
float backward_path_congestion,
4745
RoutingContext& route_ctx) {
4846
if (!is_enabled_) return;
4947

@@ -53,13 +51,6 @@ void PathManager::insert_backwards_path_into_traceback(t_heap_path* path_data,
5351
route_ctx.rr_node_route_inf[node_2].prev_edge = edge;
5452
route_ctx.rr_node_route_inf[node_2].path_cost = cost;
5553
route_ctx.rr_node_route_inf[node_2].backward_path_cost = backward_path_cost;
56-
#ifdef PROFILE_LOOKAHEAD
57-
route_ctx.rr_node_route_inf[node_2].backward_path_delay = backward_path_delay;
58-
route_ctx.rr_node_route_inf[node_2].backward_path_congestion = backward_path_congestion;
59-
#else
60-
(void)backward_path_delay;
61-
(void)backward_path_congestion;
62-
#endif
6354
}
6455
}
6556

vpr/src/route/route_path_manager.h

-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ class PathManager {
7777
void insert_backwards_path_into_traceback(t_heap_path* path_data,
7878
float cost,
7979
float backward_path_cost,
80-
float backward_path_delay,
81-
float backward_path_congestion,
8280
RoutingContext& route_ctx);
8381

8482
// Dynamically create a t_heap_path structure to be used in the heap

vpr/src/route/route_tree.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ RouteTree::update_from_heap(t_heap* hptr,
491491
SpatialRouteTreeLookup* spatial_rt_lookup,
492492
bool is_flat,
493493
const RouterLookahead& router_lookahead,
494-
const t_conn_cost_params cost_params,
494+
const t_conn_cost_params& cost_params,
495495
const Netlist<>& net_list,
496496
const ParentNetId& net_id,
497497
const int itry) {
@@ -534,7 +534,7 @@ RouteTree::add_subtree_from_heap(t_heap* hptr,
534534
int target_net_pin_index,
535535
bool is_flat,
536536
const RouterLookahead& router_lookahead,
537-
const t_conn_cost_params cost_params,
537+
const t_conn_cost_params& cost_params,
538538
const int itry,
539539
const Netlist<>& net_list,
540540
const ParentNetId& net_id) {

vpr/src/route/route_tree.h

+21-10
Original file line numberDiff line numberDiff line change
@@ -350,23 +350,34 @@ class RouteTree {
350350
free_list(_root);
351351
}
352352

353-
/** Add the most recently finished wire segment to the routing tree, and
354-
* update the Tdel, etc. numbers for the rest of the routing tree. hptr
355-
* is the heap pointer of the SINK that was reached, and target_net_pin_index
356-
* is the net pin index corresponding to the SINK that was reached. This routine
357-
* returns a tuple: RouteTreeNode of the branch it adds to the route tree and
358-
* RouteTreeNode of the SINK it adds to the routing.
359-
* Locking operation: only one thread can update_from_heap() a RouteTree at a time. */
353+
/**
354+
* @brief Add the most recently finished wire segment to the routing tree, and update the
355+
* Tdel, etc. numbers for the rest of the routing tree.
356+
*
357+
* @param hptr The heap pointer of the SINK that was reached.
358+
* @param target_net_pin_index The net pin index corresponding to the SINK that was reached.
359+
* @param spatial_rt_lookup
360+
* @param is_flat
361+
* @param router_lookahead Only needed for the LookaheadProfiler.
362+
* @param cost_params Only needed for the LookaheadProfiler.
363+
* @param net_list Only needed for the LookaheadProfiler.
364+
* @param net_id Only needed for the LookaheadProfiler.
365+
* @param itry Only needed for the LookaheadProfiler. If this function is called outside of
366+
* the router loop, this argument does not need to be specified.
367+
*
368+
* @return A tuple: RouteTreeNode of the branch it adds to the route tree and RouteTreeNode
369+
* of the SINK it adds to the routing.
370+
*/
360371
std::tuple<vtr::optional<const RouteTreeNode&>, vtr::optional<const RouteTreeNode&>>
361372
update_from_heap(t_heap* hptr,
362373
int target_net_pin_index,
363374
SpatialRouteTreeLookup* spatial_rt_lookup,
364375
bool is_flat,
365376
const RouterLookahead& router_lookahead,
366-
const t_conn_cost_params cost_params,
377+
const t_conn_cost_params& cost_params,
367378
const Netlist<>& net_list,
368379
const ParentNetId& net_id,
369-
const int itry = -1);
380+
int itry = -1);
370381

371382
/** Reload timing values (R_upstream, C_downstream, Tdel).
372383
* Can take a RouteTreeNode& to do an incremental update.
@@ -504,7 +515,7 @@ class RouteTree {
504515
int target_net_pin_index,
505516
bool is_flat,
506517
const RouterLookahead& router_lookahead,
507-
const t_conn_cost_params cost_params,
518+
const t_conn_cost_params& cost_params,
508519
const int itry,
509520
const Netlist<>& net_list,
510521
const ParentNetId& net_id);

vpr/src/route/router_delay_profiling.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ bool RouterDelayProfiler::calculate_delay(RRNodeId source_node,
149149
float RouterDelayProfiler::get_min_delay(int physical_tile_type_idx, int from_layer, int to_layer, int dx, int dy) const {
150150
return min_delays_[physical_tile_type_idx][from_layer][to_layer][dx][dy];
151151
}
152+
152153
const Netlist<>& RouterDelayProfiler::get_net_list() const {
153154
return net_list_;
154155
}
155156

156-
//Returns the shortest path delay from src_node to all RR nodes in the RR graph, or NaN if no path exists
157157
vtr::vector<RRNodeId, float> calculate_all_path_delays_from_rr_node(RRNodeId src_rr_node,
158158
const t_router_opts& router_opts,
159159
bool is_flat,

vpr/src/route/router_delay_profiling.h

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class RouterDelayProfiler {
5656
bool is_flat_;
5757
};
5858

59+
/**
60+
* @brief Returns the shortest path delay from src_node to all RR nodes in the RR graph, or NaN if no path exists.
61+
*/
5962
vtr::vector<RRNodeId, float> calculate_all_path_delays_from_rr_node(RRNodeId src_rr_node,
6063
const t_router_opts& router_opts,
6164
bool is_flat,

vpr/src/route/router_lookahead.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ float ClassicLookahead::get_expected_cost(RRNodeId current_node, RRNodeId target
7878
return delay_cost + cong_cost;
7979
}
8080

81-
std::pair<float, float> ClassicLookahead::get_expected_delay_and_cong_ignore_criticality(RRNodeId node, RRNodeId target_node, const t_conn_cost_params& /*params*/, float R_upstream) const {
81+
std::pair<float, float> ClassicLookahead::get_expected_delay_and_cong_ignore_criticality(RRNodeId node,
82+
RRNodeId target_node,
83+
const t_conn_cost_params& /*params*/,
84+
float R_upstream) const {
8285
auto& device_ctx = g_vpr_ctx.device();
8386
const auto& rr_graph = device_ctx.rr_graph;
8487

0 commit comments

Comments
 (0)