improve rr_node fast look-up in rr_graph object so that we have easily find all the channel nodes

This commit is contained in:
tangxifan 2020-02-11 11:33:30 -07:00
parent 85f3826939
commit e2e115e6f3
1 changed files with 30 additions and 17 deletions

View File

@ -1219,32 +1219,45 @@ void RRGraph::build_fast_node_lookup() const {
continue; continue;
} }
RRNodeId node = RRNodeId(id); RRNodeId node = RRNodeId(id);
/* Special for SOURCE and SINK, we should annotate in the look-up /* Special for CHANX and CHANY, we should annotate in the look-up
* for all the (x,y) upto (xhigh, yhigh) * for all the (x,y) upto (xhigh, yhigh)
*/ */
size_t x = node_xlow(node); size_t x_start = std::min(node_xlow(node), node_xhigh(node));
size_t y = node_ylow(node); size_t y_start = std::min(node_ylow(node), node_yhigh(node));
std::vector<size_t> node_x(std::abs(node_xlow(node) - node_xhigh(node)) + 1);
std::vector<size_t> node_y(std::abs(node_ylow(node) - node_yhigh(node)) + 1);
std::iota(node_x.begin(), node_x.end(), x_start);
std::iota(node_y.begin(), node_y.end(), y_start);
VTR_ASSERT(size_t(std::max(node_xlow(node), node_xhigh(node))) == node_x.back());
VTR_ASSERT(size_t(std::max(node_ylow(node), node_yhigh(node))) == node_y.back());
size_t itype = node_type(node); size_t itype = node_type(node);
size_t ptc = node_ptc_num(node); size_t ptc = node_ptc_num(node);
if (ptc >= node_lookup_[x][y][itype].size()) {
node_lookup_[x][y][itype].resize(ptc + 1);
}
size_t iside = -1; for (const size_t& x : node_x) {
if (node_type(node) == OPIN || node_type(node) == IPIN) { for (const size_t& y : node_y) {
iside = node_side(node); if (ptc >= node_lookup_[x][y][itype].size()) {
} else { node_lookup_[x][y][itype].resize(ptc + 1);
iside = NUM_SIDES; }
}
if (iside >= node_lookup_[x][y][itype][ptc].size()) { size_t iside = -1;
node_lookup_[x][y][itype][ptc].resize(iside + 1); if (node_type(node) == OPIN || node_type(node) == IPIN) {
} iside = node_side(node);
} else {
iside = NUM_SIDES;
}
//Save node in lookup if (iside >= node_lookup_[x][y][itype][ptc].size()) {
node_lookup_[x][y][itype][ptc][iside] = node; node_lookup_[x][y][itype][ptc].resize(iside + 1);
}
//Save node in lookup
node_lookup_[x][y][itype][ptc][iside] = node;
}
}
} }
} }