Skip to content

Commit f4105e2

Browse files
committed
extended_lookahead: cleaned code and reduced code duplication
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 3cb99ae commit f4105e2

9 files changed

+631
-872
lines changed

vpr/src/base/ShowSetup.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,9 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
445445
case e_router_lookahead::MAP:
446446
VTR_LOG("MAP\n");
447447
break;
448+
case e_router_lookahead::EXTENDED_MAP:
449+
VTR_LOG("EXTENDED_MAP\n");
450+
break;
448451
case e_router_lookahead::NO_OP:
449452
VTR_LOG("NO_OP\n");
450453
break;

vpr/src/route/router_lookahead_cost_map.cpp

Lines changed: 124 additions & 142 deletions
Large diffs are not rendered by default.

vpr/src/route/router_lookahead_cost_map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class CostMap {
1111
void set_counts(size_t seg_count);
1212
void build_segment_map();
1313
int node_to_segment(int from_node_ind) const;
14-
util::Cost_Entry find_cost(int from_seg_index, e_rr_type rr_type, int delta_x, int delta_y) const;
14+
util::Cost_Entry find_cost(int from_seg_index, int delta_x, int delta_y) const;
1515
void set_cost_map(const util::RoutingCosts& delay_costs, const util::RoutingCosts& base_costs);
1616
std::pair<util::Cost_Entry, int> get_nearby_cost_entry(const vtr::NdMatrix<util::Cost_Entry, 2>& matrix, int cx, int cy, const vtr::Rect<int>& bounds);
1717
void read(const std::string& file);

vpr/src/route/router_lookahead_extended_map.cpp

Lines changed: 47 additions & 454 deletions
Large diffs are not rendered by default.

vpr/src/route/router_lookahead_extended_map.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef CONNECTION_BOX_LOOKAHEAD_H_
2-
#define CONNECTION_BOX_LOOKAHEAD_H_
1+
#ifndef EXTENDED_MAP_LOOKAHEAD_H_
2+
#define EXTENDED_MAP_LOOKAHEAD_H_
33

44
#include <vector>
55
#include "physical_types.h"
@@ -10,8 +10,29 @@
1010

1111
// Implementation of RouterLookahead based on source segment and destination connection box types
1212
class ExtendedMapLookahead : public RouterLookahead {
13-
public:
13+
private:
14+
//Look-up table from SOURCE/OPIN to CHANX/CHANY of various types
15+
util::t_src_opin_delays src_opin_delays;
16+
17+
//Look-up table from CHANX/CHANY to SINK/IPIN of various types
18+
util::t_chan_ipins_delays chan_ipins_delays;
19+
1420
std::pair<float, float> get_src_opin_delays(RRNodeId from_node, int delta_x, int delta_y, float criticality_fac) const;
21+
float get_chan_ipin_delays(RRNodeId to_node) const;
22+
23+
template<typename Entry>
24+
bool add_paths(int start_node_ind,
25+
Entry current,
26+
const std::vector<util::Search_Path>& paths,
27+
util::RoutingCosts* routing_costs);
28+
29+
template<typename Entry>
30+
std::pair<float, int> run_dijkstra(int start_node_ind,
31+
std::vector<bool>* node_expanded,
32+
std::vector<util::Search_Path>* paths,
33+
util::RoutingCosts* routing_costs);
34+
35+
public:
1536
float get_expected_cost(int node, int target_node, const t_conn_cost_params& params, float R_upstream) const override;
1637
float get_map_cost(int from_node_ind, int to_node_ind, float criticality_fac) const;
1738
void compute(const std::vector<t_segment_inf>& segment_inf) override;

vpr/src/route/router_lookahead_map.cpp

Lines changed: 18 additions & 255 deletions
Large diffs are not rendered by default.

vpr/src/route/router_lookahead_map.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44
#include <limits>
55
#include "vtr_ndmatrix.h"
66
#include "router_lookahead.h"
7+
#include "router_lookahead_map_utils.h"
78

89
class MapLookahead : public RouterLookahead {
10+
private:
11+
//Look-up table from SOURCE/OPIN to CHANX/CHANY of various types
12+
util::t_src_opin_delays src_opin_delays;
13+
14+
/* queries the lookahead_map (should have been computed prior to routing) to get the expected cost
15+
* from the specified source to the specified target */
16+
float get_map_cost(RRNodeId from_node, RRNodeId to_node, float criticality_fac) const;
17+
918
protected:
1019
float get_expected_cost(int node, int target_node, const t_conn_cost_params& params, float R_upstream) const override;
1120
void compute(const std::vector<t_segment_inf>& segment_inf) override;
@@ -38,11 +47,3 @@ typedef vtr::NdMatrix<Cost_Entry, 4> t_wire_cost_map; //[0..1][[0..num_seg_types
3847

3948
void read_router_lookahead(const std::string& file);
4049
void write_router_lookahead(const std::string& file);
41-
42-
/* Computes the lookahead map to be used by the router. If a map was computed prior to this, a new one will not be computed again.
43-
* The rr graph must have been built before calling this function. */
44-
void compute_router_lookahead(const std::vector<t_segment_inf>& segment_inf);
45-
46-
/* queries the lookahead_map (should have been computed prior to routing) to get the expected cost
47-
* from the specified source to the specified target */
48-
float get_lookahead_map_cost(RRNodeId from_node, RRNodeId to_node, float criticality_fac);

0 commit comments

Comments
 (0)