Skip to content

Commit

Permalink
state in thesis
Browse files Browse the repository at this point in the history
  • Loading branch information
duck2 committed Sep 19, 2023
1 parent 0dd3038 commit c885cd9
Show file tree
Hide file tree
Showing 10 changed files with 353 additions and 177 deletions.
37 changes: 0 additions & 37 deletions vpr/src/base/vpr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,43 +909,6 @@ RouteStatus vpr_route_fixed_W(const Netlist<>& net_list,
std::shared_ptr<RoutingDelayCalculator> delay_calc,
NetPinsMatrix<float>& net_delay,
bool is_flat) {
get_cached_router_lookahead(
vpr_setup.RoutingArch,
vpr_setup.RouterOpts.lookahead_type,
vpr_setup.RouterOpts.write_router_lookahead,
vpr_setup.RouterOpts.read_router_lookahead,
vpr_setup.Segments,
is_flat);

if (is_flat) {
vtr::ScopedStartFinishTimer timer2("Adding intra-cluster resources to router lookahead");
auto& route_ctx = g_vpr_ctx.mutable_routing();
auto& router_opts = vpr_setup.RouterOpts;
auto& segment_inf = vpr_setup.Segments;
auto& det_routing_arch = vpr_setup.RoutingArch;
// If is_flat is true, the router lookahead maps related to intra-cluster resources should be initialized since
// they haven't been initialized when the map related to global resources was initialized.
auto cache_key = route_ctx.router_lookahead_cache_key_;
std::unique_ptr<RouterLookahead> mut_router_lookahead(route_ctx.cached_router_lookahead_.release());
VTR_ASSERT(mut_router_lookahead);
route_ctx.cached_router_lookahead_.clear();
if (!router_opts.read_intra_cluster_router_lookahead.empty()) {
mut_router_lookahead->read_intra_cluster(router_opts.read_intra_cluster_router_lookahead);
} else {
mut_router_lookahead->compute_intra_tile();
}
route_ctx.cached_router_lookahead_.set(cache_key, std::move(mut_router_lookahead));
auto router_lookahead = get_cached_router_lookahead(det_routing_arch,
router_opts.lookahead_type,
router_opts.write_router_lookahead,
router_opts.read_router_lookahead,
segment_inf,
is_flat);
if (!router_opts.write_intra_cluster_router_lookahead.empty()) {
router_lookahead->write_intra_cluster(router_opts.write_intra_cluster_router_lookahead);
}
}

vtr::ScopedStartFinishTimer timer("Routing");

if (NO_FIXED_CHANNEL_WIDTH == fixed_channel_width || fixed_channel_width <= 0) {
Expand Down
65 changes: 34 additions & 31 deletions vpr/src/route/connection_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ std::tuple<bool, bool, t_heap> ConnectionRouter<Heap>::timing_driven_route_conne
const RouteTree& tree,
RRNodeId source_node,
RRNodeId sink_node,
const t_conn_cost_params cost_params,
t_bb bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& bounding_box,
RouterStats& router_stats,
const ConnectionParameters& conn_params,
bool can_grow_bb) {
Expand Down Expand Up @@ -99,8 +99,8 @@ std::tuple<bool, t_heap*> ConnectionRouter<Heap>::timing_driven_route_connection
const RouteTree& tree,
RRNodeId source_node,
RRNodeId sink_node,
const t_conn_cost_params cost_params,
t_bb bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& bounding_box,
bool can_grow_bb) {
//Re-add route nodes from the existing route tree to the heap.
//They need to be repushed onto the heap since each node's cost is target specific.
Expand Down Expand Up @@ -201,8 +201,8 @@ std::tuple<bool, bool, t_heap> ConnectionRouter<Heap>::timing_driven_route_conne
const RouteTree& tree,
RRNodeId source_node,
RRNodeId sink_node,
const t_conn_cost_params cost_params,
t_bb net_bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& net_bounding_box,
const SpatialRouteTreeLookup& spatial_rt_lookup,
RouterStats& router_stats,
const ConnectionParameters& conn_params,
Expand Down Expand Up @@ -278,8 +278,8 @@ std::tuple<bool, bool, t_heap> ConnectionRouter<Heap>::timing_driven_route_conne
// Returns either the last element of the path, or nullptr if no path is found
template<typename Heap>
t_heap* ConnectionRouter<Heap>::timing_driven_route_connection_from_heap(RRNodeId sink_node,
const t_conn_cost_params cost_params,
t_bb bounding_box) {
const t_conn_cost_params& cost_params,
const t_bb& bounding_box) {
VTR_ASSERT_SAFE(heap_.is_valid());

if (heap_.is_empty_heap()) { //No source
Expand Down Expand Up @@ -343,8 +343,8 @@ t_heap* ConnectionRouter<Heap>::timing_driven_route_connection_from_heap(RRNodeI
template<typename Heap>
vtr::vector<RRNodeId, t_heap> ConnectionRouter<Heap>::timing_driven_find_all_shortest_paths_from_route_tree(
const RouteTree& tree,
const t_conn_cost_params cost_params,
t_bb bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& bounding_box,
RouterStats& router_stats,
const ConnectionParameters& conn_params) {
router_stats_ = &router_stats;
Expand All @@ -370,8 +370,8 @@ vtr::vector<RRNodeId, t_heap> ConnectionRouter<Heap>::timing_driven_find_all_sho
// no-operation lookahead which always returns zero.
template<typename Heap>
vtr::vector<RRNodeId, t_heap> ConnectionRouter<Heap>::timing_driven_find_all_shortest_paths_from_heap(
const t_conn_cost_params cost_params,
t_bb bounding_box) {
const t_conn_cost_params& cost_params,
const t_bb& bounding_box) {
vtr::vector<RRNodeId, t_heap> cheapest_paths(rr_nodes_.size());

VTR_ASSERT_SAFE(heap_.is_valid());
Expand Down Expand Up @@ -422,8 +422,8 @@ vtr::vector<RRNodeId, t_heap> ConnectionRouter<Heap>::timing_driven_find_all_sho
template<typename Heap>
void ConnectionRouter<Heap>::timing_driven_expand_cheapest(t_heap* cheapest,
RRNodeId target_node,
const t_conn_cost_params cost_params,
t_bb bounding_box) {
const t_conn_cost_params& cost_params,
const t_bb& bounding_box) {
RRNodeId inode = cheapest->index;

t_rr_node_route_inf* route_inf = &rr_node_route_inf_[inode];
Expand Down Expand Up @@ -470,8 +470,8 @@ void ConnectionRouter<Heap>::timing_driven_expand_cheapest(t_heap* cheapest,

template<typename Heap>
void ConnectionRouter<Heap>::timing_driven_expand_neighbours(t_heap* current,
const t_conn_cost_params cost_params,
t_bb bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& bounding_box,
RRNodeId target_node) {
/* Puts all the rr_nodes adjacent to current on the heap. */

Expand Down Expand Up @@ -533,27 +533,28 @@ void ConnectionRouter<Heap>::timing_driven_expand_neighbour(t_heap* current,
RRNodeId from_node,
RREdgeId from_edge,
RRNodeId to_node,
const t_conn_cost_params cost_params,
const t_bb bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& bounding_box,
RRNodeId target_node,
const t_bb target_bb) {
const t_bb& target_bb) {
int to_xlow = rr_graph_->node_xlow(to_node);
int to_ylow = rr_graph_->node_ylow(to_node);
int to_xhigh = rr_graph_->node_xhigh(to_node);
int to_yhigh = rr_graph_->node_yhigh(to_node);

// BB-pruning
// Disable BB-pruning if RCV is enabled, as this can make it harder for circuits with high negative hold slack to resolve this
// TODO: Only disable pruning if the net has negative hold slack, maybe go off budgets
// Parallel router change: only expand if to_node is inside BB
if (!inside_bb(to_node, bounding_box)
if ((to_xlow < bounding_box.xmin
|| to_ylow < bounding_box.ymin
|| to_xlow > bounding_box.xmax
|| to_ylow > bounding_box.ymax)
&& !rcv_path_manager.is_enabled()) {
VTR_LOGV_DEBUG(router_debug_,
" %p Pruned expansion of node %d edge %zu -> %d"
" (to node location %d,%dx%d,%d outside of expanded"
" net bounding box %d,%dx%d,%d)\n",
this, from_node, size_t(from_edge), size_t(to_node),
to_xlow, to_ylow, to_xhigh, to_yhigh,
to_xlow, to_ylow, rr_graph_->node_xhigh(to_node), rr_graph_->node_yhigh(to_node),
bounding_box.xmin, bounding_box.ymin, bounding_box.xmax, bounding_box.ymax);
return; /* Node is outside (expanded) bounding box. */
}
Expand All @@ -567,6 +568,8 @@ void ConnectionRouter<Heap>::timing_driven_expand_neighbour(t_heap* current,
if (to_type == IPIN) {
// Check if this IPIN leads to the target block
// IPIN's of the target block should be contained within it's bounding box
int to_xhigh = rr_graph_->node_xhigh(to_node);
int to_yhigh = rr_graph_->node_yhigh(to_node);
if (to_xlow < target_bb.xmin
|| to_ylow < target_bb.ymin
|| to_xhigh > target_bb.xmax
Expand Down Expand Up @@ -606,11 +609,11 @@ void ConnectionRouter<Heap>::timing_driven_expand_neighbour(t_heap* current,

// Add to_node to the heap, and also add any nodes which are connected by non-configurable edges
template<typename Heap>
void ConnectionRouter<Heap>::timing_driven_add_to_heap(const t_conn_cost_params cost_params,
void ConnectionRouter<Heap>::timing_driven_add_to_heap(const t_conn_cost_params& cost_params,
const t_heap* current,
RRNodeId from_node,
RRNodeId to_node,
const RREdgeId from_edge,
RREdgeId from_edge,
RRNodeId target_node) {
const auto& device_ctx = g_vpr_ctx.device();
t_heap next;
Expand Down Expand Up @@ -715,7 +718,7 @@ static bool same_non_config_node_set(RRNodeId from_node, RRNodeId to_node) {
#endif

template<typename Heap>
float ConnectionRouter<Heap>::compute_node_cost_using_rcv(const t_conn_cost_params cost_params,
float ConnectionRouter<Heap>::compute_node_cost_using_rcv(const t_conn_cost_params& cost_params,
RRNodeId to_node,
RRNodeId target_node,
float backwards_delay,
Expand Down Expand Up @@ -769,7 +772,7 @@ void ConnectionRouter<Heap>::set_rcv_enabled(bool enable) {
//Calculates the cost of reaching to_node
template<typename Heap>
void ConnectionRouter<Heap>::evaluate_timing_driven_node_costs(t_heap* to,
const t_conn_cost_params cost_params,
const t_conn_cost_params& cost_params,
RRNodeId from_node,
RRNodeId to_node,
RREdgeId from_edge,
Expand Down Expand Up @@ -921,7 +924,7 @@ void ConnectionRouter<Heap>::add_route_tree_to_heap(
const RouteTreeNode& rt_node,
RRNodeId target_node,
const t_bb& bounding_box,
const t_conn_cost_params cost_params,
const t_conn_cost_params& cost_params,
bool from_high_fanout) {
if (from_high_fanout) {
router_stats_->add_all_rt_from_high_fanout++;
Expand Down Expand Up @@ -969,7 +972,7 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
const RouteTreeNode& rt_node,
RRNodeId target_node,
const t_bb& bounding_box,
const t_conn_cost_params cost_params,
const t_conn_cost_params& cost_params,
bool is_high_fanout) {
const auto& device_ctx = g_vpr_ctx.device();
const RRNodeId inode = rt_node.inode;
Expand Down Expand Up @@ -1045,9 +1048,9 @@ template<typename Heap>
t_bb ConnectionRouter<Heap>::add_high_fanout_route_tree_to_heap(
const RouteTreeNode& rt_root,
RRNodeId target_node,
const t_conn_cost_params cost_params,
const t_conn_cost_params& cost_params,
const SpatialRouteTreeLookup& spatial_rt_lookup,
t_bb net_bounding_box) {
const t_bb& net_bounding_box) {
//For high fanout nets we only add those route tree nodes which are spatially close
//to the sink.
//
Expand Down
52 changes: 26 additions & 26 deletions vpr/src/route/connection_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class ConnectionRouter : public ConnectionRouterInterface {
const RouteTree& tree,
RRNodeId source_node,
RRNodeId sink_node,
const t_conn_cost_params cost_params,
t_bb bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& bounding_box,
RouterStats& router_stats,
const ConnectionParameters& conn_params,
bool can_grow_bb) final;
Expand All @@ -92,8 +92,8 @@ class ConnectionRouter : public ConnectionRouterInterface {
const RouteTree& tree,
RRNodeId source_node,
RRNodeId sink_node,
const t_conn_cost_params cost_params,
t_bb net_bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& net_bounding_box,
const SpatialRouteTreeLookup& spatial_rt_lookup,
RouterStats& router_stats,
const ConnectionParameters& conn_params,
Expand All @@ -110,8 +110,8 @@ class ConnectionRouter : public ConnectionRouterInterface {
// RouterLookahead used should be the NoOpLookahead.
vtr::vector<RRNodeId, t_heap> timing_driven_find_all_shortest_paths_from_route_tree(
const RouteTree& tree,
const t_conn_cost_params cost_params,
t_bb bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& bounding_box,
RouterStats& router_stats,
const ConnectionParameters& conn_params) final;

Expand Down Expand Up @@ -169,8 +169,8 @@ class ConnectionRouter : public ConnectionRouterInterface {
const RouteTree& tree,
RRNodeId source_node,
RRNodeId sink_node,
const t_conn_cost_params cost_params,
t_bb bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& bounding_box,
bool can_grow_bb);

// Finds a path to sink_node, starting from the elements currently in the
Expand All @@ -184,21 +184,21 @@ class ConnectionRouter : public ConnectionRouterInterface {
// found
t_heap* timing_driven_route_connection_from_heap(
RRNodeId sink_node,
const t_conn_cost_params cost_params,
t_bb bounding_box);
const t_conn_cost_params& cost_params,
const t_bb& bounding_box);

// Expand this current node if it is a cheaper path.
void timing_driven_expand_cheapest(
t_heap* cheapest,
RRNodeId target_node,
const t_conn_cost_params cost_params,
t_bb bounding_box);
const t_conn_cost_params& cost_params,
const t_bb& bounding_box);

// Expand each neighbor of the current node.
void timing_driven_expand_neighbours(
t_heap* current,
const t_conn_cost_params cost_params,
t_bb bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& bounding_box,
RRNodeId target_node);

// Conditionally adds to_node to the router heap (via path from from_node
Expand All @@ -211,15 +211,15 @@ class ConnectionRouter : public ConnectionRouterInterface {
RRNodeId from_node,
RREdgeId from_edge,
RRNodeId to_node,
const t_conn_cost_params cost_params,
const t_bb bounding_box,
const t_conn_cost_params& cost_params,
const t_bb& bounding_box,
RRNodeId target_node,
const t_bb target_bb);
const t_bb& target_bb);

// Add to_node to the heap, and also add any nodes which are connected by
// non-configurable edges
void timing_driven_add_to_heap(
const t_conn_cost_params cost_params,
const t_conn_cost_params& cost_params,
const t_heap* current,
RRNodeId from_node,
RRNodeId to_node,
Expand All @@ -229,16 +229,16 @@ class ConnectionRouter : public ConnectionRouterInterface {
// Calculates the cost of reaching to_node
void evaluate_timing_driven_node_costs(
t_heap* to,
const t_conn_cost_params cost_params,
const t_conn_cost_params& cost_params,
RRNodeId from_node,
RRNodeId to_node,
RREdgeId from_edge,
RRNodeId target_node);

// Find paths from current heap to all nodes in the RR graph
vtr::vector<RRNodeId, t_heap> timing_driven_find_all_shortest_paths_from_heap(
const t_conn_cost_params cost_params,
t_bb bounding_box);
const t_conn_cost_params& cost_params,
const t_bb& bounding_box);

void empty_heap_annotating_node_route_inf();

Expand All @@ -247,11 +247,11 @@ class ConnectionRouter : public ConnectionRouterInterface {
void add_route_tree_to_heap(const RouteTreeNode& rt_node,
RRNodeId target_node,
const t_bb& bounding_box,
const t_conn_cost_params cost_params,
const t_conn_cost_params& cost_params,
bool from_high_fanout);

// Evaluate node costs using the RCV algorith
float compute_node_cost_using_rcv(const t_conn_cost_params cost_params,
float compute_node_cost_using_rcv(const t_conn_cost_params& cost_params,
RRNodeId to_node,
RRNodeId target_node,
float backwards_delay,
Expand All @@ -266,15 +266,15 @@ class ConnectionRouter : public ConnectionRouterInterface {
const RouteTreeNode& rt_node,
RRNodeId target_node,
const t_bb& bounding_box,
const t_conn_cost_params cost_params,
const t_conn_cost_params& cost_params,
bool is_high_fanout);

t_bb add_high_fanout_route_tree_to_heap(
const RouteTreeNode& rt_root,
RRNodeId target_node,
const t_conn_cost_params cost_params,
const t_conn_cost_params& cost_params,
const SpatialRouteTreeLookup& spatial_route_tree_lookup,
t_bb net_bounding_box);
const t_bb& net_bounding_box);

const DeviceGrid& grid_;
const RouterLookahead& router_lookahead_;
Expand Down
Loading

0 comments on commit c885cd9

Please sign in to comment.