From 86699b42f619960bfefd4d0b479dd44a90527ea4 Mon Sep 17 00:00:00 2001 From: gatecat Date: Sat, 26 Feb 2022 15:17:46 +0000 Subject: Switch to potentially-sparse net users array This uses a new data structure for net.users that allows gaps, so removing a port from a net is no longer an O(n) operation on the number of users the net has. Signed-off-by: gatecat --- common/placer_heap.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'common/placer_heap.cc') diff --git a/common/placer_heap.cc b/common/placer_heap.cc index f8385cef..5b43dc72 100644 --- a/common/placer_heap.cc +++ b/common/placer_heap.cc @@ -655,9 +655,9 @@ class HeAPPlacer template void foreach_port(NetInfo *net, Tf func) { if (net->driver.cell != nullptr) - func(net->driver, -1); - for (size_t i = 0; i < net->users.size(); i++) - func(net->users.at(i), i); + func(net->driver, store_index()); + for (auto usr : net->users.enumerate()) + func(usr.value, usr.index); } // Build the system of equations for either X or Y @@ -682,7 +682,7 @@ class HeAPPlacer // Find the bounds of the net in this axis, and the ports that correspond to these bounds PortRef *lbport = nullptr, *ubport = nullptr; int lbpos = std::numeric_limits::max(), ubpos = std::numeric_limits::min(); - foreach_port(ni, [&](PortRef &port, int user_idx) { + foreach_port(ni, [&](PortRef &port, store_index user_idx) { int pos = cell_pos(port.cell); if (pos < lbpos) { lbpos = pos; @@ -713,17 +713,17 @@ class HeAPPlacer }; // Add all relevant connections to the matrix - foreach_port(ni, [&](PortRef &port, int user_idx) { + foreach_port(ni, [&](PortRef &port, store_index user_idx) { int this_pos = cell_pos(port.cell); auto process_arc = [&](PortRef *other) { if (other == &port) return; int o_pos = cell_pos(other->cell); - double weight = 1.0 / (ni->users.size() * + double weight = 1.0 / (ni->users.entries() * std::max(1, (yaxis ? cfg.hpwl_scale_y : cfg.hpwl_scale_x) * std::abs(o_pos - this_pos))); - if (user_idx != -1) { + if (user_idx) { weight *= (1.0 + cfg.timingWeight * std::pow(tmg.get_criticality(CellPortKey(port)), cfg.criticalityExponent)); } -- cgit v1.2.3