Skip to content

Commit

Permalink
Eliminated profile_lookahead parameter in update_from_heap
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Shreve committed Aug 14, 2024
1 parent e753094 commit d9f4ee3
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 32 deletions.
2 changes: 1 addition & 1 deletion utils/route_diag/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void do_one_route(const Netlist<>& net_list,
router.get_router_lookahead(),
cost_params,
net_list,
conn_params.net_id_);
conn_params.net_id_, 0);

//find delay
float net_delay = rt_node_of_sink.value().Tdel;
Expand Down
14 changes: 14 additions & 0 deletions vpr/src/route/lookahead_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "vtr_error.h"
#include "vtr_log.h"

void LookaheadProfiler::enable(bool should_enable) {
enabled_ = should_enable;
}

void LookaheadProfiler::record(int iteration,
int target_net_pin_index,
const t_conn_cost_params& cost_params,
Expand All @@ -19,6 +23,9 @@ void LookaheadProfiler::record(int iteration,
const auto& rr_graph = device_ctx.rr_graph;
auto& route_ctx = g_vpr_ctx.routing();

if (!enabled_)
return;

// If csv file hasn't been opened, open it and write out column headers
if (is_empty_) {
lookahead_verifier_csv_.open("lookahead_verifier_info.csv", std::ios::out);
Expand Down Expand Up @@ -158,4 +165,11 @@ void LookaheadProfiler::record(int iteration,
lookahead_verifier_csv_ << cost_params.criticality; // criticality
lookahead_verifier_csv_ << "\n";
}
}

void LookaheadProfiler::clear() {
net_pin_blocks_.clear();
sink_atom_block_.clear();
sink_cluster_block_.clear();
tile_types_.clear();
}
14 changes: 14 additions & 0 deletions vpr/src/route/lookahead_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class LookaheadProfiler {
LookaheadProfiler(const LookaheadProfiler&) = delete;
LookaheadProfiler& operator=(const LookaheadProfiler&) = delete;

/**
* @brief Enable or disable the LookaheadProfiler.
*
* @param should_enable Whether the profiler should be enabled.
*/
void enable(bool should_enable);

/**
* @brief Record information on nodes on a path from a source to a sink.
*
Expand All @@ -42,7 +49,14 @@ class LookaheadProfiler {
const Netlist<>& net_list,
const std::vector<RRNodeId>& branch_inodes);

/**
* @brief Clear the profiler's private caches to free memory.
*/
void clear();

private:
///@brief Whether to record lookahead info.
bool enabled_;
///@brief The output filestream.
std::ofstream lookahead_verifier_csv_;
///@brief Whether the output file is empty/not yet opened.
Expand Down
6 changes: 6 additions & 0 deletions vpr/src/route/route.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ bool route(const Netlist<>& net_list,
choking_spots,
is_flat);

// Enable lookahead profiling if command-line option used
route_ctx.lookahead_profiler.enable(router_opts.router_lookahead_profiling);

RouterStats router_stats;
float prev_iter_cumm_time = 0;
vtr::Timer iteration_timer;
Expand Down Expand Up @@ -563,6 +566,9 @@ bool route(const Netlist<>& net_list,
// profiling::time_on_criticality_analysis();
}

// Clear data accumulated in LookaheadProfiler
route_ctx.lookahead_profiler.clear();

/* Write out partition tree logs (no-op if debug option not set) */
PartitionTreeDebug::write("partition_tree.log");

Expand Down
12 changes: 4 additions & 8 deletions vpr/src/route/route_net.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ inline NetResultFlags route_net(ConnectionRouter& router,
spatial_route_tree_lookup,
router_stats,
is_flat,
itry,
router_opts);
itry);

if (flags.success == false)
return flags;
Expand Down Expand Up @@ -299,8 +298,7 @@ inline NetResultFlags pre_route_to_clock_root(ConnectionRouter& router,
SpatialRouteTreeLookup& spatial_rt_lookup,
RouterStats& router_stats,
bool is_flat,
int itry,
const t_router_opts& router_opts) {
int itry) {
const auto& device_ctx = g_vpr_ctx.device();
auto& route_ctx = g_vpr_ctx.mutable_routing();
auto& m_route_ctx = g_vpr_ctx.mutable_routing();
Expand Down Expand Up @@ -364,8 +362,7 @@ inline NetResultFlags pre_route_to_clock_root(ConnectionRouter& router,
cost_params,
net_list,
conn_params.net_id_,
itry,
router_opts.router_lookahead_profiling);
itry);

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

Expand Down Expand Up @@ -501,8 +498,7 @@ inline NetResultFlags route_sink(ConnectionRouter& router,
cost_params,
net_list,
conn_params.net_id_,
itry,
router_opts.router_lookahead_profiling);
itry);

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

Expand Down
25 changes: 10 additions & 15 deletions vpr/src/route/route_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,7 @@ RouteTree::update_from_heap(t_heap* hptr,
const t_conn_cost_params cost_params,
const Netlist<>& net_list,
const ParentNetId& net_id,
const int itry,
bool profile_lookahead) {
const int itry) {
/* Lock the route tree for writing. At least on Linux this shouldn't have an impact on single-threaded code */
std::unique_lock<std::mutex> write_lock(_write_mutex);

Expand All @@ -508,8 +507,7 @@ RouteTree::update_from_heap(t_heap* hptr,
cost_params,
itry,
net_list,
net_id,
profile_lookahead);
net_id);

if (!start_of_new_subtree_rt_node)
return {vtr::nullopt, *sink_rt_node};
Expand Down Expand Up @@ -539,8 +537,7 @@ RouteTree::add_subtree_from_heap(t_heap* hptr,
const t_conn_cost_params cost_params,
const int itry,
const Netlist<>& net_list,
const ParentNetId& net_id,
bool profile_lookahead) {
const ParentNetId& net_id) {
auto& device_ctx = g_vpr_ctx.device();
const auto& rr_graph = device_ctx.rr_graph;
auto& route_ctx = g_vpr_ctx.routing();
Expand Down Expand Up @@ -574,15 +571,13 @@ RouteTree::add_subtree_from_heap(t_heap* hptr,
}
new_branch_iswitches.push_back(new_iswitch);

if (profile_lookahead) {
g_vpr_ctx.mutable_routing().lookahead_profiler.record(itry,
target_net_pin_index,
cost_params,
router_lookahead,
net_id,
net_list,
new_branch_inodes);
}
g_vpr_ctx.mutable_routing().lookahead_profiler.record(itry,
target_net_pin_index,
cost_params,
router_lookahead,
net_id,
net_list,
new_branch_inodes);

/* Build the new tree branch starting from the existing node we found */
RouteTreeNode* last_node = _rr_node_to_rt_node[new_inode];
Expand Down
8 changes: 3 additions & 5 deletions vpr/src/route/route_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,10 @@ class RouteTree {
SpatialRouteTreeLookup* spatial_rt_lookup,
bool is_flat,
const RouterLookahead& router_lookahead,
t_conn_cost_params cost_params,
const t_conn_cost_params cost_params,
const Netlist<>& net_list,
const ParentNetId& net_id,
int itry = -1,
bool profile_lookahead = false);
const int itry);

/** Reload timing values (R_upstream, C_downstream, Tdel).
* Can take a RouteTreeNode& to do an incremental update.
Expand Down Expand Up @@ -508,8 +507,7 @@ class RouteTree {
const t_conn_cost_params cost_params,
const int itry,
const Netlist<>& net_list,
const ParentNetId& net_id,
bool profile_lookahead);
const ParentNetId& net_id);

void add_non_configurable_nodes(RouteTreeNode* rt_node,
bool reached_by_non_configurable_edge,
Expand Down
4 changes: 2 additions & 2 deletions vpr/src/route/router_delay_profiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool RouterDelayProfiler::calculate_delay(RRNodeId source_node,
router_.get_router_lookahead(),
cost_params,
net_list_,
conn_params.net_id_);
conn_params.net_id_, 0);

//find delay
*net_delay = rt_node_of_sink->Tdel;
Expand Down Expand Up @@ -225,7 +225,7 @@ vtr::vector<RRNodeId, float> calculate_all_path_delays_from_rr_node(RRNodeId src
router.get_router_lookahead(),
cost_params,
net_list,
conn_params.net_id_);
conn_params.net_id_, 0);

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

Expand Down
2 changes: 1 addition & 1 deletion vpr/test/test_connection_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static float do_one_route(RRNodeId source_node,
router.get_router_lookahead(),
cost_params,
net_list,
conn_params.net_id_);
conn_params.net_id_, 0);
delay = rt_node_of_sink.value().Tdel;
}

Expand Down

0 comments on commit d9f4ee3

Please sign in to comment.