fixed bug in the fast look-up for tileable rr_graph

This commit is contained in:
tangxifan 2020-03-21 17:36:08 -06:00
parent c0e8d98c6f
commit 63c4669dbb
4 changed files with 79 additions and 7 deletions

View File

@ -159,7 +159,7 @@
</tiles>
<!-- ODIN II specific config ends -->
<!-- Physical descriptions begin -->
<layout tileable="false">
<layout tileable="true">
<!--auto_layout aspect_ratio="1.0"-->
<fixed_layout name="2x2" width="4" height="4">
<!--Perimeter of 'io' blocks with 'EMPTY' blocks at corners-->

View File

@ -145,7 +145,7 @@ short RRGraph::node_capacity(const RRNodeId& node) const {
short RRGraph::node_ptc_num(const RRNodeId& node) const {
VTR_ASSERT_SAFE(valid_node_id(node));
return node_ptc_nums_[node];
return node_ptc_nums_[node][0];
}
short RRGraph::node_pin_num(const RRNodeId& node) const {
@ -165,6 +165,13 @@ short RRGraph::node_class_num(const RRNodeId& node) const {
return node_ptc_num(node);
}
std::vector<short> RRGraph::node_track_ids(const RRNodeId& node) const {
VTR_ASSERT_MSG(node_type(node) == CHANX || node_type(node) == CHANY,
"Track number valid only for CHANX/CHANY RR nodes");
VTR_ASSERT_SAFE(valid_node_id(node));
return node_ptc_nums_[node];
}
short RRGraph::node_cost_index(const RRNodeId& node) const {
VTR_ASSERT_SAFE(valid_node_id(node));
return node_cost_indices_[node];
@ -823,7 +830,7 @@ RRNodeId RRGraph::create_node(const t_rr_type& type) {
node_bounding_boxes_.emplace_back(-1, -1, -1, -1);
node_capacities_.push_back(-1);
node_ptc_nums_.push_back(-1);
node_ptc_nums_.push_back(std::vector<short>(1, -1));
node_cost_indices_.push_back(-1);
node_directions_.push_back(NO_DIRECTION);
node_sides_.push_back(NUM_SIDES);
@ -999,7 +1006,18 @@ void RRGraph::set_node_capacity(const RRNodeId& node, const short& capacity) {
void RRGraph::set_node_ptc_num(const RRNodeId& node, const short& ptc) {
VTR_ASSERT(valid_node_id(node));
node_ptc_nums_[node] = ptc;
/* For CHANX and CHANY, we will resize the ptc num to length of the node
* For other nodes, we will always assign the first element
*/
if ((CHANX == node_type(node)) || (CHANY == node_type(node))) {
if ((size_t)node_length(node) + 1 != node_ptc_nums_[node].size()) {
node_ptc_nums_[node].resize(node_length(node) + 1);
}
std::fill(node_ptc_nums_[node].begin(), node_ptc_nums_[node].end(), ptc);
} else {
VTR_ASSERT(1 == node_ptc_nums_[node].size());
node_ptc_nums_[node][0] = ptc;
}
}
void RRGraph::set_node_pin_num(const RRNodeId& node, const short& pin_id) {
@ -1023,6 +1041,22 @@ void RRGraph::set_node_class_num(const RRNodeId& node, const short& class_id) {
set_node_ptc_num(node, class_id);
}
void RRGraph::add_node_track_num(const RRNodeId& node,
const vtr::Point<size_t>& node_offset,
const short& track_id) {
VTR_ASSERT(valid_node_id(node));
VTR_ASSERT_MSG(node_type(node) == CHANX || node_type(node) == CHANY, "Track number valid only for CHANX/CHANY RR nodes");
if ((size_t)node_length(node) + 1 != node_ptc_nums_[node].size()) {
node_ptc_nums_[node].resize(node_length(node) + 1);
}
size_t offset = node_offset.x() - node_xlow(node) + node_offset.y() - node_ylow(node);
VTR_ASSERT(offset < node_ptc_nums_[node].size());
node_ptc_nums_[node][offset] = track_id;
}
void RRGraph::set_node_cost_index(const RRNodeId& node, const short& cost_index) {
VTR_ASSERT(valid_node_id(node));
node_cost_indices_[node] = cost_index;
@ -1235,10 +1269,18 @@ void RRGraph::build_fast_node_lookup() const {
size_t itype = node_type(node);
size_t ptc = node_ptc_num(node);
for (const size_t& x : node_x) {
for (const size_t& y : node_y) {
size_t ptc = node_ptc_num(node);
/* Routing channel nodes may have different ptc num
* Find the track ids using the x/y offset
*/
if (CHANX == node_type(node)) {
ptc = node_track_ids(node)[x - node_xlow(node)];
} else if (CHANY == node_type(node)) {
ptc = node_track_ids(node)[y - node_ylow(node)];
}
if (ptc >= node_lookup_[x][y][itype].size()) {
node_lookup_[x][y][itype].resize(ptc + 1);
}

View File

@ -413,11 +413,24 @@ class RRGraph {
* node_class_num() is designed for routing source and sinks, which are SOURCE and SINK nodes
*
* Due to a useful identifier, ptc_num is used in building fast look-up
*
* Note: routing channels CHANX and CHANY may have multiple ptc_num due to
* tileable routing architecture, where a routing track may bend
* when passing each SB
* By default, we always return the first ptc_num and track_num for
* these nodee, while the other ptc num is accessible through fast look-up
* when searching for a routing track in a channel
*
* For CHANX, the track id vector is the same as yhigh - ylow + 1
* For CHANY, the track id vector is the same as xhigh - xlow + 1
* The first track id is always the track id at (xlow, ylow)
* The last track id is always the track id at (xhigh, yhigh)
*/
short node_ptc_num(const RRNodeId& node) const;
short node_pin_num(const RRNodeId& node) const;
short node_track_num(const RRNodeId& node) const;
short node_class_num(const RRNodeId& node) const;
std::vector<short> node_track_ids(const RRNodeId& node) const;
/* Get the index of cost data in the list of cost_indexed_data data structure
* It contains the routing cost for different nodes in the RRGraph
@ -696,6 +709,14 @@ class RRGraph {
*/
void set_node_class_num(const RRNodeId& node, const short& class_id);
/* Add track id for a CHANX or a CHANY node.
* This is mainly used by tileable rr_graph where rr_node may
* have different track id in different channels
*/
void add_node_track_num(const RRNodeId& node,
const vtr::Point<size_t>& node_offset,
const short& track_id);
/* Set the routing cost index for node, see node_cost_index() for details */
/* TODO: the cost index should be changed to a StrongId!!! */
void set_node_cost_index(const RRNodeId& node, const short& cost_index);
@ -851,7 +872,8 @@ class RRGraph {
vtr::vector<RRNodeId, vtr::Rect<short>> node_bounding_boxes_;
vtr::vector<RRNodeId, short> node_capacities_;
vtr::vector<RRNodeId, short> node_ptc_nums_;
vtr::vector<RRNodeId, std::vector<short>> node_ptc_nums_;
vtr::vector<RRNodeId, short> node_cost_indices_;
vtr::vector<RRNodeId, e_direction> node_directions_;
vtr::vector<RRNodeId, e_side> node_sides_;

View File

@ -666,6 +666,12 @@ void load_one_chan_rr_nodes_basic_info(RRGraph& rr_graph,
rr_graph.set_node_xlow(node, chan_coordinate.x());
rr_graph.set_node_ylow(node, chan_coordinate.y());
/* Deposit xhigh and yhigh as the same value as xlow and ylow
* We will update when this track ends
*/
rr_graph.set_node_xhigh(node, chan_coordinate.x());
rr_graph.set_node_yhigh(node, chan_coordinate.y());
rr_graph.set_node_direction(node, chan_details.get_track_direction(itrack));
rr_graph.set_node_track_num(node, itrack);
@ -709,6 +715,7 @@ void load_one_chan_rr_nodes_basic_info(RRGraph& rr_graph,
if ( (rr_graph.node_xhigh(rr_node_id) > rr_graph.node_xlow(rr_node_id))
|| (rr_graph.node_yhigh(rr_node_id) > rr_graph.node_ylow(rr_node_id)) ) {
rr_node_track_ids[rr_node_id].push_back(itrack);
rr_graph.add_node_track_num(rr_node_id, chan_coordinate, itrack);
}
/* Finish here, go to next */
}
@ -734,6 +741,7 @@ void load_one_chan_rr_nodes_basic_info(RRGraph& rr_graph,
/* Update track_ids */
rr_node_track_ids[rr_node_id].push_back(itrack);
rr_graph.add_node_track_num(rr_node_id, chan_coordinate, itrack);
/* Finish here, go to next */
}
}