|
| 1 | +#pragma once |
| 2 | + |
| 3 | +/** @file Parallel and net-decomposing case for NetlistRouter. Works like |
| 4 | + * \see ParallelNetlistRouter, but tries to "decompose" nets and assign them to |
| 5 | + * the next level of the partition tree where possible. */ |
| 6 | +#include "netlist_routers.h" |
| 7 | + |
| 8 | +#include <tbb/task_group.h> |
| 9 | + |
| 10 | +/** Maximum number of iterations for net decomposition |
| 11 | + * 5 is found experimentally: higher values get more speedup on initial iters but # of iters increases */ |
| 12 | +const int MAX_DECOMP_ITER = 5; |
| 13 | + |
| 14 | +/** Maximum # of decomposition for a net: 2 means one net gets divided down to <4 virtual nets. |
| 15 | + * Higher values are more aggressive: better thread utilization but worse congestion resolving */ |
| 16 | +const int MAX_DECOMP_DEPTH = 2; |
| 17 | + |
| 18 | +/** Minimum # of fanouts of a net to consider decomp. */ |
| 19 | +const int MIN_DECOMP_SINKS = 8; |
| 20 | + |
| 21 | +/** Minimum # of fanouts of a virtual net to consider decomp. */ |
| 22 | +const int MIN_DECOMP_SINKS_VNET = 8; |
| 23 | + |
| 24 | +template<typename HeapType> |
| 25 | +class DecompNetlistRouter : public NetlistRouter { |
| 26 | + public: |
| 27 | + DecompNetlistRouter( |
| 28 | + const Netlist<>& net_list, |
| 29 | + const RouterLookahead* router_lookahead, |
| 30 | + const t_router_opts& router_opts, |
| 31 | + CBRR& connections_inf, |
| 32 | + NetPinsMatrix<float>& net_delay, |
| 33 | + const ClusteredPinAtomPinsLookup& netlist_pin_lookup, |
| 34 | + std::shared_ptr<SetupHoldTimingInfo> timing_info, |
| 35 | + NetPinTimingInvalidator* pin_timing_invalidator, |
| 36 | + route_budgets& budgeting_inf, |
| 37 | + const RoutingPredictor& routing_predictor, |
| 38 | + const vtr::vector<ParentNetId, std::vector<std::unordered_map<RRNodeId, int>>>& choking_spots, |
| 39 | + bool is_flat) |
| 40 | + : _routers_th(_make_router(router_lookahead, is_flat)) |
| 41 | + , _net_list(net_list) |
| 42 | + , _router_opts(router_opts) |
| 43 | + , _connections_inf(connections_inf) |
| 44 | + , _net_delay(net_delay) |
| 45 | + , _netlist_pin_lookup(netlist_pin_lookup) |
| 46 | + , _timing_info(timing_info) |
| 47 | + , _pin_timing_invalidator(pin_timing_invalidator) |
| 48 | + , _budgeting_inf(budgeting_inf) |
| 49 | + , _routing_predictor(routing_predictor) |
| 50 | + , _choking_spots(choking_spots) |
| 51 | + , _is_flat(is_flat) |
| 52 | + , _net_known_samples(net_list.nets().size()) |
| 53 | + , _is_decomp_disabled(net_list.nets().size()) {} |
| 54 | + ~DecompNetlistRouter() {} |
| 55 | + |
| 56 | + /** Run a single iteration of netlist routing for this->_net_list. This usually means calling |
| 57 | + * \ref route_net for each net, which will handle other global updates. |
| 58 | + * \return RouteIterResults for this iteration. */ |
| 59 | + RouteIterResults route_netlist(int itry, float pres_fac, float worst_neg_slack); |
| 60 | + /** Set RCV enable flag for all routers managed by this netlist router. |
| 61 | + * Net decomposition does not work with RCV, so calling this fn with x=true is a fatal error. */ |
| 62 | + void set_rcv_enabled(bool x); |
| 63 | + void set_timing_info(std::shared_ptr<SetupHoldTimingInfo> timing_info); |
| 64 | + |
| 65 | + private: |
| 66 | + /** Should we decompose this net? */ |
| 67 | + bool should_decompose_net(ParentNetId net_id, const PartitionTreeNode& node); |
| 68 | + /** Get a bitset with sinks to route before net decomposition */ |
| 69 | + vtr::dynamic_bitset<> get_decomposition_mask(ParentNetId net_id, const PartitionTreeNode& node); |
| 70 | + /** Get a bitset with sinks to route before virtual net decomposition */ |
| 71 | + vtr::dynamic_bitset<> get_vnet_decomposition_mask(const VirtualNet& vnet, const PartitionTreeNode& node); |
| 72 | + /** Decompose and route a regular net. Output the resulting vnets to \p left and \p right. |
| 73 | + * \return Success status: true if routing is successful and left and right now contain valid virtual nets: false otherwise. */ |
| 74 | + bool decompose_and_route_net(ParentNetId net_id, const PartitionTreeNode& node, VirtualNet& left, VirtualNet& right); |
| 75 | + /** Decompose and route a virtual net. Output the resulting vnets to \p left and \p right. |
| 76 | + * \return Success status: true if routing is successful and left and right now contain valid virtual nets: false otherwise. */ |
| 77 | + bool decompose_and_route_vnet(VirtualNet& vnet, const PartitionTreeNode& node, VirtualNet& left, VirtualNet& right); |
| 78 | + /** A single task to route nets inside a PartitionTree node and add tasks for its child nodes to task group \p g. */ |
| 79 | + void route_partition_tree_node(tbb::task_group& g, PartitionTreeNode& node); |
| 80 | + |
| 81 | + ConnectionRouter<HeapType> _make_router(const RouterLookahead* router_lookahead, bool is_flat) { |
| 82 | + auto& device_ctx = g_vpr_ctx.device(); |
| 83 | + auto& route_ctx = g_vpr_ctx.mutable_routing(); |
| 84 | + |
| 85 | + return ConnectionRouter<HeapType>( |
| 86 | + device_ctx.grid, |
| 87 | + *router_lookahead, |
| 88 | + device_ctx.rr_graph.rr_nodes(), |
| 89 | + &device_ctx.rr_graph, |
| 90 | + device_ctx.rr_rc_data, |
| 91 | + device_ctx.rr_graph.rr_switch(), |
| 92 | + route_ctx.rr_node_route_inf, |
| 93 | + is_flat); |
| 94 | + } |
| 95 | + |
| 96 | + /* Context fields. Most of them will be forwarded to route_net (see route_net.tpp) */ |
| 97 | + /** Per-thread storage for ConnectionRouters. */ |
| 98 | + tbb::enumerable_thread_specific<ConnectionRouter<HeapType>> _routers_th; |
| 99 | + const Netlist<>& _net_list; |
| 100 | + const t_router_opts& _router_opts; |
| 101 | + CBRR& _connections_inf; |
| 102 | + /** Per-thread storage for RouteIterResults. */ |
| 103 | + tbb::enumerable_thread_specific<RouteIterResults> _results_th; |
| 104 | + NetPinsMatrix<float>& _net_delay; |
| 105 | + const ClusteredPinAtomPinsLookup& _netlist_pin_lookup; |
| 106 | + std::shared_ptr<SetupHoldTimingInfo> _timing_info; |
| 107 | + NetPinTimingInvalidator* _pin_timing_invalidator; |
| 108 | + route_budgets& _budgeting_inf; |
| 109 | + const RoutingPredictor& _routing_predictor; |
| 110 | + const vtr::vector<ParentNetId, std::vector<std::unordered_map<RRNodeId, int>>>& _choking_spots; |
| 111 | + bool _is_flat; |
| 112 | + |
| 113 | + /** Cached routing parameters for current iteration (inputs to \see route_netlist()) */ |
| 114 | + int _itry; |
| 115 | + float _pres_fac; |
| 116 | + float _worst_neg_slack; |
| 117 | + |
| 118 | + /** Sinks to be always sampled for decomposition for each net: [0.._net_list.size()-1] |
| 119 | + * (i.e. when routing fails after decomposition for a sink, sample it on next iteration) */ |
| 120 | + vtr::vector<ParentNetId, vtr::dynamic_bitset<>> _net_known_samples; |
| 121 | + |
| 122 | + /** Is decomposition disabled for this net? [0.._net_list.size()-1] */ |
| 123 | + vtr::vector<ParentNetId, bool> _is_decomp_disabled; |
| 124 | +}; |
| 125 | + |
| 126 | +#include "DecompNetlistRouter.tpp" |
0 commit comments