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 d9f4ee3

Browse files
author
Nathan Shreve
committedAug 14, 2024
Eliminated profile_lookahead parameter in update_from_heap
1 parent e753094 commit d9f4ee3

File tree

9 files changed

+55
-32
lines changed

9 files changed

+55
-32
lines changed
 

‎utils/route_diag/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static void do_one_route(const Netlist<>& net_list,
137137
router.get_router_lookahead(),
138138
cost_params,
139139
net_list,
140-
conn_params.net_id_);
140+
conn_params.net_id_, 0);
141141

142142
//find delay
143143
float net_delay = rt_node_of_sink.value().Tdel;

‎vpr/src/route/lookahead_profiler.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include "vtr_error.h"
99
#include "vtr_log.h"
1010

11+
void LookaheadProfiler::enable(bool should_enable) {
12+
enabled_ = should_enable;
13+
}
14+
1115
void LookaheadProfiler::record(int iteration,
1216
int target_net_pin_index,
1317
const t_conn_cost_params& cost_params,
@@ -19,6 +23,9 @@ void LookaheadProfiler::record(int iteration,
1923
const auto& rr_graph = device_ctx.rr_graph;
2024
auto& route_ctx = g_vpr_ctx.routing();
2125

26+
if (!enabled_)
27+
return;
28+
2229
// If csv file hasn't been opened, open it and write out column headers
2330
if (is_empty_) {
2431
lookahead_verifier_csv_.open("lookahead_verifier_info.csv", std::ios::out);
@@ -158,4 +165,11 @@ void LookaheadProfiler::record(int iteration,
158165
lookahead_verifier_csv_ << cost_params.criticality; // criticality
159166
lookahead_verifier_csv_ << "\n";
160167
}
168+
}
169+
170+
void LookaheadProfiler::clear() {
171+
net_pin_blocks_.clear();
172+
sink_atom_block_.clear();
173+
sink_cluster_block_.clear();
174+
tile_types_.clear();
161175
}

‎vpr/src/route/lookahead_profiler.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ class LookaheadProfiler {
2020
LookaheadProfiler(const LookaheadProfiler&) = delete;
2121
LookaheadProfiler& operator=(const LookaheadProfiler&) = delete;
2222

23+
/**
24+
* @brief Enable or disable the LookaheadProfiler.
25+
*
26+
* @param should_enable Whether the profiler should be enabled.
27+
*/
28+
void enable(bool should_enable);
29+
2330
/**
2431
* @brief Record information on nodes on a path from a source to a sink.
2532
*
@@ -42,7 +49,14 @@ class LookaheadProfiler {
4249
const Netlist<>& net_list,
4350
const std::vector<RRNodeId>& branch_inodes);
4451

52+
/**
53+
* @brief Clear the profiler's private caches to free memory.
54+
*/
55+
void clear();
56+
4557
private:
58+
///@brief Whether to record lookahead info.
59+
bool enabled_;
4660
///@brief The output filestream.
4761
std::ofstream lookahead_verifier_csv_;
4862
///@brief Whether the output file is empty/not yet opened.

‎vpr/src/route/route.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ bool route(const Netlist<>& net_list,
221221
choking_spots,
222222
is_flat);
223223

224+
// Enable lookahead profiling if command-line option used
225+
route_ctx.lookahead_profiler.enable(router_opts.router_lookahead_profiling);
226+
224227
RouterStats router_stats;
225228
float prev_iter_cumm_time = 0;
226229
vtr::Timer iteration_timer;
@@ -563,6 +566,9 @@ bool route(const Netlist<>& net_list,
563566
// profiling::time_on_criticality_analysis();
564567
}
565568

569+
// Clear data accumulated in LookaheadProfiler
570+
route_ctx.lookahead_profiler.clear();
571+
566572
/* Write out partition tree logs (no-op if debug option not set) */
567573
PartitionTreeDebug::write("partition_tree.log");
568574

‎vpr/src/route/route_net.tpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ inline NetResultFlags route_net(ConnectionRouter& router,
190190
spatial_route_tree_lookup,
191191
router_stats,
192192
is_flat,
193-
itry,
194-
router_opts);
193+
itry);
195194

196195
if (flags.success == false)
197196
return flags;
@@ -299,8 +298,7 @@ inline NetResultFlags pre_route_to_clock_root(ConnectionRouter& router,
299298
SpatialRouteTreeLookup& spatial_rt_lookup,
300299
RouterStats& router_stats,
301300
bool is_flat,
302-
int itry,
303-
const t_router_opts& router_opts) {
301+
int itry) {
304302
const auto& device_ctx = g_vpr_ctx.device();
305303
auto& route_ctx = g_vpr_ctx.mutable_routing();
306304
auto& m_route_ctx = g_vpr_ctx.mutable_routing();
@@ -364,8 +362,7 @@ inline NetResultFlags pre_route_to_clock_root(ConnectionRouter& router,
364362
cost_params,
365363
net_list,
366364
conn_params.net_id_,
367-
itry,
368-
router_opts.router_lookahead_profiling);
365+
itry);
369366

370367
VTR_ASSERT_DEBUG(!high_fanout || validate_route_tree_spatial_lookup(tree.root(), spatial_rt_lookup));
371368

@@ -501,8 +498,7 @@ inline NetResultFlags route_sink(ConnectionRouter& router,
501498
cost_params,
502499
net_list,
503500
conn_params.net_id_,
504-
itry,
505-
router_opts.router_lookahead_profiling);
501+
itry);
506502

507503
VTR_ASSERT_DEBUG(!high_fanout || validate_route_tree_spatial_lookup(tree.root(), spatial_rt_lookup));
508504

‎vpr/src/route/route_tree.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,7 @@ RouteTree::update_from_heap(t_heap* hptr,
494494
const t_conn_cost_params cost_params,
495495
const Netlist<>& net_list,
496496
const ParentNetId& net_id,
497-
const int itry,
498-
bool profile_lookahead) {
497+
const int itry) {
499498
/* Lock the route tree for writing. At least on Linux this shouldn't have an impact on single-threaded code */
500499
std::unique_lock<std::mutex> write_lock(_write_mutex);
501500

@@ -508,8 +507,7 @@ RouteTree::update_from_heap(t_heap* hptr,
508507
cost_params,
509508
itry,
510509
net_list,
511-
net_id,
512-
profile_lookahead);
510+
net_id);
513511

514512
if (!start_of_new_subtree_rt_node)
515513
return {vtr::nullopt, *sink_rt_node};
@@ -539,8 +537,7 @@ RouteTree::add_subtree_from_heap(t_heap* hptr,
539537
const t_conn_cost_params cost_params,
540538
const int itry,
541539
const Netlist<>& net_list,
542-
const ParentNetId& net_id,
543-
bool profile_lookahead) {
540+
const ParentNetId& net_id) {
544541
auto& device_ctx = g_vpr_ctx.device();
545542
const auto& rr_graph = device_ctx.rr_graph;
546543
auto& route_ctx = g_vpr_ctx.routing();
@@ -574,15 +571,13 @@ RouteTree::add_subtree_from_heap(t_heap* hptr,
574571
}
575572
new_branch_iswitches.push_back(new_iswitch);
576573

577-
if (profile_lookahead) {
578-
g_vpr_ctx.mutable_routing().lookahead_profiler.record(itry,
579-
target_net_pin_index,
580-
cost_params,
581-
router_lookahead,
582-
net_id,
583-
net_list,
584-
new_branch_inodes);
585-
}
574+
g_vpr_ctx.mutable_routing().lookahead_profiler.record(itry,
575+
target_net_pin_index,
576+
cost_params,
577+
router_lookahead,
578+
net_id,
579+
net_list,
580+
new_branch_inodes);
586581

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

‎vpr/src/route/route_tree.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,10 @@ class RouteTree {
363363
SpatialRouteTreeLookup* spatial_rt_lookup,
364364
bool is_flat,
365365
const RouterLookahead& router_lookahead,
366-
t_conn_cost_params cost_params,
366+
const t_conn_cost_params cost_params,
367367
const Netlist<>& net_list,
368368
const ParentNetId& net_id,
369-
int itry = -1,
370-
bool profile_lookahead = false);
369+
const int itry);
371370

372371
/** Reload timing values (R_upstream, C_downstream, Tdel).
373372
* Can take a RouteTreeNode& to do an incremental update.
@@ -508,8 +507,7 @@ class RouteTree {
508507
const t_conn_cost_params cost_params,
509508
const int itry,
510509
const Netlist<>& net_list,
511-
const ParentNetId& net_id,
512-
bool profile_lookahead);
510+
const ParentNetId& net_id);
513511

514512
void add_non_configurable_nodes(RouteTreeNode* rt_node,
515513
bool reached_by_non_configurable_edge,

‎vpr/src/route/router_delay_profiling.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool RouterDelayProfiler::calculate_delay(RRNodeId source_node,
128128
router_.get_router_lookahead(),
129129
cost_params,
130130
net_list_,
131-
conn_params.net_id_);
131+
conn_params.net_id_, 0);
132132

133133
//find delay
134134
*net_delay = rt_node_of_sink->Tdel;
@@ -225,7 +225,7 @@ vtr::vector<RRNodeId, float> calculate_all_path_delays_from_rr_node(RRNodeId src
225225
router.get_router_lookahead(),
226226
cost_params,
227227
net_list,
228-
conn_params.net_id_);
228+
conn_params.net_id_, 0);
229229

230230
VTR_ASSERT(rt_node_of_sink->inode == RRNodeId(sink_rr_node));
231231

‎vpr/test/test_connection_router.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static float do_one_route(RRNodeId source_node,
9494
router.get_router_lookahead(),
9595
cost_params,
9696
net_list,
97-
conn_params.net_id_);
97+
conn_params.net_id_, 0);
9898
delay = rt_node_of_sink.value().Tdel;
9999
}
100100

0 commit comments

Comments
 (0)
Please sign in to comment.