Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d1025c9

Browse files
author
Nathan Shreve
committedAug 12, 2024·
Added command-line option for profiler
1 parent d406c57 commit d1025c9

12 files changed

+121
-22
lines changed
 

‎utils/route_diag/src/main.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,14 @@ static void do_one_route(const Netlist<>& net_list,
130130
VTR_ASSERT(cheapest.index == sink_node);
131131

132132
vtr::optional<const RouteTreeNode&> rt_node_of_sink;
133-
std::tie(std::ignore, rt_node_of_sink) = tree.update_from_heap(&cheapest, OPEN, nullptr, router_opts.flat_routing, router.get_router_lookahead(), cost_params, -1, net_list, conn_params.net_id_);
133+
std::tie(std::ignore, rt_node_of_sink) = tree.update_from_heap(&cheapest,
134+
OPEN,
135+
nullptr,
136+
router_opts.flat_routing,
137+
router.get_router_lookahead(),
138+
cost_params,
139+
net_list,
140+
conn_params.net_id_);
134141

135142
//find delay
136143
float net_delay = rt_node_of_sink.value().Tdel;

‎vpr/src/base/SetupVPR.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts)
473473
RouterOpts->router_debug_sink_rr = Options.router_debug_sink_rr;
474474
RouterOpts->router_debug_iteration = Options.router_debug_iteration;
475475
RouterOpts->lookahead_type = Options.router_lookahead_type;
476+
RouterOpts->router_lookahead_profiling = Options.router_lookahead_profiler;
476477
RouterOpts->max_convergence_count = Options.router_max_convergence_count;
477478
RouterOpts->reconvergence_cpd_threshold = Options.router_reconvergence_cpd_threshold;
478479
RouterOpts->initial_timing = Options.router_initial_timing;

‎vpr/src/base/read_options.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,14 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
26262626
.default_value("map")
26272627
.show_in(argparse::ShowIn::HELP_ONLY);
26282628

2629+
route_timing_grp.add_argument(args.router_lookahead_profiler, "--router_lookahead_profiler")
2630+
.help(
2631+
"For every routed sink, records the cost, delay, and congestion estimated by the router lookahead and the "
2632+
"actual cost, delay, and congestion, from every node along each route to the sink. These results, along with many "
2633+
"other attributes of the node, are recorded into lookahead_verifier_info.csv.")
2634+
.default_value("off")
2635+
.show_in(argparse::ShowIn::HELP_ONLY);
2636+
26292637
route_timing_grp.add_argument(args.router_max_convergence_count, "--router_max_convergence_count")
26302638
.help(
26312639
"Controls how many times the router is allowed to converge to a legal routing before halting."

‎vpr/src/base/read_options.h

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ struct t_options {
238238
argparse::ArgValue<int> router_debug_sink_rr;
239239
argparse::ArgValue<int> router_debug_iteration;
240240
argparse::ArgValue<e_router_lookahead> router_lookahead_type;
241+
argparse::ArgValue<bool> router_lookahead_profiler;
241242
argparse::ArgValue<int> router_max_convergence_count;
242243
argparse::ArgValue<float> router_reconvergence_cpd_threshold;
243244
argparse::ArgValue<bool> router_update_lower_bound_delays;

‎vpr/src/base/vpr_types.h

+1
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,7 @@ struct t_router_opts {
14581458
int router_debug_sink_rr;
14591459
int router_debug_iteration;
14601460
e_router_lookahead lookahead_type;
1461+
bool router_lookahead_profiling;
14611462
int max_convergence_count;
14621463
float reconvergence_cpd_threshold;
14631464
e_router_initial_timing initial_timing;

‎vpr/src/route/lookahead_profiler.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ LookaheadProfiler::LookaheadProfiler() {
1515
lookahead_verifier_csv.open("lookahead_verifier_info.csv", std::ios::out);
1616

1717
if (!lookahead_verifier_csv.is_open()) {
18-
VTR_LOG_ERROR("Could not open lookahead_verifier_info.csv", "error");
18+
VTR_LOG_WARN("Could not open lookahead_verifier_info.csv");
19+
return;
1920
}
2021

2122
lookahead_verifier_csv
@@ -54,6 +55,9 @@ void LookaheadProfiler::record(int iteration,
5455
const auto& rr_graph = device_ctx.rr_graph;
5556
auto& route_ctx = g_vpr_ctx.routing();
5657

58+
if (!lookahead_verifier_csv.is_open())
59+
return;
60+
5761
if (iteration < 1)
5862
return;
5963

‎vpr/src/route/route_net.tpp

+24-5
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ inline NetResultFlags route_net(ConnectionRouter& router,
190190
spatial_route_tree_lookup,
191191
router_stats,
192192
is_flat,
193-
itry);
193+
itry,
194+
router_opts);
194195

195196
if (flags.success == false)
196197
return flags;
@@ -298,7 +299,8 @@ inline NetResultFlags pre_route_to_clock_root(ConnectionRouter& router,
298299
SpatialRouteTreeLookup& spatial_rt_lookup,
299300
RouterStats& router_stats,
300301
bool is_flat,
301-
int itry) {
302+
int itry,
303+
const t_router_opts& router_opts) {
302304
const auto& device_ctx = g_vpr_ctx.device();
303305
auto& route_ctx = g_vpr_ctx.mutable_routing();
304306
auto& m_route_ctx = g_vpr_ctx.mutable_routing();
@@ -354,8 +356,16 @@ inline NetResultFlags pre_route_to_clock_root(ConnectionRouter& router,
354356
* points. Therefore, we can set the net pin index of the sink node to *
355357
* OPEN (meaning illegal) as it is not meaningful for this sink. */
356358
vtr::optional<const RouteTreeNode&> new_branch, new_sink;
357-
std::tie(new_branch, new_sink) = tree.update_from_heap(&cheapest, OPEN, ((high_fanout) ? &spatial_rt_lookup : nullptr), is_flat, router.get_router_lookahead(), cost_params, itry, net_list,
358-
conn_params.net_id_);
359+
std::tie(new_branch, new_sink) = tree.update_from_heap(&cheapest,
360+
OPEN,
361+
((high_fanout) ? &spatial_rt_lookup : nullptr),
362+
is_flat,
363+
router.get_router_lookahead(),
364+
cost_params,
365+
net_list,
366+
conn_params.net_id_,
367+
itry,
368+
router_opts.router_lookahead_profiling);
359369

360370
VTR_ASSERT_DEBUG(!high_fanout || validate_route_tree_spatial_lookup(tree.root(), spatial_rt_lookup));
361371

@@ -483,7 +493,16 @@ inline NetResultFlags route_sink(ConnectionRouter& router,
483493
profiling::sink_criticality_end(cost_params.criticality);
484494

485495
vtr::optional<const RouteTreeNode&> new_branch, new_sink;
486-
std::tie(new_branch, new_sink) = tree.update_from_heap(&cheapest, target_pin, ((high_fanout) ? &spatial_rt_lookup : nullptr), is_flat, router.get_router_lookahead(), cost_params, itry, net_list, conn_params.net_id_);
496+
std::tie(new_branch, new_sink) = tree.update_from_heap(&cheapest,
497+
target_pin,
498+
((high_fanout) ? &spatial_rt_lookup : nullptr),
499+
is_flat,
500+
router.get_router_lookahead(),
501+
cost_params,
502+
net_list,
503+
conn_params.net_id_,
504+
itry,
505+
router_opts.router_lookahead_profiling);
487506

488507
VTR_ASSERT_DEBUG(!high_fanout || validate_route_tree_spatial_lookup(tree.root(), spatial_rt_lookup));
489508

‎vpr/src/route/route_tree.cpp

+29-9
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,22 @@ void RouteTree::print(void) const {
486486
* This routine returns a tuple: RouteTreeNode of the branch it adds to the route tree and
487487
* RouteTreeNode of the SINK it adds to the routing. */
488488
std::tuple<vtr::optional<const RouteTreeNode&>, vtr::optional<const RouteTreeNode&>>
489-
RouteTree::update_from_heap(t_heap* hptr, int target_net_pin_index, SpatialRouteTreeLookup* spatial_rt_lookup, bool is_flat, const RouterLookahead& router_lookahead, const t_conn_cost_params cost_params, const int itry, const Netlist<>& net_list, const ParentNetId& net_id) {
489+
RouteTree::update_from_heap(t_heap* hptr,
490+
int target_net_pin_index,
491+
SpatialRouteTreeLookup* spatial_rt_lookup,
492+
bool is_flat,
493+
const RouterLookahead& router_lookahead,
494+
const t_conn_cost_params cost_params,
495+
const Netlist<>& net_list,
496+
const ParentNetId& net_id,
497+
const int itry,
498+
bool profile_lookahead) {
490499
/* Lock the route tree for writing. At least on Linux this shouldn't have an impact on single-threaded code */
491500
std::unique_lock<std::mutex> write_lock(_write_mutex);
492501

493502
//Create a new subtree from the target in hptr to existing routing
494503
vtr::optional<RouteTreeNode&> start_of_new_subtree_rt_node, sink_rt_node;
495-
std::tie(start_of_new_subtree_rt_node, sink_rt_node) = add_subtree_from_heap(hptr, target_net_pin_index, is_flat, router_lookahead, cost_params, itry, net_list, net_id);
504+
std::tie(start_of_new_subtree_rt_node, sink_rt_node) = add_subtree_from_heap(hptr, target_net_pin_index, is_flat, router_lookahead, cost_params, itry, net_list, net_id, profile_lookahead);
496505

497506
if (!start_of_new_subtree_rt_node)
498507
return {vtr::nullopt, *sink_rt_node};
@@ -515,7 +524,15 @@ RouteTree::update_from_heap(t_heap* hptr, int target_net_pin_index, SpatialRoute
515524
* to the SINK indicated by hptr. Returns the first (most upstream) new rt_node,
516525
* and the rt_node of the new SINK. Traverses up from SINK */
517526
std::tuple<vtr::optional<RouteTreeNode&>, vtr::optional<RouteTreeNode&>>
518-
RouteTree::add_subtree_from_heap(t_heap* hptr, int target_net_pin_index, bool is_flat, const RouterLookahead& router_lookahead, const t_conn_cost_params cost_params, const int itry, const Netlist<>& net_list, const ParentNetId& net_id) {
527+
RouteTree::add_subtree_from_heap(t_heap* hptr,
528+
int target_net_pin_index,
529+
bool is_flat,
530+
const RouterLookahead& router_lookahead,
531+
const t_conn_cost_params cost_params,
532+
const int itry,
533+
const Netlist<>& net_list,
534+
const ParentNetId& net_id,
535+
bool profile_lookahead) {
519536
auto& device_ctx = g_vpr_ctx.device();
520537
const auto& rr_graph = device_ctx.rr_graph;
521538
auto& route_ctx = g_vpr_ctx.routing();
@@ -549,12 +566,15 @@ RouteTree::add_subtree_from_heap(t_heap* hptr, int target_net_pin_index, bool is
549566
}
550567
new_branch_iswitches.push_back(new_iswitch);
551568

552-
g_vpr_ctx.mutable_routing().lookahead_profiler.record(itry,
553-
target_net_pin_index,
554-
cost_params,
555-
router_lookahead,
556-
net_id,
557-
net_list, std::vector<RRNodeId>());
569+
if (profile_lookahead) {
570+
g_vpr_ctx.mutable_routing().lookahead_profiler.record(itry,
571+
target_net_pin_index,
572+
cost_params,
573+
router_lookahead,
574+
net_id,
575+
net_list,
576+
new_branch_inodes);
577+
}
558578

559579
/* Build the new tree branch starting from the existing node we found */
560580
RouteTreeNode* last_node = _rr_node_to_rt_node[new_inode];

‎vpr/src/route/route_tree.h

+19-2
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,16 @@ class RouteTree {
358358
* RouteTreeNode of the SINK it adds to the routing.
359359
* Locking operation: only one thread can update_from_heap() a RouteTree at a time. */
360360
std::tuple<vtr::optional<const RouteTreeNode&>, vtr::optional<const RouteTreeNode&>>
361-
update_from_heap(t_heap* hptr, int target_net_pin_index, SpatialRouteTreeLookup* spatial_rt_lookup, bool is_flat, const RouterLookahead& router_lookahead, const t_conn_cost_params cost_params, const int itry, const Netlist<>& net_list, const ParentNetId& net_id);
361+
update_from_heap(t_heap* hptr,
362+
int target_net_pin_index,
363+
SpatialRouteTreeLookup* spatial_rt_lookup,
364+
bool is_flat,
365+
const RouterLookahead& router_lookahead,
366+
t_conn_cost_params cost_params,
367+
const Netlist<>& net_list,
368+
const ParentNetId& net_id,
369+
int itry = -1,
370+
bool profile_lookahead = false);
362371

363372
/** Reload timing values (R_upstream, C_downstream, Tdel).
364373
* Can take a RouteTreeNode& to do an incremental update.
@@ -492,7 +501,15 @@ class RouteTree {
492501

493502
private:
494503
std::tuple<vtr::optional<RouteTreeNode&>, vtr::optional<RouteTreeNode&>>
495-
add_subtree_from_heap(t_heap* hptr, int target_net_pin_index, bool is_flat, const RouterLookahead& router_lookahead, const t_conn_cost_params cost_params, const int itry, const Netlist<>& net_list, const ParentNetId& net_id);
504+
add_subtree_from_heap(t_heap* hptr,
505+
int target_net_pin_index,
506+
bool is_flat,
507+
const RouterLookahead& router_lookahead,
508+
const t_conn_cost_params cost_params,
509+
const int itry,
510+
const Netlist<>& net_list,
511+
const ParentNetId& net_id,
512+
bool profile_lookahead);
496513

497514
void add_non_configurable_nodes(RouteTreeNode* rt_node,
498515
bool reached_by_non_configurable_edge,

‎vpr/src/route/router_delay_profiling.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,14 @@ bool RouterDelayProfiler::calculate_delay(RRNodeId source_node,
121121
VTR_ASSERT(cheapest.index == sink_node);
122122

123123
vtr::optional<const RouteTreeNode&> rt_node_of_sink;
124-
std::tie(std::ignore, rt_node_of_sink) = tree.update_from_heap(&cheapest, OPEN, nullptr, is_flat_, router_.get_router_lookahead(), cost_params, -1, net_list_, conn_params.net_id_);
124+
std::tie(std::ignore, rt_node_of_sink) = tree.update_from_heap(&cheapest,
125+
OPEN,
126+
nullptr,
127+
is_flat_,
128+
router_.get_router_lookahead(),
129+
cost_params,
130+
net_list_,
131+
conn_params.net_id_);
125132

126133
//find delay
127134
*net_delay = rt_node_of_sink->Tdel;
@@ -208,7 +215,14 @@ vtr::vector<RRNodeId, float> calculate_all_path_delays_from_rr_node(RRNodeId src
208215
//Build the routing tree to get the delay
209216
tree = RouteTree(RRNodeId(src_rr_node));
210217
vtr::optional<const RouteTreeNode&> rt_node_of_sink;
211-
std::tie(std::ignore, rt_node_of_sink) = tree.update_from_heap(&shortest_paths[sink_rr_node], OPEN, nullptr, router_opts.flat_routing, router.get_router_lookahead(), cost_params, -1, net_list, conn_params.net_id_);
218+
std::tie(std::ignore, rt_node_of_sink) = tree.update_from_heap(&shortest_paths[sink_rr_node],
219+
OPEN,
220+
nullptr,
221+
router_opts.flat_routing,
222+
router.get_router_lookahead(),
223+
cost_params,
224+
net_list,
225+
conn_params.net_id_);
212226

213227
VTR_ASSERT(rt_node_of_sink->inode == RRNodeId(sink_rr_node));
214228

‎vpr/src/route/router_lookahead_compressed_map.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ float CompressedMapLookahead::get_expected_cost(RRNodeId current_node, RRNodeId
422422
}
423423
}
424424

425-
std::pair<float, float> CompressedMapLookahead::get_expected_delay_and_cong(RRNodeId from_node, RRNodeId to_node, const t_conn_cost_params& params, float) const {
425+
std::pair<float, float> CompressedMapLookahead::get_expected_delay_and_cong(RRNodeId from_node, RRNodeId to_node, const t_conn_cost_params& /*params*/, float) const {
426426
auto& device_ctx = g_vpr_ctx.device();
427427
auto& rr_graph = device_ctx.rr_graph;
428428

‎vpr/test/test_connection_router.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ static float do_one_route(RRNodeId source_node,
8787

8888
// Get the delay
8989
vtr::optional<const RouteTreeNode&> rt_node_of_sink;
90-
std::tie(std::ignore, rt_node_of_sink) = tree.update_from_heap(&cheapest, OPEN, nullptr, router_opts.flat_routing, router.get_router_lookahead(), cost_params, -1, net_list, conn_params.net_id_);
90+
std::tie(std::ignore, rt_node_of_sink) = tree.update_from_heap(&cheapest,
91+
OPEN,
92+
nullptr,
93+
router_opts.flat_routing,
94+
router.get_router_lookahead(),
95+
cost_params,
96+
net_list,
97+
conn_params.net_id_);
9198
delay = rt_node_of_sink.value().Tdel;
9299
}
93100

0 commit comments

Comments
 (0)
Please sign in to comment.