rr_graph working

This commit is contained in:
tangxifan 2020-02-04 15:33:15 -07:00
parent 6881863506
commit 969dd7c467
2 changed files with 19 additions and 20 deletions

View File

@ -2598,19 +2598,19 @@ static OveruseInfo calculate_overuse_info() {
} }
} }
return OveruseInfo(device_ctx.rr_nodes.size(), overused_nodes, total_overuse, worst_overuse); return OveruseInfo(device_ctx.rr_graph.nodes().size(), overused_nodes, total_overuse, worst_overuse);
} }
static size_t calculate_wirelength_available() { static size_t calculate_wirelength_available() {
auto& device_ctx = g_vpr_ctx.device(); auto& device_ctx = g_vpr_ctx.device();
size_t available_wirelength = 0; size_t available_wirelength = 0;
for (size_t i = 0; i < device_ctx.rr_nodes.size(); ++i) { for (const RRNodeId& node : device_ctx.rr_graph.nodes()) {
if (device_ctx.rr_nodes[i].type() == CHANX || device_ctx.rr_nodes[i].type() == CHANY) { if (device_ctx.rr_graph.node_type(node) == CHANX || device_ctx.rr_graph.node_type(node) == CHANY) {
size_t length_x = device_ctx.rr_nodes[i].xhigh() - device_ctx.rr_nodes[i].xlow(); size_t length_x = device_ctx.rr_graph.node_xhigh(node) - device_ctx.rr_graph.node_xlow(node);
size_t length_y = device_ctx.rr_nodes[i].yhigh() - device_ctx.rr_nodes[i].ylow(); size_t length_y = device_ctx.rr_graph.node_yhigh(node) - device_ctx.rr_graph.node_ylow(node);
available_wirelength += device_ctx.rr_nodes[i].capacity() * (length_x + length_y + 1); available_wirelength += device_ctx.rr_graph.node_capacity(node) * (length_x + length_y + 1);
} }
} }
return available_wirelength; return available_wirelength;

View File

@ -55,24 +55,23 @@ vtr::Matrix<float> calculate_routing_avail(t_rr_type rr_type) {
auto& device_ctx = g_vpr_ctx.device(); auto& device_ctx = g_vpr_ctx.device();
vtr::Matrix<float> avail({{device_ctx.grid.width(), device_ctx.grid.height()}}, 0.); vtr::Matrix<float> avail({{device_ctx.grid.width(), device_ctx.grid.height()}}, 0.);
for (size_t inode = 0; inode < device_ctx.rr_nodes.size(); ++inode) { for (const RRNodeId& inode : device_ctx.rr_graph.nodes()) {
auto& rr_node = device_ctx.rr_nodes[inode];
if (rr_node.type() == CHANX && rr_type == CHANX) { if (device_ctx.rr_graph.node_type(inode) == CHANX && rr_type == CHANX) {
VTR_ASSERT(rr_node.type() == CHANX); VTR_ASSERT(device_ctx.rr_graph.node_type(inode) == CHANX);
VTR_ASSERT(rr_node.ylow() == rr_node.yhigh()); VTR_ASSERT(device_ctx.rr_graph.node_ylow(inode) == device_ctx.rr_graph.node_yhigh(inode));
int y = rr_node.ylow(); int y = device_ctx.rr_graph.node_ylow(inode);
for (int x = rr_node.xlow(); x <= rr_node.xhigh(); ++x) { for (int x = device_ctx.rr_graph.node_xlow(inode); x <= device_ctx.rr_graph.node_xhigh(inode); ++x) {
avail[x][y] += rr_node.capacity(); avail[x][y] += device_ctx.rr_graph.node_capacity(inode);
} }
} else if (rr_node.type() == CHANY && rr_type == CHANY) { } else if (device_ctx.rr_graph.node_type(inode) == CHANY && rr_type == CHANY) {
VTR_ASSERT(rr_node.type() == CHANY); VTR_ASSERT(device_ctx.rr_graph.node_type(inode) == CHANY);
VTR_ASSERT(rr_node.xlow() == rr_node.xhigh()); VTR_ASSERT(device_ctx.rr_graph.node_xlow(inode) == device_ctx.rr_graph.node_xhigh(inode));
int x = rr_node.xlow(); int x = device_ctx.rr_graph.node_xlow(inode);
for (int y = rr_node.ylow(); y <= rr_node.yhigh(); ++y) { for (int y = device_ctx.rr_graph.node_ylow(inode); y <= device_ctx.rr_graph.node_yhigh(inode); ++y) {
avail[x][y] += rr_node.capacity(); avail[x][y] += device_ctx.rr_graph.node_capacity(inode);
} }
} }
} }