aboutsummaryrefslogtreecommitdiffstats
path: root/common/placer1.cc
diff options
context:
space:
mode:
authorEddie Hung <eddieh@ece.ubc.ca>2018-08-09 20:45:20 -0700
committerEddie Hung <eddieh@ece.ubc.ca>2018-08-09 20:45:20 -0700
commit1514903ea909a65737b1595a2c4f46544ab5c3b6 (patch)
tree3ba5b93aa6a359a6fa841815bc1c7f9a611e2f53 /common/placer1.cc
parente419b34027a38698b3b5263b7bff9e0152b3f9ef (diff)
downloadnextpnr-1514903ea909a65737b1595a2c4f46544ab5c3b6.tar.gz
nextpnr-1514903ea909a65737b1595a2c4f46544ab5c3b6.tar.bz2
nextpnr-1514903ea909a65737b1595a2c4f46544ab5c3b6.zip
Get rid of map lookup by borrowing udata to use as index into vector
Diffstat (limited to 'common/placer1.cc')
-rw-r--r--common/placer1.cc39
1 files changed, 20 insertions, 19 deletions
diff --git a/common/placer1.cc b/common/placer1.cc
index 95fa24a1..2dafb069 100644
--- a/common/placer1.cc
+++ b/common/placer1.cc
@@ -71,8 +71,7 @@ class SAPlacer
}
diameter = std::max(max_x, max_y) + 1;
- curr_cost.reserve(ctx->nets.size());
- new_cost.reserve(ctx->nets.size());
+ costs.reserve(ctx->nets.size());
old_udata.reserve(ctx->nets.size());
decltype(NetInfo::udata) n = 0;
for (auto &net : ctx->nets) {
@@ -163,8 +162,7 @@ class SAPlacer
curr_tns = 0;
for (auto &net : ctx->nets) {
wirelen_t wl = get_net_metric(ctx, net.second.get(), MetricType::COST, curr_tns);
- curr_cost[net.second->udata] = wl;
- new_cost[net.second->udata] = -1;
+ costs[net.second->udata] = CostChange{wl, -1};
curr_metric += wl;
}
@@ -265,8 +263,7 @@ class SAPlacer
curr_tns = 0;
for (auto &net : ctx->nets) {
wirelen_t wl = get_net_metric(ctx, net.second.get(), MetricType::COST, curr_tns);
- curr_cost[net.second->udata] = wl;
- new_cost[net.second->udata] = -1;
+ costs[net.second->udata] = CostChange{wl, -1};
curr_metric += wl;
}
@@ -374,9 +371,9 @@ class SAPlacer
for (const auto &port : cell->ports) {
if (port.second.net != nullptr) {
- auto &cost = new_cost[port.second.net->udata];
- if (cost == 0) continue;
- cost = 0;
+ auto &cost = costs[port.second.net->udata];
+ if (cost.new_cost == 0) continue;
+ cost.new_cost = 0;
updates.emplace_back(port.second.net);
}
}
@@ -384,9 +381,9 @@ class SAPlacer
if (other_cell != nullptr) {
for (const auto &port : other_cell->ports)
if (port.second.net != nullptr) {
- auto &cost = new_cost[port.second.net->udata];
- if (cost == 0) continue;
- cost = 0;
+ auto &cost = costs[port.second.net->udata];
+ if (cost.new_cost == 0) continue;
+ cost.new_cost = 0;
updates.emplace_back(port.second.net);
}
}
@@ -407,11 +404,12 @@ class SAPlacer
// Recalculate metrics for all nets touched by the peturbation
for (const auto &net : updates) {
- new_metric -= curr_cost[net->udata];
+ auto &c = costs[net->udata];
+ new_metric -= c.curr_cost;
float temp_tns = 0;
wirelen_t net_new_wl = get_net_metric(ctx, net, MetricType::COST, temp_tns);
new_metric += net_new_wl;
- new_cost[net->udata] = net_new_wl;
+ c.new_cost = net_new_wl;
}
new_dist = get_constraints_distance(ctx, cell);
@@ -431,8 +429,8 @@ class SAPlacer
}
curr_metric = new_metric;
for (const auto &net : updates) {
- curr_cost[net->udata] = new_cost[net->udata];
- new_cost[net->udata] = -1;
+ auto &c = costs[net->udata];
+ c = CostChange{c.new_cost, -1};
}
return true;
@@ -442,7 +440,7 @@ class SAPlacer
ctx->bindBel(newBel, other_cell, STRENGTH_WEAK);
}
for (const auto &net : updates)
- new_cost[net->udata] = -1;
+ costs[net->udata].new_cost = -1;
return false;
}
@@ -486,8 +484,11 @@ class SAPlacer
const float post_legalise_dia_scale = 1.5;
Placer1Cfg cfg;
- std::vector<wirelen_t> curr_cost;
- std::vector<wirelen_t> new_cost;
+ struct CostChange {
+ wirelen_t curr_cost;
+ wirelen_t new_cost;
+ };
+ std::vector<CostChange> costs;
std::vector<decltype(NetInfo::udata)> old_udata;
};